diff --git a/.github/update.log b/.github/update.log index 2dfd2dd649..05ce1f3671 100644 --- a/.github/update.log +++ b/.github/update.log @@ -813,3 +813,4 @@ Update On Wed Oct 30 19:35:20 CET 2024 Update On Thu Oct 31 19:36:27 CET 2024 Update On Fri Nov 1 19:37:29 CET 2024 Update On Sat Nov 2 19:33:00 CET 2024 +Update On Sun Nov 3 19:35:10 CET 2024 diff --git a/brook/ping/ping.json b/brook/ping/ping.json index 50ea04d729..79a1f04928 100644 --- a/brook/ping/ping.json +++ b/brook/ping/ping.json @@ -2,6 +2,6 @@ "version": "20240606", "text": "brook-store: an open source store for some people", "link": "https://github.com/TxThinkingInc/brook-store", - "text_zh": "我们应该怎么去理解这个世界?", - "link_zh": "https://www.youtube.com/watch?v=iRIpj6IwknU" + "text_zh": "YouTube: 中国是何时从世界强国变为次级力量的", + "link_zh": "https://www.youtube.com/watch?v=Mc6Z6OMWJzM" } diff --git a/clash-meta-android/build.gradle.kts b/clash-meta-android/build.gradle.kts index 5467252cee..7c4115e66a 100644 --- a/clash-meta-android/build.gradle.kts +++ b/clash-meta-android/build.gradle.kts @@ -40,8 +40,8 @@ subprojects { minSdk = 21 targetSdk = 31 - versionName = "2.11.1" - versionCode = 211001 + versionName = "2.11.2" + versionCode = 211002 resValue("string", "release_name", "v$versionName") resValue("integer", "release_code", "$versionCode") diff --git a/clash-meta-android/core/src/foss/golang/clash/adapter/provider/provider.go b/clash-meta-android/core/src/foss/golang/clash/adapter/provider/provider.go index 79a752a65e..2fe9633c7a 100644 --- a/clash-meta-android/core/src/foss/golang/clash/adapter/provider/provider.go +++ b/clash-meta-android/core/src/foss/golang/clash/adapter/provider/provider.go @@ -1,11 +1,9 @@ package provider import ( - "context" "encoding/json" "errors" "fmt" - "net/http" "reflect" "runtime" "strings" @@ -14,7 +12,7 @@ import ( "github.com/metacubex/mihomo/adapter" "github.com/metacubex/mihomo/common/convert" "github.com/metacubex/mihomo/common/utils" - mihomoHttp "github.com/metacubex/mihomo/component/http" + "github.com/metacubex/mihomo/component/profile/cachefile" "github.com/metacubex/mihomo/component/resource" C "github.com/metacubex/mihomo/constant" types "github.com/metacubex/mihomo/constant/provider" @@ -80,7 +78,9 @@ func (pp *proxySetProvider) Initial() error { if err != nil { return err } - pp.getSubscriptionInfo() + if subscriptionInfo := cachefile.Cache().GetSubscriptionInfo(pp.Name()); subscriptionInfo != "" { + pp.SetSubscriptionInfo(subscriptionInfo) + } pp.closeAllConnections() return nil } @@ -117,35 +117,14 @@ func (pp *proxySetProvider) setProxies(proxies []C.Proxy) { } } -func (pp *proxySetProvider) getSubscriptionInfo() { - if pp.VehicleType() != types.HTTP { - return - } - go func() { - ctx, cancel := context.WithTimeout(context.Background(), time.Second*90) - defer cancel() - resp, err := mihomoHttp.HttpRequestWithProxy(ctx, pp.Vehicle().Url(), - http.MethodGet, nil, nil, pp.Vehicle().Proxy()) - if err != nil { - return - } - defer resp.Body.Close() +func (pp *proxySetProvider) SetSubscriptionInfo(userInfo string) { + pp.subscriptionInfo = NewSubscriptionInfo(userInfo) +} - userInfoStr := strings.TrimSpace(resp.Header.Get("subscription-userinfo")) - if userInfoStr == "" { - resp2, err := mihomoHttp.HttpRequestWithProxy(ctx, pp.Vehicle().Url(), - http.MethodGet, http.Header{"User-Agent": {"Quantumultx"}}, nil, pp.Vehicle().Proxy()) - if err != nil { - return - } - defer resp2.Body.Close() - userInfoStr = strings.TrimSpace(resp2.Header.Get("subscription-userinfo")) - if userInfoStr == "" { - return - } - } - pp.subscriptionInfo = NewSubscriptionInfo(userInfoStr) - }() +func (pp *proxySetProvider) SetProvider(provider types.ProxyProvider) { + if httpVehicle, ok := pp.Vehicle().(*resource.HTTPVehicle); ok { + httpVehicle.SetProvider(provider) + } } func (pp *proxySetProvider) closeAllConnections() { @@ -196,6 +175,9 @@ func NewProxySetProvider(name string, interval time.Duration, filter string, exc fetcher := resource.NewFetcher[[]C.Proxy](name, interval, vehicle, proxiesParseAndFilter(filter, excludeFilter, excludeTypeArray, filterRegs, excludeFilterReg, dialerProxy, override), proxiesOnUpdate(pd)) pd.Fetcher = fetcher wrapper := &ProxySetProvider{pd} + if httpVehicle, ok := vehicle.(*resource.HTTPVehicle); ok { + httpVehicle.SetProvider(wrapper) + } runtime.SetFinalizer(wrapper, (*ProxySetProvider).Close) return wrapper, nil } @@ -205,16 +187,21 @@ func (pp *ProxySetProvider) Close() error { return pp.proxySetProvider.Close() } +func (pp *ProxySetProvider) SetProvider(provider types.ProxyProvider) { + pp.proxySetProvider.SetProvider(provider) +} + // CompatibleProvider for auto gc type CompatibleProvider struct { *compatibleProvider } type compatibleProvider struct { - name string - healthCheck *HealthCheck - proxies []C.Proxy - version uint32 + name string + healthCheck *HealthCheck + subscriptionInfo *SubscriptionInfo + proxies []C.Proxy + version uint32 } func (cp *compatibleProvider) MarshalJSON() ([]byte, error) { @@ -284,6 +271,10 @@ func (cp *compatibleProvider) Close() error { return nil } +func (cp *compatibleProvider) SetSubscriptionInfo(userInfo string) { + cp.subscriptionInfo = NewSubscriptionInfo(userInfo) +} + func NewCompatibleProvider(name string, proxies []C.Proxy, hc *HealthCheck) (*CompatibleProvider, error) { if len(proxies) == 0 { return nil, errors.New("provider need one proxy at least") @@ -313,7 +304,6 @@ func proxiesOnUpdate(pd *proxySetProvider) func([]C.Proxy) { return func(elm []C.Proxy) { pd.setProxies(elm) pd.version += 1 - pd.getSubscriptionInfo() } } diff --git a/clash-meta-android/core/src/foss/golang/clash/adapter/provider/subscription_info.go b/clash-meta-android/core/src/foss/golang/clash/adapter/provider/subscription_info.go index b72c7b6161..412b4342fc 100644 --- a/clash-meta-android/core/src/foss/golang/clash/adapter/provider/subscription_info.go +++ b/clash-meta-android/core/src/foss/golang/clash/adapter/provider/subscription_info.go @@ -16,8 +16,7 @@ type SubscriptionInfo struct { } func NewSubscriptionInfo(userinfo string) (si *SubscriptionInfo) { - userinfo = strings.ToLower(userinfo) - userinfo = strings.ReplaceAll(userinfo, " ", "") + userinfo = strings.ReplaceAll(strings.ToLower(userinfo), " ", "") si = new(SubscriptionInfo) for _, field := range strings.Split(userinfo, ";") { diff --git a/clash-meta-android/core/src/foss/golang/clash/component/profile/cachefile/cache.go b/clash-meta-android/core/src/foss/golang/clash/component/profile/cachefile/cache.go index f5101f5bb7..7b4cdfc2a6 100644 --- a/clash-meta-android/core/src/foss/golang/clash/component/profile/cachefile/cache.go +++ b/clash-meta-android/core/src/foss/golang/clash/component/profile/cachefile/cache.go @@ -17,9 +17,10 @@ var ( fileMode os.FileMode = 0o666 defaultCache *CacheFile - bucketSelected = []byte("selected") - bucketFakeip = []byte("fakeip") - bucketETag = []byte("etag") + bucketSelected = []byte("selected") + bucketFakeip = []byte("fakeip") + bucketETag = []byte("etag") + bucketSubscriptionInfo = []byte("subscriptioninfo") ) // CacheFile store and update the cache file diff --git a/clash-meta-android/core/src/foss/golang/clash/component/profile/cachefile/subscriptioninfo.go b/clash-meta-android/core/src/foss/golang/clash/component/profile/cachefile/subscriptioninfo.go new file mode 100644 index 0000000000..c68f92ebc9 --- /dev/null +++ b/clash-meta-android/core/src/foss/golang/clash/component/profile/cachefile/subscriptioninfo.go @@ -0,0 +1,41 @@ +package cachefile + +import ( + "github.com/metacubex/mihomo/log" + + "github.com/metacubex/bbolt" +) + +func (c *CacheFile) SetSubscriptionInfo(name string, userInfo string) { + if c.DB == nil { + return + } + + err := c.DB.Batch(func(t *bbolt.Tx) error { + bucket, err := t.CreateBucketIfNotExists(bucketSubscriptionInfo) + if err != nil { + return err + } + + return bucket.Put([]byte(name), []byte(userInfo)) + }) + if err != nil { + log.Warnln("[CacheFile] write cache to %s failed: %s", c.DB.Path(), err.Error()) + return + } +} +func (c *CacheFile) GetSubscriptionInfo(name string) (userInfo string) { + if c.DB == nil { + return + } + c.DB.View(func(t *bbolt.Tx) error { + if bucket := t.Bucket(bucketSubscriptionInfo); bucket != nil { + if v := bucket.Get([]byte(name)); v != nil { + userInfo = string(v) + } + } + return nil + }) + + return +} diff --git a/clash-meta-android/core/src/foss/golang/clash/component/resource/vehicle.go b/clash-meta-android/core/src/foss/golang/clash/component/resource/vehicle.go index a9382329fc..7c3cb1c2a1 100644 --- a/clash-meta-android/core/src/foss/golang/clash/component/resource/vehicle.go +++ b/clash-meta-android/core/src/foss/golang/clash/component/resource/vehicle.go @@ -84,11 +84,12 @@ func NewFileVehicle(path string) *FileVehicle { } type HTTPVehicle struct { - url string - path string - proxy string - header http.Header - timeout time.Duration + url string + path string + proxy string + header http.Header + timeout time.Duration + provider types.ProxyProvider } func (h *HTTPVehicle) Url() string { @@ -111,6 +112,10 @@ func (h *HTTPVehicle) Write(buf []byte) error { return safeWrite(h.path, buf) } +func (h *HTTPVehicle) SetProvider(provider types.ProxyProvider) { + h.provider = provider +} + func (h *HTTPVehicle) Read(ctx context.Context, oldHash utils.HashType) (buf []byte, hash utils.HashType, err error) { ctx, cancel := context.WithTimeout(ctx, h.timeout) defer cancel() @@ -133,6 +138,12 @@ func (h *HTTPVehicle) Read(ctx context.Context, oldHash utils.HashType) (buf []b return } defer resp.Body.Close() + + if subscriptionInfo := resp.Header.Get("subscription-userinfo"); h.provider != nil && subscriptionInfo != "" { + cachefile.Cache().SetSubscriptionInfo(h.provider.Name(), subscriptionInfo) + h.provider.SetSubscriptionInfo(subscriptionInfo) + } + if resp.StatusCode < 200 || resp.StatusCode > 299 { if setIfNoneMatch && resp.StatusCode == http.StatusNotModified { return nil, oldHash, nil diff --git a/clash-meta-android/core/src/foss/golang/clash/constant/adapters.go b/clash-meta-android/core/src/foss/golang/clash/constant/adapters.go index b303eb846b..c7b73a0693 100644 --- a/clash-meta-android/core/src/foss/golang/clash/constant/adapters.go +++ b/clash-meta-android/core/src/foss/golang/clash/constant/adapters.go @@ -213,6 +213,8 @@ func (at AdapterType) String() string { return "WireGuard" case Tuic: return "Tuic" + case Ssh: + return "Ssh" case Relay: return "Relay" @@ -224,8 +226,6 @@ func (at AdapterType) String() string { return "URLTest" case LoadBalance: return "LoadBalance" - case Ssh: - return "Ssh" default: return "Unknown" } diff --git a/clash-meta-android/core/src/foss/golang/clash/constant/provider/interface.go b/clash-meta-android/core/src/foss/golang/clash/constant/provider/interface.go index 065b801ae4..925c173469 100644 --- a/clash-meta-android/core/src/foss/golang/clash/constant/provider/interface.go +++ b/clash-meta-android/core/src/foss/golang/clash/constant/provider/interface.go @@ -81,6 +81,7 @@ type ProxyProvider interface { Version() uint32 RegisterHealthCheckTask(url string, expectedStatus utils.IntRanges[uint16], filter string, interval uint) HealthCheckURL() string + SetSubscriptionInfo(userInfo string) } // RuleProvider interface diff --git a/clash-meta-android/core/src/foss/golang/clash/go.mod b/clash-meta-android/core/src/foss/golang/clash/go.mod index a223cf77ac..098030629a 100644 --- a/clash-meta-android/core/src/foss/golang/clash/go.mod +++ b/clash-meta-android/core/src/foss/golang/clash/go.mod @@ -20,12 +20,12 @@ require ( github.com/metacubex/bbolt v0.0.0-20240822011022-aed6d4850399 github.com/metacubex/chacha v0.1.0 github.com/metacubex/gopacket v1.1.20-0.20230608035415-7e2f98a3e759 - github.com/metacubex/quic-go v0.47.1-0.20240909010619-6b38f24bfcc4 + github.com/metacubex/quic-go v0.48.1-0.20241021013658-51ca987e0174 github.com/metacubex/randv2 v0.2.0 github.com/metacubex/sing-quic v0.0.0-20240827003841-cd97758ed8b4 github.com/metacubex/sing-shadowsocks v0.2.8 github.com/metacubex/sing-shadowsocks2 v0.2.2 - github.com/metacubex/sing-tun v0.2.7-0.20240729131039-ed03f557dee1 + github.com/metacubex/sing-tun v0.2.7-0.20241021011113-857bcd6ee47c github.com/metacubex/sing-vmess v0.1.9-0.20240719134745-1df6fb20bbf9 github.com/metacubex/sing-wireguard v0.0.0-20240924052438-b0976fc59ea3 github.com/metacubex/tfo-go v0.0.0-20241006021335-daedaf0ca7aa @@ -39,7 +39,7 @@ require ( github.com/sagernet/cors v1.2.1 github.com/sagernet/fswatch v0.1.1 github.com/sagernet/netlink v0.0.0-20240612041022-b9a21c07ac6a - github.com/sagernet/sing v0.5.0-alpha.13 + github.com/sagernet/sing v0.5.0-rc.4 github.com/sagernet/sing-mux v0.2.1-0.20240124034317-9bfb33698bb6 github.com/sagernet/sing-shadowtls v0.1.4 github.com/samber/lo v1.47.0 @@ -116,4 +116,4 @@ require ( golang.org/x/tools v0.24.0 // indirect ) -replace github.com/sagernet/sing => github.com/metacubex/sing v0.0.0-20240724044459-6f3cf5896297 +replace github.com/sagernet/sing => github.com/metacubex/sing v0.0.0-20241021005542-18b67490300a diff --git a/clash-meta-android/core/src/foss/golang/clash/go.sum b/clash-meta-android/core/src/foss/golang/clash/go.sum index 2b3bba6542..0508ac59ce 100644 --- a/clash-meta-android/core/src/foss/golang/clash/go.sum +++ b/clash-meta-android/core/src/foss/golang/clash/go.sum @@ -104,20 +104,20 @@ github.com/metacubex/gopacket v1.1.20-0.20230608035415-7e2f98a3e759 h1:cjd4biTvO github.com/metacubex/gopacket v1.1.20-0.20230608035415-7e2f98a3e759/go.mod h1:UHOv2xu+RIgLwpXca7TLrXleEd4oR3sPatW6IF8wU88= github.com/metacubex/gvisor v0.0.0-20240320004321-933faba989ec h1:HxreOiFTUrJXJautEo8rnE1uKTVGY8wtZepY1Tii/Nc= github.com/metacubex/gvisor v0.0.0-20240320004321-933faba989ec/go.mod h1:8BVmQ+3cxjqzWElafm24rb2Ae4jRI6vAXNXWqWjfrXw= -github.com/metacubex/quic-go v0.47.1-0.20240909010619-6b38f24bfcc4 h1:CgdUBRxmNlxEGkp35HwvgQ10jwOOUJKWdOxpi8yWi8o= -github.com/metacubex/quic-go v0.47.1-0.20240909010619-6b38f24bfcc4/go.mod h1:Y7yRGqFE6UQL/3aKPYmiYdjfVkeujJaStP4+jiZMcN8= +github.com/metacubex/quic-go v0.48.1-0.20241021013658-51ca987e0174 h1:GvigRPEU+cbnzdLWne47cxLrc28Abohl3ECtVdnrbq0= +github.com/metacubex/quic-go v0.48.1-0.20241021013658-51ca987e0174/go.mod h1:AiZ+UPgrkO1DTnmiAX4b+kRoV1Vfc65UkYD7RbFlIZA= github.com/metacubex/randv2 v0.2.0 h1:uP38uBvV2SxYfLj53kuvAjbND4RUDfFJjwr4UigMiLs= github.com/metacubex/randv2 v0.2.0/go.mod h1:kFi2SzrQ5WuneuoLLCMkABtiBu6VRrMrWFqSPyj2cxY= -github.com/metacubex/sing v0.0.0-20240724044459-6f3cf5896297 h1:YG/JkwGPbca5rUtEMHIu8ZuqzR7BSVm1iqY8hNoMeMA= -github.com/metacubex/sing v0.0.0-20240724044459-6f3cf5896297/go.mod h1:ARkL0gM13/Iv5VCZmci/NuoOlePoIsW0m7BWfln/Hak= +github.com/metacubex/sing v0.0.0-20241021005542-18b67490300a h1:JuR0/7RDxQtlZp/GOzrdqNq04HplTxavPRHrek8ouJk= +github.com/metacubex/sing v0.0.0-20241021005542-18b67490300a/go.mod h1:ARkL0gM13/Iv5VCZmci/NuoOlePoIsW0m7BWfln/Hak= github.com/metacubex/sing-quic v0.0.0-20240827003841-cd97758ed8b4 h1:HobpULaPK6OoxrHMmgcwLkwwIduXVmwdcznwUfH1GQM= github.com/metacubex/sing-quic v0.0.0-20240827003841-cd97758ed8b4/go.mod h1:g7Mxj7b7zm7YVqD975mk/hSmrb0A0G4bVvIMr2MMzn8= github.com/metacubex/sing-shadowsocks v0.2.8 h1:wIhlaigswzjPw4hej75sEvWte3QR0+AJRafgwBHO5B4= github.com/metacubex/sing-shadowsocks v0.2.8/go.mod h1:X3x88XtJpBxG0W0/ECOJL6Ib0SJ3xdniAkU/6/RMWU0= github.com/metacubex/sing-shadowsocks2 v0.2.2 h1:eaf42uVx4Lr21S6MDYs0ZdTvGA0GEhDpb9no4+gdXPo= github.com/metacubex/sing-shadowsocks2 v0.2.2/go.mod h1:BhOug03a/RbI7y6hp6q+6ITM1dXjnLTmeWBHSTwvv2Q= -github.com/metacubex/sing-tun v0.2.7-0.20240729131039-ed03f557dee1 h1:ypfofGDZbP8p3Y4P/m74JYu7sQViesi3c8nbmT6cS0Y= -github.com/metacubex/sing-tun v0.2.7-0.20240729131039-ed03f557dee1/go.mod h1:olbEx9yVcaw5tHTNlRamRoxmMKcvDvcVS1YLnQGzvWE= +github.com/metacubex/sing-tun v0.2.7-0.20241021011113-857bcd6ee47c h1:qfUZ8xBrViOCZamvcC8CyV7Ii8sAUrn7RqZxFGn56tQ= +github.com/metacubex/sing-tun v0.2.7-0.20241021011113-857bcd6ee47c/go.mod h1:lCrP0AW7ieKnXG1JEeZLW+9h99QzjuOX0MfCQfz6TgE= github.com/metacubex/sing-vmess v0.1.9-0.20240719134745-1df6fb20bbf9 h1:OAXiCosqY8xKDp3pqTW3qbrCprZ1l6WkrXSFSCwyY4I= github.com/metacubex/sing-vmess v0.1.9-0.20240719134745-1df6fb20bbf9/go.mod h1:olVkD4FChQ5gKMHG4ZzuD7+fMkJY1G8vwOKpRehjrmY= github.com/metacubex/sing-wireguard v0.0.0-20240924052438-b0976fc59ea3 h1:xg71VmzLS6ByAzi/57phwDvjE+dLLs+ozH00k4DnOns= diff --git a/clash-meta-android/core/src/foss/golang/clash/listener/sing_tun/server.go b/clash-meta-android/core/src/foss/golang/clash/listener/sing_tun/server.go index 79856c466c..ad3d113e4a 100644 --- a/clash-meta-android/core/src/foss/golang/clash/listener/sing_tun/server.go +++ b/clash-meta-android/core/src/foss/golang/clash/listener/sing_tun/server.go @@ -279,7 +279,7 @@ func New(options LC.Tun, tunnel C.Tunnel, additions ...inbound.Addition) (l *Lis return } - defaultInterfaceMonitor, err = tun.NewDefaultInterfaceMonitor(networkUpdateMonitor, log.SingLogger, tun.DefaultInterfaceMonitorOptions{OverrideAndroidVPN: true}) + defaultInterfaceMonitor, err = tun.NewDefaultInterfaceMonitor(networkUpdateMonitor, log.SingLogger, tun.DefaultInterfaceMonitorOptions{InterfaceFinder: interfaceFinder, OverrideAndroidVPN: true}) if err != nil { err = E.Cause(err, "create DefaultInterfaceMonitor") return diff --git a/clash-meta-android/core/src/foss/golang/go.mod b/clash-meta-android/core/src/foss/golang/go.mod index 302c3469bb..49e1ab674f 100644 --- a/clash-meta-android/core/src/foss/golang/go.mod +++ b/clash-meta-android/core/src/foss/golang/go.mod @@ -48,12 +48,12 @@ require ( github.com/metacubex/gopacket v1.1.20-0.20230608035415-7e2f98a3e759 // indirect github.com/metacubex/gvisor v0.0.0-20240320004321-933faba989ec // indirect github.com/metacubex/mihomo v1.7.0 // indirect - github.com/metacubex/quic-go v0.47.1-0.20240909010619-6b38f24bfcc4 // indirect + github.com/metacubex/quic-go v0.48.1-0.20241021013658-51ca987e0174 // indirect github.com/metacubex/randv2 v0.2.0 // indirect github.com/metacubex/sing-quic v0.0.0-20240827003841-cd97758ed8b4 // indirect github.com/metacubex/sing-shadowsocks v0.2.8 // indirect github.com/metacubex/sing-shadowsocks2 v0.2.2 // indirect - github.com/metacubex/sing-tun v0.2.7-0.20240729131039-ed03f557dee1 // indirect + github.com/metacubex/sing-tun v0.2.7-0.20241021011113-857bcd6ee47c // indirect github.com/metacubex/sing-vmess v0.1.9-0.20240719134745-1df6fb20bbf9 // indirect github.com/metacubex/sing-wireguard v0.0.0-20240924052438-b0976fc59ea3 // indirect github.com/metacubex/tfo-go v0.0.0-20241006021335-daedaf0ca7aa // indirect @@ -74,7 +74,7 @@ require ( github.com/sagernet/fswatch v0.1.1 // indirect github.com/sagernet/netlink v0.0.0-20240612041022-b9a21c07ac6a // indirect github.com/sagernet/nftables v0.3.0-beta.4 // indirect - github.com/sagernet/sing v0.5.0-alpha.13 // indirect + github.com/sagernet/sing v0.5.0-rc.4 // indirect github.com/sagernet/sing-mux v0.2.1-0.20240124034317-9bfb33698bb6 // indirect github.com/sagernet/sing-shadowtls v0.1.4 // indirect github.com/sagernet/smux v0.0.0-20231208180855-7041f6ea79e7 // indirect @@ -111,7 +111,7 @@ require ( lukechampine.com/blake3 v1.3.0 // indirect ) -replace github.com/sagernet/sing => github.com/metacubex/sing v0.0.0-20240724044459-6f3cf5896297 +replace github.com/sagernet/sing => github.com/metacubex/sing v0.0.0-20241021005542-18b67490300a replace cfa => ../../main/golang diff --git a/clash-meta-android/core/src/foss/golang/go.sum b/clash-meta-android/core/src/foss/golang/go.sum index f76f3a5eef..dfa910d576 100644 --- a/clash-meta-android/core/src/foss/golang/go.sum +++ b/clash-meta-android/core/src/foss/golang/go.sum @@ -100,20 +100,20 @@ github.com/metacubex/gopacket v1.1.20-0.20230608035415-7e2f98a3e759 h1:cjd4biTvO github.com/metacubex/gopacket v1.1.20-0.20230608035415-7e2f98a3e759/go.mod h1:UHOv2xu+RIgLwpXca7TLrXleEd4oR3sPatW6IF8wU88= github.com/metacubex/gvisor v0.0.0-20240320004321-933faba989ec h1:HxreOiFTUrJXJautEo8rnE1uKTVGY8wtZepY1Tii/Nc= github.com/metacubex/gvisor v0.0.0-20240320004321-933faba989ec/go.mod h1:8BVmQ+3cxjqzWElafm24rb2Ae4jRI6vAXNXWqWjfrXw= -github.com/metacubex/quic-go v0.47.1-0.20240909010619-6b38f24bfcc4 h1:CgdUBRxmNlxEGkp35HwvgQ10jwOOUJKWdOxpi8yWi8o= -github.com/metacubex/quic-go v0.47.1-0.20240909010619-6b38f24bfcc4/go.mod h1:Y7yRGqFE6UQL/3aKPYmiYdjfVkeujJaStP4+jiZMcN8= +github.com/metacubex/quic-go v0.48.1-0.20241021013658-51ca987e0174 h1:GvigRPEU+cbnzdLWne47cxLrc28Abohl3ECtVdnrbq0= +github.com/metacubex/quic-go v0.48.1-0.20241021013658-51ca987e0174/go.mod h1:AiZ+UPgrkO1DTnmiAX4b+kRoV1Vfc65UkYD7RbFlIZA= github.com/metacubex/randv2 v0.2.0 h1:uP38uBvV2SxYfLj53kuvAjbND4RUDfFJjwr4UigMiLs= github.com/metacubex/randv2 v0.2.0/go.mod h1:kFi2SzrQ5WuneuoLLCMkABtiBu6VRrMrWFqSPyj2cxY= -github.com/metacubex/sing v0.0.0-20240724044459-6f3cf5896297 h1:YG/JkwGPbca5rUtEMHIu8ZuqzR7BSVm1iqY8hNoMeMA= -github.com/metacubex/sing v0.0.0-20240724044459-6f3cf5896297/go.mod h1:ARkL0gM13/Iv5VCZmci/NuoOlePoIsW0m7BWfln/Hak= +github.com/metacubex/sing v0.0.0-20241021005542-18b67490300a h1:JuR0/7RDxQtlZp/GOzrdqNq04HplTxavPRHrek8ouJk= +github.com/metacubex/sing v0.0.0-20241021005542-18b67490300a/go.mod h1:ARkL0gM13/Iv5VCZmci/NuoOlePoIsW0m7BWfln/Hak= github.com/metacubex/sing-quic v0.0.0-20240827003841-cd97758ed8b4 h1:HobpULaPK6OoxrHMmgcwLkwwIduXVmwdcznwUfH1GQM= github.com/metacubex/sing-quic v0.0.0-20240827003841-cd97758ed8b4/go.mod h1:g7Mxj7b7zm7YVqD975mk/hSmrb0A0G4bVvIMr2MMzn8= github.com/metacubex/sing-shadowsocks v0.2.8 h1:wIhlaigswzjPw4hej75sEvWte3QR0+AJRafgwBHO5B4= github.com/metacubex/sing-shadowsocks v0.2.8/go.mod h1:X3x88XtJpBxG0W0/ECOJL6Ib0SJ3xdniAkU/6/RMWU0= github.com/metacubex/sing-shadowsocks2 v0.2.2 h1:eaf42uVx4Lr21S6MDYs0ZdTvGA0GEhDpb9no4+gdXPo= github.com/metacubex/sing-shadowsocks2 v0.2.2/go.mod h1:BhOug03a/RbI7y6hp6q+6ITM1dXjnLTmeWBHSTwvv2Q= -github.com/metacubex/sing-tun v0.2.7-0.20240729131039-ed03f557dee1 h1:ypfofGDZbP8p3Y4P/m74JYu7sQViesi3c8nbmT6cS0Y= -github.com/metacubex/sing-tun v0.2.7-0.20240729131039-ed03f557dee1/go.mod h1:olbEx9yVcaw5tHTNlRamRoxmMKcvDvcVS1YLnQGzvWE= +github.com/metacubex/sing-tun v0.2.7-0.20241021011113-857bcd6ee47c h1:qfUZ8xBrViOCZamvcC8CyV7Ii8sAUrn7RqZxFGn56tQ= +github.com/metacubex/sing-tun v0.2.7-0.20241021011113-857bcd6ee47c/go.mod h1:lCrP0AW7ieKnXG1JEeZLW+9h99QzjuOX0MfCQfz6TgE= github.com/metacubex/sing-vmess v0.1.9-0.20240719134745-1df6fb20bbf9 h1:OAXiCosqY8xKDp3pqTW3qbrCprZ1l6WkrXSFSCwyY4I= github.com/metacubex/sing-vmess v0.1.9-0.20240719134745-1df6fb20bbf9/go.mod h1:olVkD4FChQ5gKMHG4ZzuD7+fMkJY1G8vwOKpRehjrmY= github.com/metacubex/sing-wireguard v0.0.0-20240924052438-b0976fc59ea3 h1:xg71VmzLS6ByAzi/57phwDvjE+dLLs+ozH00k4DnOns= diff --git a/clash-meta-android/core/src/main/golang/go.mod b/clash-meta-android/core/src/main/golang/go.mod index 5373b176e5..3568b55bf6 100644 --- a/clash-meta-android/core/src/main/golang/go.mod +++ b/clash-meta-android/core/src/main/golang/go.mod @@ -11,7 +11,7 @@ require ( replace github.com/metacubex/mihomo => ../../foss/golang/clash -replace github.com/sagernet/sing => github.com/metacubex/sing v0.0.0-20240724044459-6f3cf5896297 +replace github.com/sagernet/sing => github.com/metacubex/sing v0.0.0-20241021005542-18b67490300a require ( github.com/3andne/restls-client-go v0.1.6 // indirect @@ -55,12 +55,12 @@ require ( github.com/metacubex/chacha v0.1.0 // indirect github.com/metacubex/gopacket v1.1.20-0.20230608035415-7e2f98a3e759 // indirect github.com/metacubex/gvisor v0.0.0-20240320004321-933faba989ec // indirect - github.com/metacubex/quic-go v0.47.1-0.20240909010619-6b38f24bfcc4 // indirect + github.com/metacubex/quic-go v0.48.1-0.20241021013658-51ca987e0174 // indirect github.com/metacubex/randv2 v0.2.0 // indirect github.com/metacubex/sing-quic v0.0.0-20240827003841-cd97758ed8b4 // indirect github.com/metacubex/sing-shadowsocks v0.2.8 // indirect github.com/metacubex/sing-shadowsocks2 v0.2.2 // indirect - github.com/metacubex/sing-tun v0.2.7-0.20240729131039-ed03f557dee1 // indirect + github.com/metacubex/sing-tun v0.2.7-0.20241021011113-857bcd6ee47c // indirect github.com/metacubex/sing-vmess v0.1.9-0.20240719134745-1df6fb20bbf9 // indirect github.com/metacubex/sing-wireguard v0.0.0-20240924052438-b0976fc59ea3 // indirect github.com/metacubex/tfo-go v0.0.0-20241006021335-daedaf0ca7aa // indirect @@ -81,7 +81,7 @@ require ( github.com/sagernet/fswatch v0.1.1 // indirect github.com/sagernet/netlink v0.0.0-20240612041022-b9a21c07ac6a // indirect github.com/sagernet/nftables v0.3.0-beta.4 // indirect - github.com/sagernet/sing v0.5.0-alpha.13 // indirect + github.com/sagernet/sing v0.5.0-rc.4 // indirect github.com/sagernet/sing-mux v0.2.1-0.20240124034317-9bfb33698bb6 // indirect github.com/sagernet/sing-shadowtls v0.1.4 // indirect github.com/sagernet/smux v0.0.0-20231208180855-7041f6ea79e7 // indirect diff --git a/clash-meta-android/core/src/main/golang/go.sum b/clash-meta-android/core/src/main/golang/go.sum index f76f3a5eef..dfa910d576 100644 --- a/clash-meta-android/core/src/main/golang/go.sum +++ b/clash-meta-android/core/src/main/golang/go.sum @@ -100,20 +100,20 @@ github.com/metacubex/gopacket v1.1.20-0.20230608035415-7e2f98a3e759 h1:cjd4biTvO github.com/metacubex/gopacket v1.1.20-0.20230608035415-7e2f98a3e759/go.mod h1:UHOv2xu+RIgLwpXca7TLrXleEd4oR3sPatW6IF8wU88= github.com/metacubex/gvisor v0.0.0-20240320004321-933faba989ec h1:HxreOiFTUrJXJautEo8rnE1uKTVGY8wtZepY1Tii/Nc= github.com/metacubex/gvisor v0.0.0-20240320004321-933faba989ec/go.mod h1:8BVmQ+3cxjqzWElafm24rb2Ae4jRI6vAXNXWqWjfrXw= -github.com/metacubex/quic-go v0.47.1-0.20240909010619-6b38f24bfcc4 h1:CgdUBRxmNlxEGkp35HwvgQ10jwOOUJKWdOxpi8yWi8o= -github.com/metacubex/quic-go v0.47.1-0.20240909010619-6b38f24bfcc4/go.mod h1:Y7yRGqFE6UQL/3aKPYmiYdjfVkeujJaStP4+jiZMcN8= +github.com/metacubex/quic-go v0.48.1-0.20241021013658-51ca987e0174 h1:GvigRPEU+cbnzdLWne47cxLrc28Abohl3ECtVdnrbq0= +github.com/metacubex/quic-go v0.48.1-0.20241021013658-51ca987e0174/go.mod h1:AiZ+UPgrkO1DTnmiAX4b+kRoV1Vfc65UkYD7RbFlIZA= github.com/metacubex/randv2 v0.2.0 h1:uP38uBvV2SxYfLj53kuvAjbND4RUDfFJjwr4UigMiLs= github.com/metacubex/randv2 v0.2.0/go.mod h1:kFi2SzrQ5WuneuoLLCMkABtiBu6VRrMrWFqSPyj2cxY= -github.com/metacubex/sing v0.0.0-20240724044459-6f3cf5896297 h1:YG/JkwGPbca5rUtEMHIu8ZuqzR7BSVm1iqY8hNoMeMA= -github.com/metacubex/sing v0.0.0-20240724044459-6f3cf5896297/go.mod h1:ARkL0gM13/Iv5VCZmci/NuoOlePoIsW0m7BWfln/Hak= +github.com/metacubex/sing v0.0.0-20241021005542-18b67490300a h1:JuR0/7RDxQtlZp/GOzrdqNq04HplTxavPRHrek8ouJk= +github.com/metacubex/sing v0.0.0-20241021005542-18b67490300a/go.mod h1:ARkL0gM13/Iv5VCZmci/NuoOlePoIsW0m7BWfln/Hak= github.com/metacubex/sing-quic v0.0.0-20240827003841-cd97758ed8b4 h1:HobpULaPK6OoxrHMmgcwLkwwIduXVmwdcznwUfH1GQM= github.com/metacubex/sing-quic v0.0.0-20240827003841-cd97758ed8b4/go.mod h1:g7Mxj7b7zm7YVqD975mk/hSmrb0A0G4bVvIMr2MMzn8= github.com/metacubex/sing-shadowsocks v0.2.8 h1:wIhlaigswzjPw4hej75sEvWte3QR0+AJRafgwBHO5B4= github.com/metacubex/sing-shadowsocks v0.2.8/go.mod h1:X3x88XtJpBxG0W0/ECOJL6Ib0SJ3xdniAkU/6/RMWU0= github.com/metacubex/sing-shadowsocks2 v0.2.2 h1:eaf42uVx4Lr21S6MDYs0ZdTvGA0GEhDpb9no4+gdXPo= github.com/metacubex/sing-shadowsocks2 v0.2.2/go.mod h1:BhOug03a/RbI7y6hp6q+6ITM1dXjnLTmeWBHSTwvv2Q= -github.com/metacubex/sing-tun v0.2.7-0.20240729131039-ed03f557dee1 h1:ypfofGDZbP8p3Y4P/m74JYu7sQViesi3c8nbmT6cS0Y= -github.com/metacubex/sing-tun v0.2.7-0.20240729131039-ed03f557dee1/go.mod h1:olbEx9yVcaw5tHTNlRamRoxmMKcvDvcVS1YLnQGzvWE= +github.com/metacubex/sing-tun v0.2.7-0.20241021011113-857bcd6ee47c h1:qfUZ8xBrViOCZamvcC8CyV7Ii8sAUrn7RqZxFGn56tQ= +github.com/metacubex/sing-tun v0.2.7-0.20241021011113-857bcd6ee47c/go.mod h1:lCrP0AW7ieKnXG1JEeZLW+9h99QzjuOX0MfCQfz6TgE= github.com/metacubex/sing-vmess v0.1.9-0.20240719134745-1df6fb20bbf9 h1:OAXiCosqY8xKDp3pqTW3qbrCprZ1l6WkrXSFSCwyY4I= github.com/metacubex/sing-vmess v0.1.9-0.20240719134745-1df6fb20bbf9/go.mod h1:olVkD4FChQ5gKMHG4ZzuD7+fMkJY1G8vwOKpRehjrmY= github.com/metacubex/sing-wireguard v0.0.0-20240924052438-b0976fc59ea3 h1:xg71VmzLS6ByAzi/57phwDvjE+dLLs+ozH00k4DnOns= diff --git a/clash-nyanpasu/manifest/version.json b/clash-nyanpasu/manifest/version.json index e7cf18a26d..bb67b65f2f 100644 --- a/clash-nyanpasu/manifest/version.json +++ b/clash-nyanpasu/manifest/version.json @@ -5,7 +5,7 @@ "mihomo_alpha": "alpha-3e966e8", "clash_rs": "v0.7.0", "clash_premium": "2023-09-05-gdcc8d87", - "clash_rs_alpha": "0.7.0-alpha+sha.98d183b" + "clash_rs_alpha": "0.7.0-alpha+sha.e2a4be4" }, "arch_template": { "mihomo": { @@ -69,5 +69,5 @@ "linux-armv7hf": "clash-armv7-unknown-linux-gnueabihf" } }, - "updated_at": "2024-10-28T22:20:42.142Z" + "updated_at": "2024-11-02T22:20:39.008Z" } diff --git a/geoip/.gitignore b/geoip/.gitignore index 22e58a6c8d..3cfe64d06d 100644 --- a/geoip/.gitignore +++ b/geoip/.gitignore @@ -69,8 +69,11 @@ $RECYCLE.BIN/ tmp/ data/ geolite2/ +db-ip/ +ipinfo/ output/ geoip *.dat *.mmdb *.srs +*.mrs diff --git a/geoip/README.md b/geoip/README.md index 2a0473baa5..43bea759ac 100644 --- a/geoip/README.md +++ b/geoip/README.md @@ -21,6 +21,7 @@ This project releases various formats of GeoIP files automatically every Thursda - `geoip:netflix`(`GEOIP,NETFLIX`) - `geoip:telegram`(`GEOIP,TELEGRAM`) - `geoip:twitter`(`GEOIP,TWITTER`) + - `geoip:tor`(`GEOIP,TOR`) ## 下载地址与使用方法 @@ -461,6 +462,8 @@ These two concepts are notable: `input` and `output`. The `input` is the data so - **maxmindMMDB**:MaxMind GeoLite2 country mmdb 数据格式(`GeoLite2-Country.mmdb`) - **maxmindGeoLite2ASNCSV**:MaxMind GeoLite2 ASN CSV 数据格式(`GeoLite2-ASN-CSV.zip`) - **maxmindGeoLite2CountryCSV**:MaxMind GeoLite2 country CSV 数据格式(`GeoLite2-Country-CSV.zip`) +- **dbipCountryMMDB**:DB-IP country mmdb 数据格式(`dbip-country-lite.mmdb`) +- **ipinfoCountryMMDB**:IPInfo country mmdb 数据格式(`country.mmdb`) - **mihomoMRS**:mihomo MRS 数据格式(`geoip-cn.mrs`) - **singboxSRS**:sing-box SRS 数据格式(`geoip-cn.srs`) - **clashRuleSetClassical**:[classical 类型的 Clash RuleSet](https://github.com/Dreamacro/clash/wiki/premium-core-features#classical) @@ -473,7 +476,9 @@ These two concepts are notable: `input` and `output`. The `input` is the data so - **stdout**:将纯文本 CIDR 输出到 standard output(例如:`1.0.0.0/24`) - **lookup**:从指定的列表中查找指定的 IP 或 CIDR - **v2rayGeoIPDat**:V2Ray GeoIP dat 数据格式(`geoip.dat`) -- **maxmindMMDB**:MaxMind mmdb 数据格式(`GeoLite2-Country.mmdb`) +- **maxmindMMDB**:MaxMind GeoLite2 country mmdb 数据格式(`GeoLite2-Country.mmdb`) +- **dbipCountryMMDB**:DB-IP country mmdb 数据格式(`dbip-country-lite.mmdb`) +- **ipinfoCountryMMDB**:IPInfo country mmdb 数据格式(`country.mmdb`) - **mihomoMRS**:mihomo MRS 数据格式(`geoip-cn.mrs`) - **singboxSRS**:sing-box SRS 数据格式(`geoip-cn.srs`) - **clashRuleSetClassical**:[classical 类型的 Clash RuleSet](https://github.com/Dreamacro/clash/wiki/premium-core-features#classical) @@ -482,9 +487,9 @@ These two concepts are notable: `input` and `output`. The `input` is the data so ### 注意事项 -由于 MaxMind mmdb 文件格式的限制,当不同列表的 IP 或 CIDR 数据有交集或重复项时,后写入的列表的 IP 或 CIDR 数据会覆盖(overwrite)之前已写入的列表的数据。譬如,IP `1.1.1.1` 同属于列表 `AU` 和列表 `Cloudflare`。如果 `Cloudflare` 在 `AU` 之后写入,则 IP `1.1.1.1` 归属于列表 `Cloudflare`。 +由于 MaxMind、DB-IP、IPInfo 的 mmdb 文件格式的限制,当不同列表的 IP 或 CIDR 数据有交集或重复项时,后写入的列表的 IP 或 CIDR 数据会覆盖(overwrite)之前已写入的列表的数据。譬如,IP `1.1.1.1` 同属于列表 `AU` 和列表 `Cloudflare`。如果 `Cloudflare` 在 `AU` 之后写入,则 IP `1.1.1.1` 归属于列表 `Cloudflare`。 -为了确保某些指定的列表、被修改的列表一定囊括属于它的所有 IP 或 CIDR 数据,可在 `output` 输出格式为 `maxmindMMDB` 的配置中增加选项 `overwriteList`,该选项中指定的列表会在最后逐一写入,列表中最后一项优先级最高。若已设置选项 `wantedList`,则无需设置 `overwriteList`。`wantedList` 中指定的列表会在最后逐一写入,列表中最后一项优先级最高。 +为了确保某些指定的列表、被修改的列表一定囊括属于它的所有 IP 或 CIDR 数据,可在 `output` 相应输出格式的配置中增加选项 `overwriteList`,该选项中指定的列表会在最后逐一写入,列表中最后一项优先级最高。若已设置选项 `wantedList`,则无需设置 `overwriteList`。`wantedList` 中指定的列表会在最后逐一写入,列表中最后一项优先级最高。 ## CLI 功能展示 @@ -527,6 +532,8 @@ All available input formats: - clashRuleSet (Convert ipcidr type of Clash RuleSet to other formats) - clashRuleSetClassical (Convert classical type of Clash RuleSet to other formats (just processing IP & CIDR lines)) - cutter (Remove data from previous steps) + - dbipCountryMMDB (Convert DB-IP country mmdb database to other formats) + - ipinfoCountryMMDB (Convert IPInfo country mmdb database to other formats) - json (Convert JSON data to other formats) - maxmindGeoLite2ASNCSV (Convert MaxMind GeoLite2 ASN CSV data to other formats) - maxmindGeoLite2CountryCSV (Convert MaxMind GeoLite2 country CSV data to other formats) @@ -543,6 +550,8 @@ All available input formats: All available output formats: - clashRuleSet (Convert data to ipcidr type of Clash RuleSet) - clashRuleSetClassical (Convert data to classical type of Clash RuleSet) + - dbipCountryMMDB (Convert data to DB-IP country mmdb database format) + - ipinfoCountryMMDB (Convert data to IPInfo country mmdb database format) - lookup (Lookup specified IP or CIDR from various formats of data) - maxmindMMDB (Convert data to MaxMind mmdb database format) - mihomoMRS (Convert data to mihomo MRS format) diff --git a/geoip/config.json b/geoip/config.json index 44444ca638..b7352e9f7a 100644 --- a/geoip/config.json +++ b/geoip/config.json @@ -44,6 +44,14 @@ "onlyIPType": "ipv6" } }, + { + "type": "text", + "action": "add", + "args": { + "name": "tor", + "uri": "https://check.torproject.org/torbulkexitlist" + } + }, { "type": "text", "action": "add", @@ -203,7 +211,8 @@ "google", "netflix", "telegram", - "twitter" + "twitter", + "tor" ] } }, @@ -231,7 +240,6 @@ "outputName": "Country.mmdb", "overwriteList": [ "cn", - "private", "cloudflare", "cloudfront", "facebook", @@ -239,7 +247,9 @@ "google", "netflix", "telegram", - "twitter" + "twitter", + "tor", + "private" ] } }, @@ -258,7 +268,8 @@ "google", "netflix", "telegram", - "twitter" + "twitter", + "tor" ] } }, @@ -285,7 +296,8 @@ "google", "netflix", "telegram", - "twitter" + "twitter", + "tor" ] } }, diff --git a/geoip/configuration.md b/geoip/configuration.md index 2a6d6ea440..ee248607c4 100644 --- a/geoip/configuration.md +++ b/geoip/configuration.md @@ -18,6 +18,8 @@ - **clashRuleSet**:ipcidr 类型的 Clash RuleSet - **clashRuleSetClassical**:classical 类型的 Clash RuleSet - **cutter**:用于裁剪前置步骤中的数据 +- **dbipCountryMMDB**:DB-IP country mmdb 数据格式(`dbip-country-lite.mmdb`) +- **ipinfoCountryMMDB**:IPInfo country mmdb 数据格式(`country.mmdb`) - **json**:JSON 数据格式 - **maxmindGeoLite2ASNCSV**:MaxMind GeoLite2 ASN CSV 数据格式(`GeoLite2-ASN-CSV.zip`) - **maxmindGeoLite2CountryCSV**:MaxMind GeoLite2 country CSV 数据格式(`GeoLite2-Country-CSV.zip`) @@ -34,8 +36,10 @@ - **clashRuleSet**:ipcidr 类型的 Clash RuleSet - **clashRuleSetClassical**:classical 类型的 Clash RuleSet +- **dbipCountryMMDB**:DB-IP country mmdb 数据格式(`dbip-country-lite.mmdb`) +- **ipinfoCountryMMDB**:IPInfo country mmdb 数据格式(`country.mmdb`) - **lookup**:从指定的列表中查找指定的 IP 或 CIDR -- **maxmindMMDB**:MaxMind mmdb 数据格式(`GeoLite2-Country.mmdb`) +- **maxmindMMDB**:MaxMind GeoLite2 country mmdb 数据格式(`GeoLite2-Country.mmdb`) - **mihomoMRS**:mihomo MRS 数据格式(`geoip-cn.mrs`) - **singboxSRS**:sing-box SRS 数据格式(`geoip-cn.srs`) - **stdout**:将纯文本 CIDR 输出到 standard output(例如:`1.0.0.0/24`) @@ -166,6 +170,110 @@ } ``` +### **dbipCountryMMDB** + +- **type**:(必须)输入格式的名称 +- **action**:(必须)操作类型,值为 `add`(添加 IP 地址)或 `remove`(移除 IP 地址) +- **args**:(可选) + - **uri**:(可选)DB-IP country MMDB 格式文件路径,可为本地文件路径或远程 `http`、`https` 文件 URL。 + - **wantedList**:(可选)指定需要的类别/文件。 + - **onlyIPType**:(可选)只处理的 IP 地址类型,值为 `ipv4` 或 `ipv6`。 + +```jsonc +// 默认使用文件: +// ./db-ip/dbip-country-lite.mmdb +{ + "type": "dbipCountryMMDB", + "action": "add" // 添加 IP 地址 +} +``` + +```jsonc +{ + "type": "dbipCountryMMDB", + "action": "add", // 添加 IP 地址 + "args": { + "uri": "./db-ip/dbip-country-lite.mmdb" + } +} +``` + +```jsonc +{ + "type": "dbipCountryMMDB", + "action": "add", // 添加 IP 地址 + "args": { + "uri": "https://example.com/my.mmdb", + "wantedList": ["cn", "us", "jp"], // 只需要名为 cn、us、jp 的类别 + "onlyIPType": "ipv4" // 只添加 IPv4 地址 + } +} +``` + +```jsonc +{ + "type": "dbipCountryMMDB", + "action": "remove", // 添加 IP 地址 + "args": { + "uri": "https://example.com/my.mmdb", + "wantedList": ["cn", "us", "jp"], // 只移除名为 cn、us、jp 这三个类别的 IPv4 地址 + "onlyIPType": "ipv4" // 只移除 IPv4 地址 + } +} +``` + +### **ipinfoCountryMMDB** + +- **type**:(必须)输入格式的名称 +- **action**:(必须)操作类型,值为 `add`(添加 IP 地址)或 `remove`(移除 IP 地址) +- **args**:(可选) + - **uri**:(可选)IPInfo country MMDB 格式文件路径,可为本地文件路径或远程 `http`、`https` 文件 URL。 + - **wantedList**:(可选)指定需要的类别/文件。 + - **onlyIPType**:(可选)只处理的 IP 地址类型,值为 `ipv4` 或 `ipv6`。 + +```jsonc +// 默认使用文件: +// ./ipinfo/country.mmdb +{ + "type": "ipinfoCountryMMDB", + "action": "add" // 添加 IP 地址 +} +``` + +```jsonc +{ + "type": "ipinfoCountryMMDB", + "action": "add", // 添加 IP 地址 + "args": { + "uri": "./ipinfo/country.mmdb" + } +} +``` + +```jsonc +{ + "type": "ipinfoCountryMMDB", + "action": "add", // 添加 IP 地址 + "args": { + "uri": "https://example.com/my.mmdb", + "wantedList": ["cn", "us", "jp"], // 只需要名为 cn、us、jp 的类别 + "onlyIPType": "ipv4" // 只添加 IPv4 地址 + } +} +``` + +```jsonc +{ + "type": "ipinfoCountryMMDB", + "action": "remove", // 添加 IP 地址 + "args": { + "uri": "https://example.com/my.mmdb", + "wantedList": ["cn", "us", "jp"], // 只移除名为 cn、us、jp 这三个类别的 IPv4 地址 + "onlyIPType": "ipv4" // 只移除 IPv4 地址 + } +} +``` + ### **json** - **type**:(必须)输入格式的名称 @@ -854,6 +962,200 @@ } ``` +### **dbipCountryMMDB** + +- **type**:(必须)输入格式的名称 +- **action**:(必须)操作类型,值必须为 `output` +- **args**:(可选) + - **outputName**:(可选)输出的文件名 + - **outputDir**:(可选)输出目录 + - **onlyIPType**:(可选)输出的 IP 地址类型,值为 `ipv4` 或 `ipv6` + - **wantedList**:(可选,数组)指定需要输出的类别 + - **excludedList**:(可选,数组)指定不需要输出的类别 + - **overwriteList**:(可选,数组)指定最后写入的类别(原因见👇) + +> 由于 DB-IP mmdb 文件格式的限制,当不同列表的 IP 或 CIDR 数据有交集或重复项时,后写入的列表的 IP 或 CIDR 数据会覆盖(overwrite)之前已写入的列表的数据。譬如,IP `1.1.1.1` 同属于列表 `AU` 和列表 `Cloudflare`。如果 `Cloudflare` 在 `AU` 之后写入,则 IP `1.1.1.1` 最终归属于列表 `Cloudflare`。 +> +> 为了确保某些指定的列表、被修改的列表一定囊括属于它的所有 IP 或 CIDR 数据,可在 output 输出格式为 `dbipCountryMMDB` 的配置中增加选项 `overwriteList`,该选项中指定的列表会在最后逐一写入,列表中最后一项优先级最高。若已设置选项 `wantedList`,则无需设置 `overwriteList`。`wantedList` 中指定的列表会在最后逐一写入,列表中最后一项优先级最高。 +> +> `wantedList`、`overwriteList`、`excludedList` 三者中,`excludedList` 优先级最高。即:若设置了选项 `excludedList`,最终不会输出存在于 `excludedList` 中的列表。 + +```jsonc +// 默认输出目录 ./output/db-ip +{ + "type": "dbipCountryMMDB", + "action": "output" +} +``` + +```jsonc +{ + "type": "dbipCountryMMDB", + "action": "output", + "args": { + "outputDir": "./output", // 输出文件到 output 目录 + "outputName": "Country-only-cn-private.mmdb", // 输出文件名为 Country-only-cn-private.mmdb + "wantedList": ["cn", "private"] // 只输出 cn、private 类别 + } +} +``` + +```jsonc +{ + "type": "dbipCountryMMDB", + "action": "output", + "args": { + "outputDir": "./output", // 输出文件到 output 目录 + "outputName": "Country-without-cn-private.mmdb", // 输出文件名为 Country-without-cn-private.mmdb + "excludedList": ["cn", "private"] // 不输出 cn、private 类别 + } +} +``` + +```jsonc +{ + "type": "dbipCountryMMDB", + "action": "output", + "args": { + "outputName": "Country.mmdb", // 输出文件名为 Country.mmdb + "overwriteList": ["cn", "google"] // 确保 cn、google 类别最后写入,且 google 比 cn 后写入 + } +} +``` + +```jsonc +{ + "type": "dbipCountryMMDB", + "action": "output", + "args": { + "outputName": "Country.mmdb", // 输出文件名为 Country.mmdb + "overwriteList": ["cn", "google"], // 确保 cn、google 类别最后写入,且 google 比 cn 后写入 + "onlyIPType": "ipv4" // 只输出 cn、private 类别的 IPv4 地址 + } +} +``` + +```jsonc +{ + "type": "dbipCountryMMDB", + "action": "output", + "args": { + "outputName": "Country.mmdb", // 输出文件名为 Country.mmdb + "excludedList": ["private"], // 最终不输出 private 类别 + "wantedList": ["private" ,"au", "cloudflare"] // 只输出 au、cloudflare 类别,并确保 cloudflare 比 au 后写入。但由于 private 存在于 excludedList 中,最终不输出 private 类别 + } +} +``` + +```jsonc +{ + "type": "dbipCountryMMDB", + "action": "output", + "args": { + "outputName": "Country.mmdb", // 输出文件名为 Country.mmdb + "excludedList": ["private"], // 最终不输出 private 类别 + "overwriteList": ["private" ,"cn", "google"] // 确保 cn、google 类别最后写入,且 google 比 cn 后写入。但由于 private 存在于 excludedList 中,最终不输出 private 类别 + } +} +``` + +### **ipinfoCountryMMDB** + +- **type**:(必须)输入格式的名称 +- **action**:(必须)操作类型,值必须为 `output` +- **args**:(可选) + - **outputName**:(可选)输出的文件名 + - **outputDir**:(可选)输出目录 + - **onlyIPType**:(可选)输出的 IP 地址类型,值为 `ipv4` 或 `ipv6` + - **wantedList**:(可选,数组)指定需要输出的类别 + - **excludedList**:(可选,数组)指定不需要输出的类别 + - **overwriteList**:(可选,数组)指定最后写入的类别(原因见👇) + +> 由于 IPInfo mmdb 文件格式的限制,当不同列表的 IP 或 CIDR 数据有交集或重复项时,后写入的列表的 IP 或 CIDR 数据会覆盖(overwrite)之前已写入的列表的数据。譬如,IP `1.1.1.1` 同属于列表 `AU` 和列表 `Cloudflare`。如果 `Cloudflare` 在 `AU` 之后写入,则 IP `1.1.1.1` 最终归属于列表 `Cloudflare`。 +> +> 为了确保某些指定的列表、被修改的列表一定囊括属于它的所有 IP 或 CIDR 数据,可在 output 输出格式为 `ipinfoCountryMMDB` 的配置中增加选项 `overwriteList`,该选项中指定的列表会在最后逐一写入,列表中最后一项优先级最高。若已设置选项 `wantedList`,则无需设置 `overwriteList`。`wantedList` 中指定的列表会在最后逐一写入,列表中最后一项优先级最高。 +> +> `wantedList`、`overwriteList`、`excludedList` 三者中,`excludedList` 优先级最高。即:若设置了选项 `excludedList`,最终不会输出存在于 `excludedList` 中的列表。 + +```jsonc +// 默认输出目录 ./output/ipinfo +{ + "type": "ipinfoCountryMMDB", + "action": "output" +} +``` + +```jsonc +{ + "type": "ipinfoCountryMMDB", + "action": "output", + "args": { + "outputDir": "./output", // 输出文件到 output 目录 + "outputName": "Country-only-cn-private.mmdb", // 输出文件名为 Country-only-cn-private.mmdb + "wantedList": ["cn", "private"] // 只输出 cn、private 类别 + } +} +``` + +```jsonc +{ + "type": "ipinfoCountryMMDB", + "action": "output", + "args": { + "outputDir": "./output", // 输出文件到 output 目录 + "outputName": "Country-without-cn-private.mmdb", // 输出文件名为 Country-without-cn-private.mmdb + "excludedList": ["cn", "private"] // 不输出 cn、private 类别 + } +} +``` + +```jsonc +{ + "type": "ipinfoCountryMMDB", + "action": "output", + "args": { + "outputName": "Country.mmdb", // 输出文件名为 Country.mmdb + "overwriteList": ["cn", "google"] // 确保 cn、google 类别最后写入,且 google 比 cn 后写入 + } +} +``` + +```jsonc +{ + "type": "ipinfoCountryMMDB", + "action": "output", + "args": { + "outputName": "Country.mmdb", // 输出文件名为 Country.mmdb + "overwriteList": ["cn", "google"], // 确保 cn、google 类别最后写入,且 google 比 cn 后写入 + "onlyIPType": "ipv4" // 只输出 cn、private 类别的 IPv4 地址 + } +} +``` + +```jsonc +{ + "type": "ipinfoCountryMMDB", + "action": "output", + "args": { + "outputName": "Country.mmdb", // 输出文件名为 Country.mmdb + "excludedList": ["private"], // 最终不输出 private 类别 + "wantedList": ["private" ,"au", "cloudflare"] // 只输出 au、cloudflare 类别,并确保 cloudflare 比 au 后写入。但由于 private 存在于 excludedList 中,最终不输出 private 类别 + } +} +``` + +```jsonc +{ + "type": "ipinfoCountryMMDB", + "action": "output", + "args": { + "outputName": "Country.mmdb", // 输出文件名为 Country.mmdb + "excludedList": ["private"], // 最终不输出 private 类别 + "overwriteList": ["private" ,"cn", "google"] // 确保 cn、google 类别最后写入,且 google 比 cn 后写入。但由于 private 存在于 excludedList 中,最终不输出 private 类别 + } +} +``` + ### **lookup** - **type**:(必须)输入格式的名称 diff --git a/geoip/go.mod b/geoip/go.mod index 5a445dc5aa..ed5bb6c82e 100644 --- a/geoip/go.mod +++ b/geoip/go.mod @@ -7,6 +7,7 @@ toolchain go1.23.2 require ( github.com/klauspost/compress v1.17.11 github.com/maxmind/mmdbwriter v1.0.0 + github.com/oschwald/geoip2-golang v1.11.0 github.com/oschwald/maxminddb-golang v1.13.1 github.com/sagernet/sing-box v1.10.1 github.com/spf13/cobra v1.8.1 diff --git a/geoip/go.sum b/geoip/go.sum index 72055a5f9a..2bc39c3b63 100644 --- a/geoip/go.sum +++ b/geoip/go.sum @@ -22,6 +22,8 @@ github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWb github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/onsi/ginkgo/v2 v2.9.7 h1:06xGQy5www2oN160RtEZoTvnP2sPhEfePYmCDc2szss= github.com/onsi/ginkgo/v2 v2.9.7/go.mod h1:cxrmXWykAwTwhQsJOPfdIDiJ+l2RYq7U8hFU+M/1uw0= +github.com/oschwald/geoip2-golang v1.11.0 h1:hNENhCn1Uyzhf9PTmquXENiWS6AlxAEnBII6r8krA3w= +github.com/oschwald/geoip2-golang v1.11.0/go.mod h1:P9zG+54KPEFOliZ29i7SeYZ/GM6tfEL+rgSn03hYuUo= github.com/oschwald/maxminddb-golang v1.13.1 h1:G3wwjdN9JmIK2o/ermkHM+98oX5fS+k5MbwsmL4MRQE= github.com/oschwald/maxminddb-golang v1.13.1/go.mod h1:K4pgV9N/GcK694KSTmVSDTODk4IsCNThNdTmnaBZ/F8= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= diff --git a/geoip/lookup.go b/geoip/lookup.go index 503eeed97e..442229c7a4 100644 --- a/geoip/lookup.go +++ b/geoip/lookup.go @@ -21,6 +21,8 @@ import ( var supportedInputFormats = map[string]bool{ strings.ToLower("clashRuleSet"): true, strings.ToLower("clashRuleSetClassical"): true, + strings.ToLower("dbipCountryMMDB"): true, + strings.ToLower("ipinfoCountryMMDB"): true, strings.ToLower("maxmindMMDB"): true, strings.ToLower("mihomoMRS"): true, strings.ToLower("singboxSRS"): true, @@ -32,7 +34,7 @@ var supportedInputFormats = map[string]bool{ func init() { rootCmd.AddCommand(lookupCmd) - lookupCmd.Flags().StringP("format", "f", "", "(Required) The input format. Available formats: text, v2rayGeoIPDat, maxmindMMDB, mihomoMRS, singboxSRS, clashRuleSet, clashRuleSetClassical, surgeRuleSet") + lookupCmd.Flags().StringP("format", "f", "", "(Required) The input format. Available formats: text, v2rayGeoIPDat, maxmindMMDB, dbipCountryMMDB, ipinfoCountryMMDB, mihomoMRS, singboxSRS, clashRuleSet, clashRuleSetClassical, surgeRuleSet") lookupCmd.Flags().StringP("uri", "u", "", "URI of the input file, support both local file path and remote HTTP(S) URL. (Cannot be used with \"dir\" flag)") lookupCmd.Flags().StringP("dir", "d", "", "Path to the input directory. The filename without extension will be as the name of the list. (Cannot be used with \"uri\" flag)") lookupCmd.Flags().StringSliceP("searchlist", "l", []string{}, "The lists to search from, separated by comma") @@ -161,13 +163,29 @@ func getInputForLookup(format, name, uri, dir string) lib.InputConverter { switch strings.ToLower(format) { case strings.ToLower(maxmind.TypeMaxmindMMDBIn): - input = &maxmind.MaxmindMMDBIn{ + input = &maxmind.MMDBIn{ Type: maxmind.TypeMaxmindMMDBIn, Action: lib.ActionAdd, Description: maxmind.DescMaxmindMMDBIn, URI: uri, } + case strings.ToLower(maxmind.TypeDBIPCountryMMDBIn): + input = &maxmind.MMDBIn{ + Type: maxmind.TypeDBIPCountryMMDBIn, + Action: lib.ActionAdd, + Description: maxmind.DescDBIPCountryMMDBIn, + URI: uri, + } + + case strings.ToLower(maxmind.TypeIPInfoCountryMMDBIn): + input = &maxmind.MMDBIn{ + Type: maxmind.TypeIPInfoCountryMMDBIn, + Action: lib.ActionAdd, + Description: maxmind.DescIPInfoCountryMMDBIn, + URI: uri, + } + case strings.ToLower(mihomo.TypeMRSIn): input = &mihomo.MRSIn{ Type: mihomo.TypeMRSIn, diff --git a/geoip/plugin/maxmind/common_in.go b/geoip/plugin/maxmind/common_in.go new file mode 100644 index 0000000000..0bf61e51fc --- /dev/null +++ b/geoip/plugin/maxmind/common_in.go @@ -0,0 +1,59 @@ +package maxmind + +import ( + "encoding/json" + "path/filepath" + "strings" + + "github.com/Loyalsoldier/geoip/lib" +) + +var ( + defaultGeoLite2MMDBFile = filepath.Join("./", "geolite2", "GeoLite2-Country.mmdb") + defaultDBIPCountryMMDBFile = filepath.Join("./", "db-ip", "dbip-country-lite.mmdb") + defaultIPInfoCountryMMDBFile = filepath.Join("./", "ipinfo", "country.mmdb") +) + +func newMMDBIn(iType string, iDesc string, action lib.Action, data json.RawMessage) (lib.InputConverter, error) { + var tmp struct { + URI string `json:"uri"` + Want []string `json:"wantedList"` + OnlyIPType lib.IPType `json:"onlyIPType"` + } + + if len(data) > 0 { + if err := json.Unmarshal(data, &tmp); err != nil { + return nil, err + } + } + + if tmp.URI == "" { + switch iType { + case TypeMaxmindMMDBIn: + tmp.URI = defaultGeoLite2MMDBFile + + case TypeDBIPCountryMMDBIn: + tmp.URI = defaultDBIPCountryMMDBFile + + case TypeIPInfoCountryMMDBIn: + tmp.URI = defaultIPInfoCountryMMDBFile + } + } + + // Filter want list + wantList := make(map[string]bool) + for _, want := range tmp.Want { + if want = strings.ToUpper(strings.TrimSpace(want)); want != "" { + wantList[want] = true + } + } + + return &MMDBIn{ + Type: iType, + Action: action, + Description: iDesc, + URI: tmp.URI, + Want: wantList, + OnlyIPType: tmp.OnlyIPType, + }, nil +} diff --git a/geoip/plugin/maxmind/common_out.go b/geoip/plugin/maxmind/common_out.go new file mode 100644 index 0000000000..28b18c3c31 --- /dev/null +++ b/geoip/plugin/maxmind/common_out.go @@ -0,0 +1,61 @@ +package maxmind + +import ( + "encoding/json" + "path/filepath" + + "github.com/Loyalsoldier/geoip/lib" +) + +var ( + defaultOutputName = "Country.mmdb" + defaultMaxmindOutputDir = filepath.Join("./", "output", "maxmind") + defaultDBIPOutputDir = filepath.Join("./", "output", "db-ip") + defaultIPInfoOutputDir = filepath.Join("./", "output", "ipinfo") +) + +func newMMDBOut(iType string, iDesc string, action lib.Action, data json.RawMessage) (lib.OutputConverter, error) { + var tmp struct { + OutputName string `json:"outputName"` + OutputDir string `json:"outputDir"` + Want []string `json:"wantedList"` + Overwrite []string `json:"overwriteList"` + Exclude []string `json:"excludedList"` + OnlyIPType lib.IPType `json:"onlyIPType"` + } + + if len(data) > 0 { + if err := json.Unmarshal(data, &tmp); err != nil { + return nil, err + } + } + + if tmp.OutputName == "" { + tmp.OutputName = defaultOutputName + } + + if tmp.OutputDir == "" { + switch iType { + case TypeMaxmindMMDBOut: + tmp.OutputDir = defaultMaxmindOutputDir + + case TypeDBIPCountryMMDBOut: + tmp.OutputDir = defaultDBIPOutputDir + + case TypeIPInfoCountryMMDBOut: + tmp.OutputDir = defaultIPInfoOutputDir + } + } + + return &MMDBOut{ + Type: iType, + Action: action, + Description: iDesc, + OutputName: tmp.OutputName, + OutputDir: tmp.OutputDir, + Want: tmp.Want, + Overwrite: tmp.Overwrite, + Exclude: tmp.Exclude, + OnlyIPType: tmp.OnlyIPType, + }, nil +} diff --git a/geoip/plugin/maxmind/dbip_country_mmdb_in.go b/geoip/plugin/maxmind/dbip_country_mmdb_in.go new file mode 100644 index 0000000000..b23e753c50 --- /dev/null +++ b/geoip/plugin/maxmind/dbip_country_mmdb_in.go @@ -0,0 +1,26 @@ +package maxmind + +import ( + "encoding/json" + + "github.com/Loyalsoldier/geoip/lib" +) + +/* +The types in this file extend the type `typeMaxmindMMDBIn`, +which make it possible to support more formats for the project. +*/ + +const ( + TypeDBIPCountryMMDBIn = "dbipCountryMMDB" + DescDBIPCountryMMDBIn = "Convert DB-IP country mmdb database to other formats" +) + +func init() { + lib.RegisterInputConfigCreator(TypeDBIPCountryMMDBIn, func(action lib.Action, data json.RawMessage) (lib.InputConverter, error) { + return newMMDBIn(TypeDBIPCountryMMDBIn, DescDBIPCountryMMDBIn, action, data) + }) + lib.RegisterInputConverter(TypeDBIPCountryMMDBIn, &MMDBIn{ + Description: DescDBIPCountryMMDBIn, + }) +} diff --git a/geoip/plugin/maxmind/dbip_country_mmdb_out.go b/geoip/plugin/maxmind/dbip_country_mmdb_out.go new file mode 100644 index 0000000000..e60a3adf13 --- /dev/null +++ b/geoip/plugin/maxmind/dbip_country_mmdb_out.go @@ -0,0 +1,26 @@ +package maxmind + +import ( + "encoding/json" + + "github.com/Loyalsoldier/geoip/lib" +) + +/* +The types in this file extend the type `typeMaxmindMMDBOut`, +which make it possible to support more formats for the project. +*/ + +const ( + TypeDBIPCountryMMDBOut = "dbipCountryMMDB" + DescDBIPCountryMMDBOut = "Convert data to DB-IP country mmdb database format" +) + +func init() { + lib.RegisterOutputConfigCreator(TypeDBIPCountryMMDBOut, func(action lib.Action, data json.RawMessage) (lib.OutputConverter, error) { + return newMMDBOut(TypeDBIPCountryMMDBOut, DescDBIPCountryMMDBOut, action, data) + }) + lib.RegisterOutputConverter(TypeDBIPCountryMMDBOut, &MMDBOut{ + Description: DescDBIPCountryMMDBOut, + }) +} diff --git a/geoip/plugin/maxmind/ipinfo_country_mmdb_in.go b/geoip/plugin/maxmind/ipinfo_country_mmdb_in.go new file mode 100644 index 0000000000..4e7b1a5cf2 --- /dev/null +++ b/geoip/plugin/maxmind/ipinfo_country_mmdb_in.go @@ -0,0 +1,26 @@ +package maxmind + +import ( + "encoding/json" + + "github.com/Loyalsoldier/geoip/lib" +) + +/* +The types in this file extend the type `typeMaxmindMMDBIn`, +which make it possible to support more formats for the project. +*/ + +const ( + TypeIPInfoCountryMMDBIn = "ipinfoCountryMMDB" + DescIPInfoCountryMMDBIn = "Convert IPInfo country mmdb database to other formats" +) + +func init() { + lib.RegisterInputConfigCreator(TypeIPInfoCountryMMDBIn, func(action lib.Action, data json.RawMessage) (lib.InputConverter, error) { + return newMMDBIn(TypeIPInfoCountryMMDBIn, DescIPInfoCountryMMDBIn, action, data) + }) + lib.RegisterInputConverter(TypeIPInfoCountryMMDBIn, &MMDBIn{ + Description: DescIPInfoCountryMMDBIn, + }) +} diff --git a/geoip/plugin/maxmind/ipinfo_country_mmdb_out.go b/geoip/plugin/maxmind/ipinfo_country_mmdb_out.go new file mode 100644 index 0000000000..ac9e5a343f --- /dev/null +++ b/geoip/plugin/maxmind/ipinfo_country_mmdb_out.go @@ -0,0 +1,26 @@ +package maxmind + +import ( + "encoding/json" + + "github.com/Loyalsoldier/geoip/lib" +) + +/* +The types in this file extend the type `typeMaxmindMMDBOut`, +which make it possible to support more formats for the project. +*/ + +const ( + TypeIPInfoCountryMMDBOut = "ipinfoCountryMMDB" + DescIPInfoCountryMMDBOut = "Convert data to IPInfo country mmdb database format" +) + +func init() { + lib.RegisterOutputConfigCreator(TypeIPInfoCountryMMDBOut, func(action lib.Action, data json.RawMessage) (lib.OutputConverter, error) { + return newMMDBOut(TypeIPInfoCountryMMDBOut, DescIPInfoCountryMMDBOut, action, data) + }) + lib.RegisterOutputConverter(TypeIPInfoCountryMMDBOut, &MMDBOut{ + Description: DescIPInfoCountryMMDBOut, + }) +} diff --git a/geoip/plugin/maxmind/asn_csv.go b/geoip/plugin/maxmind/maxmind_asn_csv_in.go similarity index 100% rename from geoip/plugin/maxmind/asn_csv.go rename to geoip/plugin/maxmind/maxmind_asn_csv_in.go diff --git a/geoip/plugin/maxmind/country_csv.go b/geoip/plugin/maxmind/maxmind_country_csv_in.go similarity index 100% rename from geoip/plugin/maxmind/country_csv.go rename to geoip/plugin/maxmind/maxmind_country_csv_in.go diff --git a/geoip/plugin/maxmind/mmdb_in.go b/geoip/plugin/maxmind/maxmind_country_mmdb_in.go similarity index 51% rename from geoip/plugin/maxmind/mmdb_in.go rename to geoip/plugin/maxmind/maxmind_country_mmdb_in.go index 80fa2523c2..d69acbdc1a 100644 --- a/geoip/plugin/maxmind/mmdb_in.go +++ b/geoip/plugin/maxmind/maxmind_country_mmdb_in.go @@ -3,11 +3,12 @@ package maxmind import ( "encoding/json" "fmt" + "net" "os" - "path/filepath" "strings" "github.com/Loyalsoldier/geoip/lib" + "github.com/oschwald/geoip2-golang" "github.com/oschwald/maxminddb-golang" ) @@ -16,55 +17,16 @@ const ( DescMaxmindMMDBIn = "Convert MaxMind mmdb database to other formats" ) -var ( - defaultMMDBFile = filepath.Join("./", "geolite2", "GeoLite2-Country.mmdb") -) - func init() { lib.RegisterInputConfigCreator(TypeMaxmindMMDBIn, func(action lib.Action, data json.RawMessage) (lib.InputConverter, error) { - return newMaxmindMMDBIn(action, data) + return newMMDBIn(TypeMaxmindMMDBIn, DescMaxmindMMDBIn, action, data) }) - lib.RegisterInputConverter(TypeMaxmindMMDBIn, &MaxmindMMDBIn{ + lib.RegisterInputConverter(TypeMaxmindMMDBIn, &MMDBIn{ Description: DescMaxmindMMDBIn, }) } -func newMaxmindMMDBIn(action lib.Action, data json.RawMessage) (lib.InputConverter, error) { - var tmp struct { - URI string `json:"uri"` - Want []string `json:"wantedList"` - OnlyIPType lib.IPType `json:"onlyIPType"` - } - - if len(data) > 0 { - if err := json.Unmarshal(data, &tmp); err != nil { - return nil, err - } - } - - if tmp.URI == "" { - tmp.URI = defaultMMDBFile - } - - // Filter want list - wantList := make(map[string]bool) - for _, want := range tmp.Want { - if want = strings.ToUpper(strings.TrimSpace(want)); want != "" { - wantList[want] = true - } - } - - return &MaxmindMMDBIn{ - Type: TypeMaxmindMMDBIn, - Action: action, - Description: DescMaxmindMMDBIn, - URI: tmp.URI, - Want: wantList, - OnlyIPType: tmp.OnlyIPType, - }, nil -} - -type MaxmindMMDBIn struct { +type MMDBIn struct { Type string Action lib.Action Description string @@ -73,19 +35,19 @@ type MaxmindMMDBIn struct { OnlyIPType lib.IPType } -func (m *MaxmindMMDBIn) GetType() string { +func (m *MMDBIn) GetType() string { return m.Type } -func (m *MaxmindMMDBIn) GetAction() lib.Action { +func (m *MMDBIn) GetAction() lib.Action { return m.Action } -func (m *MaxmindMMDBIn) GetDescription() string { +func (m *MMDBIn) GetDescription() string { return m.Description } -func (m *MaxmindMMDBIn) Input(container lib.Container) (lib.Container, error) { +func (m *MMDBIn) Input(container lib.Container) (lib.Container, error) { var content []byte var err error switch { @@ -134,7 +96,7 @@ func (m *MaxmindMMDBIn) Input(container lib.Container) (lib.Container, error) { return container, nil } -func (m *MaxmindMMDBIn) generateEntries(content []byte, entries map[string]*lib.Entry) error { +func (m *MMDBIn) generateEntries(content []byte, entries map[string]*lib.Entry) error { db, err := maxminddb.FromBytes(content) if err != nil { return err @@ -143,32 +105,42 @@ func (m *MaxmindMMDBIn) generateEntries(content []byte, entries map[string]*lib. networks := db.Networks(maxminddb.SkipAliasedNetworks) for networks.Next() { - record := struct { - Country struct { - IsoCode string `maxminddb:"iso_code"` - } `maxminddb:"country"` - RegisteredCountry struct { - IsoCode string `maxminddb:"iso_code"` - } `maxminddb:"registered_country"` - RepresentedCountry struct { - IsoCode string `maxminddb:"iso_code"` - } `maxminddb:"represented_country"` - }{} + var name string + var subnet *net.IPNet + var err error - subnet, err := networks.Network(&record) - if err != nil { - continue + switch m.Type { + case TypeMaxmindMMDBIn, TypeDBIPCountryMMDBIn: + var record geoip2.Country + subnet, err = networks.Network(&record) + if err != nil { + return err + } + + switch { + case strings.TrimSpace(record.Country.IsoCode) != "": + name = strings.ToUpper(strings.TrimSpace(record.Country.IsoCode)) + case strings.TrimSpace(record.RegisteredCountry.IsoCode) != "": + name = strings.ToUpper(strings.TrimSpace(record.RegisteredCountry.IsoCode)) + case strings.TrimSpace(record.RepresentedCountry.IsoCode) != "": + name = strings.ToUpper(strings.TrimSpace(record.RepresentedCountry.IsoCode)) + } + + case TypeIPInfoCountryMMDBIn: + record := struct { + Country string `maxminddb:"country"` + }{} + subnet, err = networks.Network(&record) + if err != nil { + return err + } + name = strings.ToUpper(strings.TrimSpace(record.Country)) + + default: + return lib.ErrNotSupportedFormat } - name := "" - switch { - case strings.TrimSpace(record.Country.IsoCode) != "": - name = strings.ToUpper(strings.TrimSpace(record.Country.IsoCode)) - case strings.TrimSpace(record.RegisteredCountry.IsoCode) != "": - name = strings.ToUpper(strings.TrimSpace(record.RegisteredCountry.IsoCode)) - case strings.TrimSpace(record.RepresentedCountry.IsoCode) != "": - name = strings.ToUpper(strings.TrimSpace(record.RepresentedCountry.IsoCode)) - default: + if name == "" || subnet == nil { continue } diff --git a/geoip/plugin/maxmind/mmdb_out.go b/geoip/plugin/maxmind/maxmind_country_mmdb_out.go similarity index 75% rename from geoip/plugin/maxmind/mmdb_out.go rename to geoip/plugin/maxmind/maxmind_country_mmdb_out.go index 08e0c04c91..46883f909c 100644 --- a/geoip/plugin/maxmind/mmdb_out.go +++ b/geoip/plugin/maxmind/maxmind_country_mmdb_out.go @@ -19,57 +19,15 @@ const ( DescMaxmindMMDBOut = "Convert data to MaxMind mmdb database format" ) -var ( - defaultOutputName = "Country.mmdb" - defaultOutputDir = filepath.Join("./", "output", "maxmind") -) - func init() { lib.RegisterOutputConfigCreator(TypeMaxmindMMDBOut, func(action lib.Action, data json.RawMessage) (lib.OutputConverter, error) { - return newMMDBOut(action, data) + return newMMDBOut(TypeMaxmindMMDBOut, DescMaxmindMMDBOut, action, data) }) lib.RegisterOutputConverter(TypeMaxmindMMDBOut, &MMDBOut{ Description: DescMaxmindMMDBOut, }) } -func newMMDBOut(action lib.Action, data json.RawMessage) (lib.OutputConverter, error) { - var tmp struct { - OutputName string `json:"outputName"` - OutputDir string `json:"outputDir"` - Want []string `json:"wantedList"` - Overwrite []string `json:"overwriteList"` - Exclude []string `json:"excludedList"` - OnlyIPType lib.IPType `json:"onlyIPType"` - } - - if len(data) > 0 { - if err := json.Unmarshal(data, &tmp); err != nil { - return nil, err - } - } - - if tmp.OutputName == "" { - tmp.OutputName = defaultOutputName - } - - if tmp.OutputDir == "" { - tmp.OutputDir = defaultOutputDir - } - - return &MMDBOut{ - Type: TypeMaxmindMMDBOut, - Action: action, - Description: DescMaxmindMMDBOut, - OutputName: tmp.OutputName, - OutputDir: tmp.OutputDir, - Want: tmp.Want, - Overwrite: tmp.Overwrite, - Exclude: tmp.Exclude, - OnlyIPType: tmp.OnlyIPType, - }, nil -} - type MMDBOut struct { Type string Action lib.Action @@ -95,11 +53,30 @@ func (m *MMDBOut) GetDescription() string { } func (m *MMDBOut) Output(container lib.Container) error { + dbName := "" + dbDesc := "" + recordSize := 28 + + switch m.Type { + case TypeMaxmindMMDBOut: + dbName = "GeoLite2-Country" + dbDesc = "Customized GeoLite2 Country database" + + case TypeDBIPCountryMMDBOut: + dbName = "DBIP-Country-Lite" + dbDesc = "Customized DB-IP Country Lite database" + + case TypeIPInfoCountryMMDBOut: + dbName = "IPInfo-Country" + dbDesc = "Customized IPInfo Country database" + recordSize = 32 + } + writer, err := mmdbwriter.New( mmdbwriter.Options{ - DatabaseType: "GeoLite2-Country", - Description: map[string]string{"en": "Customized GeoLite2 Country database"}, - RecordSize: 24, + DatabaseType: dbName, + Description: map[string]string{"en": dbDesc}, + RecordSize: recordSize, IncludeReservedNetworks: true, }, ) @@ -200,10 +177,19 @@ func (m *MMDBOut) marshalData(writer *mmdbwriter.Tree, entry *lib.Entry) error { return err } - record := mmdbtype.Map{ - "country": mmdbtype.Map{ - "iso_code": mmdbtype.String(entry.GetName()), - }, + var record mmdbtype.DataType + switch m.Type { + case TypeMaxmindMMDBOut, TypeDBIPCountryMMDBOut: + record = mmdbtype.Map{ + "country": mmdbtype.Map{ + "iso_code": mmdbtype.String(entry.GetName()), + }, + } + + case TypeIPInfoCountryMMDBOut: + record = mmdbtype.Map{ + "country": mmdbtype.String(entry.GetName()), + } } for _, cidr := range entryCidr { diff --git a/geoip/plugin/plaintext/clash_in.go b/geoip/plugin/plaintext/clash_in.go index 78af932f3f..9dc9ae2ddb 100644 --- a/geoip/plugin/plaintext/clash_in.go +++ b/geoip/plugin/plaintext/clash_in.go @@ -21,14 +21,14 @@ const ( func init() { lib.RegisterInputConfigCreator(TypeClashRuleSetClassicalIn, func(action lib.Action, data json.RawMessage) (lib.InputConverter, error) { - return newTextIn(TypeClashRuleSetClassicalIn, action, data) + return newTextIn(TypeClashRuleSetClassicalIn, DescClashClassicalIn, action, data) }) lib.RegisterInputConverter(TypeClashRuleSetClassicalIn, &TextIn{ Description: DescClashClassicalIn, }) lib.RegisterInputConfigCreator(TypeClashRuleSetIPCIDRIn, func(action lib.Action, data json.RawMessage) (lib.InputConverter, error) { - return newTextIn(TypeClashRuleSetIPCIDRIn, action, data) + return newTextIn(TypeClashRuleSetIPCIDRIn, DescClashRuleSetIn, action, data) }) lib.RegisterInputConverter(TypeClashRuleSetIPCIDRIn, &TextIn{ Description: DescClashRuleSetIn, diff --git a/geoip/plugin/plaintext/clash_out.go b/geoip/plugin/plaintext/clash_out.go index 28071c8454..596a53842b 100644 --- a/geoip/plugin/plaintext/clash_out.go +++ b/geoip/plugin/plaintext/clash_out.go @@ -21,14 +21,14 @@ const ( func init() { lib.RegisterOutputConfigCreator(TypeClashRuleSetClassicalOut, func(action lib.Action, data json.RawMessage) (lib.OutputConverter, error) { - return newTextOut(TypeClashRuleSetClassicalOut, action, data) + return newTextOut(TypeClashRuleSetClassicalOut, DescClashClassicalOut, action, data) }) lib.RegisterOutputConverter(TypeClashRuleSetClassicalOut, &TextOut{ Description: DescClashClassicalOut, }) lib.RegisterOutputConfigCreator(TypeClashRuleSetIPCIDROut, func(action lib.Action, data json.RawMessage) (lib.OutputConverter, error) { - return newTextOut(TypeClashRuleSetIPCIDROut, action, data) + return newTextOut(TypeClashRuleSetIPCIDROut, DescClashRuleSetOut, action, data) }) lib.RegisterOutputConverter(TypeClashRuleSetIPCIDROut, &TextOut{ Description: DescClashRuleSetOut, diff --git a/geoip/plugin/plaintext/common_out.go b/geoip/plugin/plaintext/common_out.go index 4fc6375c14..e772293ada 100644 --- a/geoip/plugin/plaintext/common_out.go +++ b/geoip/plugin/plaintext/common_out.go @@ -32,7 +32,7 @@ type TextOut struct { AddSuffixInLine string } -func newTextOut(iType string, action lib.Action, data json.RawMessage) (lib.OutputConverter, error) { +func newTextOut(iType string, iDesc string, action lib.Action, data json.RawMessage) (lib.OutputConverter, error) { var tmp struct { OutputDir string `json:"outputDir"` OutputExt string `json:"outputExtension"` @@ -70,7 +70,7 @@ func newTextOut(iType string, action lib.Action, data json.RawMessage) (lib.Outp return &TextOut{ Type: iType, Action: action, - Description: DescTextOut, + Description: iDesc, OutputDir: tmp.OutputDir, OutputExt: tmp.OutputExt, Want: tmp.Want, diff --git a/geoip/plugin/plaintext/json_in.go b/geoip/plugin/plaintext/json_in.go index 14af7c87c4..a46436095d 100644 --- a/geoip/plugin/plaintext/json_in.go +++ b/geoip/plugin/plaintext/json_in.go @@ -13,7 +13,7 @@ const ( func init() { lib.RegisterInputConfigCreator(TypeJSONIn, func(action lib.Action, data json.RawMessage) (lib.InputConverter, error) { - return newTextIn(TypeJSONIn, action, data) + return newTextIn(TypeJSONIn, DescJSONIn, action, data) }) lib.RegisterInputConverter(TypeJSONIn, &TextIn{ diff --git a/geoip/plugin/plaintext/surge_in.go b/geoip/plugin/plaintext/surge_in.go index ebe7f37a45..7621d0a125 100644 --- a/geoip/plugin/plaintext/surge_in.go +++ b/geoip/plugin/plaintext/surge_in.go @@ -18,7 +18,7 @@ const ( func init() { lib.RegisterInputConfigCreator(TypeSurgeRuleSetIn, func(action lib.Action, data json.RawMessage) (lib.InputConverter, error) { - return newTextIn(TypeSurgeRuleSetIn, action, data) + return newTextIn(TypeSurgeRuleSetIn, DescSurgeRuleSetIn, action, data) }) lib.RegisterInputConverter(TypeSurgeRuleSetIn, &TextIn{ Description: DescSurgeRuleSetIn, diff --git a/geoip/plugin/plaintext/surge_out.go b/geoip/plugin/plaintext/surge_out.go index 6af83271c8..8fe62fb460 100644 --- a/geoip/plugin/plaintext/surge_out.go +++ b/geoip/plugin/plaintext/surge_out.go @@ -18,7 +18,7 @@ const ( func init() { lib.RegisterOutputConfigCreator(TypeSurgeRuleSetOut, func(action lib.Action, data json.RawMessage) (lib.OutputConverter, error) { - return newTextOut(TypeSurgeRuleSetOut, action, data) + return newTextOut(TypeSurgeRuleSetOut, DescSurgeRuleSetOut, action, data) }) lib.RegisterOutputConverter(TypeSurgeRuleSetOut, &TextOut{ Description: DescSurgeRuleSetOut, diff --git a/geoip/plugin/plaintext/text_in.go b/geoip/plugin/plaintext/text_in.go index f129c3cb64..41fb8177d1 100644 --- a/geoip/plugin/plaintext/text_in.go +++ b/geoip/plugin/plaintext/text_in.go @@ -19,14 +19,14 @@ const ( func init() { lib.RegisterInputConfigCreator(TypeTextIn, func(action lib.Action, data json.RawMessage) (lib.InputConverter, error) { - return newTextIn(TypeTextIn, action, data) + return newTextIn(TypeTextIn, DescTextIn, action, data) }) lib.RegisterInputConverter(TypeTextIn, &TextIn{ Description: DescTextIn, }) } -func newTextIn(iType string, action lib.Action, data json.RawMessage) (lib.InputConverter, error) { +func newTextIn(iType string, iDesc string, action lib.Action, data json.RawMessage) (lib.InputConverter, error) { var tmp struct { Name string `json:"name"` URI string `json:"uri"` @@ -80,7 +80,7 @@ func newTextIn(iType string, action lib.Action, data json.RawMessage) (lib.Input return &TextIn{ Type: iType, Action: action, - Description: DescTextIn, + Description: iDesc, Name: tmp.Name, URI: tmp.URI, IPOrCIDR: tmp.IPOrCIDR, diff --git a/geoip/plugin/plaintext/text_out.go b/geoip/plugin/plaintext/text_out.go index 41c6065b9d..06f4df63a2 100644 --- a/geoip/plugin/plaintext/text_out.go +++ b/geoip/plugin/plaintext/text_out.go @@ -16,7 +16,7 @@ const ( func init() { lib.RegisterOutputConfigCreator(TypeTextOut, func(action lib.Action, data json.RawMessage) (lib.OutputConverter, error) { - return newTextOut(TypeTextOut, action, data) + return newTextOut(TypeTextOut, DescTextOut, action, data) }) lib.RegisterOutputConverter(TypeTextOut, &TextOut{ Description: DescTextOut, diff --git a/lede/target/linux/mediatek/files-6.6/arch/arm64/boot/dts/mediatek/mt7988a-bananapi-bpi-r4.dtsi b/lede/target/linux/mediatek/files-6.6/arch/arm64/boot/dts/mediatek/mt7988a-bananapi-bpi-r4.dtsi index 14c615b67c..dd541ff327 100644 --- a/lede/target/linux/mediatek/files-6.6/arch/arm64/boot/dts/mediatek/mt7988a-bananapi-bpi-r4.dtsi +++ b/lede/target/linux/mediatek/files-6.6/arch/arm64/boot/dts/mediatek/mt7988a-bananapi-bpi-r4.dtsi @@ -297,11 +297,22 @@ status = "okay"; }; +&pio { + pwm0_pins: pwm0-pins { + mux { + groups = "pwm0"; + function = "pwm"; + }; + }; +}; + &pwm { status = "okay"; }; &fan { + pinctrl-names = "default"; + pinctrl-0 = <&pwm0_pins>; pwms = <&pwm 0 50000>; status = "okay"; }; diff --git a/lede/target/linux/mediatek/files-6.6/drivers/pinctrl/mediatek/pinctrl-mt7988.c b/lede/target/linux/mediatek/files-6.6/drivers/pinctrl/mediatek/pinctrl-mt7988.c index 9f92911245..648bd03acb 100644 --- a/lede/target/linux/mediatek/files-6.6/drivers/pinctrl/mediatek/pinctrl-mt7988.c +++ b/lede/target/linux/mediatek/files-6.6/drivers/pinctrl/mediatek/pinctrl-mt7988.c @@ -776,21 +776,39 @@ static int mt7988_pwm1_funcs[] = { 1 }; static int mt7988_pwm2_pins[] = { 80 }; static int mt7988_pwm2_funcs[] = { 2 }; +static int mt7988_pwm2_0_pins[] = { 58 }; +static int mt7988_pwm2_0_funcs[] = { 5 }; + static int mt7988_pwm3_pins[] = { 81 }; static int mt7988_pwm3_funcs[] = { 2 }; +static int mt7988_pwm3_0_pins[] = { 59 }; +static int mt7988_pwm3_0_funcs[] = { 5 }; + static int mt7988_pwm4_pins[] = { 82 }; static int mt7988_pwm4_funcs[] = { 2 }; +static int mt7988_pwm4_0_pins[] = { 60 }; +static int mt7988_pwm4_0_funcs[] = { 5 }; + static int mt7988_pwm5_pins[] = { 83 }; static int mt7988_pwm5_funcs[] = { 2 }; +static int mt7988_pwm5_0_pins[] = { 61 }; +static int mt7988_pwm5_0_funcs[] = { 5 }; + static int mt7988_pwm6_pins[] = { 69 }; static int mt7988_pwm6_funcs[] = { 3 }; +static int mt7988_pwm6_0_pins[] = { 62 }; +static int mt7988_pwm6_0_funcs[] = { 5 }; + static int mt7988_pwm7_pins[] = { 70 }; static int mt7988_pwm7_funcs[] = { 3 }; +static int mt7988_pwm7_0_pins[] = { 4 }; +static int mt7988_pwm7_0_funcs[] = { 3 }; + /* dfd */ static int mt7988_dfd_pins[] = { 0, 1, 2, 3, 4 }; static int mt7988_dfd_funcs[] = { 4, 4, 4, 4, 4 }; @@ -1113,6 +1131,8 @@ static const struct group_desc mt7988_groups[] = { PINCTRL_PIN_GROUP("xfi_phy_pll_i2c0", mt7988_xfi_phy_pll_i2c0), /* @GPIO(3,4): xfi_phy_pll_i2c1 */ PINCTRL_PIN_GROUP("xfi_phy_pll_i2c1", mt7988_xfi_phy_pll_i2c1), + /* @GPIO(4): pwm7 */ + PINCTRL_PIN_GROUP("pwm7_0", mt7988_pwm7_0), /* @GPIO(5,6) i2c0_0 */ PINCTRL_PIN_GROUP("i2c0_0", mt7988_i2c0_0), /* @GPIO(5,6) i2c1_sfp */ @@ -1243,6 +1263,14 @@ static const struct group_desc mt7988_groups[] = { PINCTRL_PIN_GROUP("wo2_jtag", mt7988_wo2_jtag), /* @GPIO(57) pwm0 */ PINCTRL_PIN_GROUP("pwm0", mt7988_pwm0), + /* @GPIO(58) pwm2_0 */ + PINCTRL_PIN_GROUP("pwm2_0", mt7988_pwm2_0), + /* @GPIO(59) pwm3_0 */ + PINCTRL_PIN_GROUP("pwm3_0", mt7988_pwm3_0), + /* @GPIO(60) pwm4_0 */ + PINCTRL_PIN_GROUP("pwm4_0", mt7988_pwm4_0), + /* @GPIO(61) pwm5_0 */ + PINCTRL_PIN_GROUP("pwm5_0", mt7988_pwm5_0), /* @GPIO(58,59,60,61,62) jtag */ PINCTRL_PIN_GROUP("jtag", mt7988_jtag), /* @GPIO(58,59,60,61,62) tops_jtag0_1 */ @@ -1256,6 +1284,8 @@ static const struct group_desc mt7988_groups[] = { PINCTRL_PIN_GROUP("gbe1_led1", mt7988_gbe1_led1), PINCTRL_PIN_GROUP("gbe2_led1", mt7988_gbe2_led1), PINCTRL_PIN_GROUP("gbe3_led1", mt7988_gbe3_led1), + /* @GPIO(62) pwm6_0 */ + PINCTRL_PIN_GROUP("pwm6_0", mt7988_pwm6_0), /* @GPIO(62) 2p5gbe_led1 */ PINCTRL_PIN_GROUP("2p5gbe_led1", mt7988_2p5gbe_led1), /* @GPIO(64,65,66,67) gbe_led0 */ @@ -1336,7 +1366,8 @@ static const char * const mt7988_int_usxgmii_groups[] = { "int_usxgmii", }; static const char * const mt7988_pwm_groups[] = { - "pwm0", "pwm1", "pwm2", "pwm3", "pwm4", "pwm5", "pwm6", "pwm7" + "pwm0", "pwm1", "pwm2", "pwm2_0", "pwm3", "pwm3_0", "pwm4", "pwm4_0", + "pwm5", "pwm5_0", "pwm6", "pwm6_0", "pwm7", "pwm7_0", }; static const char * const mt7988_dfd_groups[] = { "dfd", diff --git a/openwrt-packages/alist/Makefile b/openwrt-packages/alist/Makefile index efb12b5ffe..3920d0007e 100644 --- a/openwrt-packages/alist/Makefile +++ b/openwrt-packages/alist/Makefile @@ -7,13 +7,13 @@ include $(TOPDIR)/rules.mk PKG_NAME:=alist -PKG_VERSION:=3.38.0 -PKG_WEB_VERSION:=3.38.0 +PKG_VERSION:=3.39.1 +PKG_WEB_VERSION:=3.39.0 PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz -PKG_SOURCE_URL:=https://codeload.github.com/alist-org/alist/tar.gz/v$(PKG_VERSION)? -PKG_HASH:=bc8983900786afdc2ac3d4a60d5e71a1e5db0c2c63f00190c728974ee266ce12 +PKG_SOURCE_URL:=https://codeload.github.com/AlistGo/alist/tar.gz/v$(PKG_VERSION)? +PKG_HASH:=f211a3b35b6c600a94dbee9041cb5e167284613be383c5944afef6b0b86ab330 PKG_LICENSE:=GPL-3.0 PKG_LICENSE_FILE:=LICENSE @@ -22,8 +22,8 @@ PKG_MAINTAINER:=sbwml define Download/$(PKG_NAME)-web FILE:=$(PKG_NAME)-web-$(PKG_WEB_VERSION).tar.gz URL_FILE:=dist.tar.gz - URL:=https://github.com/alist-org/alist-web/releases/download/$(PKG_WEB_VERSION)/ - HASH:=8c76d6863bc77e0b5da1cbae10b6cec2b3332fcb4e41f055747f4cc5ab04c06a + URL:=https://github.com/AlistGo/alist-web/releases/download/$(PKG_WEB_VERSION)/ + HASH:=59f5dae6fed76ca708b12a7a6323ef85cdee48861ffafb8864c785b7d7c36e89 endef PKG_BUILD_DEPENDS:=golang/host @@ -48,7 +48,7 @@ define Package/$(PKG_NAME) CATEGORY:=Network SUBMENU:=Web Servers/Proxies TITLE:=A file list program that supports multiple storage - URL:=https://alist.nn.ci/ + URL:=http://www.alistgo.com DEPENDS:=$(GO_ARCH_DEPENDS) +ca-bundle endef diff --git a/openwrt-passwall/luci-app-passwall/luasrc/model/cbi/passwall/client/type/ray.lua b/openwrt-passwall/luci-app-passwall/luasrc/model/cbi/passwall/client/type/ray.lua index 8bdc199605..1872017f1a 100644 --- a/openwrt-passwall/luci-app-passwall/luasrc/model/cbi/passwall/client/type/ray.lua +++ b/openwrt-passwall/luci-app-passwall/luasrc/model/cbi/passwall/client/type/ray.lua @@ -574,8 +574,23 @@ o = s:option(Value, option_name("splithttp_path"), translate("SplitHTTP Path")) o.placeholder = "/" o:depends({ [option_name("transport")] = "splithttp" }) --- [[ Mux ]]-- -o = s:option(Flag, option_name("mux"), translate("Mux")) +o = s:option(Flag, option_name("splithttp_xmux"), "XMUX", translate("Enable SplitHTTP XMUX. It's not recommended to enable Mux.Cool at the same time.")) +o:depends({ [option_name("transport")] = "splithttp" }) + +o = s:option(Value, option_name("maxConcurrency"), translate("XMUX Max Concurrency")) +o:depends({ [option_name("splithttp_xmux")] = true }) + +o = s:option(Value, option_name("maxConnections"), translate("XMUX Max Connections")) +o:depends({ [option_name("splithttp_xmux")] = true }) + +o = s:option(Value, option_name("cMaxReuseTimes"), translate("XMUX Connection Max Reuse Times")) +o:depends({ [option_name("splithttp_xmux")] = true }) + +o = s:option(Value, option_name("cMaxLifetimeMs"), translate("XMUX Connection Max Lifetime (ms)")) +o:depends({ [option_name("splithttp_xmux")] = true }) + +-- [[ Mux.Cool ]]-- +o = s:option(Flag, option_name("mux"), "Mux", translate("Enable Mux.Cool")) o:depends({ [option_name("protocol")] = "vmess" }) o:depends({ [option_name("protocol")] = "vless", [option_name("flow")] = "" }) o:depends({ [option_name("protocol")] = "http" }) @@ -588,7 +603,7 @@ o.default = 8 o:depends({ [option_name("mux")] = true }) -- [[ XUDP Mux ]]-- -o = s:option(Flag, option_name("xmux"), translate("xMux")) +o = s:option(Flag, option_name("xmux"), "XUDP Mux") o.default = 1 o:depends({ [option_name("protocol")] = "vless", [option_name("flow")] = "xtls-rprx-vision" }) diff --git a/openwrt-passwall/luci-app-passwall/luasrc/passwall/util_xray.lua b/openwrt-passwall/luci-app-passwall/luasrc/passwall/util_xray.lua index 4a2ef63e06..b07657589c 100644 --- a/openwrt-passwall/luci-app-passwall/luasrc/passwall/util_xray.lua +++ b/openwrt-passwall/luci-app-passwall/luasrc/passwall/util_xray.lua @@ -288,6 +288,18 @@ function gen_outbound(flag, node, tag, proxy_table) result.streamSettings.tlsSettings.alpn = alpn end end + + local xmux = {} + if node.splithttp_xmux then + xmux.maxConcurrency = node.maxConcurrency and (string.find(node.maxConcurrency, "-") and node.maxConcurrency or tonumber(node.maxConcurrency)) or 0 + xmux.maxConnections = node.maxConnections and (string.find(node.maxConnections, "-") and node.maxConnections or tonumber(node.maxConnections)) or 0 + xmux.cMaxReuseTimes = node.cMaxReuseTimes and (string.find(node.cMaxReuseTimes, "-") and node.cMaxReuseTimes or tonumber(node.cMaxReuseTimes)) or 0 + xmux.cMaxLifetimeMs = node.cMaxLifetimeMs and (string.find(node.cMaxLifetimeMs, "-") and node.cMaxLifetimeMs or tonumber(node.cMaxLifetimeMs)) or 0 + if result.streamSettings.splithttpSettings then + result.streamSettings.splithttpSettings.xmux = xmux + end + end + end return result end diff --git a/openwrt-passwall/luci-app-passwall/po/zh-cn/passwall.po b/openwrt-passwall/luci-app-passwall/po/zh-cn/passwall.po index da6f05a1fd..34f991d980 100644 --- a/openwrt-passwall/luci-app-passwall/po/zh-cn/passwall.po +++ b/openwrt-passwall/luci-app-passwall/po/zh-cn/passwall.po @@ -1519,6 +1519,24 @@ msgstr "客户端文件不适合当前设备。" msgid "Can't move new file to path: %s" msgstr "无法移动新文件到:%s" +msgid "Enable SplitHTTP XMUX. It's not recommended to enable Mux.Cool at the same time." +msgstr "启用 SplitHTTP XMUX。不建议与 Mux.Cool 同时启用。" + +msgid "XMUX Max Concurrency" +msgstr "XMUX 连接最大复用流数" + +msgid "XMUX Max Connections" +msgstr "XMUX 最大连接数" + +msgid "XMUX Connection Max Reuse Times" +msgstr "XMUX 连接最多复用次数" + +msgid "XMUX Connection Max Lifetime (ms)" +msgstr "XMUX 连接最大存活时间(ms)" + +msgid "Enable Mux.Cool" +msgstr "启用 Mux.Cool" + msgid "Mux concurrency" msgstr "最大并发连接数" diff --git a/shadowsocks-android/build.gradle.kts b/shadowsocks-android/build.gradle.kts index 150fbfdcb4..67133813b4 100644 --- a/shadowsocks-android/build.gradle.kts +++ b/shadowsocks-android/build.gradle.kts @@ -2,7 +2,7 @@ plugins { id("com.github.ben-manes.versions") version "0.51.0" - id("com.google.devtools.ksp") version "2.0.20-1.0.24" apply false + id("com.google.devtools.ksp") version "2.0.21-1.0.26" apply false } buildscript { @@ -21,7 +21,7 @@ buildscript { classpath("com.google.android.gms:oss-licenses-plugin:0.10.6") classpath("com.google.firebase:firebase-crashlytics-gradle:3.0.2") classpath("com.google.gms:google-services:4.4.2") - classpath("com.vanniktech:gradle-maven-publish-plugin:0.29.0") + classpath("com.vanniktech:gradle-maven-publish-plugin:0.30.0") classpath("org.jetbrains.dokka:dokka-gradle-plugin:1.9.20") classpath("org.mozilla.rust-android-gradle:plugin:0.9.4") } diff --git a/shadowsocks-android/buildSrc/src/main/kotlin/Helpers.kt b/shadowsocks-android/buildSrc/src/main/kotlin/Helpers.kt index 85d6e5e56e..d5526a9353 100644 --- a/shadowsocks-android/buildSrc/src/main/kotlin/Helpers.kt +++ b/shadowsocks-android/buildSrc/src/main/kotlin/Helpers.kt @@ -8,7 +8,7 @@ import org.jetbrains.kotlin.gradle.dsl.JvmTarget import org.jetbrains.kotlin.gradle.dsl.KotlinAndroidProjectExtension import java.util.Locale -const val lifecycleVersion = "2.8.4" +const val lifecycleVersion = "2.8.7" private val Project.android get() = extensions.getByName("android") private val BaseExtension.lint get() = (this as CommonExtension<*, *, *, *, *, *>).lint @@ -64,9 +64,9 @@ fun Project.setupCore() { disable += "UseAppTint" } buildFeatures.buildConfig = true - ndkVersion = "27.0.12077973" + ndkVersion = "27.2.12479018" } - dependencies.add("coreLibraryDesugaring", "com.android.tools:desugar_jdk_libs:2.1.1") + dependencies.add("coreLibraryDesugaring", "com.android.tools:desugar_jdk_libs:2.1.2") } fun Project.setupApp() { diff --git a/shadowsocks-android/core/build.gradle.kts b/shadowsocks-android/core/build.gradle.kts index 2db45c69e6..86e3fda496 100644 --- a/shadowsocks-android/core/build.gradle.kts +++ b/shadowsocks-android/core/build.gradle.kts @@ -88,12 +88,12 @@ tasks.register("cargoClean") { tasks.clean.dependsOn("cargoClean") dependencies { - val coroutinesVersion = "1.8.1" + val coroutinesVersion = "1.9.0" val roomVersion = "2.6.1" - val workVersion = "2.9.1" + val workVersion = "2.10.0" api(project(":plugin")) - api("androidx.core:core-ktx:1.13.1") + api("androidx.core:core-ktx:1.15.0") api("com.google.android.material:material:1.12.0") api("androidx.lifecycle:lifecycle-livedata-core-ktx:$lifecycleVersion") @@ -103,10 +103,10 @@ dependencies { api("androidx.work:work-runtime-ktx:$workVersion") api("com.google.android.gms:play-services-oss-licenses:17.1.0") api("com.google.code.gson:gson:2.11.0") - api("com.google.firebase:firebase-analytics:22.1.0") - api("com.google.firebase:firebase-crashlytics:19.0.3") + api("com.google.firebase:firebase-analytics:22.1.2") + api("com.google.firebase:firebase-crashlytics:19.2.1") api("com.jakewharton.timber:timber:5.0.1") - api("dnsjava:dnsjava:3.6.1") + api("dnsjava:dnsjava:3.6.2") api("org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutinesVersion") api("org.jetbrains.kotlinx:kotlinx-coroutines-play-services:$coroutinesVersion") ksp("androidx.room:room-compiler:$roomVersion") diff --git a/shadowsocks-android/core/src/main/java/com/github/shadowsocks/net/DnsResolverCompat.kt b/shadowsocks-android/core/src/main/java/com/github/shadowsocks/net/DnsResolverCompat.kt index 86ccb78bab..90d8ce1643 100644 --- a/shadowsocks-android/core/src/main/java/com/github/shadowsocks/net/DnsResolverCompat.kt +++ b/shadowsocks-android/core/src/main/java/com/github/shadowsocks/net/DnsResolverCompat.kt @@ -92,7 +92,8 @@ sealed class DnsResolverCompat { * See also: https://issuetracker.google.com/issues/133874590 */ private val unboundedIO by lazy { - if (Core.activity.isLowRamDevice) Dispatchers.IO else Dispatchers.IO.limitedParallelism(Int.MAX_VALUE) + if (Core.activity.isLowRamDevice) Dispatchers.IO + else Dispatchers.IO.limitedParallelism(Int.MAX_VALUE, "unboundedIO") } override suspend fun resolve(network: Network, host: String) = diff --git a/shadowsocks-android/core/src/main/jni/Android.mk b/shadowsocks-android/core/src/main/jni/Android.mk index dffc5f81fa..f9855a8b57 100755 --- a/shadowsocks-android/core/src/main/jni/Android.mk +++ b/shadowsocks-android/core/src/main/jni/Android.mk @@ -159,6 +159,7 @@ TUN2SOCKS_SOURCES := \ base/BPending.c \ system/BDatagram_unix.c \ flowextra/PacketPassInactivityMonitor.c \ + socks_udp_client/SocksUdpClient.c \ tun2socks/SocksUdpGwClient.c \ udpgw_client/UdpGwClient.c diff --git a/shadowsocks-android/core/src/main/jni/badvpn/BUILD-WINDOWS.md b/shadowsocks-android/core/src/main/jni/badvpn/BUILD-WINDOWS.md deleted file mode 100644 index 830267c1ea..0000000000 --- a/shadowsocks-android/core/src/main/jni/badvpn/BUILD-WINDOWS.md +++ /dev/null @@ -1,23 +0,0 @@ -To build on Windows, you need Visual Studio 2015 or 2017 and CMake. - -If you only want to build tun2socks, then no additional dependencies are needed, but pass `-DBUILD_NOTHING_BY_DEFAULT=1 -DBUILD_TUN2SOCKS=1` options to the CMake command line (see below). If the VPN system components are needed, then you will need to build OpenSSL and NSS yourself and we provide no instructions for that. - -Create a build directory (either in or outside the source directory). - -Open a command line and navigate to the build directory. - -Run CMake: - -``` -cmake "" -G "" -DCMAKE_INSTALL_PREFIX="" [options...] -``` - -See [here](https://cmake.org/cmake/help/latest/manual/cmake-generators.7.html) for the list of generators, for example you may want "Visual Studio 15 2017 Win64" for a 64-build with VS2017. - -Once cmake is successful, build with the following command: - -``` -cmake --build . --target install -``` - -If successful you will have the binaries in `/bin`. diff --git a/shadowsocks-android/core/src/main/jni/badvpn/CMakeLists.txt b/shadowsocks-android/core/src/main/jni/badvpn/CMakeLists.txt index 02c6ddcb6f..6751e13854 100644 --- a/shadowsocks-android/core/src/main/jni/badvpn/CMakeLists.txt +++ b/shadowsocks-android/core/src/main/jni/badvpn/CMakeLists.txt @@ -332,6 +332,7 @@ endif () if (BUILD_TUN2SOCKS) add_subdirectory(socksclient) add_subdirectory(udpgw_client) + add_subdirectory(socks_udp_client) add_subdirectory(lwip) endif () diff --git a/shadowsocks-android/core/src/main/jni/badvpn/blog_channels.txt b/shadowsocks-android/core/src/main/jni/badvpn/blog_channels.txt index 8daa1e3983..18657d5eb2 100644 --- a/shadowsocks-android/core/src/main/jni/badvpn/blog_channels.txt +++ b/shadowsocks-android/core/src/main/jni/badvpn/blog_channels.txt @@ -89,6 +89,7 @@ NCDRfkillMonitor 4 udpgw 4 UdpGwClient 4 SocksUdpGwClient 4 +SocksUdpClient 4 BNetwork 4 BConnection 4 BSSLConnection 4 diff --git a/shadowsocks-android/core/src/main/jni/badvpn/build.nix b/shadowsocks-android/core/src/main/jni/badvpn/build.nix index 8a5264d86b..8589ea2b37 100644 --- a/shadowsocks-android/core/src/main/jni/badvpn/build.nix +++ b/shadowsocks-android/core/src/main/jni/badvpn/build.nix @@ -1,4 +1,5 @@ -with import {}; +{ pkgs ? (import {}) }: +with pkgs; rec { badvpnFunc = import ./badvpn.nix; badvpn = pkgs.callPackage badvpnFunc {}; diff --git a/shadowsocks-android/core/src/main/jni/badvpn/compile-tun2socks.sh b/shadowsocks-android/core/src/main/jni/badvpn/compile-tun2socks.sh index 19a87211cd..e06f43bc07 100755 --- a/shadowsocks-android/core/src/main/jni/badvpn/compile-tun2socks.sh +++ b/shadowsocks-android/core/src/main/jni/badvpn/compile-tun2socks.sh @@ -61,6 +61,7 @@ system/BConnection_common.c system/BTime.c system/BUnixSignal.c system/BNetwork.c +system/BDatagram_common.c system/BDatagram_unix.c flow/StreamRecvInterface.c flow/PacketRecvInterface.c @@ -109,6 +110,7 @@ base/BPending.c flowextra/PacketPassInactivityMonitor.c tun2socks/SocksUdpGwClient.c udpgw_client/UdpGwClient.c +socks_udp_client/SocksUdpClient.c " set -e diff --git a/shadowsocks-android/core/src/main/jni/badvpn/generated/blog_channel_SocksUdpClient.h b/shadowsocks-android/core/src/main/jni/badvpn/generated/blog_channel_SocksUdpClient.h new file mode 100644 index 0000000000..25779f48b9 --- /dev/null +++ b/shadowsocks-android/core/src/main/jni/badvpn/generated/blog_channel_SocksUdpClient.h @@ -0,0 +1,4 @@ +#ifdef BLOG_CURRENT_CHANNEL +#undef BLOG_CURRENT_CHANNEL +#endif +#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_SocksUdpClient diff --git a/shadowsocks-android/core/src/main/jni/badvpn/generated/blog_channels_defines.h b/shadowsocks-android/core/src/main/jni/badvpn/generated/blog_channels_defines.h index 4f554e406d..804c91487f 100644 --- a/shadowsocks-android/core/src/main/jni/badvpn/generated/blog_channels_defines.h +++ b/shadowsocks-android/core/src/main/jni/badvpn/generated/blog_channels_defines.h @@ -89,60 +89,61 @@ #define BLOG_CHANNEL_udpgw 88 #define BLOG_CHANNEL_UdpGwClient 89 #define BLOG_CHANNEL_SocksUdpGwClient 90 -#define BLOG_CHANNEL_BNetwork 91 -#define BLOG_CHANNEL_BConnection 92 -#define BLOG_CHANNEL_BSSLConnection 93 -#define BLOG_CHANNEL_BDatagram 94 -#define BLOG_CHANNEL_PeerChat 95 -#define BLOG_CHANNEL_BArpProbe 96 -#define BLOG_CHANNEL_NCDModuleIndex 97 -#define BLOG_CHANNEL_NCDModuleProcess 98 -#define BLOG_CHANNEL_NCDValGenerator 99 -#define BLOG_CHANNEL_ncd_from_string 100 -#define BLOG_CHANNEL_ncd_to_string 101 -#define BLOG_CHANNEL_ncd_value 102 -#define BLOG_CHANNEL_ncd_try 103 -#define BLOG_CHANNEL_ncd_sys_request_server 104 -#define BLOG_CHANNEL_NCDRequest 105 -#define BLOG_CHANNEL_ncd_net_ipv6_wait_dynamic_addr 106 -#define BLOG_CHANNEL_NCDRequestClient 107 -#define BLOG_CHANNEL_ncd_request 108 -#define BLOG_CHANNEL_ncd_sys_request_client 109 -#define BLOG_CHANNEL_ncd_exit 110 -#define BLOG_CHANNEL_ncd_getargs 111 -#define BLOG_CHANNEL_ncd_arithmetic 112 -#define BLOG_CHANNEL_ncd_parse 113 -#define BLOG_CHANNEL_ncd_valuemetic 114 -#define BLOG_CHANNEL_ncd_file 115 -#define BLOG_CHANNEL_ncd_netmask 116 -#define BLOG_CHANNEL_ncd_implode 117 -#define BLOG_CHANNEL_ncd_call2 118 -#define BLOG_CHANNEL_ncd_assert 119 -#define BLOG_CHANNEL_ncd_reboot 120 -#define BLOG_CHANNEL_ncd_explode 121 -#define BLOG_CHANNEL_NCDPlaceholderDb 122 -#define BLOG_CHANNEL_NCDVal 123 -#define BLOG_CHANNEL_ncd_net_ipv6_addr 124 -#define BLOG_CHANNEL_ncd_net_ipv6_route 125 -#define BLOG_CHANNEL_ncd_net_ipv4_addr_in_network 126 -#define BLOG_CHANNEL_ncd_net_ipv6_addr_in_network 127 -#define BLOG_CHANNEL_dostest_server 128 -#define BLOG_CHANNEL_dostest_attacker 129 -#define BLOG_CHANNEL_ncd_timer 130 -#define BLOG_CHANNEL_ncd_file_open 131 -#define BLOG_CHANNEL_ncd_backtrack 132 -#define BLOG_CHANNEL_ncd_socket 133 -#define BLOG_CHANNEL_ncd_depend_scope 134 -#define BLOG_CHANNEL_ncd_substr 135 -#define BLOG_CHANNEL_ncd_sys_start_process 136 -#define BLOG_CHANNEL_NCDBuildProgram 137 -#define BLOG_CHANNEL_ncd_log 138 -#define BLOG_CHANNEL_ncd_log_msg 139 -#define BLOG_CHANNEL_ncd_buffer 140 -#define BLOG_CHANNEL_ncd_getenv 141 -#define BLOG_CHANNEL_BThreadSignal 142 -#define BLOG_CHANNEL_BLockReactor 143 -#define BLOG_CHANNEL_ncd_load_module 144 -#define BLOG_CHANNEL_ncd_basic_functions 145 -#define BLOG_CHANNEL_ncd_objref 146 -#define BLOG_NUM_CHANNELS 147 +#define BLOG_CHANNEL_SocksUdpClient 91 +#define BLOG_CHANNEL_BNetwork 92 +#define BLOG_CHANNEL_BConnection 93 +#define BLOG_CHANNEL_BSSLConnection 94 +#define BLOG_CHANNEL_BDatagram 95 +#define BLOG_CHANNEL_PeerChat 96 +#define BLOG_CHANNEL_BArpProbe 97 +#define BLOG_CHANNEL_NCDModuleIndex 98 +#define BLOG_CHANNEL_NCDModuleProcess 99 +#define BLOG_CHANNEL_NCDValGenerator 100 +#define BLOG_CHANNEL_ncd_from_string 101 +#define BLOG_CHANNEL_ncd_to_string 102 +#define BLOG_CHANNEL_ncd_value 103 +#define BLOG_CHANNEL_ncd_try 104 +#define BLOG_CHANNEL_ncd_sys_request_server 105 +#define BLOG_CHANNEL_NCDRequest 106 +#define BLOG_CHANNEL_ncd_net_ipv6_wait_dynamic_addr 107 +#define BLOG_CHANNEL_NCDRequestClient 108 +#define BLOG_CHANNEL_ncd_request 109 +#define BLOG_CHANNEL_ncd_sys_request_client 110 +#define BLOG_CHANNEL_ncd_exit 111 +#define BLOG_CHANNEL_ncd_getargs 112 +#define BLOG_CHANNEL_ncd_arithmetic 113 +#define BLOG_CHANNEL_ncd_parse 114 +#define BLOG_CHANNEL_ncd_valuemetic 115 +#define BLOG_CHANNEL_ncd_file 116 +#define BLOG_CHANNEL_ncd_netmask 117 +#define BLOG_CHANNEL_ncd_implode 118 +#define BLOG_CHANNEL_ncd_call2 119 +#define BLOG_CHANNEL_ncd_assert 120 +#define BLOG_CHANNEL_ncd_reboot 121 +#define BLOG_CHANNEL_ncd_explode 122 +#define BLOG_CHANNEL_NCDPlaceholderDb 123 +#define BLOG_CHANNEL_NCDVal 124 +#define BLOG_CHANNEL_ncd_net_ipv6_addr 125 +#define BLOG_CHANNEL_ncd_net_ipv6_route 126 +#define BLOG_CHANNEL_ncd_net_ipv4_addr_in_network 127 +#define BLOG_CHANNEL_ncd_net_ipv6_addr_in_network 128 +#define BLOG_CHANNEL_dostest_server 129 +#define BLOG_CHANNEL_dostest_attacker 130 +#define BLOG_CHANNEL_ncd_timer 131 +#define BLOG_CHANNEL_ncd_file_open 132 +#define BLOG_CHANNEL_ncd_backtrack 133 +#define BLOG_CHANNEL_ncd_socket 134 +#define BLOG_CHANNEL_ncd_depend_scope 135 +#define BLOG_CHANNEL_ncd_substr 136 +#define BLOG_CHANNEL_ncd_sys_start_process 137 +#define BLOG_CHANNEL_NCDBuildProgram 138 +#define BLOG_CHANNEL_ncd_log 139 +#define BLOG_CHANNEL_ncd_log_msg 140 +#define BLOG_CHANNEL_ncd_buffer 141 +#define BLOG_CHANNEL_ncd_getenv 142 +#define BLOG_CHANNEL_BThreadSignal 143 +#define BLOG_CHANNEL_BLockReactor 144 +#define BLOG_CHANNEL_ncd_load_module 145 +#define BLOG_CHANNEL_ncd_basic_functions 146 +#define BLOG_CHANNEL_ncd_objref 147 +#define BLOG_NUM_CHANNELS 148 diff --git a/shadowsocks-android/core/src/main/jni/badvpn/generated/blog_channels_list.h b/shadowsocks-android/core/src/main/jni/badvpn/generated/blog_channels_list.h index d099b2ba8a..930bd8b288 100644 --- a/shadowsocks-android/core/src/main/jni/badvpn/generated/blog_channels_list.h +++ b/shadowsocks-android/core/src/main/jni/badvpn/generated/blog_channels_list.h @@ -89,6 +89,7 @@ {"udpgw", 4}, {"UdpGwClient", 4}, {"SocksUdpGwClient", 4}, +{"SocksUdpClient", 4}, {"BNetwork", 4}, {"BConnection", 4}, {"BSSLConnection", 4}, diff --git a/shadowsocks-android/core/src/main/jni/badvpn/misc/socks_proto.h b/shadowsocks-android/core/src/main/jni/badvpn/misc/socks_proto.h index 41f5a1fde1..89e277503d 100644 --- a/shadowsocks-android/core/src/main/jni/badvpn/misc/socks_proto.h +++ b/shadowsocks-android/core/src/main/jni/badvpn/misc/socks_proto.h @@ -112,7 +112,15 @@ B_START_PACKED struct socks_addr_ipv6 { uint8_t addr[16]; uint16_t port; -} B_PACKED; +} B_PACKED; +B_END_PACKED + +B_START_PACKED +struct socks_udp_header { + uint16_t rsv; + uint8_t frag; + uint8_t atyp; +} B_PACKED; B_END_PACKED #endif diff --git a/shadowsocks-android/core/src/main/jni/badvpn/protocol/udpgw_proto.h b/shadowsocks-android/core/src/main/jni/badvpn/protocol/udpgw_proto.h index 7978ccdb5c..f927136a1a 100644 --- a/shadowsocks-android/core/src/main/jni/badvpn/protocol/udpgw_proto.h +++ b/shadowsocks-android/core/src/main/jni/badvpn/protocol/udpgw_proto.h @@ -33,22 +33,15 @@ #include #include +#ifdef __ANDROID__ +#include +#endif #define UDPGW_CLIENT_FLAG_KEEPALIVE (1 << 0) #define UDPGW_CLIENT_FLAG_REBIND (1 << 1) #define UDPGW_CLIENT_FLAG_DNS (1 << 2) #define UDPGW_CLIENT_FLAG_IPV6 (1 << 3) -#ifdef __ANDROID__ -B_START_PACKED -struct socks_udp_header { - uint16_t rsv; - uint8_t frag; - uint8_t atyp; -} B_PACKED; -B_END_PACKED -#endif - B_START_PACKED struct udpgw_header { uint8_t flags; diff --git a/shadowsocks-android/core/src/main/jni/badvpn/socks_udp_client/CMakeLists.txt b/shadowsocks-android/core/src/main/jni/badvpn/socks_udp_client/CMakeLists.txt new file mode 100644 index 0000000000..4598b48f82 --- /dev/null +++ b/shadowsocks-android/core/src/main/jni/badvpn/socks_udp_client/CMakeLists.txt @@ -0,0 +1 @@ +badvpn_add_library(socks_udp_client "base;system;flow;flowextra;socksclient" "" SocksUdpClient.c) diff --git a/shadowsocks-android/core/src/main/jni/badvpn/socks_udp_client/SocksUdpClient.c b/shadowsocks-android/core/src/main/jni/badvpn/socks_udp_client/SocksUdpClient.c new file mode 100644 index 0000000000..524ec0a511 --- /dev/null +++ b/shadowsocks-android/core/src/main/jni/badvpn/socks_udp_client/SocksUdpClient.c @@ -0,0 +1,634 @@ +/* + * Copyright (C) 2018 Jigsaw Operations LLC + * Copyright (C) 2019 Ambroz Bizjak (modifications) + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the author nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +static const int DnsPort = 53; + +static int addr_comparator (void *unused, BAddr *v1, BAddr *v2); +static struct SocksUdpClient_connection * find_connection (SocksUdpClient *o, BAddr addr); +static void socks_state_handler (struct SocksUdpClient_connection *con, int event); +static void datagram_state_handler (struct SocksUdpClient_connection *con, int event); +static void send_monitor_handler (struct SocksUdpClient_connection *con); +static void recv_if_handler_send ( + struct SocksUdpClient_connection *con, uint8_t *data, int data_len); +static struct SocksUdpClient_connection * connection_init ( + SocksUdpClient *o, BAddr local_addr, BAddr first_remote_addr, + const uint8_t *first_data, int first_data_len); +static void connection_free (struct SocksUdpClient_connection *con); +static void connection_send (struct SocksUdpClient_connection *con, + BAddr remote_addr, const uint8_t *data, int data_len); +static void first_job_handler (struct SocksUdpClient_connection *con); +static int compute_socks_mtu (int udp_mtu); +static int get_dns_id (BAddr *remote_addr, const uint8_t *data, int data_len); + +int addr_comparator (void *unused, BAddr *v1, BAddr *v2) +{ + return BAddr_CompareOrder(v1, v2); +} + +struct SocksUdpClient_connection * find_connection (SocksUdpClient *o, BAddr addr) +{ + BAVLNode *tree_node = BAVL_LookupExact(&o->connections_tree, &addr); + if (!tree_node) { + return NULL; + } + + return UPPER_OBJECT(tree_node, struct SocksUdpClient_connection, connections_tree_node); +} + +void socks_state_handler (struct SocksUdpClient_connection *con, int event) +{ + DebugObject_Access(&con->client->d_obj); + + switch (event) { + case BSOCKSCLIENT_EVENT_CONNECTED: { + // Get the local address of the SOCKS TCP connection. + BAddr tcp_local_addr; + if (!BSocksClient_GetLocalAddr(&con->socks, &tcp_local_addr)) { + BLog(BLOG_ERROR, "Failed to get TCP local address."); + return connection_free(con); + } + + // Sanity check the address type (required by SetPort below). + if (tcp_local_addr.type != BADDR_TYPE_IPV4 && + tcp_local_addr.type != BADDR_TYPE_IPV6) + { + BLog(BLOG_ERROR, "Bad address type in TCP local address."); + return connection_free(con); + } + + // Bind the UDP socket to the same IP address and let the kernel pick the port. + BAddr udp_bound_addr = tcp_local_addr; + BAddr_SetPort(&udp_bound_addr, 0); + if (!BDatagram_Bind(&con->socket, udp_bound_addr)) { + BLog(BLOG_ERROR, "Failed to bind the UDP socket."); + return connection_free(con); + } + + // Update udp_bound_addr to the actual address that was bound. + if (!BDatagram_GetLocalAddr(&con->socket, &udp_bound_addr)) { + BLog(BLOG_ERROR, "Failed to get UDP bound address."); + return connection_free(con); + } + + // Set the DST.ADDR for SOCKS. + BSocksClient_SetDestAddr(&con->socks, udp_bound_addr); + } break; + + case BSOCKSCLIENT_EVENT_UP: { + // The remote address to send datagrams to is the BND.ADDR provided by the + // SOCKS server. + BAddr remote_addr = BSocksClient_GetBindAddr(&con->socks); + + // Don't bother setting a source address for datagrams since we are bound. + BIPAddr local_addr; + BIPAddr_InitInvalid(&local_addr); + + // Set the addresses for BDatagram. + // This will unblock the queue of outgoing packets. + BDatagram_SetSendAddrs(&con->socket, remote_addr, local_addr); + } break; + + case BSOCKSCLIENT_EVENT_ERROR: { + char local_buffer[BADDR_MAX_PRINT_LEN]; + BAddr_Print(&con->local_addr, local_buffer); + BLog(BLOG_ERROR, + "SOCKS error event for %s, removing connection.", local_buffer); + + connection_free(con); + } break; + + case BSOCKSCLIENT_EVENT_ERROR_CLOSED: { + char local_buffer[BADDR_MAX_PRINT_LEN]; + BAddr_Print(&con->local_addr, local_buffer); + BLog(BLOG_WARNING, + "SOCKS closed event for %s, removing connection.", local_buffer); + + connection_free(con); + } break; + } +} + +void datagram_state_handler (struct SocksUdpClient_connection *con, int event) +{ + DebugObject_Access(&con->client->d_obj); + + if (event == BDATAGRAM_EVENT_ERROR) { + char local_buffer[BADDR_MAX_PRINT_LEN]; + BAddr_Print(&con->local_addr, local_buffer); + BLog(BLOG_ERROR, + "Low-level datagram error %s, removing connection.", local_buffer); + + // Remove the connection. Note that BDatagram requires that we free + // the BDatagram after an error is reported. + connection_free(con); + } +} + +void send_monitor_handler (struct SocksUdpClient_connection *con) +{ + DebugObject_Access(&con->client->d_obj); + + char local_buffer[BADDR_MAX_PRINT_LEN]; + BAddr_Print(&con->local_addr, local_buffer); + BLog(BLOG_INFO, + "Removing connection for %s due to inactivity.", local_buffer); + + // The connection has passed its idle timeout. Remove it. + connection_free(con); +} + +void recv_if_handler_send ( + struct SocksUdpClient_connection *con, uint8_t *data, int data_len) +{ + DebugObject_Access(&con->client->d_obj); + SocksUdpClient *o = con->client; + ASSERT(data_len >= 0) + ASSERT(data_len <= o->socks_mtu) + + // accept packet + PacketPassInterface_Done(&con->recv_if); + + // check header + struct socks_udp_header header; + if (data_len < sizeof(header)) { + BLog(BLOG_ERROR, "Missing SOCKS-UDP header."); + return; + } + memcpy(&header, data, sizeof(header)); + data += sizeof(header); + data_len -= sizeof(header); + + // parse address + BAddr remote_addr; + switch (header.atyp) { + case SOCKS_ATYP_IPV4: { + struct socks_addr_ipv4 addr_ipv4; + if (data_len < sizeof(addr_ipv4)) { + BLog(BLOG_ERROR, "Missing IPv4 address."); + return; + } + memcpy(&addr_ipv4, data, sizeof(addr_ipv4)); + data += sizeof(addr_ipv4); + data_len -= sizeof(addr_ipv4); + remote_addr.type = BADDR_TYPE_IPV4; + remote_addr.ipv4.ip = addr_ipv4.addr; + remote_addr.ipv4.port = addr_ipv4.port; + } break; + case SOCKS_ATYP_IPV6: { + struct socks_addr_ipv6 addr_ipv6; + if (data_len < sizeof(addr_ipv6)) { + BLog(BLOG_ERROR, "Missing IPv6 address."); + return; + } + memcpy(&addr_ipv6, data, sizeof(addr_ipv6)); + data += sizeof(addr_ipv6); + data_len -= sizeof(addr_ipv6); + remote_addr.type = BADDR_TYPE_IPV6; + memcpy(remote_addr.ipv6.ip, addr_ipv6.addr, sizeof(remote_addr.ipv6.ip)); + remote_addr.ipv6.port = addr_ipv6.port; + } break; + default: { + BLog(BLOG_ERROR, "Bad address type"); + return; + } break; + } + + // check remaining data + if (data_len > o->udp_mtu) { + BLog(BLOG_ERROR, "too much data"); + return; + } + + // pass packet to user + SocksUdpClient *client = con->client; + client->handler_received(client->user, con->local_addr, remote_addr, data, data_len); + + // Was this connection used for a DNS query? + if (con->dns_id >= 0) { + // Get the DNS transaction ID of the response. + int recv_dns_id = get_dns_id(&remote_addr, data, data_len); + + // Does the transaction ID matche that of the request? + if (recv_dns_id == con->dns_id) { + // We have now forwarded the response, so this connection is no longer needed. + char local_buffer[BADDR_MAX_PRINT_LEN]; + BAddr_Print(&con->local_addr, local_buffer); + BLog(BLOG_DEBUG, + "Removing connection for %s after the DNS response.", local_buffer); + + connection_free(con); + } else { + BLog(BLOG_INFO, "DNS client port received an unexpected non-DNS packet, " + "disabling DNS optimization."); + + con->dns_id = -1; + } + } +} + +struct SocksUdpClient_connection * connection_init ( + SocksUdpClient *o, BAddr local_addr, BAddr first_remote_addr, + const uint8_t *first_data, int first_data_len) +{ + ASSERT(o->num_connections <= o->max_connections) + ASSERT(!find_connection(o, local_addr)) + + char local_buffer[BADDR_MAX_PRINT_LEN]; + BAddr_Print(&local_addr, local_buffer); + BLog(BLOG_DEBUG, "Creating connection for %s.", local_buffer); + + // allocate structure + struct SocksUdpClient_connection *con = + (struct SocksUdpClient_connection *)BAlloc(sizeof(*con)); + if (!con) { + BLog(BLOG_ERROR, "BAlloc connection failed"); + goto fail0; + } + + // set basic things + con->client = o; + con->local_addr = local_addr; + + // store first outgoing packet + con->first_data = BAlloc(first_data_len); + if (!con->first_data) { + BLog(BLOG_ERROR, "BAlloc first data failed"); + goto fail1; + } + memcpy(con->first_data, first_data, first_data_len); + con->first_data_len = first_data_len; + con->first_remote_addr = first_remote_addr; + + // Get the DNS transaction ID from the packet, if any. + con->dns_id = get_dns_id(&first_remote_addr, first_data, first_data_len); + + BPendingGroup *pg = BReactor_PendingGroup(o->reactor); + + // Init first job, to send the first packet asynchronously. This has to happen + // asynchronously because con->send_writer (a BufferWriter) cannot accept writes until + // after it is linked with its PacketBuffer (con->send_buffer), which happens + // asynchronously. + BPending_Init(&con->first_job, pg, (BPending_handler)first_job_handler, con); + // Add the first job to the pending set. BPending acts as a LIFO stack, and + // first_job_handler needs to run after async actions that occur in PacketBuffer_Init, + // so we need to put first_job on the stack first. + BPending_Set(&con->first_job); + + // Create a datagram socket + if (!BDatagram_Init(&con->socket, con->local_addr.type, o->reactor, con, + (BDatagram_handler)datagram_state_handler)) + { + BLog(BLOG_ERROR, "Failed to create a UDP socket"); + goto fail2; + } + + // We will set the DST.ADDR for SOCKS later (BSOCKSCLIENT_EVENT_CONNECTED). + BAddr dummy_dst_addr; + BAddr_InitNone(&dummy_dst_addr); + + // Initiate connection to socks server + if (!BSocksClient_Init(&con->socks, o->server_addr, o->auth_info, o->num_auth_info, + dummy_dst_addr, true, (BSocksClient_handler)socks_state_handler, con, o->reactor)) + { + BLog(BLOG_ERROR, "Failed to initialize SOCKS client"); + goto fail3; + } + + // Since we use o->socks_mtu for send and receive pipelines, we can handle maximally + // sized packets (o->udp_mtu) including the SOCKS-UDP header. + + // Send pipeline: send_writer -> send_buffer -> send_monitor -> send_if -> socket. + BDatagram_SendAsync_Init(&con->socket, o->socks_mtu); + PacketPassInactivityMonitor_Init(&con->send_monitor, + BDatagram_SendAsync_GetIf(&con->socket), o->reactor, o->keepalive_time, + (PacketPassInactivityMonitor_handler)send_monitor_handler, con); + BufferWriter_Init(&con->send_writer, o->socks_mtu, pg); + if (!PacketBuffer_Init(&con->send_buffer, BufferWriter_GetOutput(&con->send_writer), + PacketPassInactivityMonitor_GetInput(&con->send_monitor), o->send_buf_size, pg)) + { + BLog(BLOG_ERROR, "Send buffer init failed"); + goto fail4; + } + + // Receive pipeline: socket -> recv_buffer -> recv_if + BDatagram_RecvAsync_Init(&con->socket, o->socks_mtu); + PacketPassInterface_Init(&con->recv_if, o->socks_mtu, + (PacketPassInterface_handler_send)recv_if_handler_send, con, pg); + if (!SinglePacketBuffer_Init(&con->recv_buffer, + BDatagram_RecvAsync_GetIf(&con->socket), &con->recv_if, pg)) + { + BLog(BLOG_ERROR, "Receive buffer init failed"); + goto fail5; + } + + // Insert to connections tree, it must succeed because of the assert. + int inserted = BAVL_Insert(&o->connections_tree, &con->connections_tree_node, NULL); + ASSERT(inserted) + B_USE(inserted) + + // increment number of connections + o->num_connections++; + + return con; + +fail5: + PacketPassInterface_Free(&con->recv_if); + BDatagram_RecvAsync_Free(&con->socket); + PacketBuffer_Free(&con->send_buffer); +fail4: + BufferWriter_Free(&con->send_writer); + PacketPassInactivityMonitor_Free(&con->send_monitor); + BDatagram_SendAsync_Free(&con->socket); + BSocksClient_Free(&con->socks); +fail3: + BDatagram_Free(&con->socket); +fail2: + BPending_Free(&con->first_job); + BFree(con->first_data); +fail1: + BFree(con); +fail0: + return NULL; +} + +void connection_free (struct SocksUdpClient_connection *con) +{ + SocksUdpClient *o = con->client; + + // decrement number of connections + ASSERT(o->num_connections > 0) + o->num_connections--; + + // remove from connections tree + BAVL_Remove(&o->connections_tree, &con->connections_tree_node); + + // Free UDP receive pipeline components + SinglePacketBuffer_Free(&con->recv_buffer); + PacketPassInterface_Free(&con->recv_if); + BDatagram_RecvAsync_Free(&con->socket); + + // Free UDP send pipeline components + PacketBuffer_Free(&con->send_buffer); + BufferWriter_Free(&con->send_writer); + PacketPassInactivityMonitor_Free(&con->send_monitor); + BDatagram_SendAsync_Free(&con->socket); + + // Free SOCKS client + BSocksClient_Free(&con->socks); + + // Free UDP socket + BDatagram_Free(&con->socket); + + // Free first job + BPending_Free(&con->first_job); + + // Free first outgoing packet + BFree(con->first_data); + + // Free structure + BFree(con); +} + +void connection_send (struct SocksUdpClient_connection *con, + BAddr remote_addr, const uint8_t *data, int data_len) +{ + ASSERT(data_len >= 0) + ASSERT(data_len <= con->client->udp_mtu) + + if (con->dns_id >= 0) { + // So far, this connection has only sent a single DNS query. + int new_dns_id = get_dns_id(&remote_addr, data, data_len); + if (new_dns_id != con->dns_id) { + BLog(BLOG_DEBUG, "Client reused DNS query port. Disabling DNS optimization."); + con->dns_id = -1; + } + } + + // Check if we're sending to an IPv4 or IPv6 destination. + int atyp; + size_t address_size; + // write address + switch (remote_addr.type) { + case BADDR_TYPE_IPV4: { + atyp = SOCKS_ATYP_IPV4; + address_size = sizeof(struct socks_addr_ipv4); + } break; + case BADDR_TYPE_IPV6: { + atyp = SOCKS_ATYP_IPV6; + address_size = sizeof(struct socks_addr_ipv6); + } break; + default: { + BLog(BLOG_ERROR, "Bad address type in outgoing packet."); + return; + } break; + } + + // Determine total packet size in the buffer. + // This cannot exceed o->socks_mtu because data_len is required to not exceed + // o->udp_mtu and o->socks_mtu is calculated to accomodate any UDP packet not + // not exceeding o->udp_mtu. + size_t total_len = sizeof(struct socks_udp_header) + address_size + data_len; + ASSERT(total_len <= con->client->socks_mtu) + + // Get a pointer to write the packet to. + uint8_t *out_data_begin; + if (!BufferWriter_StartPacket(&con->send_writer, &out_data_begin)) { + BLog(BLOG_ERROR, "Send buffer is full."); + return; + } + uint8_t *out_data = out_data_begin; + + // Write header + struct socks_udp_header header; + header.rsv = 0; + header.frag = 0; + header.atyp = atyp; + memcpy(out_data, &header, sizeof(header)); + out_data += sizeof(header); + + // Write address + switch (atyp) { + case SOCKS_ATYP_IPV4: { + struct socks_addr_ipv4 addr_ipv4; + addr_ipv4.addr = remote_addr.ipv4.ip; + addr_ipv4.port = remote_addr.ipv4.port; + memcpy(out_data, &addr_ipv4, sizeof(addr_ipv4)); + out_data += sizeof(addr_ipv4); + } break; + case SOCKS_ATYP_IPV6: { + struct socks_addr_ipv6 addr_ipv6; + memcpy(addr_ipv6.addr, remote_addr.ipv6.ip, sizeof(addr_ipv6.addr)); + addr_ipv6.port = remote_addr.ipv6.port; + memcpy(out_data, &addr_ipv6, sizeof(addr_ipv6)); + out_data += sizeof(addr_ipv6); + } break; + } + + // Write payload + memcpy(out_data, data, data_len); + out_data += data_len; + + ASSERT(out_data - out_data_begin == total_len) + + // Submit packet to buffer + BufferWriter_EndPacket(&con->send_writer, total_len); +} + +void first_job_handler (struct SocksUdpClient_connection *con) +{ + DebugObject_Access(&con->client->d_obj); + ASSERT(con->first_data) + + // Send the first packet. + connection_send(con, con->first_remote_addr, con->first_data, con->first_data_len); + + // Release the first packet buffer. + BFree(con->first_data); + con->first_data = NULL; + con->first_data_len = 0; +} + +int compute_socks_mtu (int udp_mtu) +{ + bsize_t bs = bsize_add( + bsize_fromint(udp_mtu), + bsize_add( + bsize_fromsize(sizeof(struct socks_udp_header)), + bsize_fromsize(sizeof(struct socks_addr_ipv6)) + ) + ); + int s; + return bsize_toint(bs, &s) ? s : -1; +} + +// Get the DNS transaction ID, or -1 if this does not look like a DNS packet. +int get_dns_id (BAddr *remote_addr, const uint8_t *data, int data_len) +{ + if (ntoh16(BAddr_GetPort(remote_addr)) == DnsPort && data_len >= 2) { + return (data[0] << 8) | data[1]; + } else { + return -1; + } +} + +int SocksUdpClient_Init (SocksUdpClient *o, int udp_mtu, int max_connections, + int send_buf_size, btime_t keepalive_time, BAddr server_addr, + const struct BSocksClient_auth_info *auth_info, size_t num_auth_info, + BReactor *reactor, void *user, SocksUdpClient_handler_received handler_received) +{ + ASSERT(udp_mtu >= 0) + ASSERT(max_connections > 0) + ASSERT(send_buf_size > 0) + + // init simple things + o->server_addr = server_addr; + o->auth_info = auth_info; + o->num_auth_info = num_auth_info; + o->num_connections = 0; + o->max_connections = max_connections; + o->send_buf_size = send_buf_size; + o->udp_mtu = udp_mtu; + o->keepalive_time = keepalive_time; + o->reactor = reactor; + o->user = user; + o->handler_received = handler_received; + + // calculate full MTU with SOCKS header + o->socks_mtu = compute_socks_mtu(udp_mtu); + if (o->socks_mtu < 0) { + BLog(BLOG_ERROR, "SocksUdpClient_Init: MTU too large."); + goto fail0; + } + + // init connections tree + BAVL_Init(&o->connections_tree, + OFFSET_DIFF(struct SocksUdpClient_connection, local_addr, connections_tree_node), + (BAVL_comparator)addr_comparator, NULL); + + DebugObject_Init(&o->d_obj); + return 1; + +fail0: + return 0; +} + +void SocksUdpClient_Free (SocksUdpClient *o) +{ + DebugObject_Free(&o->d_obj); + + // free connections + while (!BAVL_IsEmpty(&o->connections_tree)) { + BAVLNode *node = BAVL_GetFirst(&o->connections_tree); + struct SocksUdpClient_connection *con = + UPPER_OBJECT(node, struct SocksUdpClient_connection, connections_tree_node); + connection_free(con); + } +} + +void SocksUdpClient_SubmitPacket (SocksUdpClient *o, + BAddr local_addr, BAddr remote_addr, const uint8_t *data, int data_len) +{ + DebugObject_Access(&o->d_obj); + ASSERT(local_addr.type == BADDR_TYPE_IPV4 || local_addr.type == BADDR_TYPE_IPV6) + ASSERT(remote_addr.type == BADDR_TYPE_IPV4 || remote_addr.type == BADDR_TYPE_IPV6) + ASSERT(data_len >= 0) + ASSERT(data_len <= o->udp_mtu) + + // lookup connection + struct SocksUdpClient_connection *con = find_connection(o, local_addr); + if (!con) { + if (o->num_connections >= o->max_connections) { + // Drop the packet. + BLog(BLOG_WARNING, "Dropping UDP packet, reached max number of connections."); + return; + } + // create new connection and enqueue the packet + connection_init(o, local_addr, remote_addr, data, data_len); + } else { + // send packet + connection_send(con, remote_addr, data, data_len); + } +} diff --git a/shadowsocks-android/core/src/main/jni/badvpn/socks_udp_client/SocksUdpClient.h b/shadowsocks-android/core/src/main/jni/badvpn/socks_udp_client/SocksUdpClient.h new file mode 100644 index 0000000000..52ded104a6 --- /dev/null +++ b/shadowsocks-android/core/src/main/jni/badvpn/socks_udp_client/SocksUdpClient.h @@ -0,0 +1,144 @@ +/* + * Copyright (C) 2018 Jigsaw Operations LLC + * Copyright (C) 2019 Ambroz Bizjak (modifications) + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the author nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef BADVPN_SOCKS_UDP_CLIENT_SOCKSUDPCLIENT_H +#define BADVPN_SOCKS_UDP_CLIENT_SOCKSUDPCLIENT_H + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +typedef void (*SocksUdpClient_handler_received) ( + void *user, BAddr local_addr, BAddr remote_addr, const uint8_t *data, int data_len); + +typedef struct { + BAddr server_addr; + const struct BSocksClient_auth_info *auth_info; + size_t num_auth_info; + int num_connections; + int max_connections; + int send_buf_size; + int udp_mtu; + int socks_mtu; + btime_t keepalive_time; + BReactor *reactor; + void *user; + SocksUdpClient_handler_received handler_received; + BAVL connections_tree; // By local_addr + DebugObject d_obj; +} SocksUdpClient; + +struct SocksUdpClient_connection { + SocksUdpClient *client; + BAddr local_addr; + BSocksClient socks; + BufferWriter send_writer; + PacketBuffer send_buffer; + PacketPassInactivityMonitor send_monitor; + PacketPassInterface send_if; + BDatagram socket; + PacketPassInterface recv_if; + SinglePacketBuffer recv_buffer; + // The first_* members represent the initial packet, which has to be stored so it can + // wait for send_writer to become ready. + uint8_t *first_data; + int first_data_len; + BAddr first_remote_addr; + // If all packets sent so far have been sent to the same IP, port 53, with the + // same DNS ID, then this is that ID. Otherwise, it is -1. This is used to + // close ephemeral DNS query connections once a response is received. + int dns_id; + BPending first_job; + BAVLNode connections_tree_node; +}; + +/** + * Initializes the SOCKS5-UDP client object. + * + * This function only initialzies the object and does not perform network access. + * + * @param o the object + * @param udp_mtu the maximum size of packets that will be sent through the tunnel + * @param max_connections how many local ports to track before dropping packets + * @param send_buf_size maximum number of buffered outgoing packets per connection + * @param keepalive_time how long to track an idle local port before forgetting it + * @param server_addr SOCKS5 server address + * @param auth_info List of authentication info for BSocksClient. The pointer must remain + * valid while this object exists, the data is not copied. + * @param num_auth_info Number of the above. + * @param reactor reactor we live in + * @param user value passed to handler + * @param handler_received handler for incoming UDP packets + * @return 1 on success, 0 on failure + */ +int SocksUdpClient_Init (SocksUdpClient *o, int udp_mtu, int max_connections, + int send_buf_size, btime_t keepalive_time, BAddr server_addr, + const struct BSocksClient_auth_info *auth_info, size_t num_auth_info, + BReactor *reactor, void *user, SocksUdpClient_handler_received handler_received); + +/** + * Frees the SOCKS5-UDP client object. + * + * @param o the object + */ +void SocksUdpClient_Free (SocksUdpClient *o); + +/** + * Submit a packet to be sent through the proxy. + * + * This will reuse an existing connection for packets from local_addr, or create one if + * there is none. If the number of live connections exceeds max_connections, or if the + * number of buffered packets from this port exceeds a limit, packets will be dropped + * silently. + * + * As a resource optimization, if a connection has only been used to send one DNS query, + * then the connection will be closed and freed once the reply is received. + * + * @param o the object + * @param local_addr the UDP packet's source address, and the expected destination for + * replies + * @param remote_addr the destination of the packet after it exits the proxy + * @param data the packet contents. Caller retains ownership. + * @param data_len number of bytes in the data + */ +void SocksUdpClient_SubmitPacket (SocksUdpClient *o, + BAddr local_addr, BAddr remote_addr, const uint8_t *data, int data_len); + +#endif diff --git a/shadowsocks-android/core/src/main/jni/badvpn/socksclient/BSocksClient.c b/shadowsocks-android/core/src/main/jni/badvpn/socksclient/BSocksClient.c index 21415af4c4..e87bf54754 100644 --- a/shadowsocks-android/core/src/main/jni/badvpn/socksclient/BSocksClient.c +++ b/shadowsocks-android/core/src/main/jni/badvpn/socksclient/BSocksClient.c @@ -38,14 +38,15 @@ #include #define STATE_CONNECTING 1 -#define STATE_SENDING_HELLO 2 -#define STATE_SENT_HELLO 3 -#define STATE_SENDING_PASSWORD 10 -#define STATE_SENT_PASSWORD 11 -#define STATE_SENDING_REQUEST 4 -#define STATE_SENT_REQUEST 5 -#define STATE_RECEIVED_REPLY_HEADER 6 -#define STATE_UP 7 +#define STATE_CONNECTED_HANDLER 2 +#define STATE_SENDING_HELLO 3 +#define STATE_SENT_HELLO 4 +#define STATE_SENDING_PASSWORD 5 +#define STATE_SENT_PASSWORD 6 +#define STATE_SENDING_REQUEST 7 +#define STATE_SENT_REQUEST 8 +#define STATE_RECEIVED_REPLY_HEADER 9 +#define STATE_UP 10 static void report_error (BSocksClient *o, int error); static void init_control_io (BSocksClient *o); @@ -57,6 +58,7 @@ static void start_receive (BSocksClient *o, uint8_t *dest, int total); static void do_receive (BSocksClient *o); static void connector_handler (BSocksClient* o, int is_error); static void connection_handler (BSocksClient* o, int event); +static void continue_job_handler (BSocksClient *o); static void recv_handler_done (BSocksClient *o, int data_len); static void send_handler_done (BSocksClient *o); static void auth_finished (BSocksClient *p); @@ -166,12 +168,45 @@ void connector_handler (BSocksClient* o, int is_error) // init control I/O init_control_io(o); + // go to STATE_CONNECTED_HANDLER and set the continue job in order to continue + // in continue_job_handler + o->state = STATE_CONNECTED_HANDLER; + BPending_Set(&o->continue_job); + + // call the handler with the connected event + o->handler(o->user, BSOCKSCLIENT_EVENT_CONNECTED); + return; + +fail0: + report_error(o, BSOCKSCLIENT_EVENT_ERROR); + return; +} + +void connection_handler (BSocksClient* o, int event) +{ + DebugObject_Access(&o->d_obj); + ASSERT(o->state != STATE_CONNECTING) + + if (o->state == STATE_UP && event == BCONNECTION_EVENT_RECVCLOSED) { + report_error(o, BSOCKSCLIENT_EVENT_ERROR_CLOSED); + return; + } + + report_error(o, BSOCKSCLIENT_EVENT_ERROR); + return; +} + +void continue_job_handler (BSocksClient *o) +{ + DebugObject_Access(&o->d_obj); + ASSERT(o->state == STATE_CONNECTED_HANDLER) + // check number of methods if (o->num_auth_info == 0 || o->num_auth_info > 255) { BLog(BLOG_ERROR, "invalid number of authentication methods"); - goto fail1; + goto fail0; } - + // allocate buffer for sending hello bsize_t size = bsize_add( bsize_fromsize(sizeof(struct socks_client_hello_header)), @@ -181,7 +216,7 @@ void connector_handler (BSocksClient* o, int is_error) ) ); if (!reserve_buffer(o, size)) { - goto fail1; + goto fail0; } // write hello header @@ -202,27 +237,10 @@ void connector_handler (BSocksClient* o, int is_error) // set state o->state = STATE_SENDING_HELLO; - - return; - -fail1: - free_control_io(o); - BConnection_Free(&o->con); -fail0: - report_error(o, BSOCKSCLIENT_EVENT_ERROR); - return; -} -void connection_handler (BSocksClient* o, int event) -{ - DebugObject_Access(&o->d_obj); - ASSERT(o->state != STATE_CONNECTING) - - if (o->state == STATE_UP && event == BCONNECTION_EVENT_RECVCLOSED) { - report_error(o, BSOCKSCLIENT_EVENT_ERROR_CLOSED); - return; - } - + return; + +fail0: report_error(o, BSOCKSCLIENT_EVENT_ERROR); return; } @@ -329,9 +347,11 @@ void recv_handler_done (BSocksClient *o, int data_len) int addr_len; switch (ntoh8(imsg.atyp)) { case SOCKS_ATYP_IPV4: + o->bind_addr.type = BADDR_TYPE_IPV4; addr_len = sizeof(struct socks_addr_ipv4); break; case SOCKS_ATYP_IPV6: + o->bind_addr.type = BADDR_TYPE_IPV6; addr_len = sizeof(struct socks_addr_ipv6); break; default: @@ -365,6 +385,28 @@ void recv_handler_done (BSocksClient *o, int data_len) case STATE_RECEIVED_REPLY_HEADER: { BLog(BLOG_DEBUG, "received reply rest"); + // Record the address of the new socket bound by the server. + // For a CONNECT command, this is the address of the TCP client socket to dest_addr. + // Knowing this address is usually not important. + // For a UDP_ASSOCIATE command, this is the UDP address to which to send SOCKS UDP. + // Recording this address is a prerequisite to send traffic on a SOCKS-UDP association. + void *addr_buffer = o->buffer + sizeof(struct socks_reply_header); + switch (o->bind_addr.type) { + case BADDR_TYPE_IPV4: { + struct socks_addr_ipv4 ip4; + memcpy(&ip4, addr_buffer, sizeof(ip4)); + o->bind_addr.ipv4.ip = ip4.addr; + o->bind_addr.ipv4.port = ip4.port; + } break; + case BADDR_TYPE_IPV6: { + struct socks_addr_ipv6 ip6; + memcpy(&ip6, addr_buffer, sizeof(ip6)); + memcpy(o->bind_addr.ipv6.ip, ip6.addr, sizeof(ip6.addr)); + o->bind_addr.ipv6.port = ip6.port; + } break; + default: ASSERT(0); + } + // free buffer BFree(o->buffer); o->buffer = NULL; @@ -373,6 +415,8 @@ void recv_handler_done (BSocksClient *o, int data_len) free_control_io(o); // init up I/O + // Initializing this is not needed for UDP ASSOCIATE but it doesn't hurt. + // We anyway don't allow the user to use these interfaces in that case. init_up_io(o); // set state @@ -465,8 +509,16 @@ void auth_finished (BSocksClient *o) // allocate request buffer bsize_t size = bsize_fromsize(sizeof(struct socks_request_header)); switch (o->dest_addr.type) { - case BADDR_TYPE_IPV4: size = bsize_add(size, bsize_fromsize(sizeof(struct socks_addr_ipv4))); break; - case BADDR_TYPE_IPV6: size = bsize_add(size, bsize_fromsize(sizeof(struct socks_addr_ipv6))); break; + case BADDR_TYPE_IPV4: + size = bsize_add(size, bsize_fromsize(sizeof(struct socks_addr_ipv4))); + break; + case BADDR_TYPE_IPV6: + size = bsize_add(size, bsize_fromsize(sizeof(struct socks_addr_ipv6))); + break; + default: + BLog(BLOG_ERROR, "Invalid dest_addr address type."); + report_error(o, BSOCKSCLIENT_EVENT_ERROR); + return; } if (!reserve_buffer(o, size)) { report_error(o, BSOCKSCLIENT_EVENT_ERROR); @@ -476,7 +528,7 @@ void auth_finished (BSocksClient *o) // write request struct socks_request_header header; header.ver = hton8(SOCKS_VERSION); - header.cmd = hton8(SOCKS_CMD_CONNECT); + header.cmd = hton8(o->udp ? SOCKS_CMD_UDP_ASSOCIATE : SOCKS_CMD_CONNECT); header.rsv = hton8(0); switch (o->dest_addr.type) { case BADDR_TYPE_IPV4: { @@ -523,12 +575,11 @@ struct BSocksClient_auth_info BSocksClient_auth_password (const char *username, return info; } -int BSocksClient_Init (BSocksClient *o, - BAddr server_addr, const struct BSocksClient_auth_info *auth_info, size_t num_auth_info, - BAddr dest_addr, BSocksClient_handler handler, void *user, BReactor *reactor) +int BSocksClient_Init (BSocksClient *o, BAddr server_addr, + const struct BSocksClient_auth_info *auth_info, size_t num_auth_info, BAddr dest_addr, + bool udp, BSocksClient_handler handler, void *user, BReactor *reactor) { ASSERT(!BAddr_IsInvalid(&server_addr)) - ASSERT(dest_addr.type == BADDR_TYPE_IPV4 || dest_addr.type == BADDR_TYPE_IPV6) #ifndef NDEBUG for (size_t i = 0; i < num_auth_info; i++) { ASSERT(auth_info[i].auth_type == SOCKS_METHOD_NO_AUTHENTICATION_REQUIRED || @@ -540,12 +591,17 @@ int BSocksClient_Init (BSocksClient *o, o->auth_info = auth_info; o->num_auth_info = num_auth_info; o->dest_addr = dest_addr; + o->udp = udp; o->handler = handler; o->user = user; o->reactor = reactor; // set no buffer o->buffer = NULL; + + // init continue_job + BPending_Init(&o->continue_job, BReactor_PendingGroup(o->reactor), + (BPending_handler)continue_job_handler, o); // init connector if (!BConnector_Init(&o->connector, server_addr, o->reactor, o, (BConnector_handler)connector_handler)) { @@ -561,6 +617,7 @@ int BSocksClient_Init (BSocksClient *o, return 1; fail0: + BPending_Free(&o->continue_job); return 0; } @@ -585,15 +642,43 @@ void BSocksClient_Free (BSocksClient *o) // free connector BConnector_Free(&o->connector); + // free continue job + BPending_Free(&o->continue_job); + // free buffer if (o->buffer) { BFree(o->buffer); } } +int BSocksClient_GetLocalAddr (BSocksClient *o, BAddr *local_addr) +{ + ASSERT(o->state != STATE_CONNECTING) + DebugObject_Access(&o->d_obj); + + return BConnection_GetLocalAddress(&o->con, local_addr); +} + +void BSocksClient_SetDestAddr (BSocksClient *o, BAddr dest_addr) +{ + ASSERT(o->state == STATE_CONNECTING || o->state == STATE_CONNECTED_HANDLER) + DebugObject_Access(&o->d_obj); + + o->dest_addr = dest_addr; +} + +BAddr BSocksClient_GetBindAddr (BSocksClient *o) +{ + ASSERT(o->state == STATE_UP) + DebugObject_Access(&o->d_obj); + + return o->bind_addr; +} + StreamPassInterface * BSocksClient_GetSendInterface (BSocksClient *o) { ASSERT(o->state == STATE_UP) + ASSERT(!o->udp) DebugObject_Access(&o->d_obj); return BConnection_SendAsync_GetIf(&o->con); @@ -602,6 +687,7 @@ StreamPassInterface * BSocksClient_GetSendInterface (BSocksClient *o) StreamRecvInterface * BSocksClient_GetRecvInterface (BSocksClient *o) { ASSERT(o->state == STATE_UP) + ASSERT(!o->udp) DebugObject_Access(&o->d_obj); return BConnection_RecvAsync_GetIf(&o->con); diff --git a/shadowsocks-android/core/src/main/jni/badvpn/socksclient/BSocksClient.h b/shadowsocks-android/core/src/main/jni/badvpn/socksclient/BSocksClient.h index f19b3a85c0..5311e40216 100644 --- a/shadowsocks-android/core/src/main/jni/badvpn/socksclient/BSocksClient.h +++ b/shadowsocks-android/core/src/main/jni/badvpn/socksclient/BSocksClient.h @@ -34,31 +34,42 @@ #ifndef BADVPN_SOCKS_BSOCKSCLIENT_H #define BADVPN_SOCKS_BSOCKSCLIENT_H +#include #include +#include #include #include #include #include #include +#include #include #include #define BSOCKSCLIENT_EVENT_ERROR 1 #define BSOCKSCLIENT_EVENT_UP 2 #define BSOCKSCLIENT_EVENT_ERROR_CLOSED 3 +#define BSOCKSCLIENT_EVENT_CONNECTED 4 /** * Handler for events generated by the SOCKS client. * + * The event is one of the following: + * - BSOCKSCLIENT_EVENT_ERROR: An error has occured. The object must be freed from the + * job closure of the handler and no further I/O must be attempted. + * - BSOCKSCLIENT_EVENT_ERROR_CLOSED: The server has closed the connection. This event + * can only be reported after BSOCKSCLIENT_EVENT_UP. The object must be freed from + * the job closure of the handler and no further I/O must be attempted. + * - BSOCKSCLIENT_EVENT_UP: The CONNECT or UDP ASSOCIATE operation was successful. In + * the case of CONNECT, application I/O may now begin. + * - BSOCKSCLIENT_EVENT_CONNECTED: The TCP connection to the server has been established + * and the SOCKS protocol is about to begin. The local address of the TCP connection is + * now available via @ref BSocksClient_GetLocalAddr. The job closure of this callback + * is the last chance to call @ref BSocksClient_SetDestAddr. + * * @param user as in {@link BSocksClient_Init} - * @param event event type. One of BSOCKSCLIENT_EVENT_ERROR, BSOCKSCLIENT_EVENT_UP - * and BSOCKSCLIENT_EVENT_ERROR_CLOSED. - * If event is BSOCKSCLIENT_EVENT_UP, the object was previously in down - * state and has transitioned to up state; I/O can be done from this point on. - * If event is BSOCKSCLIENT_EVENT_ERROR or BSOCKSCLIENT_EVENT_ERROR_CLOSED, - * the object must be freed from within the job closure of this handler, - * and no further I/O must be attempted. + * @param event See above. */ typedef void (*BSocksClient_handler) (void *user, int event); @@ -78,6 +89,8 @@ typedef struct { const struct BSocksClient_auth_info *auth_info; size_t num_auth_info; BAddr dest_addr; + bool udp; + BAddr bind_addr; BSocksClient_handler handler; void *user; BReactor *reactor; @@ -85,6 +98,7 @@ typedef struct { char *buffer; BConnector connector; BConnection con; + BPending continue_job; union { struct { PacketPassInterface *send_if; @@ -104,20 +118,34 @@ struct BSocksClient_auth_info BSocksClient_auth_password (const char *username, /** * Initializes the object. - * The object is initialized in down state. The object must transition to up - * state before the user may begin any I/O. + * + * This object connects to a SOCKS5 server and performs a CONNECT or UDP ASSOCIATE + * operation. In any case, the object reports the BSOCKSCLIENT_EVENT_UP event via the + * handler when the operation was completed successfully. In the case of CONNECT, the + * user may then use the send and receive interfaces to exchange data through the + * connection (@ref BSocksClient_GetSendInterface and @ref BSocksClient_GetRecvInterface). * * @param o the object * @param server_addr SOCKS5 server address - * @param dest_addr remote address + * @param auth_info List of supported authentication methods and associated parameters. + * Initialize these using functions such as BSocksClient_auth_none() and + * BSocksClient_auth_password(). The pointer must remain valid while this object + * exists, the data is not copied. + * @param num_auth_info Number of the above. There should be at least one, otherwise it + * certainly won't work. + * @param dest_addr Address to send as DST.ADDR in the CONNECT or UDP ASSOCIATE request. + * It is also possible to specify it later from the BSOCKSCLIENT_EVENT_CONNECTED + * event callback using @ref BSocksClient_SetDestAddr; this is necessary for UDP + * if the local TCP connection address must be known to bind the UDP socket. + * @param udp false to perform a CONNECT, true to perform a UDP ASSOCIATE * @param handler handler for up and error events * @param user value passed to handler * @param reactor reactor we live in * @return 1 on success, 0 on failure */ -int BSocksClient_Init (BSocksClient *o, - BAddr server_addr, const struct BSocksClient_auth_info *auth_info, size_t num_auth_info, - BAddr dest_addr, BSocksClient_handler handler, void *user, BReactor *reactor) WARN_UNUSED; +int BSocksClient_Init (BSocksClient *o, BAddr server_addr, + const struct BSocksClient_auth_info *auth_info, size_t num_auth_info, BAddr dest_addr, + bool udp, BSocksClient_handler handler, void *user, BReactor *reactor) WARN_UNUSED; /** * Frees the object. @@ -126,9 +154,44 @@ int BSocksClient_Init (BSocksClient *o, */ void BSocksClient_Free (BSocksClient *o); +/** + * Get the local address of the TCP socket for the SOCKS server connection. + * + * This may only be called after the BSOCKSCLIENT_EVENT_CONNECTED event was reported. + * + * @param o the object + * @param local_addr On success the local address is returned here. + * @return 1 on success, 0 on failure + */ +int BSocksClient_GetLocalAddr (BSocksClient *o, BAddr *local_addr); + +/** + * Set the DST.ADDR to send, overriding that specified in @ref BSocksClient_Init. + * + * The last chance to call this function is in the job closure of the + * BSOCKSCLIENT_EVENT_CONNECTED event, this must not be called after that. + * + * @param o the object + * @param dest_addr DST.ADDR to set. + */ +void BSocksClient_SetDestAddr (BSocksClient *o, BAddr dest_addr); + +/** + * Return the BND.ADDR that the SOCKS server reported. + * + * This may only be called after the BSOCKSCLIENT_EVENT_UP event was reported. + * This address is needed for UDP ASSOCIATE because it is the address that the + * client should send UDP packets to. + * + * @param o the object + * @return The BND.ADDR, of type BADDR_TYPE_IPV4 or BADDR_TYPE_IPV6. + */ +BAddr BSocksClient_GetBindAddr (BSocksClient *o); + /** * Returns the send interface. - * The object must be in up state. + * The object must be in up state. Additionally this must not be called if the + * object was initialized in UDP ASSOCIATE mode. * * @param o the object * @return send interface @@ -137,7 +200,8 @@ StreamPassInterface * BSocksClient_GetSendInterface (BSocksClient *o); /** * Returns the receive interface. - * The object must be in up state. + * The object must be in up state. Additionally this must not be called if the + * object was initialized in UDP ASSOCIATE mode. * * @param o the object * @return receive interface diff --git a/shadowsocks-android/core/src/main/jni/badvpn/system/BAddr.h b/shadowsocks-android/core/src/main/jni/badvpn/system/BAddr.h index a5f3f10b9b..70d4fa1a1f 100644 --- a/shadowsocks-android/core/src/main/jni/badvpn/system/BAddr.h +++ b/shadowsocks-android/core/src/main/jni/badvpn/system/BAddr.h @@ -97,6 +97,8 @@ static int BIPAddr_Resolve (BIPAddr *addr, char *str, int noresolve) WARN_UNUSED static int BIPAddr_Compare (BIPAddr *addr1, BIPAddr *addr2); +static void BIPAddr_InitLocalhost (BIPAddr *addr, int addr_type); + /** * Converts an IP address to human readable form. * @@ -805,4 +807,20 @@ int BAddr_CompareOrder (BAddr *addr1, BAddr *addr2) } } +void BIPAddr_InitLocalhost (BIPAddr *addr, int addr_type) +{ + if (addr_type == BADDR_TYPE_IPV4) { + addr->type = addr_type; + addr->ipv4 = hton32(0x7f000001); + } + else if (addr_type == BADDR_TYPE_IPV6) { + addr->type = addr_type; + memset(addr->ipv6, 0, 16); + addr->ipv6[15] = 1; + } + else { + addr->type = BADDR_TYPE_NONE; + } +} + #endif diff --git a/shadowsocks-android/core/src/main/jni/badvpn/system/BConnection.h b/shadowsocks-android/core/src/main/jni/badvpn/system/BConnection.h index 0b2ca6c318..e3d6a9e060 100644 --- a/shadowsocks-android/core/src/main/jni/badvpn/system/BConnection.h +++ b/shadowsocks-android/core/src/main/jni/badvpn/system/BConnection.h @@ -359,6 +359,19 @@ void BConnection_SetHandlers (BConnection *o, void *user, BConnection_handler ha */ int BConnection_SetSendBuffer (BConnection *o, int buf_size); +/** + * Determines the local address. + * + * This calls getsockname() to determine the local address and returns the result as + * BAddr. This function fails if the address cannot be determined or translated to + * BAddr (it never succeeds but returns a BADDR_TYPE_NONE address). + * + * @param o the object + * @param local_addr returns the local bound address. + * @return 1 on success, 0 on failure + */ +int BConnection_GetLocalAddress (BConnection *o, BAddr *local_addr); + /** * Initializes the send interface for the connection. * The send interface must not be initialized. diff --git a/shadowsocks-android/core/src/main/jni/badvpn/system/BConnection_unix.c b/shadowsocks-android/core/src/main/jni/badvpn/system/BConnection_unix.c index fc1e2944e0..8c8d86ca22 100644 --- a/shadowsocks-android/core/src/main/jni/badvpn/system/BConnection_unix.c +++ b/shadowsocks-android/core/src/main/jni/badvpn/system/BConnection_unix.c @@ -876,6 +876,30 @@ int BConnection_SetSendBuffer (BConnection *o, int buf_size) return 1; } +int BConnection_GetLocalAddress (BConnection *o, BAddr *local_addr) +{ + DebugObject_Access(&o->d_obj); + + struct sys_addr sysaddr; + sysaddr.len = sizeof(sysaddr.addr); + if (getsockname(o->fd, &sysaddr.addr.generic, &sysaddr.len) != 0) { + BLog(BLOG_ERROR, "BConnection_GetLocalAddress: getsockname failed"); + return 0; + } + + BAddr addr; + addr_sys_to_socket(&addr, sysaddr); + + if (addr.type == BADDR_TYPE_NONE) { + BLog(BLOG_ERROR, "BConnection_GetLocalAddress: Unsupported address family " + "from getsockname: %d", (int)sysaddr.addr.generic.sa_family); + return 0; + } + + *local_addr = addr; + return 1; +} + void BConnection_SendAsync_Init (BConnection *o) { DebugObject_Access(&o->d_obj); diff --git a/shadowsocks-android/core/src/main/jni/badvpn/system/BConnection_win.c b/shadowsocks-android/core/src/main/jni/badvpn/system/BConnection_win.c index 1f3f900c97..1241c5be0a 100644 --- a/shadowsocks-android/core/src/main/jni/badvpn/system/BConnection_win.c +++ b/shadowsocks-android/core/src/main/jni/badvpn/system/BConnection_win.c @@ -792,6 +792,31 @@ int BConnection_SetSendBuffer (BConnection *o, int buf_size) return 1; } +int BConnection_GetLocalAddress (BConnection *o, BAddr *local_addr) +{ + DebugObject_Access(&o->d_obj); + + struct sys_addr sysaddr; + socklen_t addr_size = sizeof(sysaddr.addr.generic); + if (getsockname(o->sock, &sysaddr.addr.generic, &addr_size) != 0) { + BLog(BLOG_ERROR, "BConnection_GetLocalAddress: getsockname failed"); + return 0; + } + sysaddr.len = addr_size; + + BAddr addr; + addr_sys_to_socket(&addr, sysaddr); + + if (addr.type == BADDR_TYPE_NONE) { + BLog(BLOG_ERROR, "BConnection_GetLocalAddress: Unsupported address family " + "from getsockname: %d", sysaddr.addr.generic.sa_family); + return 0; + } + + *local_addr = addr; + return 1; +} + void BConnection_SendAsync_Init (BConnection *o) { DebugObject_Access(&o->d_obj); diff --git a/shadowsocks-android/core/src/main/jni/badvpn/system/BDatagram.h b/shadowsocks-android/core/src/main/jni/badvpn/system/BDatagram.h index 33efb45126..9b9b5c24ee 100644 --- a/shadowsocks-android/core/src/main/jni/badvpn/system/BDatagram.h +++ b/shadowsocks-android/core/src/main/jni/badvpn/system/BDatagram.h @@ -123,6 +123,30 @@ void BDatagram_SetSendAddrs (BDatagram *o, BAddr remote_addr, BIPAddr local_addr */ int BDatagram_GetLastReceiveAddrs (BDatagram *o, BAddr *remote_addr, BIPAddr *local_addr); +/** + * Determines the local address. + * + * This calls getsockname() to determine the local address and returns the result as + * BAddr. This function fails if the address cannot be determined or translated to + * BAddr (it never succeeds but returns a BADDR_TYPE_NONE address). + * + * @param o the object + * @param local_addr returns the local bound address. + * @return 1 on success, 0 on failure + */ +int BDatagram_GetLocalAddr (BDatagram *o, BAddr *local_addr); + +/** + * Returns the local port. + * + * This is a convenience function implemented based on BDatagram_GetLocalAddr. + * + * @param o the object + * @param local_port returns the local bound port. + * @return 1 on success, 0 on failure + */ +int BDatagram_GetLocalPort (BDatagram *o, uint16_t *local_port); + #ifndef BADVPN_USE_WINAPI /** * Returns the underlying socket file descriptor of the datagram object. diff --git a/shadowsocks-android/core/src/main/jni/badvpn/system/BDatagram_common.c b/shadowsocks-android/core/src/main/jni/badvpn/system/BDatagram_common.c new file mode 100644 index 0000000000..5421140600 --- /dev/null +++ b/shadowsocks-android/core/src/main/jni/badvpn/system/BDatagram_common.c @@ -0,0 +1,52 @@ +/** + * @file BDatagram_unix.c + * @author Ambroz Bizjak + * + * @section LICENSE + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the author nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include + +#include "BDatagram.h" + +#include + +int BDatagram_GetLocalPort (BDatagram *o, uint16_t *local_port) +{ + BAddr addr; + if (!BDatagram_GetLocalAddr(o, &addr)) { + return 0; + } + + if (addr.type != BADDR_TYPE_IPV4 && addr.type != BADDR_TYPE_IPV6) { + BLog(BLOG_ERROR, + "BDatagram_GetLocalPort: Port not defined for this address type."); + return 0; + } + + *local_port = BAddr_GetPort(&addr); + return 1; +} diff --git a/shadowsocks-android/core/src/main/jni/badvpn/system/BDatagram_unix.c b/shadowsocks-android/core/src/main/jni/badvpn/system/BDatagram_unix.c index b49b865c80..61b8f8d908 100644 --- a/shadowsocks-android/core/src/main/jni/badvpn/system/BDatagram_unix.c +++ b/shadowsocks-android/core/src/main/jni/badvpn/system/BDatagram_unix.c @@ -734,6 +734,30 @@ int BDatagram_GetLastReceiveAddrs (BDatagram *o, BAddr *remote_addr, BIPAddr *lo return 1; } +int BDatagram_GetLocalAddr (BDatagram *o, BAddr *local_addr) +{ + DebugObject_Access(&o->d_obj); + + struct sys_addr sysaddr; + sysaddr.len = sizeof(sysaddr.addr); + if (getsockname(o->fd, &sysaddr.addr.generic, &sysaddr.len) != 0) { + BLog(BLOG_ERROR, "BDatagram_GetLocalAddr: getsockname failed"); + return 0; + } + + BAddr addr; + addr_sys_to_socket(&addr, sysaddr); + + if (addr.type == BADDR_TYPE_NONE) { + BLog(BLOG_ERROR, "BDatagram_GetLocalAddr: Unsupported address family " + "from getsockname: %d", (int)sysaddr.addr.generic.sa_family); + return 0; + } + + *local_addr = addr; + return 1; +} + int BDatagram_GetFd (BDatagram *o) { DebugObject_Access(&o->d_obj); diff --git a/shadowsocks-android/core/src/main/jni/badvpn/system/BDatagram_win.c b/shadowsocks-android/core/src/main/jni/badvpn/system/BDatagram_win.c index b8b9b1f241..cf6d3ffa37 100644 --- a/shadowsocks-android/core/src/main/jni/badvpn/system/BDatagram_win.c +++ b/shadowsocks-android/core/src/main/jni/badvpn/system/BDatagram_win.c @@ -635,6 +635,31 @@ int BDatagram_GetLastReceiveAddrs (BDatagram *o, BAddr *remote_addr, BIPAddr *lo return 1; } +int BDatagram_GetLocalAddr (BDatagram *o, BAddr *local_addr) +{ + DebugObject_Access(&o->d_obj); + + struct BDatagram_sys_addr sysaddr; + socklen_t addr_size = sizeof(sysaddr.addr.generic); + if (getsockname(o->sock, &sysaddr.addr.generic, &addr_size) != 0) { + BLog(BLOG_ERROR, "BDatagram_GetLocalAddr: getsockname failed"); + return 0; + } + sysaddr.len = addr_size; + + BAddr addr; + addr_sys_to_socket(&addr, sysaddr); + + if (addr.type == BADDR_TYPE_NONE) { + BLog(BLOG_ERROR, "BDatagram_GetLocalAddr: Unsupported address family " + "from getsockname: %d", sysaddr.addr.generic.sa_family); + return 0; + } + + *local_addr = addr; + return 1; +} + int BDatagram_SetReuseAddr (BDatagram *o, int reuse) { DebugObject_Access(&o->d_obj); diff --git a/shadowsocks-android/core/src/main/jni/badvpn/system/CMakeLists.txt b/shadowsocks-android/core/src/main/jni/badvpn/system/CMakeLists.txt index 796dc27c0a..fb41acb3e0 100644 --- a/shadowsocks-android/core/src/main/jni/badvpn/system/CMakeLists.txt +++ b/shadowsocks-android/core/src/main/jni/badvpn/system/CMakeLists.txt @@ -6,6 +6,7 @@ if (NOT EMSCRIPTEN) BSignal.c BNetwork.c BConnection_common.c + BDatagram_common.c ) if (WIN32) diff --git a/shadowsocks-android/core/src/main/jni/badvpn/tun2socks/CMakeLists.txt b/shadowsocks-android/core/src/main/jni/badvpn/tun2socks/CMakeLists.txt index 4246fd0524..3d5ec329ac 100644 --- a/shadowsocks-android/core/src/main/jni/badvpn/tun2socks/CMakeLists.txt +++ b/shadowsocks-android/core/src/main/jni/badvpn/tun2socks/CMakeLists.txt @@ -2,7 +2,7 @@ add_executable(badvpn-tun2socks tun2socks.c SocksUdpGwClient.c ) -target_link_libraries(badvpn-tun2socks system flow tuntap lwip socksclient udpgw_client) +target_link_libraries(badvpn-tun2socks system flow tuntap lwip socksclient udpgw_client socks_udp_client) install( TARGETS badvpn-tun2socks diff --git a/shadowsocks-android/core/src/main/jni/badvpn/tun2socks/SocksUdpGwClient.c b/shadowsocks-android/core/src/main/jni/badvpn/tun2socks/SocksUdpGwClient.c index 87efb14c91..996510a8b3 100644 --- a/shadowsocks-android/core/src/main/jni/badvpn/tun2socks/SocksUdpGwClient.c +++ b/shadowsocks-android/core/src/main/jni/badvpn/tun2socks/SocksUdpGwClient.c @@ -404,7 +404,10 @@ static void try_connect (SocksUdpGwClient *o) ASSERT(!BTimer_IsRunning(&o->reconnect_timer)) // init SOCKS client - if (!BSocksClient_Init(&o->socks_client, o->socks_server_addr, o->auth_info, o->num_auth_info, o->remote_udpgw_addr, (BSocksClient_handler)socks_client_handler, o, o->reactor)) { + if (!BSocksClient_Init(&o->socks_client, o->socks_server_addr, + o->auth_info, o->num_auth_info, o->remote_udpgw_addr, /*udp=*/false, + (BSocksClient_handler)socks_client_handler, o, o->reactor)) + { BLog(BLOG_ERROR, "BSocksClient_Init failed"); goto fail0; } @@ -471,8 +474,6 @@ static void socks_client_handler (SocksUdpGwClient *o, int event) // set reconnect timer BReactor_SetTimer(o->reactor, &o->reconnect_timer); } break; - - default: ASSERT(0); } } diff --git a/shadowsocks-android/core/src/main/jni/badvpn/tun2socks/tun2socks.c b/shadowsocks-android/core/src/main/jni/badvpn/tun2socks/tun2socks.c index b4352bcf9e..641d10c41b 100644 --- a/shadowsocks-android/core/src/main/jni/badvpn/tun2socks/tun2socks.c +++ b/shadowsocks-android/core/src/main/jni/badvpn/tun2socks/tun2socks.c @@ -65,6 +65,7 @@ #include #include #include +#include #ifndef BADVPN_USE_WINAPI #include @@ -206,6 +207,7 @@ struct { #else char *tundev; #endif + int socks5_udp; } options; // TCP client @@ -270,10 +272,17 @@ uint8_t *device_write_buf; SinglePacketBuffer device_read_buffer; PacketPassInterface device_read_interface; +// UDP support mode +enum UdpMode {UdpModeNone, UdpModeUdpgw, UdpModeSocks}; +enum UdpMode udp_mode; + // udpgw client SocksUdpGwClient udpgw_client; int udp_mtu; +// SOCKS5-UDP client +SocksUdpClient socks_udp_client; + // TCP timer BTimer tcp_timer; int tcp_timer_mod4; @@ -297,9 +306,9 @@ LinkedList1 tcp_clients; // number of clients int num_clients; -#ifdef __ANDROID__ // Address of dnsgw BAddr dnsgw; +#ifdef __ANDROID__ void terminate (void); #else static void terminate (void); @@ -340,7 +349,7 @@ static void client_socks_recv_initiate (struct tcp_client *client); static void client_socks_recv_handler_done (struct tcp_client *client, int data_len); static int client_socks_recv_send_out (struct tcp_client *client); static err_t client_sent_func (void *arg, struct tcp_pcb *tpcb, u16_t len); -static void udpgw_client_handler_received (void *unused, BAddr local_addr, BAddr remote_addr, const uint8_t *data, int data_len); +static void udp_send_packet_to_device (void *unused, BAddr local_addr, BAddr remote_addr, const uint8_t *data, int data_len); #ifdef __ANDROID__ static void daemonize(const char* path) { @@ -411,7 +420,7 @@ int wait_for_fd() } fcntl(sock, F_SETFL, flags | O_NONBLOCK); - char *path = "/data/data/com.github.shadowsocks/sock_path"; + char *path = "./sock_path"; if (options.sock_path != NULL) { path = options.sock_path; } @@ -485,12 +494,6 @@ int main (int argc, char **argv) goto fail0; } - if (options.fake_proc) { - // Fake process name to cheat on Lollipop - strcpy(argv[0], "com.github.shadowsocks"); - prctl(PR_SET_NAME, "com.github.shadowsocks"); - } - // handle --help and --version if (options.help) { print_version(); @@ -608,8 +611,8 @@ int main (int argc, char **argv) goto fail4; } - if (options.udpgw_remote_server_addr) { - // compute maximum UDP payload size we need to pass through udpgw + // Compute the largest possible UDP payload that we can receive from or send to the + // TUN device. udp_mtu = BTap_GetMTU(&device) - (int)(sizeof(struct ipv4_header) + sizeof(struct udp_header)); if (options.netif_ip6addr) { int udp_ip6_mtu = BTap_GetMTU(&device) - (int)(sizeof(struct ipv6_header) + sizeof(struct udp_header)); @@ -621,6 +624,9 @@ int main (int argc, char **argv) udp_mtu = 0; } + if (options.udpgw_remote_server_addr) { + udp_mode = UdpModeUdpgw; + // make sure our UDP payloads aren't too large for udpgw int udpgw_mtu = udpgw_compute_mtu(udp_mtu); if (udpgw_mtu < 0 || udpgw_mtu > PACKETPROTO_MAXPAYLOAD) { @@ -629,13 +635,23 @@ int main (int argc, char **argv) } // init udpgw client - if (!SocksUdpGwClient_Init(&udpgw_client, udp_mtu, DEFAULT_UDPGW_MAX_CONNECTIONS, options.udpgw_connection_buffer_size, UDPGW_KEEPALIVE_TIME, - socks_server_addr, dnsgw, socks_auth_info, socks_num_auth_info, - udpgw_remote_server_addr, UDPGW_RECONNECT_TIME, &ss, NULL, udpgw_client_handler_received - )) { + if (!SocksUdpGwClient_Init(&udpgw_client, udp_mtu, DEFAULT_UDPGW_MAX_CONNECTIONS, + options.udpgw_connection_buffer_size, UDPGW_KEEPALIVE_TIME, socks_server_addr, + dnsgw, socks_auth_info, socks_num_auth_info, udpgw_remote_server_addr, + UDPGW_RECONNECT_TIME, &ss, NULL, udp_send_packet_to_device)) + { BLog(BLOG_ERROR, "SocksUdpGwClient_Init failed"); goto fail4a; } + } else if (options.socks5_udp) { + udp_mode = UdpModeSocks; + + // init SOCKS UDP client + SocksUdpClient_Init(&socks_udp_client, udp_mtu, DEFAULT_UDPGW_MAX_CONNECTIONS, + SOCKS_UDP_SEND_BUFFER_PACKETS, UDPGW_KEEPALIVE_TIME, socks_server_addr, + socks_auth_info, socks_num_auth_info, &ss, NULL, udp_send_packet_to_device); + } else { + udp_mode = UdpModeNone; } // init lwip init job @@ -704,8 +720,10 @@ int main (int argc, char **argv) fail5: BPending_Free(&lwip_init_job); - if (options.udpgw_remote_server_addr) { + if (udp_mode == UdpModeUdpgw) { SocksUdpGwClient_Free(&udpgw_client); + } else if (udp_mode == UdpModeSocks) { + SocksUdpClient_Free(&socks_udp_client); } fail4a: SinglePacketBuffer_Free(&device_read_buffer); @@ -782,6 +800,7 @@ void print_help (const char *name) " [--udpgw-connection-buffer-size ]\n" " [--udpgw-transparent-dns]\n" #endif + " [--socks5-udp]\n" "Address format is a.b.c.d:port (IPv4) or [addr]:port (IPv6).\n", name ); @@ -829,6 +848,7 @@ int parse_arguments (int argc, char *argv[]) options.udpgw_max_connections = DEFAULT_UDPGW_MAX_CONNECTIONS; options.udpgw_connection_buffer_size = DEFAULT_UDPGW_CONNECTION_BUFFER_SIZE; options.udpgw_transparent_dns = 0; + options.socks5_udp = 0; int i; for (i = 1; i < argc; i++) { @@ -1058,6 +1078,9 @@ int parse_arguments (int argc, char *argv[]) options.udpgw_transparent_dns = 1; } #endif + else if (!strcmp(arg, "--socks5-udp")) { + options.socks5_udp = 1; + } else { fprintf(stderr, "unknown option: %s\n", arg); return 0; @@ -1412,14 +1435,14 @@ int process_device_udp_packet (uint8_t *data, int data_len) { ASSERT(data_len >= 0) - // do nothing if we don't have udpgw - if (!options.udpgw_remote_server_addr) { + // do nothing if we don't use udpgw or SOCKS UDP + if (udp_mode == UdpModeNone) { goto fail; } BAddr local_addr; BAddr remote_addr; - int is_dns; + int is_dns = 0; uint8_t ip_version = 0; if (data_len > 0) { @@ -1459,6 +1482,7 @@ int process_device_udp_packet (uint8_t *data, int data_len) BAddr_InitIPv4(&local_addr, ipv4_header.source_address, udp_header.source_port); BAddr_InitIPv4(&remote_addr, ipv4_header.destination_address, udp_header.dest_port); +#ifdef __ANDROID__ // if transparent DNS is enabled, any packet arriving at out netif // address to port 53 is considered a DNS packet is_dns = (options.dnsgw && udp_header.dest_port == hton16(53)); @@ -1475,6 +1499,7 @@ int process_device_udp_packet (uint8_t *data, int data_len) is_dns = (header->qr == 0 && header->rcode == 0 && header->ans_count == 0 && header->auth_count == 0); } } +#endif } break; case 6: { @@ -1529,8 +1554,13 @@ int process_device_udp_packet (uint8_t *data, int data_len) goto fail; } - // submit packet to udpgw - SocksUdpGwClient_SubmitPacket(&udpgw_client, local_addr, remote_addr, is_dns, data, data_len); + // submit packet to udpgw or SOCKS UDP + if (udp_mode == UdpModeUdpgw) { + SocksUdpGwClient_SubmitPacket(&udpgw_client, local_addr, remote_addr, + is_dns, data, data_len); + } else if (udp_mode == UdpModeSocks) { + SocksUdpClient_SubmitPacket(&socks_udp_client, local_addr, remote_addr, data, data_len); + } return 1; @@ -1678,8 +1708,10 @@ err_t listener_accept_func (void *arg, struct tcp_pcb *newpcb, err_t err) } // init SOCKS - if (!BSocksClient_Init(&client->socks_client, socks_server_addr, socks_auth_info, socks_num_auth_info, - addr, (BSocksClient_handler)client_socks_handler, client, &ss)) { + if (!BSocksClient_Init(&client->socks_client, + socks_server_addr, socks_auth_info, socks_num_auth_info, addr, /*udp=*/false, + (BSocksClient_handler)client_socks_handler, client, &ss)) + { BLog(BLOG_ERROR, "listener accept: BSocksClient_Init failed"); goto fail1; } @@ -1995,9 +2027,6 @@ void client_socks_handler (struct tcp_client *client, int event) client_free_socks(client); } break; - - default: - ASSERT(0); } } @@ -2193,13 +2222,15 @@ out: return (DEAD_KILLED > 0) ? ERR_ABRT : ERR_OK; } -void udpgw_client_handler_received (void *unused, BAddr local_addr, BAddr remote_addr, const uint8_t *data, int data_len) +void udp_send_packet_to_device (void *unused, BAddr local_addr, BAddr remote_addr, const uint8_t *data, int data_len) { - ASSERT(options.udpgw_remote_server_addr) + ASSERT(udp_mode != UdpModeNone) ASSERT(local_addr.type == BADDR_TYPE_IPV4 || local_addr.type == BADDR_TYPE_IPV6) ASSERT(local_addr.type == remote_addr.type) ASSERT(data_len >= 0) + char const *source_name = (udp_mode == UdpModeUdpgw) ? "udpgw" : "SOCKS UDP"; + int packet_length = 0; switch (local_addr.type) { @@ -2207,7 +2238,7 @@ void udpgw_client_handler_received (void *unused, BAddr local_addr, BAddr remote #ifdef __ANDROID__ BLog(BLOG_INFO, "UDP: from udprelay %d bytes", data_len); #else - BLog(BLOG_INFO, "UDP: from udpgw %d bytes", data_len); + BLog(BLOG_INFO, "UDP: from %s %d bytes", source_name, data_len); #endif if (data_len > UINT16_MAX - (sizeof(struct ipv4_header) + sizeof(struct udp_header)) || @@ -2250,14 +2281,14 @@ void udpgw_client_handler_received (void *unused, BAddr local_addr, BAddr remote #ifdef __ANDROID__ BLog(BLOG_INFO, "UDP/IPv6: from udprelay %d bytes", data_len); #else - BLog(BLOG_INFO, "UDP/IPv6: from udpgw %d bytes", data_len); + BLog(BLOG_INFO, "UDP/IPv6: from %s %d bytes", source_name, data_len); #endif if (!options.netif_ip6addr) { #ifdef __ANDROID__ BLog(BLOG_ERROR, "got IPv6 packet from udprelay but IPv6 is disabled"); #else - BLog(BLOG_ERROR, "got IPv6 packet from udpgw but IPv6 is disabled"); + BLog(BLOG_ERROR, "got IPv6 packet from %s but IPv6 is disabled", source_name); #endif return; } diff --git a/shadowsocks-android/core/src/main/jni/badvpn/tun2socks/tun2socks.h b/shadowsocks-android/core/src/main/jni/badvpn/tun2socks/tun2socks.h index caf577827d..27d4129493 100644 --- a/shadowsocks-android/core/src/main/jni/badvpn/tun2socks/tun2socks.h +++ b/shadowsocks-android/core/src/main/jni/badvpn/tun2socks/tun2socks.h @@ -44,3 +44,9 @@ // option to override the destination addresses to give the SOCKS server //#define OVERRIDE_DEST_ADDR "10.111.0.2:2000" + +// Max number of buffered outgoing UDP packets for SOCKS5-UDP. It should be large +// enough to prevent packet loss while the SOCKS UDP association is being set up. A slow +// or far-away SOCKS server could require 300 ms to connect, and a chatty client (e.g. +// STUN) could send a packet every 20 ms, so a default limit of 16 seems reasonable. +#define SOCKS_UDP_SEND_BUFFER_PACKETS 16 diff --git a/shadowsocks-android/core/src/main/jni/libancillary/CMakeLists.txt b/shadowsocks-android/core/src/main/jni/libancillary/CMakeLists.txt new file mode 100644 index 0000000000..c291820e61 --- /dev/null +++ b/shadowsocks-android/core/src/main/jni/libancillary/CMakeLists.txt @@ -0,0 +1,24 @@ + +cmake_minimum_required(VERSION 3.4.1) +project(ancillary C) + +set(CMAKE_C_STANDARD 11) + +set(LIB_ANCILLARY_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "ancillary library path" FORCE) + +include_directories(.) + +add_library( ancillary STATIC ancillary.h fd_recv.c fd_send.c ) + +option(libancillary_build_test OFF) + +if (libancillary_build_test) + add_executable( test_exe test.c ) + target_link_libraries( test_exe ancillary ) + + add_executable( evclient evclient.c ) + target_link_libraries( evclient ancillary ) + + add_executable( evserver evserver.c ) + target_link_libraries( evserver ancillary ) +endif (libancillary_build_test) diff --git a/shadowsocks-android/core/src/main/jni/libancillary/README b/shadowsocks-android/core/src/main/jni/libancillary/README index df91eb05af..1a5fb54522 100644 --- a/shadowsocks-android/core/src/main/jni/libancillary/README +++ b/shadowsocks-android/core/src/main/jni/libancillary/README @@ -12,6 +12,7 @@ run evserver in one window run evclient in another window + This code uses the libancil library: http://www.normalesup.org/~george/comp/libancillary/ Michael Haberler 1/2014 diff --git a/shadowsocks-android/core/src/main/jni/libancillary/README.md b/shadowsocks-android/core/src/main/jni/libancillary/README.md new file mode 100644 index 0000000000..43efdfb3f6 --- /dev/null +++ b/shadowsocks-android/core/src/main/jni/libancillary/README.md @@ -0,0 +1,3 @@ + + +[![Build Status](https://jenkins.stiwoll.mah.priv.at/job/libancillary/badge/icon)](https://jenkins.stiwoll.mah.priv.at/job/libancillary/) diff --git a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/.circleci/config.yml b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/.circleci/config.yml index b21c69e6b6..8e42d3d7d3 100644 --- a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/.circleci/config.yml +++ b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/.circleci/config.yml @@ -1,7 +1,7 @@ version: 2.1 orbs: - windows: circleci/windows@2.4.0 + windows: circleci/windows@5.0.0 jobs: build-linux: @@ -186,7 +186,7 @@ jobs: publish-github-releases: docker: - - image: circleci/golang:1.12 + - image: circleci/golang:1.17 steps: - attach_workspace: at: /tmp/workspace diff --git a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/.github/dependabot.yml b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/.github/dependabot.yml index e9c9a377f5..92bb2ac15d 100644 --- a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/.github/dependabot.yml +++ b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/.github/dependabot.yml @@ -4,23 +4,4 @@ updates: directory: "/" schedule: interval: weekly - open-pull-requests-limit: 10 - ignore: - - dependency-name: libc - versions: - - 0.2.92 - - dependency-name: tokio - versions: - - 1.4.0 - - dependency-name: bloomfilter - versions: - - 1.0.5 - - dependency-name: regex - versions: - - 1.4.5 - - dependency-name: serde - versions: - - 1.0.124 - - dependency-name: tower - versions: - - 0.4.6 + open-pull-requests-limit: 0 diff --git a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/.github/workflows/build-docker-image.yml b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/.github/workflows/build-docker-image.yml index b413da3048..a042a28ad9 100644 --- a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/.github/workflows/build-docker-image.yml +++ b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/.github/workflows/build-docker-image.yml @@ -16,20 +16,20 @@ jobs: - name: Checkout uses: actions/checkout@v4 - name: Setup Docker Buildx - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v3 - name: Login to GitHub Container Registry - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - name: Docker metadata id: metadata - uses: docker/metadata-action@v4 + uses: docker/metadata-action@v5 with: images: ghcr.io/${{ github.repository_owner }}/${{ matrix.bin }}-rust - name: Build and release Docker images - uses: docker/build-push-action@v3 + uses: docker/build-push-action@v6 with: platforms: linux/386,linux/amd64,linux/arm64/v8 target: ${{ matrix.bin }} diff --git a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/.github/workflows/build-release.yml b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/.github/workflows/build-release.yml index 17b97643c0..c9958c0258 100644 --- a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/.github/workflows/build-release.yml +++ b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/.github/workflows/build-release.yml @@ -71,7 +71,7 @@ jobs: ./build-release -t ${{ matrix.target }} $compile_features $compile_compress - name: Upload Github Assets - uses: softprops/action-gh-release@v1 + uses: softprops/action-gh-release@v2 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: @@ -116,7 +116,7 @@ jobs: ./build/build-host-release -t ${{ matrix.target }} - name: Upload Github Assets - uses: softprops/action-gh-release@v1 + uses: softprops/action-gh-release@v2 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: @@ -145,7 +145,7 @@ jobs: pwsh ./build/build-host-release.ps1 "full winservice" - name: Upload Github Assets - uses: softprops/action-gh-release@v1 + uses: softprops/action-gh-release@v2 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: diff --git a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/Cargo.lock b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/Cargo.lock index 752a662bdb..342d58f05d 100644 --- a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/Cargo.lock +++ b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/Cargo.lock @@ -4,18 +4,18 @@ version = 3 [[package]] name = "addr2line" -version = "0.22.0" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678" +checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1" dependencies = [ "gimli", ] [[package]] -name = "adler" -version = "1.0.2" +name = "adler2" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" [[package]] name = "aead" @@ -170,9 +170,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.86" +version = "1.0.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" +checksum = "c042108f3ed77fd83760a5fd79b53be043192bb3b9dba91d8c574c0ada7850c8" [[package]] name = "arc-swap" @@ -182,41 +182,43 @@ checksum = "69f7f8c3906b62b754cd5326047894316021dcfe5a194c8ea52bdd94934a3457" [[package]] name = "arrayref" -version = "0.3.8" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d151e35f61089500b617991b791fc8bfd237ae50cd5950803758a179b41e67a" +checksum = "76a2e8124351fda1ef8aaaa3bbd7ebbcb486bbcd4225aca0aa0d84bb2db8fecb" [[package]] name = "arrayvec" -version = "0.7.4" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" +checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" [[package]] -name = "async-compression" -version = "0.4.12" +name = "async-channel" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fec134f64e2bc57411226dfc4e52dec859ddfc7e711fc5e07b612584f000e4aa" +checksum = "89b47800b0be77592da0afd425cc03468052844aff33b84e33cc696f64e77b6a" dependencies = [ - "brotli", - "flate2", + "concurrent-queue", + "event-listener-strategy", "futures-core", - "memchr", "pin-project-lite", - "tokio", - "zstd", - "zstd-safe", ] [[package]] -name = "async-trait" -version = "0.1.81" +name = "async-task" +version = "4.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e0c28dcc82d7c8ead5cb13beb15405b57b8546e93215673ff8ca0349a028107" +checksum = "8b75356056920673b02621b35afd0f7dda9306d03c79a30f5c56c44cf256e3de" + +[[package]] +name = "async-trait" +version = "0.1.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.85", ] [[package]] @@ -227,23 +229,23 @@ checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" [[package]] name = "autocfg" -version = "1.3.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "backtrace" -version = "0.3.73" +version = "0.3.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cc23269a4f8976d0a4d2e7109211a419fe30e8d88d677cd60b6bc79c5732e0a" +checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a" dependencies = [ "addr2line", - "cc", "cfg-if", "libc", "miniz_oxide", "object", "rustc-demangle", + "windows-targets 0.52.6", ] [[package]] @@ -308,9 +310,9 @@ dependencies = [ [[package]] name = "blake3" -version = "1.5.3" +version = "1.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9ec96fe9a81b5e365f9db71fe00edc4fe4ca2cc7dcb7861f0603012a7caa210" +checksum = "d82033247fd8e890df8f740e407ad4d038debb9eb1f40533fffb32e7d17dc6f7" dependencies = [ "arrayref", "arrayvec", @@ -328,6 +330,19 @@ dependencies = [ "generic-array", ] +[[package]] +name = "blocking" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "703f41c54fc768e63e091340b424302bb1c29ef4aa0c7f10fe849dfb114d29ea" +dependencies = [ + "async-channel", + "async-task", + "futures-io", + "futures-lite", + "piper", +] + [[package]] name = "bloomfilter" version = "1.0.14" @@ -341,9 +356,9 @@ dependencies = [ [[package]] name = "brotli" -version = "6.0.0" +version = "7.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74f7971dbd9326d58187408ab83117d8ac1bb9c17b085fdacd1cf2f598719b6b" +checksum = "cc97b8f16f944bba54f0433f07e30be199b6dc2bd25937444bbad560bcea29bd" dependencies = [ "alloc-no-stdlib", "alloc-stdlib", @@ -362,9 +377,9 @@ dependencies = [ [[package]] name = "bson" -version = "2.11.0" +version = "2.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8a88e82b9106923b5c4d6edfca9e7db958d4e98a478ec115022e81b9b38e2c8" +checksum = "068208f2b6fcfa27a7f1ee37488d2bb8ba2640f68f5475d08e1d9130696aba59" dependencies = [ "ahash", "base64 0.13.1", @@ -391,7 +406,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.85", ] [[package]] @@ -414,24 +429,24 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.7.1" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50" +checksum = "9ac0150caa2ae65ca5bd83f25c7de183dea78d4d366469f148435e2acfbad0da" [[package]] name = "c2rust-bitfields" -version = "0.18.0" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b43c3f07ab0ef604fa6f595aa46ec2f8a22172c975e186f6f5bf9829a3b72c41" +checksum = "367e5d1b30f28be590b6b3868da1578361d29d9bfac516d22f497d28ed7c9055" dependencies = [ "c2rust-bitfields-derive", ] [[package]] name = "c2rust-bitfields-derive" -version = "0.18.0" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3cbc102e2597c9744c8bd8c15915d554300601c91a079430d309816b0912545" +checksum = "a279db9c50c4024eeca1a763b6e0f033848ce74e83e47454bcf8a8a98f7b0b56" dependencies = [ "proc-macro2", "quote", @@ -450,12 +465,13 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.6" +version = "1.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2aba8f4e9906c7ce3c73463f62a7f0c65183ada1a2d47e397cc8810827f9694f" +checksum = "c2e7962b54006dcfcc61cb72735f4d89bb97061dd6a7ed882ec6b8ee53714c6f" dependencies = [ "jobserver", "libc", + "shlex", ] [[package]] @@ -531,18 +547,18 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.15" +version = "4.5.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11d8838454fda655dafd3accb2b6e2bea645b9e4078abe84a22ceb947235c5cc" +checksum = "b97f376d85a664d5837dbae44bf546e6477a679ff6610010f17276f686d867e8" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.5.15" +version = "4.5.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "216aec2b177652e3846684cbfe25c9964d18ec45234f0f5da5157b207ed1aab6" +checksum = "19bc80abd44e4bed93ca373a0704ccbd1b710dc5749406201bb018272808dc54" dependencies = [ "anstream", "anstyle", @@ -559,9 +575,9 @@ checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97" [[package]] name = "cmake" -version = "0.1.50" +version = "0.1.51" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a31c789563b815f77f4250caee12365734369f942439b7defd71e18a48197130" +checksum = "fb1e43aa7fd152b1f968787f7dbcdeb306d1867ff373c69955211876c053f91a" dependencies = [ "cc", ] @@ -572,6 +588,15 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0" +[[package]] +name = "concurrent-queue" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ca0197aee26d1ae37445ee532fefce43251d24cc7c166799f4d46817f1d3973" +dependencies = [ + "crossbeam-utils", +] + [[package]] name = "const-oid" version = "0.9.6" @@ -580,9 +605,9 @@ checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" [[package]] name = "constant_time_eq" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7144d30dcf0fafbce74250a3963025d8d52177934239851c917d29f1df280c2" +checksum = "7c74b8349d32d297c9134b8c88677813a227df8f779daa29bfc29c183fe3dca6" [[package]] name = "core-foundation" @@ -596,15 +621,15 @@ dependencies = [ [[package]] name = "core-foundation-sys" -version = "0.8.6" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" [[package]] name = "cpufeatures" -version = "0.2.12" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" +checksum = "608697df725056feaccfa42cffdaeeec3fccc4ffc38358ecd19b243e716a78e0" dependencies = [ "libc", ] @@ -709,7 +734,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.85", ] [[package]] @@ -797,7 +822,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.85", ] [[package]] @@ -841,23 +866,23 @@ dependencies = [ [[package]] name = "encoding_rs" -version = "0.8.34" +version = "0.8.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59" +checksum = "75030f3c4f45dafd7586dd6780965a8c7e8e285a5ecb86713e63a79c5b2766f3" dependencies = [ "cfg-if", ] [[package]] name = "enum-as-inner" -version = "0.6.0" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ffccbb6966c05b32ef8fbac435df276c4ae4d3dc55a8cd0eb9745e6c12f546a" +checksum = "a1e6a265c649f3f5979b601d26f1d05ada116434c87741c9493cb56218f76cbc" dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.85", ] [[package]] @@ -901,13 +926,34 @@ dependencies = [ [[package]] name = "etherparse" -version = "0.15.0" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21696e6dfe1057a166a042c6d27b89a46aad2ee1003e6e1e03c49d54fd3270d7" +checksum = "b8d8a704b617484e9d867a0423cd45f7577f008c4068e2e33378f8d3860a6d73" dependencies = [ "arrayvec", ] +[[package]] +name = "event-listener" +version = "5.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6032be9bd27023a771701cc49f9f053c751055f71efb2e0ae5c15809093675ba" +dependencies = [ + "concurrent-queue", + "parking", + "pin-project-lite", +] + +[[package]] +name = "event-listener-strategy" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f214dc438f977e6d4e3500aaa277f5ad94ca83fbbd9b1a15713ce2344ccc5a1" +dependencies = [ + "event-listener", + "pin-project-lite", +] + [[package]] name = "fastrand" version = "1.9.0" @@ -919,9 +965,9 @@ dependencies = [ [[package]] name = "fastrand" -version = "2.1.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" +checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6" [[package]] name = "ff" @@ -935,21 +981,21 @@ dependencies = [ [[package]] name = "filetime" -version = "0.2.23" +version = "0.2.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ee447700ac8aa0b2f2bd7bc4462ad686ba06baa6727ac149a2d6277f0d240fd" +checksum = "35c0522e981e68cbfa8c3f978441a5f34b30b96e146b33cd3359176b50fe8586" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.4.1", - "windows-sys 0.52.0", + "libredox", + "windows-sys 0.59.0", ] [[package]] name = "flate2" -version = "1.0.31" +version = "1.0.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f211bbe8e69bbd0cfdea405084f128ae8b4aaa6b0b522fc8f2b009084797920" +checksum = "a1b589b4dc103969ad3cf85c950899926ec64300a1a46d76c03a6072957036f0" dependencies = [ "crc32fast", "miniz_oxide", @@ -1012,9 +1058,9 @@ checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" [[package]] name = "futures" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" +checksum = "65bc07b1a8bc7c85c5f2e110c476c7389b4554ba72af57d8445ea63a576b0876" dependencies = [ "futures-channel", "futures-core", @@ -1027,9 +1073,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" +checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" dependencies = [ "futures-core", "futures-sink", @@ -1037,15 +1083,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" +checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" [[package]] name = "futures-executor" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" +checksum = "1e28d1d997f585e54aebc3f97d39e72338912123a67330d723fdbb564d646c9f" dependencies = [ "futures-core", "futures-task", @@ -1054,38 +1100,48 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" +checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" + +[[package]] +name = "futures-lite" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52527eb5074e35e9339c6b4e8d12600c7128b68fb25dcb9fa9dec18f7c25f3a5" +dependencies = [ + "futures-core", + "pin-project-lite", +] [[package]] name = "futures-macro" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" +checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.85", ] [[package]] name = "futures-sink" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" +checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" [[package]] name = "futures-task" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" +checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" [[package]] name = "futures-util" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" +checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" dependencies = [ "futures-channel", "futures-core", @@ -1144,9 +1200,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.29.0" +version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" +checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" [[package]] name = "group" @@ -1180,9 +1236,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa82e28a107a8cc405f0839610bdc9b15f1e25ec7d696aa5cf173edbcb1486ab" +checksum = "524e8ac6999421f49a846c2d4411f337e53497d8ec55d67753beffa43c5d9205" dependencies = [ "atomic-waker", "bytes", @@ -1236,9 +1292,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.14.5" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" +checksum = "1e087f84d4f86bf4b218b927129862374b72199ae7d8657835f1e89000eea4fb" [[package]] name = "heapless" @@ -1252,9 +1308,9 @@ dependencies = [ [[package]] name = "heck" -version = "0.4.1" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" [[package]] name = "hermit-abi" @@ -1409,9 +1465,9 @@ dependencies = [ [[package]] name = "httparse" -version = "1.9.4" +version = "1.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fcc0b4a115bf80b728eb8ea024ad5bd707b615bfed49e0665b6e0f86fd082d9" +checksum = "7d71d3574edd2771538b901e6549113b4006ece66150fb69c0fb6d9a2adae946" [[package]] name = "httpdate" @@ -1427,14 +1483,14 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "hyper" -version = "1.4.1" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50dfd22e0e76d0f662d429a5f80fcaf3855009297eab6a0a9f8543834744ba05" +checksum = "bbbff0a806a4728c99295b254c8838933b5b082d75e3cb70c8dab21fdfbcfa9a" dependencies = [ "bytes", "futures-channel", "futures-util", - "h2 0.4.5", + "h2 0.4.6", "http 1.1.0", "http-body", "httparse", @@ -1448,21 +1504,21 @@ dependencies = [ [[package]] name = "hyper-rustls" -version = "0.27.2" +version = "0.27.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ee4be2c948921a1a5320b629c4193916ed787a7f7f293fd3f7f5a6c9de74155" +checksum = "08afdbb5c31130e3034af566421053ab03787c640246a446327f550d11bcb333" dependencies = [ "futures-util", "http 1.1.0", "hyper", "hyper-util", - "rustls 0.23.12", - "rustls-native-certs 0.7.1", + "rustls 0.23.15", + "rustls-native-certs 0.8.0", "rustls-pki-types", "tokio", "tokio-rustls 0.26.0", "tower-service", - "webpki-roots 0.26.3", + "webpki-roots 0.26.6", ] [[package]] @@ -1483,9 +1539,9 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.6" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ab92f4f49ee4fb4f997c784b7a2e0fa70050211e0b6a287f898c3c9785ca956" +checksum = "41296eb09f183ac68eec06e03cdbea2e759633d4067b2f6552fc2e009bcad08b" dependencies = [ "bytes", "futures-channel", @@ -1496,16 +1552,15 @@ dependencies = [ "pin-project-lite", "socket2", "tokio", - "tower", "tower-service", "tracing", ] [[package]] name = "iana-time-zone" -version = "0.1.60" +version = "0.1.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141" +checksum = "235e081f3925a06703c2d0117ea8b91f042756fd6e7a6e5d901e8ca1a996b220" dependencies = [ "android_system_properties", "core-foundation-sys", @@ -1639,7 +1694,7 @@ checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.85", ] [[package]] @@ -1676,9 +1731,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.2.6" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" dependencies = [ "equivalent", "hashbrown", @@ -1731,14 +1786,14 @@ dependencies = [ "socket2", "widestring", "windows-sys 0.48.0", - "winreg 0.50.0", + "winreg", ] [[package]] name = "ipnet" -version = "2.9.0" +version = "2.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" +checksum = "ddc24109865250148c2e0f3d25d4f0f479571723792d3802153c60922a4fb708" [[package]] name = "iprange" @@ -1792,9 +1847,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.69" +version = "0.3.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" +checksum = "6a88f1bda2bd75b0452a14784937d796722fdebfe50df998aeb3f0b7603019a9" dependencies = [ "wasm-bindgen", ] @@ -1838,9 +1893,9 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.155" +version = "0.2.161" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" +checksum = "8e9489c2807c139ffd9c1794f4af0ebe86a828db53ecdc7fea2111d0fed085d1" [[package]] name = "libloading" @@ -1870,6 +1925,7 @@ checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ "bitflags 2.6.0", "libc", + "redox_syscall 0.5.7", ] [[package]] @@ -2012,11 +2068,11 @@ checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" [[package]] name = "miniz_oxide" -version = "0.7.4" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" +checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" dependencies = [ - "adler", + "adler2", ] [[package]] @@ -2033,9 +2089,9 @@ dependencies = [ [[package]] name = "mio" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4569e456d394deccd22ce1c1913e6ea0e54519f577285001215d33557431afe4" +checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec" dependencies = [ "hermit-abi", "libc", @@ -2127,18 +2183,18 @@ dependencies = [ [[package]] name = "object" -version = "0.36.2" +version = "0.36.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f203fa8daa7bb185f760ae12bd8e097f63d17041dcdcaf675ac54cdf863170e" +checksum = "aedf0a2d09c573ed1d8d85b30c119153926a2b36dce0ab28322c09a117a4683e" dependencies = [ "memchr", ] [[package]] name = "once_cell" -version = "1.19.0" +version = "1.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" [[package]] name = "opaque-debug" @@ -2148,9 +2204,9 @@ checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" [[package]] name = "openssl" -version = "0.10.66" +version = "0.10.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9529f4786b70a3e8c61e11179af17ab6188ad8d0ded78c5529441ed39d4bd9c1" +checksum = "6174bc48f102d208783c2c84bf931bb75927a617866870de8a4ea85597f871f5" dependencies = [ "bitflags 2.6.0", "cfg-if", @@ -2169,7 +2225,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.85", ] [[package]] @@ -2180,18 +2236,18 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-src" -version = "300.3.1+3.3.1" +version = "300.4.0+3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7259953d42a81bf137fbbd73bd30a8e1914d6dce43c2b90ed575783a22608b91" +checksum = "a709e02f2b4aca747929cca5ed248880847c650233cf8b8cdc48f40aaf4898a6" dependencies = [ "cc", ] [[package]] name = "openssl-sys" -version = "0.9.103" +version = "0.9.104" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f9e8deee91df40a943c71b917e5874b951d32a802526c85721ce3b776c929d6" +checksum = "45abf306cbf99debc8195b66b7346498d7b10c210de50418b5ccd7ceba08c741" dependencies = [ "cc", "libc", @@ -2242,6 +2298,12 @@ dependencies = [ "primeorder", ] +[[package]] +name = "parking" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f38d5652c16fde515bb1ecef450ab0f6a219d619a7274976324d5e377f7dceba" + [[package]] name = "parking_lot" version = "0.11.2" @@ -2285,7 +2347,7 @@ checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.5.3", + "redox_syscall 0.5.7", "smallvec", "windows-targets 0.52.6", ] @@ -2298,9 +2360,9 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pest" -version = "2.7.11" +version = "2.7.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd53dff83f26735fdc1ca837098ccf133605d794cdae66acfc2bfac3ec809d95" +checksum = "879952a81a83930934cbf1786752d6dedc3b1f29e8f8fb2ad1d0a36f377cf442" dependencies = [ "memchr", "thiserror", @@ -2309,9 +2371,9 @@ dependencies = [ [[package]] name = "pest_derive" -version = "2.7.11" +version = "2.7.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a548d2beca6773b1c244554d36fcf8548a8a58e74156968211567250e48e49a" +checksum = "d214365f632b123a47fd913301e14c946c61d1c183ee245fa76eb752e59a02dd" dependencies = [ "pest", "pest_generator", @@ -2319,22 +2381,22 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.7.11" +version = "2.7.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c93a82e8d145725dcbaf44e5ea887c8a869efdcc28706df2d08c69e17077183" +checksum = "eb55586734301717aea2ac313f50b2eb8f60d2fc3dc01d190eefa2e625f60c4e" dependencies = [ "pest", "pest_meta", "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.85", ] [[package]] name = "pest_meta" -version = "2.7.11" +version = "2.7.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a941429fea7e08bedec25e4f6785b6ffaacc6b755da98df5ef3e7dcf4a124c4f" +checksum = "b75da2a70cf4d9cb76833c990ac9cd3923c9a8905a8929789ce347c84564d03d" dependencies = [ "once_cell", "pest", @@ -2343,29 +2405,29 @@ dependencies = [ [[package]] name = "pin-project" -version = "1.1.5" +version = "1.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6bf43b791c5b9e34c3d182969b4abb522f9343702850a2e57f460d00d09b4b3" +checksum = "be57f64e946e500c8ee36ef6331845d40a93055567ec57e8fae13efd33759b95" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.1.5" +version = "1.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" +checksum = "3c0f5fad0874fc7abcd4d750e76917eaebbecaa2c20bde22e1dbeeba8beb758c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.85", ] [[package]] name = "pin-project-lite" -version = "0.2.14" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" +checksum = "915a1e146535de9163f3987b8944ed8cf49a18bb0056bcebcdcece385cece4ff" [[package]] name = "pin-utils" @@ -2373,6 +2435,17 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "piper" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96c8c490f422ef9a4efd2cb5b42b76c8613d7e7dfc1caf667b8a3350a5acc066" +dependencies = [ + "atomic-waker", + "fastrand 2.1.1", + "futures-io", +] + [[package]] name = "pkcs8" version = "0.10.2" @@ -2385,9 +2458,9 @@ dependencies = [ [[package]] name = "pkg-config" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" +checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" [[package]] name = "poly1305" @@ -2420,9 +2493,12 @@ checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" [[package]] name = "ppv-lite86" -version = "0.2.17" +version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" +checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" +dependencies = [ + "zerocopy", +] [[package]] name = "primeorder" @@ -2459,9 +2535,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.86" +version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" +checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e" dependencies = [ "unicode-ident", ] @@ -2488,7 +2564,7 @@ dependencies = [ "pin-project-lite", "quinn-proto 0.10.6", "quinn-udp 0.4.1", - "rustc-hash", + "rustc-hash 1.1.0", "rustls 0.21.12", "thiserror", "tokio", @@ -2497,16 +2573,17 @@ dependencies = [ [[package]] name = "quinn" -version = "0.11.2" +version = "0.11.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4ceeeeabace7857413798eb1ffa1e9c905a9946a57d81fb69b4b71c4d8eb3ad" +checksum = "8c7c5fdde3cdae7203427dc4f0a68fe0ed09833edc525a03456b153b79828684" dependencies = [ "bytes", "pin-project-lite", - "quinn-proto 0.11.3", - "quinn-udp 0.5.4", - "rustc-hash", - "rustls 0.23.12", + "quinn-proto 0.11.8", + "quinn-udp 0.5.5", + "rustc-hash 2.0.0", + "rustls 0.23.15", + "socket2", "thiserror", "tokio", "tracing", @@ -2521,7 +2598,7 @@ dependencies = [ "bytes", "rand", "ring 0.16.20", - "rustc-hash", + "rustc-hash 1.1.0", "rustls 0.21.12", "slab", "thiserror", @@ -2531,15 +2608,15 @@ dependencies = [ [[package]] name = "quinn-proto" -version = "0.11.3" +version = "0.11.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddf517c03a109db8100448a4be38d498df8a210a99fe0e1b9eaf39e78c640efe" +checksum = "fadfaed2cd7f389d0161bb73eeb07b7b78f8691047a6f3e73caaeae55310a4a6" dependencies = [ "bytes", "rand", "ring 0.17.8", - "rustc-hash", - "rustls 0.23.12", + "rustc-hash 2.0.0", + "rustls 0.23.15", "slab", "thiserror", "tinyvec", @@ -2561,21 +2638,22 @@ dependencies = [ [[package]] name = "quinn-udp" -version = "0.5.4" +version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bffec3605b73c6f1754535084a85229fa8a30f86014e6c81aeec4abb68b0285" +checksum = "4fe68c2e9e1a1234e218683dbdf9f9dfcb094113c5ac2b938dfcb9bab4c4140b" dependencies = [ "libc", "once_cell", "socket2", - "windows-sys 0.52.0", + "tracing", + "windows-sys 0.59.0", ] [[package]] name = "quote" -version = "1.0.36" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" dependencies = [ "proc-macro2", ] @@ -2627,27 +2705,18 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.4.1" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" -dependencies = [ - "bitflags 1.3.2", -] - -[[package]] -name = "redox_syscall" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a908a6e00f1fdd0dfd9c0eb08ce85126f6d8bbda50017e74bc4a4b7d4a926a4" +checksum = "9b6dfecf2c74bce2466cabf93f6664d6998a69eb21e39f4207930065b27b771f" dependencies = [ "bitflags 2.6.0", ] [[package]] name = "redox_users" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd283d9651eeda4b2a83a43c1c91b266c40fd76ecd39a50a8c630ae69dc72891" +checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43" dependencies = [ "getrandom", "libredox", @@ -2656,14 +2725,14 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.5" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f" +checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.4.7", - "regex-syntax 0.8.4", + "regex-automata 0.4.8", + "regex-syntax 0.8.5", ] [[package]] @@ -2677,13 +2746,13 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" +checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3" dependencies = [ "aho-corasick", "memchr", - "regex-syntax 0.8.4", + "regex-syntax 0.8.5", ] [[package]] @@ -2694,24 +2763,23 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] name = "regex-syntax" -version = "0.8.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "reqwest" -version = "0.12.5" +version = "0.12.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7d6d2a27d57148378eb5e111173f4276ad26340ecc5c49a4a2152167a2d6a37" +checksum = "f713147fbe92361e52392c73b8c9e48c04c6625bce969ef54dc901e58e042a7b" dependencies = [ - "async-compression", "base64 0.22.1", "bytes", "encoding_rs", "futures-channel", "futures-core", "futures-util", - "h2 0.4.5", + "h2 0.4.6", "http 1.1.0", "http-body", "http-body-util", @@ -2727,10 +2795,10 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite", - "quinn 0.11.2", - "rustls 0.23.12", - "rustls-native-certs 0.7.1", - "rustls-pemfile 2.1.2", + "quinn 0.11.5", + "rustls 0.23.15", + "rustls-native-certs 0.8.0", + "rustls-pemfile 2.2.0", "rustls-pki-types", "serde", "serde_json", @@ -2740,14 +2808,13 @@ dependencies = [ "tokio", "tokio-native-tls", "tokio-rustls 0.26.0", - "tokio-util", "tower-service", "url", "wasm-bindgen", "wasm-bindgen-futures", "web-sys", - "webpki-roots 0.26.3", - "winreg 0.52.0", + "webpki-roots 0.26.6", + "windows-registry", ] [[package]] @@ -2863,10 +2930,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" [[package]] -name = "rustix" -version = "0.38.34" +name = "rustc-hash" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" +checksum = "583034fd73374156e66797ed8e5b0d5690409c9226b22d87cb7f19821c05d152" + +[[package]] +name = "rustix" +version = "0.38.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8acb788b847c24f28525660c4d7758620a7210875711f79e7f663cc152726811" dependencies = [ "bitflags 2.6.0", "errno", @@ -2889,15 +2962,15 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.12" +version = "0.23.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c58f8c84392efc0a126acce10fa59ff7b3d2ac06ab451a33f2741989b806b044" +checksum = "5fbb44d7acc4e873d613422379f69f237a1b141928c02f6bc6ccfddddc2d7993" dependencies = [ "log", "once_cell", "ring 0.17.8", "rustls-pki-types", - "rustls-webpki 0.102.6", + "rustls-webpki 0.102.8", "subtle", "zeroize", ] @@ -2916,12 +2989,12 @@ dependencies = [ [[package]] name = "rustls-native-certs" -version = "0.7.1" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a88d6d420651b496bdd98684116959239430022a115c1240e6c3993be0b15fba" +checksum = "fcaf18a4f2be7326cd874a5fa579fae794320a0f388d365dca7e480e55f83f8a" dependencies = [ "openssl-probe", - "rustls-pemfile 2.1.2", + "rustls-pemfile 2.2.0", "rustls-pki-types", "schannel", "security-framework", @@ -2938,19 +3011,18 @@ dependencies = [ [[package]] name = "rustls-pemfile" -version = "2.1.2" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29993a25686778eb88d4189742cd713c9bce943bc54251a33509dc63cbacf73d" +checksum = "dce314e5fee3f39953d46bb63bb8a46d40c2f8fb7cc5a3b6cab2bde9721d6e50" dependencies = [ - "base64 0.22.1", "rustls-pki-types", ] [[package]] name = "rustls-pki-types" -version = "1.7.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "976295e77ce332211c0d24d92c0e83e50f5c5f046d11082cea19f3df13a3562d" +checksum = "16f1201b3c9a7ee8039bcadc17b7e605e2945b27eee7631788c1bd2b0643674b" [[package]] name = "rustls-webpki" @@ -2964,9 +3036,9 @@ dependencies = [ [[package]] name = "rustls-webpki" -version = "0.102.6" +version = "0.102.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e6b52d4fda176fd835fdc55a835d4a89b8499cad995885a21149d5ad62f852e" +checksum = "64ca1bc8749bd4cf37b5ce386cc146580777b4e8572c7b97baf22c83f444bee9" dependencies = [ "ring 0.17.8", "rustls-pki-types", @@ -2990,11 +3062,11 @@ dependencies = [ [[package]] name = "schannel" -version = "0.1.23" +version = "0.1.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbc91545643bcf3a0bbb6569265615222618bdf33ce4ffbbd13c4bbd4c093534" +checksum = "01227be5826fa0690321a2ba6c5cd57a19cf3f6a09e76973b58e61de6ab9d1c1" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -3041,9 +3113,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.11.1" +version = "2.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75da29fe9b9b08fe9d6b22b5b4bcbc75d8db3aa31e639aa56bb62e9d46bfceaf" +checksum = "ea4a292869320c0272d7bc55a5a6aafaff59b4f63404a003887b679a2e05b4b6" dependencies = [ "core-foundation-sys", "libc", @@ -3061,9 +3133,9 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.204" +version = "1.0.213" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" +checksum = "3ea7893ff5e2466df8d720bb615088341b295f849602c6956047f8f80f0e9bc1" dependencies = [ "serde_derive", ] @@ -3089,20 +3161,20 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.204" +version = "1.0.213" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" +checksum = "7e85ad2009c50b58e87caa8cd6dac16bdf511bbfb7af6c33df902396aa480fa5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.85", ] [[package]] name = "serde_json" -version = "1.0.124" +version = "1.0.132" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66ad62847a56b3dba58cc891acd13884b9c61138d330c0d7b6181713d4fce38d" +checksum = "d726bfaff4b320266d395898905d0eba0345aae23b54aee3a737e260fd46db03" dependencies = [ "indexmap", "itoa", @@ -3160,7 +3232,7 @@ dependencies = [ [[package]] name = "shadowsocks" -version = "1.20.2" +version = "1.21.0" dependencies = [ "aes", "arc-swap", @@ -3226,7 +3298,7 @@ dependencies = [ [[package]] name = "shadowsocks-rust" -version = "1.20.4" +version = "1.21.2" dependencies = [ "base64 0.22.1", "build-time", @@ -3267,7 +3339,7 @@ dependencies = [ [[package]] name = "shadowsocks-service" -version = "1.20.4" +version = "1.21.2" dependencies = [ "arc-swap", "async-trait", @@ -3300,7 +3372,7 @@ dependencies = [ "pin-project", "rand", "regex", - "rustls-native-certs 0.7.1", + "rustls-native-certs 0.8.0", "serde", "shadowsocks", "sled", @@ -3312,7 +3384,7 @@ dependencies = [ "tokio-native-tls", "tokio-rustls 0.26.0", "tun2", - "webpki-roots 0.26.3", + "webpki-roots 0.26.6", "windows-sys 0.59.0", "zstd", ] @@ -3326,6 +3398,12 @@ dependencies = [ "lazy_static", ] +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + [[package]] name = "signal-hook-registry" version = "1.4.2" @@ -3489,9 +3567,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.72" +version = "2.0.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc4b9b9bf2add8093d3f2c0204471e951b2285580335de42f9d2534f3ae7a8af" +checksum = "5023162dfcd14ef8f32034d8bcd4cc5ddc61ef7a247c024a33e24e1f24d21b56" dependencies = [ "proc-macro2", "quote", @@ -3503,6 +3581,9 @@ name = "sync_wrapper" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" +dependencies = [ + "futures-core", +] [[package]] name = "synstructure" @@ -3512,31 +3593,31 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.85", ] [[package]] name = "sysexits" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4008983d29e823b1415f5f12732d5c9a44059795fb6218262cc0185668851e2" +checksum = "c5649c51a0a23b49261cc66a328925546beaf86d7c9af801b3993732deccec7a" [[package]] name = "system-configuration" -version = "0.5.1" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" +checksum = "3c879d448e9d986b661742763247d3693ed13609438cf3d006f51f5368a5ba6b" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.6.0", "core-foundation", "system-configuration-sys", ] [[package]] name = "system-configuration-sys" -version = "0.5.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" +checksum = "8e1d1b10ced5ca923a1fcb8d03e96b8d3268065d724548c0211415ff6ac6bac4" dependencies = [ "core-foundation-sys", "libc", @@ -3565,44 +3646,45 @@ checksum = "3b7ad73e635dd232c2c2106d59269f59a61de421cc6b95252d2d932094ff1f40" [[package]] name = "tempfile" -version = "3.10.1" +version = "3.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" +checksum = "f0f2c9fc62d0beef6951ccffd757e241266a2c833136efbe35af6cd2567dca5b" dependencies = [ "cfg-if", - "fastrand 2.1.0", + "fastrand 2.1.1", + "once_cell", "rustix", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] name = "terminal_size" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21bebf2b7c9e0a515f6e0f8c51dc0f8e4696391e6f1ff30379559f8365fb0df7" +checksum = "4f599bd7ca042cfdf8f4512b277c02ba102247820f9d9d4a9f521f496751a6ef" dependencies = [ "rustix", - "windows-sys 0.48.0", + "windows-sys 0.59.0", ] [[package]] name = "thiserror" -version = "1.0.63" +version = "1.0.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" +checksum = "5d11abd9594d9b38965ef50805c5e469ca9cc6f197f883f717e0269a3057b3d5" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.63" +version = "1.0.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" +checksum = "ae71770322cbd277e69d762a16c444af02aa0575ac0d174f0b9562d3b37f8602" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.85", ] [[package]] @@ -3685,14 +3767,14 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.39.2" +version = "1.41.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "daa4fb1bc778bd6f04cbfc4bb2d06a7396a8f299dc33ea1900cedaa316f467b1" +checksum = "145f3413504347a2be84393cc8a7d2fb4d863b375909ea59f2158261aa258bbb" dependencies = [ "backtrace", "bytes", "libc", - "mio 1.0.1", + "mio 1.0.2", "parking_lot 0.12.3", "pin-project-lite", "signal-hook-registry", @@ -3709,7 +3791,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.85", ] [[package]] @@ -3738,7 +3820,7 @@ version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" dependencies = [ - "rustls 0.23.12", + "rustls 0.23.15", "rustls-pki-types", "tokio", ] @@ -3762,9 +3844,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.11" +version = "0.7.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cf6b47b3771c49ac75ad09a6162f53ad4b8088b76ac60e8ec1455b31a189fe1" +checksum = "61e7c3654c13bcd040d4a03abee2c75b1d14a37b423cf5a813ceae1cc903ec6a" dependencies = [ "bytes", "futures-core", @@ -3773,32 +3855,11 @@ dependencies = [ "tokio", ] -[[package]] -name = "tower" -version = "0.4.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" -dependencies = [ - "futures-core", - "futures-util", - "pin-project", - "pin-project-lite", - "tokio", - "tower-layer", - "tower-service", -] - -[[package]] -name = "tower-layer" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0" - [[package]] name = "tower-service" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" [[package]] name = "tracing" @@ -3820,7 +3881,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.85", ] [[package]] @@ -3871,23 +3932,23 @@ checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] name = "tun2" -version = "2.0.5" +version = "3.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50ff242bea1c5ceb9b6aa4918cf340a6c157e1328a2389c5353cf91049d8cf17" +checksum = "294ac0e21fef392b8952f1dd538bc5752fd7c2ebfde1c204b0dd09aaa5489cd0" dependencies = [ "bytes", "cfg-if", + "futures", "futures-core", "ipnet", "libc", - "libloading", "log", "nix", "thiserror", "tokio", "tokio-util", - "windows-sys 0.52.0", - "wintun", + "windows-sys 0.59.0", + "wintun-bindings", ] [[package]] @@ -3907,27 +3968,27 @@ checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "ucd-trie" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed646292ffc8188ef8ea4d1e0e0150fb15a5c2e12ad9b8fc191ae7a8a7f3c4b9" +checksum = "2896d95c02a80c6d6a5d6e953d479f5ddf2dfdb6a244441010e373ac0fb88971" [[package]] name = "unicode-bidi" -version = "0.3.15" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" +checksum = "5ab17db44d7388991a428b2ee655ce0c212e862eff1768a455c58f9aad6e7893" [[package]] name = "unicode-ident" -version = "1.0.12" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" [[package]] name = "unicode-normalization" -version = "0.1.23" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" +checksum = "5033c97c4262335cded6d6fc3e5c18ab755e1a3dc96376350f3d8e9f009ad956" dependencies = [ "tinyvec", ] @@ -4001,9 +4062,9 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "uuid" -version = "1.10.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81dfa00651efa65069b0b6b651f4aaa31ba9e3c3ce0137aaad053604ee7e0314" +checksum = "f8c5f0a0af699448548ad1a2fbf920fb4bee257eae39953ba95cb84891a0446a" dependencies = [ "getrandom", "serde", @@ -4054,34 +4115,35 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.92" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" +checksum = "128d1e363af62632b8eb57219c8fd7877144af57558fb2ef0368d0087bddeb2e" dependencies = [ "cfg-if", + "once_cell", "wasm-bindgen-macro", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.92" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" +checksum = "cb6dd4d3ca0ddffd1dd1c9c04f94b868c37ff5fac97c30b97cff2d74fce3a358" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.85", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.42" +version = "0.4.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76bc14366121efc8dbb487ab05bcc9d346b3b5ec0eaa76e46594cabbe51762c0" +checksum = "cc7ec4f8827a71586374db3e87abdb5a2bb3a15afed140221307c3ec06b1f63b" dependencies = [ "cfg-if", "js-sys", @@ -4091,9 +4153,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.92" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" +checksum = "e79384be7f8f5a9dd5d7167216f022090cf1f9ec128e6e6a482a2cb5c5422c56" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -4101,28 +4163,28 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.92" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" +checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.85", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.92" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" +checksum = "65fc09f10666a9f147042251e0dda9c18f166ff7de300607007e96bdebc1068d" [[package]] name = "web-sys" -version = "0.3.69" +version = "0.3.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77afa9a11836342370f4817622a2f0f418b134426d91a82dfb48f532d2ec13ef" +checksum = "f6488b90108c040df0fe62fa815cbdee25124641df01814dd7282749234c6112" dependencies = [ "js-sys", "wasm-bindgen", @@ -4136,9 +4198,9 @@ checksum = "5f20c57d8d7db6d3b86154206ae5d8fba62dd39573114de97c2cb0578251f8e1" [[package]] name = "webpki-roots" -version = "0.26.3" +version = "0.26.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd7c23921eeb1713a4e851530e9b9756e4fb0e89978582942612524cf09f01cd" +checksum = "841c67bff177718f1d4dfefde8d8f0e78f9b6589319ba88312f567fc5841a958" dependencies = [ "rustls-pki-types", ] @@ -4167,11 +4229,11 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.8" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b" +checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -4189,6 +4251,26 @@ dependencies = [ "windows-targets 0.52.6", ] +[[package]] +name = "windows-registry" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e400001bb720a623c1c69032f8e3e4cf09984deec740f007dd2b03ec864804b0" +dependencies = [ + "windows-result", + "windows-strings", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-result" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d1043d8214f791817bab27572aaa8af63732e11bf84aa21a45a78d6c317ae0e" +dependencies = [ + "windows-targets 0.52.6", +] + [[package]] name = "windows-service" version = "0.7.0" @@ -4200,6 +4282,16 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "windows-strings" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10" +dependencies = [ + "windows-result", + "windows-targets 0.52.6", +] + [[package]] name = "windows-sys" version = "0.48.0" @@ -4359,26 +4451,18 @@ dependencies = [ ] [[package]] -name = "winreg" -version = "0.52.0" +name = "wintun-bindings" +version = "0.7.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a277a57398d4bfa075df44f501a17cfdf8542d224f0d36095a2adc7aee4ef0a5" -dependencies = [ - "cfg-if", - "windows-sys 0.48.0", -] - -[[package]] -name = "wintun" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b196f9328341b035820c54beebca487823e2e20a5977f284f2af2a0ee8f04400" +checksum = "74675b7fccee92389d38c3d120445864d1085c421ee91c7ed05d66fb9bb76050" dependencies = [ + "blocking", "c2rust-bitfields", + "futures", "libloading", "log", "thiserror", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -4428,7 +4512,7 @@ checksum = "28cc31741b18cb6f1d5ff12f5b7523e3d6eb0852bbbad19d73905511d9849b95" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.85", "synstructure", ] @@ -4438,6 +4522,7 @@ version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" dependencies = [ + "byteorder", "zerocopy-derive", ] @@ -4449,7 +4534,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.85", ] [[package]] @@ -4469,7 +4554,7 @@ checksum = "0ea7b4a3637ea8669cedf0f1fd5c286a17f3de97b8dd5a70a6c167a1730e63a5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.85", "synstructure", ] @@ -4498,7 +4583,7 @@ checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.85", ] [[package]] @@ -4512,18 +4597,18 @@ dependencies = [ [[package]] name = "zstd-safe" -version = "7.2.0" +version = "7.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa556e971e7b568dc775c136fc9de8c779b1c2fc3a63defaafadffdbd3181afa" +checksum = "54a3ab4db68cea366acc5c897c7b4d4d1b8994a9cd6e6f841f8964566a419059" dependencies = [ "zstd-sys", ] [[package]] name = "zstd-sys" -version = "2.0.12+zstd.1.5.6" +version = "2.0.13+zstd.1.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a4e40c320c3cb459d9a9ff6de98cff88f4751ee9275d140e2be94a2b74e4c13" +checksum = "38ff0f21cfee8f97d94cef41359e0c89aa6113028ab0291aa8ca0038995a95aa" dependencies = [ "cc", "pkg-config", diff --git a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/Cargo.toml b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/Cargo.toml index b81b29d02d..1002e194b1 100644 --- a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/Cargo.toml +++ b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "shadowsocks-rust" -version = "1.20.4" +version = "1.21.2" authors = ["Shadowsocks Contributors"] description = "shadowsocks is a fast tunnel proxy that helps you bypass firewalls." repository = "https://github.com/shadowsocks/shadowsocks-rust" @@ -240,7 +240,7 @@ rand = "0.8" futures = "0.3" tokio = { version = "1", features = ["rt", "signal"] } -ipnet = { version = "2.9", optional = true } +ipnet = { version = "2.10", optional = true } mimalloc = { version = "0.1", default-features = false, optional = true } tcmalloc = { version = "0.3", optional = true } @@ -248,7 +248,7 @@ jemallocator = { version = "0.5", optional = true } snmalloc-rs = { version = "0.3", optional = true } rpmalloc = { version = "0.2", optional = true } -shadowsocks-service = { version = "1.20.4", path = "./crates/shadowsocks-service" } +shadowsocks-service = { version = "1.21.2", path = "./crates/shadowsocks-service" } windows-service = { version = "0.7", optional = true } @@ -260,20 +260,12 @@ reqwest = { version = "0.12", features = [ "blocking", "rustls-tls", "rustls-tls-native-roots", - "deflate", - "gzip", - "brotli", - "zstd", ], default-features = false, optional = true } [target.'cfg(not(any(target_arch = "x86", target_arch = "x86_64", target_arch = "aarch64")))'.dependencies] reqwest = { version = "0.12", features = [ "blocking", "native-tls-vendored", - "deflate", - "gzip", - "brotli", - "zstd", ], optional = true } [dev-dependencies] diff --git a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/Dockerfile b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/Dockerfile index 06df73794e..fd7f1a3d35 100644 --- a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/Dockerfile +++ b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/Dockerfile @@ -46,7 +46,7 @@ COPY --from=builder /root/shadowsocks-rust/docker/docker-entrypoint.sh /usr/bin/ ENTRYPOINT [ "docker-entrypoint.sh" ] CMD [ "sslocal", "--log-without-time", "-c", "/etc/shadowsocks-rust/config.json" ] -FROM alpine:3.17 AS ssserver +FROM alpine:3.20 AS ssserver COPY --from=builder /root/shadowsocks-rust/target/release/ssserver /usr/bin/ COPY --from=builder /root/shadowsocks-rust/examples/config.json /etc/shadowsocks-rust/ diff --git a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/Cargo.toml b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/Cargo.toml index e69351366a..9b1771b3c2 100644 --- a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/Cargo.toml +++ b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "shadowsocks-service" -version = "1.20.4" +version = "1.21.2" authors = ["Shadowsocks Contributors"] description = "shadowsocks is a fast tunnel proxy that helps you bypass firewalls." repository = "https://github.com/shadowsocks/shadowsocks-rust" @@ -72,7 +72,7 @@ local-dns-relay = ["local-dns"] # Currently is only used in Android local-flow-stat = ["local"] # Enable HTTP protocol for sslocal -local-http = ["local", "hyper", "http-body-util"] +local-http = ["local", "hyper", "http", "http-body-util"] local-http-native-tls = ["local-http", "tokio-native-tls", "native-tls"] local-http-native-tls-vendored = [ "local-http-native-tls", @@ -161,11 +161,11 @@ tokio-rustls = { version = "0.26", optional = true, default-features = false, fe "tls12", "ring", ] } -rustls-native-certs = { version = "0.7", optional = true } +rustls-native-certs = { version = "0.8", optional = true } async-trait = "0.1" socket2 = { version = "0.5", features = ["all"] } -libc = "0.2.141" +libc = "~0.2.141" hyper = { version = "1.4", optional = true, features = ["full"] } http-body-util = { version = "0.1", optional = true } @@ -177,19 +177,19 @@ hickory-resolver = { version = "0.24", optional = true, features = [ ] } idna = "1.0" -ipnet = "2.9" +ipnet = "2.10" iprange = "0.6" regex = "1.4" mime = { version = "0.3", optional = true } flate2 = { version = "1.0", optional = true } -brotli = { version = "6.0", optional = true } +brotli = { version = "7.0", optional = true } zstd = { version = "0.13", optional = true } -tun2 = { version = "2.0.2", optional = true, default-features = false, features = [ +tun2 = { version = "3.1", optional = true, default-features = false, features = [ "async", ] } -etherparse = { version = "0.15", optional = true } +etherparse = { version = "0.16", optional = true } smoltcp = { version = "0.11", optional = true, default-features = false, features = [ "std", "log", @@ -203,12 +203,12 @@ smoltcp = { version = "0.11", optional = true, default-features = false, feature serde = { version = "1.0", features = ["derive"] } json5 = "0.4" -bson = { version = "2.10.0", optional = true } +bson = { version = "2.13.0", optional = true } -shadowsocks = { version = "1.20.2", path = "../shadowsocks", default-features = false } +shadowsocks = { version = "1.21.0", path = "../shadowsocks", default-features = false } # Just for the ioctl call macro -[target.'cfg(any(target_os = "macos", target_os = "ios", target_os = "freebsd"))'.dependencies] +[target.'cfg(any(target_os = "macos", target_os = "ios", target_os = "freebsd", target_os = "openbsd"))'.dependencies] nix = { version = "0.29", features = ["ioctl"] } [target.'cfg(windows)'.dependencies] diff --git a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/config.rs b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/config.rs index 5a82323ef9..4586b0c848 100644 --- a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/config.rs +++ b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/config.rs @@ -480,6 +480,7 @@ cfg_if! { /// Document: #[cfg(any( target_os = "freebsd", + target_os = "openbsd", target_os = "macos", target_os = "ios" ))] @@ -544,6 +545,30 @@ cfg_if! { const AVAILABLE_TYPES: &[&str] = &[RedirType::PacketFilter.name(), RedirType::IpFirewall.name()]; AVAILABLE_TYPES } + } else if #[cfg(target_os = "openbsd")] { + /// Default TCP transparent proxy solution on this platform + pub fn tcp_default() -> RedirType { + RedirType::PacketFilter + } + + /// Available TCP transparent proxy types + #[doc(hidden)] + pub fn tcp_available_types() -> &'static [&'static str] { + const AVAILABLE_TYPES: &[&str] = &[RedirType::PacketFilter.name()]; + AVAILABLE_TYPES + } + + /// Default UDP transparent proxy solution on this platform + pub fn udp_default() -> RedirType { + RedirType::PacketFilter + } + + /// Available UDP transparent proxy types + #[doc(hidden)] + pub const fn udp_available_types() -> &'static [&'static str] { + const AVAILABLE_TYPES: &[&str] = &[RedirType::PacketFilter.name()]; + AVAILABLE_TYPES + } } else if #[cfg(any(target_os = "macos", target_os = "ios"))] { /// Default TCP transparent proxy solution on this platform pub fn tcp_default() -> RedirType { @@ -614,6 +639,7 @@ cfg_if! { #[cfg(any( target_os = "freebsd", + target_os = "openbsd", target_os = "macos", target_os = "ios" ))] @@ -654,6 +680,7 @@ cfg_if! { #[cfg(any( target_os = "freebsd", + target_os = "openbsd", target_os = "macos", target_os = "ios", ))] diff --git a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/dns/upstream.rs b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/dns/upstream.rs index 161f5d62cb..981f22e944 100644 --- a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/dns/upstream.rs +++ b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/dns/upstream.rs @@ -61,7 +61,7 @@ pub enum DnsClient { stream: ProxyClientStream>, }, UdpRemote { - socket: MonProxySocket, + socket: MonProxySocket, ns: Address, control: UdpSocketControlData, server_windows: LruCache, diff --git a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/http/http_client.rs b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/http/http_client.rs index f304f48c04..275bf02378 100644 --- a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/http/http_client.rs +++ b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/http/http_client.rs @@ -1,6 +1,7 @@ //! HTTP Client use std::{ + borrow::Cow, collections::VecDeque, fmt::Debug, future::Future, @@ -11,6 +12,7 @@ use std::{ time::{Duration, Instant}, }; +use http::{header::InvalidHeaderValue, HeaderValue, Method as HttpMethod, Uri, Version as HttpVersion}; use hyper::{ body::{self, Body}, client::conn::{http1, http2}, @@ -43,6 +45,12 @@ pub enum HttpClientError { /// std::io::Error #[error("{0}")] Io(#[from] io::Error), + /// Errors from http + #[error("{0}")] + Http(#[from] http::Error), + /// Errors from http header + #[error("{0}")] + InvalidHeaderValue(#[from] InvalidHeaderValue), } #[derive(Clone, Debug)] @@ -133,7 +141,7 @@ where pub async fn send_request( &self, context: Arc, - req: Request, + mut req: Request, balancer: Option<&PingBalancer>, ) -> Result, HttpClientError> { let host = match host_addr(req.uri()) { @@ -141,15 +149,24 @@ where None => panic!("URI missing host: {}", req.uri()), }; + // Set Host header if it was missing in the Request + { + let headers = req.headers_mut(); + if !headers.contains_key("Host") { + let host_value = match host { + Address::DomainNameAddress(ref domain, _) => HeaderValue::from_str(domain)?, + Address::SocketAddress(ref saddr) => HeaderValue::from_str(saddr.ip().to_string().as_str())?, + }; + headers.insert("Host", host_value); + } + } + // 1. Check if there is an available client // - // FIXME: If the cached connection is closed unexpectly, this request will fail immediately. + // FIXME: If the cached connection is closed unexpectedly, this request will fail immediately. if let Some(c) = self.get_cached_connection(&host).await { trace!("HTTP client for host: {} taken from cache", host); - match self.send_request_conn(host, c, req).await { - Ok(o) => return Ok(o), - Err(err) => return Err(err.into()), - } + return self.send_request_conn(host, c, req).await; } // 2. If no. Make a new connection @@ -158,13 +175,12 @@ where None => &Scheme::HTTP, }; - let domain = req - .uri() - .host() - .unwrap() - .trim_start_matches('[') - .trim_start_matches(']'); - let c = match HttpConnection::connect(context.clone(), scheme, host.clone(), domain, balancer).await { + let domain = match host { + Address::DomainNameAddress(ref domain, _) => Cow::Borrowed(domain.as_str()), + Address::SocketAddress(ref saddr) => Cow::Owned(saddr.ip().to_string()), + }; + + let c = match HttpConnection::connect(context.clone(), scheme, host.clone(), &domain, balancer).await { Ok(c) => c, Err(err) => { error!("failed to connect to host: {}, error: {}", host, err); @@ -172,7 +188,7 @@ where } }; - self.send_request_conn(host, c, req).await.map_err(Into::into) + self.send_request_conn(host, c, req).await } async fn get_cached_connection(&self, host: &Address) -> Option> { @@ -196,7 +212,7 @@ where host: Address, mut c: HttpConnection, req: Request, - ) -> hyper::Result> { + ) -> Result, HttpClientError> { trace!("HTTP making request to host: {}, request: {:?}", host, req); let response = c.send_request(req).await?; trace!("HTTP received response from host: {}, response: {:?}", host, response); @@ -298,7 +314,7 @@ where let stream = ProxyHttpStream::connect_https(stream, domain).await?; if stream.negotiated_http2() { - // H2 connnection + // H2 connection let (send_request, connection) = match http2::Builder::new(TokioExecutor) .timer(TokioTimer) .keep_alive_interval(Duration::from_secs(15)) @@ -339,10 +355,45 @@ where } #[inline] - pub async fn send_request(&mut self, req: Request) -> hyper::Result> { + pub async fn send_request(&mut self, mut req: Request) -> Result, HttpClientError> { match self { - HttpConnection::Http1(r) => r.send_request(req).await, - HttpConnection::Http2(r) => r.send_request(req).await, + HttpConnection::Http1(r) => { + if !matches!( + req.version(), + HttpVersion::HTTP_09 | HttpVersion::HTTP_10 | HttpVersion::HTTP_11 + ) { + trace!( + "HTTP client changed Request.version to HTTP/1.1 from {:?}", + req.version() + ); + + *req.version_mut() = HttpVersion::HTTP_11; + } + + // Remove Scheme, Host part from URI + if req.method() != HttpMethod::CONNECT + && (req.uri().scheme().is_some() || req.uri().authority().is_some()) + { + let mut builder = Uri::builder(); + if let Some(path_and_query) = req.uri().path_and_query() { + builder = builder.path_and_query(path_and_query.as_str()); + } else { + builder = builder.path_and_query("/"); + } + *(req.uri_mut()) = builder.build()?; + } + + r.send_request(req).await.map_err(Into::into) + } + HttpConnection::Http2(r) => { + if !matches!(req.version(), HttpVersion::HTTP_2) { + trace!("HTTP client changed Request.version to HTTP/2 from {:?}", req.version()); + + *req.version_mut() = HttpVersion::HTTP_2; + } + + r.send_request(req).await.map_err(Into::into) + } } } diff --git a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/http/http_service.rs b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/http/http_service.rs index d45b23631f..cba174fd97 100644 --- a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/http/http_service.rs +++ b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/http/http_service.rs @@ -158,6 +158,14 @@ impl HttpService { error!("failed to make request to host: {}, error: {}", host, err); return make_internal_server_error(); } + Err(HttpClientError::Http(err)) => { + error!("failed to make request to host: {}, error: {}", host, err); + return make_bad_request(); + } + Err(HttpClientError::InvalidHeaderValue(err)) => { + error!("failed to make request to host: {}, error: {}", host, err); + return make_bad_request(); + } }; trace!("received {} <- {} {:?}", self.peer_addr, host, res); diff --git a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/http/http_stream.rs b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/http/http_stream.rs index 607e119e9f..c8875030e1 100644 --- a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/http/http_stream.rs +++ b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/http/http_stream.rs @@ -62,6 +62,7 @@ impl ProxyHttpStream { pub async fn connect_https(stream: AutoProxyClientStream, domain: &str) -> io::Result { use log::warn; use once_cell::sync::Lazy; + use rustls_native_certs::CertificateResult; use std::sync::Arc; use tokio_rustls::{ rustls::{pki_types::ServerName, ClientConfig, RootCertStore}, @@ -75,11 +76,16 @@ impl ProxyHttpStream { let mut store = RootCertStore::empty(); store.extend(webpki_roots::TLS_SERVER_ROOTS.iter().cloned()); - if let Ok(certs) = rustls_native_certs::load_native_certs() { - for cert in certs { - if let Err(err) = store.add(cert) { - warn!("failed to add cert (native), error: {}", err); - } + let CertificateResult { certs, errors, .. } = rustls_native_certs::load_native_certs(); + if !errors.is_empty() { + for error in errors { + warn!("failed to load cert (native), error: {}", error); + } + } + + for cert in certs { + if let Err(err) = store.add(cert) { + warn!("failed to add cert (native), error: {}", err); } } diff --git a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/loadbalancing/ping_balancer.rs b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/loadbalancing/ping_balancer.rs index 35e521fb65..1a84e4d67b 100644 --- a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/loadbalancing/ping_balancer.rs +++ b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/loadbalancing/ping_balancer.rs @@ -875,10 +875,8 @@ impl PingChecker { let mut headers = [httparse::EMPTY_HEADER; 1]; let mut response = httparse::Response::new(&mut headers); - if let Ok(..) = response.parse(&buf) { - if matches!(response.code, Some(204)) { - return Ok(()); - } + if response.parse(&buf).is_ok() && matches!(response.code, Some(204)) { + return Ok(()); } Err(Error::new( @@ -916,10 +914,8 @@ impl PingChecker { let mut headers = [httparse::EMPTY_HEADER; 1]; let mut response = httparse::Response::new(&mut headers); - if let Ok(..) = response.parse(&buf) { - if matches!(response.code, Some(200) | Some(204)) { - return Ok(()); - } + if response.parse(&buf).is_ok() && matches!(response.code, Some(200) | Some(204)) { + return Ok(()); } Err(Error::new( diff --git a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/loadbalancing/server_data.rs b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/loadbalancing/server_data.rs index 9f9c27d30d..86c224cffe 100644 --- a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/loadbalancing/server_data.rs +++ b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/loadbalancing/server_data.rs @@ -53,7 +53,7 @@ impl ServerScore { pub async fn push_score_fetch_statistic(&self, score: Score) -> (u32, ServerStatData) { let (updated_score, data) = { let mut stat = self.stat_data.lock().await; - (stat.push_score(score), stat.data().clone()) + (stat.push_score(score), *stat.data()) }; self.score.store(updated_score, Ordering::Release); (updated_score, data) @@ -66,7 +66,7 @@ impl ServerScore { /// Get statistic data pub async fn stat_data(&self) -> ServerStatData { - self.stat_data.lock().await.data().clone() + *self.stat_data.lock().await.data() } } diff --git a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/loadbalancing/server_stat.rs b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/loadbalancing/server_stat.rs index e417797104..a81d2e7165 100644 --- a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/loadbalancing/server_stat.rs +++ b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/loadbalancing/server_stat.rs @@ -188,7 +188,7 @@ impl ServerStat { // MAD let mut vlat_abs_diff: Vec = vlat .iter() - .map(|s| (*s as i32 - self.data.latency_median as i32).abs() as u32) + .map(|s| (*s as i32 - self.data.latency_median as i32).unsigned_abs()) .collect(); vlat_abs_diff.sort_unstable(); diff --git a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/net/udp/association.rs b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/net/udp/association.rs index 210d232131..5ca4da94c6 100644 --- a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/net/udp/association.rs +++ b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/net/udp/association.rs @@ -217,7 +217,7 @@ where peer_addr: SocketAddr, bypassed_ipv4_socket: Option, bypassed_ipv6_socket: Option, - proxied_socket: Option, + proxied_socket: Option>, keepalive_tx: mpsc::Sender, keepalive_flag: bool, balancer: PingBalancer, @@ -409,7 +409,7 @@ where #[inline] async fn receive_from_proxied_opt( - socket: &Option, + socket: &Option>, buf: &mut Vec, ) -> io::Result<(usize, Address, Option)> { match *socket { diff --git a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/redir/sys/mod.rs b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/redir/sys/mod.rs index 7ad9169df3..64a290d1b8 100644 --- a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/redir/sys/mod.rs +++ b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/redir/sys/mod.rs @@ -21,7 +21,7 @@ where let fd = socket.as_raw_fd(); let sock = unsafe { Socket::from_raw_fd(fd) }; let result = sock.set_only_v6(ipv6_only); - sock.into_raw_fd(); + let _ = sock.into_raw_fd(); result } @@ -36,6 +36,6 @@ where let handle = socket.as_raw_socket(); let sock = unsafe { Socket::from_raw_socket(handle) }; let result = sock.set_only_v6(ipv6_only); - sock.into_raw_socket(); + let _ = sock.into_raw_socket(); result } diff --git a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/redir/sys/unix/mod.rs b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/redir/sys/unix/mod.rs index 2c910bf870..cd0eeec7c0 100644 --- a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/redir/sys/unix/mod.rs +++ b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/redir/sys/unix/mod.rs @@ -20,5 +20,10 @@ cfg_if! { #[allow(dead_code, non_upper_case_globals, non_snake_case, non_camel_case_types)] #[allow(clippy::useless_transmute, clippy::too_many_arguments, clippy::unnecessary_cast)] mod pfvar; + } else if #[cfg(target_os = "openbsd")] { + #[path = "pfvar_bindgen_openbsd.rs"] + #[allow(dead_code, non_upper_case_globals, non_snake_case, non_camel_case_types)] + #[allow(clippy::useless_transmute, clippy::too_many_arguments, clippy::unnecessary_cast)] + mod pfvar; } } diff --git a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/redir/sys/unix/pfvar_bindgen_openbsd.rs b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/redir/sys/unix/pfvar_bindgen_openbsd.rs new file mode 100644 index 0000000000..28e5d39059 --- /dev/null +++ b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/redir/sys/unix/pfvar_bindgen_openbsd.rs @@ -0,0 +1,16756 @@ +/* automatically generated by rust-bindgen 0.69.4 */ + +pub const __ISO_C_VISIBLE: u32 = 2011; +pub const __XPG_VISIBLE: u32 = 700; +pub const __POSIX_VISIBLE: u32 = 200809; +pub const __BSD_VISIBLE: u32 = 1; +pub const _STACKALIGNBYTES: u32 = 15; +pub const _MAX_PAGE_SHIFT: u32 = 12; +pub const INT8_MIN: i32 = -128; +pub const INT16_MIN: i32 = -32768; +pub const INT32_MIN: i32 = -2147483648; +pub const INT64_MIN: i64 = -9223372036854775808; +pub const INT8_MAX: u32 = 127; +pub const INT16_MAX: u32 = 32767; +pub const INT32_MAX: u32 = 2147483647; +pub const INT64_MAX: u64 = 9223372036854775807; +pub const UINT8_MAX: u32 = 255; +pub const UINT16_MAX: u32 = 65535; +pub const UINT32_MAX: u32 = 4294967295; +pub const UINT64_MAX: i32 = -1; +pub const INT_LEAST8_MIN: i32 = -128; +pub const INT_LEAST16_MIN: i32 = -32768; +pub const INT_LEAST32_MIN: i32 = -2147483648; +pub const INT_LEAST64_MIN: i64 = -9223372036854775808; +pub const INT_LEAST8_MAX: u32 = 127; +pub const INT_LEAST16_MAX: u32 = 32767; +pub const INT_LEAST32_MAX: u32 = 2147483647; +pub const INT_LEAST64_MAX: u64 = 9223372036854775807; +pub const UINT_LEAST8_MAX: u32 = 255; +pub const UINT_LEAST16_MAX: u32 = 65535; +pub const UINT_LEAST32_MAX: u32 = 4294967295; +pub const UINT_LEAST64_MAX: i32 = -1; +pub const INTPTR_MIN: i64 = -9223372036854775808; +pub const INTPTR_MAX: u64 = 9223372036854775807; +pub const UINTPTR_MAX: i32 = -1; +pub const INTMAX_MIN: i64 = -9223372036854775808; +pub const INTMAX_MAX: u64 = 9223372036854775807; +pub const UINTMAX_MAX: i32 = -1; +pub const PTRDIFF_MIN: i64 = -9223372036854775808; +pub const PTRDIFF_MAX: u64 = 9223372036854775807; +pub const SIG_ATOMIC_MIN: i32 = -2147483648; +pub const SIG_ATOMIC_MAX: u32 = 2147483647; +pub const SIZE_MAX: i32 = -1; +pub const WCHAR_MIN: i32 = -2147483648; +pub const WCHAR_MAX: u32 = 2147483647; +pub const WINT_MIN: i32 = -2147483648; +pub const WINT_MAX: u32 = 2147483647; +pub const UIO_MAXIOV: u32 = 1024; +pub const _LITTLE_ENDIAN: u32 = 1234; +pub const _BIG_ENDIAN: u32 = 4321; +pub const _PDP_ENDIAN: u32 = 3412; +pub const _QUAD_HIGHWORD: u32 = 1; +pub const _QUAD_LOWWORD: u32 = 0; +pub const LITTLE_ENDIAN: u32 = 1234; +pub const BIG_ENDIAN: u32 = 4321; +pub const PDP_ENDIAN: u32 = 3412; +pub const SOCK_STREAM: u32 = 1; +pub const SOCK_DGRAM: u32 = 2; +pub const SOCK_RAW: u32 = 3; +pub const SOCK_RDM: u32 = 4; +pub const SOCK_SEQPACKET: u32 = 5; +pub const SOCK_CLOEXEC: u32 = 32768; +pub const SOCK_NONBLOCK: u32 = 16384; +pub const SOCK_DNS: u32 = 4096; +pub const SO_DEBUG: u32 = 1; +pub const SO_ACCEPTCONN: u32 = 2; +pub const SO_REUSEADDR: u32 = 4; +pub const SO_KEEPALIVE: u32 = 8; +pub const SO_DONTROUTE: u32 = 16; +pub const SO_BROADCAST: u32 = 32; +pub const SO_USELOOPBACK: u32 = 64; +pub const SO_LINGER: u32 = 128; +pub const SO_OOBINLINE: u32 = 256; +pub const SO_REUSEPORT: u32 = 512; +pub const SO_TIMESTAMP: u32 = 2048; +pub const SO_BINDANY: u32 = 4096; +pub const SO_ZEROIZE: u32 = 8192; +pub const SO_SNDBUF: u32 = 4097; +pub const SO_RCVBUF: u32 = 4098; +pub const SO_SNDLOWAT: u32 = 4099; +pub const SO_RCVLOWAT: u32 = 4100; +pub const SO_SNDTIMEO: u32 = 4101; +pub const SO_RCVTIMEO: u32 = 4102; +pub const SO_ERROR: u32 = 4103; +pub const SO_TYPE: u32 = 4104; +pub const SO_NETPROC: u32 = 4128; +pub const SO_RTABLE: u32 = 4129; +pub const SO_PEERCRED: u32 = 4130; +pub const SO_SPLICE: u32 = 4131; +pub const SO_DOMAIN: u32 = 4132; +pub const SO_PROTOCOL: u32 = 4133; +pub const RT_TABLEID_MAX: u32 = 255; +pub const RT_TABLEID_BITS: u32 = 8; +pub const RT_TABLEID_MASK: u32 = 255; +pub const SOL_SOCKET: u32 = 65535; +pub const AF_UNSPEC: u32 = 0; +pub const AF_UNIX: u32 = 1; +pub const AF_LOCAL: u32 = 1; +pub const AF_INET: u32 = 2; +pub const AF_IMPLINK: u32 = 3; +pub const AF_PUP: u32 = 4; +pub const AF_CHAOS: u32 = 5; +pub const AF_NS: u32 = 6; +pub const AF_ISO: u32 = 7; +pub const AF_OSI: u32 = 7; +pub const AF_ECMA: u32 = 8; +pub const AF_DATAKIT: u32 = 9; +pub const AF_CCITT: u32 = 10; +pub const AF_SNA: u32 = 11; +pub const AF_DECnet: u32 = 12; +pub const AF_DLI: u32 = 13; +pub const AF_LAT: u32 = 14; +pub const AF_HYLINK: u32 = 15; +pub const AF_APPLETALK: u32 = 16; +pub const AF_ROUTE: u32 = 17; +pub const AF_LINK: u32 = 18; +pub const pseudo_AF_XTP: u32 = 19; +pub const AF_COIP: u32 = 20; +pub const AF_CNT: u32 = 21; +pub const pseudo_AF_RTIP: u32 = 22; +pub const AF_IPX: u32 = 23; +pub const AF_INET6: u32 = 24; +pub const pseudo_AF_PIP: u32 = 25; +pub const AF_ISDN: u32 = 26; +pub const AF_E164: u32 = 26; +pub const AF_NATM: u32 = 27; +pub const AF_ENCAP: u32 = 28; +pub const AF_SIP: u32 = 29; +pub const AF_KEY: u32 = 30; +pub const pseudo_AF_HDRCMPLT: u32 = 31; +pub const AF_BLUETOOTH: u32 = 32; +pub const AF_MPLS: u32 = 33; +pub const pseudo_AF_PFLOW: u32 = 34; +pub const pseudo_AF_PIPEX: u32 = 35; +pub const AF_MAX: u32 = 36; +pub const PF_UNSPEC: u32 = 0; +pub const PF_LOCAL: u32 = 1; +pub const PF_UNIX: u32 = 1; +pub const PF_INET: u32 = 2; +pub const PF_IMPLINK: u32 = 3; +pub const PF_PUP: u32 = 4; +pub const PF_CHAOS: u32 = 5; +pub const PF_NS: u32 = 6; +pub const PF_ISO: u32 = 7; +pub const PF_OSI: u32 = 7; +pub const PF_ECMA: u32 = 8; +pub const PF_DATAKIT: u32 = 9; +pub const PF_CCITT: u32 = 10; +pub const PF_SNA: u32 = 11; +pub const PF_DECnet: u32 = 12; +pub const PF_DLI: u32 = 13; +pub const PF_LAT: u32 = 14; +pub const PF_HYLINK: u32 = 15; +pub const PF_APPLETALK: u32 = 16; +pub const PF_ROUTE: u32 = 17; +pub const PF_LINK: u32 = 18; +pub const PF_XTP: u32 = 19; +pub const PF_COIP: u32 = 20; +pub const PF_CNT: u32 = 21; +pub const PF_IPX: u32 = 23; +pub const PF_INET6: u32 = 24; +pub const PF_RTIP: u32 = 22; +pub const PF_PIP: u32 = 25; +pub const PF_ISDN: u32 = 26; +pub const PF_NATM: u32 = 27; +pub const PF_ENCAP: u32 = 28; +pub const PF_SIP: u32 = 29; +pub const PF_KEY: u32 = 30; +pub const PF_BPF: u32 = 31; +pub const PF_BLUETOOTH: u32 = 32; +pub const PF_MPLS: u32 = 33; +pub const PF_PFLOW: u32 = 34; +pub const PF_PIPEX: u32 = 35; +pub const PF_MAX: u32 = 36; +pub const SHUT_RD: u32 = 0; +pub const SHUT_WR: u32 = 1; +pub const SHUT_RDWR: u32 = 2; +pub const NET_MAXID: u32 = 36; +pub const NET_RT_DUMP: u32 = 1; +pub const NET_RT_FLAGS: u32 = 2; +pub const NET_RT_IFLIST: u32 = 3; +pub const NET_RT_STATS: u32 = 4; +pub const NET_RT_TABLE: u32 = 5; +pub const NET_RT_IFNAMES: u32 = 6; +pub const NET_RT_SOURCE: u32 = 7; +pub const NET_RT_MAXID: u32 = 8; +pub const NET_UNIX_INFLIGHT: u32 = 6; +pub const NET_UNIX_DEFERRED: u32 = 7; +pub const NET_UNIX_MAXID: u32 = 8; +pub const UNPCTL_RECVSPACE: u32 = 1; +pub const UNPCTL_SENDSPACE: u32 = 2; +pub const NET_UNIX_PROTO_MAXID: u32 = 3; +pub const NET_LINK_IFRXQ: u32 = 1; +pub const NET_LINK_MAXID: u32 = 2; +pub const NET_LINK_IFRXQ_PRESSURE_RETURN: u32 = 1; +pub const NET_LINK_IFRXQ_PRESSURE_DROP: u32 = 2; +pub const NET_LINK_IFRXQ_MAXID: u32 = 3; +pub const NET_KEY_SADB_DUMP: u32 = 1; +pub const NET_KEY_SPD_DUMP: u32 = 2; +pub const NET_KEY_MAXID: u32 = 3; +pub const NET_BPF_BUFSIZE: u32 = 1; +pub const NET_BPF_MAXBUFSIZE: u32 = 2; +pub const NET_BPF_MAXID: u32 = 3; +pub const NET_PFLOW_STATS: u32 = 1; +pub const NET_PFLOW_MAXID: u32 = 2; +pub const SOMAXCONN: u32 = 128; +pub const MSG_OOB: u32 = 1; +pub const MSG_PEEK: u32 = 2; +pub const MSG_DONTROUTE: u32 = 4; +pub const MSG_EOR: u32 = 8; +pub const MSG_TRUNC: u32 = 16; +pub const MSG_CTRUNC: u32 = 32; +pub const MSG_WAITALL: u32 = 64; +pub const MSG_DONTWAIT: u32 = 128; +pub const MSG_BCAST: u32 = 256; +pub const MSG_MCAST: u32 = 512; +pub const MSG_NOSIGNAL: u32 = 1024; +pub const MSG_CMSG_CLOEXEC: u32 = 2048; +pub const MSG_WAITFORONE: u32 = 4096; +pub const SCM_RIGHTS: u32 = 1; +pub const SCM_TIMESTAMP: u32 = 4; +pub const IF_NAMESIZE: u32 = 16; +pub const FD_SETSIZE: u32 = 1024; +pub const __NBBY: u32 = 8; +pub const NBBY: u32 = 8; +pub const DST_NONE: u32 = 0; +pub const DST_USA: u32 = 1; +pub const DST_AUST: u32 = 2; +pub const DST_WET: u32 = 3; +pub const DST_MET: u32 = 4; +pub const DST_EET: u32 = 5; +pub const DST_CAN: u32 = 6; +pub const ITIMER_REAL: u32 = 0; +pub const ITIMER_VIRTUAL: u32 = 1; +pub const ITIMER_PROF: u32 = 2; +pub const CLOCKS_PER_SEC: u32 = 100; +pub const CLOCK_REALTIME: u32 = 0; +pub const CLOCK_PROCESS_CPUTIME_ID: u32 = 2; +pub const CLOCK_MONOTONIC: u32 = 3; +pub const CLOCK_THREAD_CPUTIME_ID: u32 = 4; +pub const CLOCK_UPTIME: u32 = 5; +pub const CLOCK_BOOTTIME: u32 = 6; +pub const TIMER_RELTIME: u32 = 0; +pub const TIMER_ABSTIME: u32 = 1; +pub const CLK_TCK: u32 = 100; +pub const TIME_UTC: u32 = 1; +pub const MCLPOOLS: u32 = 8; +pub const IFQ_NQUEUES: u32 = 8; +pub const IFQ_MINPRIO: u32 = 0; +pub const IFQ_MAXPRIO: u32 = 7; +pub const IFQ_DEFPRIO: u32 = 3; +pub const LINK_STATE_UNKNOWN: u32 = 0; +pub const LINK_STATE_INVALID: u32 = 1; +pub const LINK_STATE_DOWN: u32 = 2; +pub const LINK_STATE_KALIVE_DOWN: u32 = 3; +pub const LINK_STATE_UP: u32 = 4; +pub const LINK_STATE_HALF_DUPLEX: u32 = 5; +pub const LINK_STATE_FULL_DUPLEX: u32 = 6; +pub const IFNAMSIZ: u32 = 16; +pub const IFDESCRSIZE: u32 = 64; +pub const IFF_UP: u32 = 1; +pub const IFF_BROADCAST: u32 = 2; +pub const IFF_DEBUG: u32 = 4; +pub const IFF_LOOPBACK: u32 = 8; +pub const IFF_POINTOPOINT: u32 = 16; +pub const IFF_STATICARP: u32 = 32; +pub const IFF_RUNNING: u32 = 64; +pub const IFF_NOARP: u32 = 128; +pub const IFF_PROMISC: u32 = 256; +pub const IFF_ALLMULTI: u32 = 512; +pub const IFF_OACTIVE: u32 = 1024; +pub const IFF_SIMPLEX: u32 = 2048; +pub const IFF_LINK0: u32 = 4096; +pub const IFF_LINK1: u32 = 8192; +pub const IFF_LINK2: u32 = 16384; +pub const IFF_MULTICAST: u32 = 32768; +pub const IFF_CANTCHANGE: u32 = 36434; +pub const IFXF_MPSAFE: u32 = 1; +pub const IFXF_CLONED: u32 = 2; +pub const IFXF_AUTOCONF6TEMP: u32 = 4; +pub const IFXF_MPLS: u32 = 8; +pub const IFXF_WOL: u32 = 16; +pub const IFXF_AUTOCONF6: u32 = 32; +pub const IFXF_INET6_NOSOII: u32 = 64; +pub const IFXF_AUTOCONF4: u32 = 128; +pub const IFXF_MONITOR: u32 = 256; +pub const IFXF_LRO: u32 = 512; +pub const IFXF_CANTCHANGE: u32 = 3; +pub const IFCAP_CSUM_IPv4: u32 = 1; +pub const IFCAP_CSUM_TCPv4: u32 = 2; +pub const IFCAP_CSUM_UDPv4: u32 = 4; +pub const IFCAP_VLAN_MTU: u32 = 16; +pub const IFCAP_VLAN_HWTAGGING: u32 = 32; +pub const IFCAP_CSUM_TCPv6: u32 = 128; +pub const IFCAP_CSUM_UDPv6: u32 = 256; +pub const IFCAP_TSOv4: u32 = 4096; +pub const IFCAP_TSOv6: u32 = 8192; +pub const IFCAP_LRO: u32 = 16384; +pub const IFCAP_WOL: u32 = 32768; +pub const IFCAP_CSUM_MASK: u32 = 391; +pub const IFQCTL_LEN: u32 = 1; +pub const IFQCTL_MAXLEN: u32 = 2; +pub const IFQCTL_DROPS: u32 = 3; +pub const IFQCTL_CONGESTION: u32 = 4; +pub const IFQCTL_MAXID: u32 = 5; +pub const IFAN_ARRIVAL: u32 = 0; +pub const IFAN_DEPARTURE: u32 = 1; +pub const IFG_ALL: &[u8; 4] = b"all\0"; +pub const IFG_EGRESS: &[u8; 7] = b"egress\0"; +pub const IF_HDRPRIO_MIN: u32 = 0; +pub const IF_HDRPRIO_MAX: u32 = 7; +pub const IF_HDRPRIO_PACKET: i32 = -1; +pub const IF_HDRPRIO_PAYLOAD: i32 = -2; +pub const IF_HDRPRIO_OUTER: i32 = -3; +pub const IF_PWE3_ETHERNET: u32 = 1; +pub const IF_PWE3_IP: u32 = 2; +pub const IFLR_PREFIX: u32 = 32768; +pub const IFSFF_ADDR_EEPROM: u32 = 160; +pub const IFSFF_ADDR_DDM: u32 = 162; +pub const IFSFF_DATA_LEN: u32 = 256; +pub const ARPHRD_ETHER: u32 = 1; +pub const ARPHRD_IEEE802: u32 = 6; +pub const ARPHRD_FRELAY: u32 = 15; +pub const ARPHRD_IEEE1394: u32 = 24; +pub const ARPOP_REQUEST: u32 = 1; +pub const ARPOP_REPLY: u32 = 2; +pub const ARPOP_REVREQUEST: u32 = 3; +pub const ARPOP_REVREPLY: u32 = 4; +pub const ARPOP_INVREQUEST: u32 = 8; +pub const ARPOP_INVREPLY: u32 = 9; +pub const ATF_INUSE: u32 = 1; +pub const ATF_COM: u32 = 2; +pub const ATF_PERM: u32 = 4; +pub const ATF_PUBL: u32 = 8; +pub const ATF_USETRAILERS: u32 = 16; +pub const SPLAY_NEGINF: i32 = -1; +pub const SPLAY_INF: u32 = 1; +pub const RB_BLACK: u32 = 0; +pub const RB_RED: u32 = 1; +pub const RB_NEGINF: i32 = -1; +pub const RB_INF: u32 = 1; +pub const LO_CLASSFLAGS: u32 = 65535; +pub const LO_INITIALIZED: u32 = 65536; +pub const LO_WITNESS: u32 = 131072; +pub const LO_QUIET: u32 = 262144; +pub const LO_RECURSABLE: u32 = 524288; +pub const LO_SLEEPABLE: u32 = 1048576; +pub const LO_UPGRADABLE: u32 = 2097152; +pub const LO_DUPOK: u32 = 4194304; +pub const LO_IS_VNODE: u32 = 8388608; +pub const LO_CLASSMASK: u32 = 251658240; +pub const LO_NOPROFILE: u32 = 268435456; +pub const LO_NEW: u32 = 536870912; +pub const LO_CLASSSHIFT: u32 = 24; +pub const RWL_DUPOK: u32 = 1; +pub const RWL_NOWITNESS: u32 = 2; +pub const RWL_IS_VNODE: u32 = 4; +pub const RWLOCK_WAIT: u32 = 1; +pub const RWLOCK_WRWANT: u32 = 2; +pub const RWLOCK_WRLOCK: u32 = 4; +pub const RWLOCK_MASK: u32 = 7; +pub const RWLOCK_READER_SHIFT: u32 = 3; +pub const RWLOCK_READ_INCR: u32 = 8; +pub const RW_WRITE: u32 = 1; +pub const RW_READ: u32 = 2; +pub const RW_DOWNGRADE: u32 = 4; +pub const RW_OPMASK: u32 = 7; +pub const RW_INTR: u32 = 16; +pub const RW_SLEEPFAIL: u32 = 32; +pub const RW_NOSLEEP: u32 = 64; +pub const RW_RECURSEFAIL: u32 = 128; +pub const RW_DUPOK: u32 = 256; +pub const RW_WRITE_OTHER: u32 = 256; +pub const ARG_MAX: u32 = 524288; +pub const CHILD_MAX: u32 = 80; +pub const LINK_MAX: u32 = 32767; +pub const MAX_CANON: u32 = 255; +pub const MAX_INPUT: u32 = 255; +pub const NAME_MAX: u32 = 255; +pub const NGROUPS_MAX: u32 = 16; +pub const OPEN_MAX: u32 = 64; +pub const PATH_MAX: u32 = 1024; +pub const PIPE_BUF: u32 = 512; +pub const SYMLINK_MAX: u32 = 1024; +pub const SYMLOOP_MAX: u32 = 32; +pub const BC_DIM_MAX: u32 = 65535; +pub const COLL_WEIGHTS_MAX: u32 = 2; +pub const EXPR_NEST_MAX: u32 = 32; +pub const LINE_MAX: u32 = 2048; +pub const RE_DUP_MAX: u32 = 255; +pub const IOV_MAX: u32 = 1024; +pub const NZERO: u32 = 20; +pub const TTY_NAME_MAX: u32 = 260; +pub const LOGIN_NAME_MAX: u32 = 32; +pub const HOST_NAME_MAX: u32 = 255; +pub const _MAXCOMLEN: u32 = 24; +pub const TIMEOUT_PROC: u32 = 1; +pub const TIMEOUT_ONQUEUE: u32 = 2; +pub const TIMEOUT_INITIALIZED: u32 = 4; +pub const TIMEOUT_TRIGGERED: u32 = 8; +pub const TIMEOUT_MPSAFE: u32 = 16; +pub const IPPROTO_IP: u32 = 0; +pub const IPPROTO_HOPOPTS: u32 = 0; +pub const IPPROTO_ICMP: u32 = 1; +pub const IPPROTO_IGMP: u32 = 2; +pub const IPPROTO_GGP: u32 = 3; +pub const IPPROTO_IPIP: u32 = 4; +pub const IPPROTO_IPV4: u32 = 4; +pub const IPPROTO_TCP: u32 = 6; +pub const IPPROTO_EGP: u32 = 8; +pub const IPPROTO_PUP: u32 = 12; +pub const IPPROTO_UDP: u32 = 17; +pub const IPPROTO_IDP: u32 = 22; +pub const IPPROTO_TP: u32 = 29; +pub const IPPROTO_IPV6: u32 = 41; +pub const IPPROTO_ROUTING: u32 = 43; +pub const IPPROTO_FRAGMENT: u32 = 44; +pub const IPPROTO_RSVP: u32 = 46; +pub const IPPROTO_GRE: u32 = 47; +pub const IPPROTO_ESP: u32 = 50; +pub const IPPROTO_AH: u32 = 51; +pub const IPPROTO_MOBILE: u32 = 55; +pub const IPPROTO_ICMPV6: u32 = 58; +pub const IPPROTO_NONE: u32 = 59; +pub const IPPROTO_DSTOPTS: u32 = 60; +pub const IPPROTO_EON: u32 = 80; +pub const IPPROTO_ETHERIP: u32 = 97; +pub const IPPROTO_ENCAP: u32 = 98; +pub const IPPROTO_PIM: u32 = 103; +pub const IPPROTO_IPCOMP: u32 = 108; +pub const IPPROTO_CARP: u32 = 112; +pub const IPPROTO_SCTP: u32 = 132; +pub const IPPROTO_UDPLITE: u32 = 136; +pub const IPPROTO_MPLS: u32 = 137; +pub const IPPROTO_PFSYNC: u32 = 240; +pub const IPPROTO_RAW: u32 = 255; +pub const IPPROTO_MAX: u32 = 256; +pub const IPPROTO_DIVERT: u32 = 258; +pub const IPPORT_RESERVED: u32 = 1024; +pub const IPPORT_USERRESERVED: u32 = 49151; +pub const IPPORT_HIFIRSTAUTO: u32 = 49152; +pub const IPPORT_HILASTAUTO: u32 = 65535; +pub const IPPROTO_DONE: u32 = 257; +pub const IN_CLASSA_NSHIFT: u32 = 24; +pub const IN_CLASSA_MAX: u32 = 128; +pub const IN_CLASSB_NSHIFT: u32 = 16; +pub const IN_CLASSB_MAX: u32 = 65536; +pub const IN_CLASSC_NSHIFT: u32 = 8; +pub const IN_CLASSD_NSHIFT: u32 = 28; +pub const IN_RFC3021_NSHIFT: u32 = 31; +pub const IN_LOOPBACKNET: u32 = 127; +pub const IP_OPTIONS: u32 = 1; +pub const IP_HDRINCL: u32 = 2; +pub const IP_TOS: u32 = 3; +pub const IP_TTL: u32 = 4; +pub const IP_RECVOPTS: u32 = 5; +pub const IP_RECVRETOPTS: u32 = 6; +pub const IP_RECVDSTADDR: u32 = 7; +pub const IP_RETOPTS: u32 = 8; +pub const IP_MULTICAST_IF: u32 = 9; +pub const IP_MULTICAST_TTL: u32 = 10; +pub const IP_MULTICAST_LOOP: u32 = 11; +pub const IP_ADD_MEMBERSHIP: u32 = 12; +pub const IP_DROP_MEMBERSHIP: u32 = 13; +pub const IP_PORTRANGE: u32 = 19; +pub const IP_AUTH_LEVEL: u32 = 20; +pub const IP_ESP_TRANS_LEVEL: u32 = 21; +pub const IP_ESP_NETWORK_LEVEL: u32 = 22; +pub const IP_IPSEC_LOCAL_ID: u32 = 23; +pub const IP_IPSEC_REMOTE_ID: u32 = 24; +pub const IP_IPSEC_LOCAL_CRED: u32 = 25; +pub const IP_IPSEC_REMOTE_CRED: u32 = 26; +pub const IP_IPSEC_LOCAL_AUTH: u32 = 27; +pub const IP_IPSEC_REMOTE_AUTH: u32 = 28; +pub const IP_IPCOMP_LEVEL: u32 = 29; +pub const IP_RECVIF: u32 = 30; +pub const IP_RECVTTL: u32 = 31; +pub const IP_MINTTL: u32 = 32; +pub const IP_RECVDSTPORT: u32 = 33; +pub const IP_PIPEX: u32 = 34; +pub const IP_RECVRTABLE: u32 = 35; +pub const IP_IPSECFLOWINFO: u32 = 36; +pub const IP_IPDEFTTL: u32 = 37; +pub const IP_SENDSRCADDR: u32 = 7; +pub const IP_RTABLE: u32 = 4129; +pub const IPSEC_LEVEL_BYPASS: u32 = 0; +pub const IPSEC_LEVEL_NONE: u32 = 0; +pub const IPSEC_LEVEL_AVAIL: u32 = 1; +pub const IPSEC_LEVEL_USE: u32 = 2; +pub const IPSEC_LEVEL_REQUIRE: u32 = 3; +pub const IPSEC_LEVEL_UNIQUE: u32 = 4; +pub const IPSEC_LEVEL_DEFAULT: u32 = 1; +pub const IPSEC_AUTH_LEVEL_DEFAULT: u32 = 1; +pub const IPSEC_ESP_TRANS_LEVEL_DEFAULT: u32 = 1; +pub const IPSEC_ESP_NETWORK_LEVEL_DEFAULT: u32 = 1; +pub const IPSEC_IPCOMP_LEVEL_DEFAULT: u32 = 1; +pub const IP_DEFAULT_MULTICAST_TTL: u32 = 1; +pub const IP_DEFAULT_MULTICAST_LOOP: u32 = 1; +pub const IP_MIN_MEMBERSHIPS: u32 = 15; +pub const IP_MAX_MEMBERSHIPS: u32 = 4095; +pub const IP_PORTRANGE_DEFAULT: u32 = 0; +pub const IP_PORTRANGE_HIGH: u32 = 1; +pub const IP_PORTRANGE_LOW: u32 = 2; +pub const INET_ADDRSTRLEN: u32 = 16; +pub const IPPROTO_MAXID: u32 = 259; +pub const IPCTL_FORWARDING: u32 = 1; +pub const IPCTL_SENDREDIRECTS: u32 = 2; +pub const IPCTL_DEFTTL: u32 = 3; +pub const IPCTL_SOURCEROUTE: u32 = 5; +pub const IPCTL_DIRECTEDBCAST: u32 = 6; +pub const IPCTL_IPPORT_FIRSTAUTO: u32 = 7; +pub const IPCTL_IPPORT_LASTAUTO: u32 = 8; +pub const IPCTL_IPPORT_HIFIRSTAUTO: u32 = 9; +pub const IPCTL_IPPORT_HILASTAUTO: u32 = 10; +pub const IPCTL_IPPORT_MAXQUEUE: u32 = 11; +pub const IPCTL_ENCDEBUG: u32 = 12; +pub const IPCTL_IPSEC_STATS: u32 = 13; +pub const IPCTL_IPSEC_EXPIRE_ACQUIRE: u32 = 14; +pub const IPCTL_IPSEC_EMBRYONIC_SA_TIMEOUT: u32 = 15; +pub const IPCTL_IPSEC_REQUIRE_PFS: u32 = 16; +pub const IPCTL_IPSEC_SOFT_ALLOCATIONS: u32 = 17; +pub const IPCTL_IPSEC_ALLOCATIONS: u32 = 18; +pub const IPCTL_IPSEC_SOFT_BYTES: u32 = 19; +pub const IPCTL_IPSEC_BYTES: u32 = 20; +pub const IPCTL_IPSEC_TIMEOUT: u32 = 21; +pub const IPCTL_IPSEC_SOFT_TIMEOUT: u32 = 22; +pub const IPCTL_IPSEC_SOFT_FIRSTUSE: u32 = 23; +pub const IPCTL_IPSEC_FIRSTUSE: u32 = 24; +pub const IPCTL_IPSEC_ENC_ALGORITHM: u32 = 25; +pub const IPCTL_IPSEC_AUTH_ALGORITHM: u32 = 26; +pub const IPCTL_MTUDISC: u32 = 27; +pub const IPCTL_MTUDISCTIMEOUT: u32 = 28; +pub const IPCTL_IPSEC_IPCOMP_ALGORITHM: u32 = 29; +pub const IPCTL_IFQUEUE: u32 = 30; +pub const IPCTL_MFORWARDING: u32 = 31; +pub const IPCTL_MULTIPATH: u32 = 32; +pub const IPCTL_STATS: u32 = 33; +pub const IPCTL_MRTPROTO: u32 = 34; +pub const IPCTL_MRTSTATS: u32 = 35; +pub const IPCTL_ARPQUEUED: u32 = 36; +pub const IPCTL_MRTMFC: u32 = 37; +pub const IPCTL_MRTVIF: u32 = 38; +pub const IPCTL_ARPTIMEOUT: u32 = 39; +pub const IPCTL_ARPDOWN: u32 = 40; +pub const IPCTL_ARPQUEUE: u32 = 41; +pub const IPCTL_MAXID: u32 = 42; +pub const INET6_ADDRSTRLEN: u32 = 46; +pub const __IPV6_ADDR_SCOPE_NODELOCAL: u32 = 1; +pub const __IPV6_ADDR_SCOPE_INTFACELOCAL: u32 = 1; +pub const __IPV6_ADDR_SCOPE_LINKLOCAL: u32 = 2; +pub const __IPV6_ADDR_SCOPE_SITELOCAL: u32 = 5; +pub const __IPV6_ADDR_SCOPE_ORGLOCAL: u32 = 8; +pub const __IPV6_ADDR_SCOPE_GLOBAL: u32 = 14; +pub const IPV6_UNICAST_HOPS: u32 = 4; +pub const IPV6_MULTICAST_IF: u32 = 9; +pub const IPV6_MULTICAST_HOPS: u32 = 10; +pub const IPV6_MULTICAST_LOOP: u32 = 11; +pub const IPV6_JOIN_GROUP: u32 = 12; +pub const IPV6_LEAVE_GROUP: u32 = 13; +pub const IPV6_PORTRANGE: u32 = 14; +pub const ICMP6_FILTER: u32 = 18; +pub const IPV6_CHECKSUM: u32 = 26; +pub const IPV6_V6ONLY: u32 = 27; +pub const IPV6_RTHDRDSTOPTS: u32 = 35; +pub const IPV6_RECVPKTINFO: u32 = 36; +pub const IPV6_RECVHOPLIMIT: u32 = 37; +pub const IPV6_RECVRTHDR: u32 = 38; +pub const IPV6_RECVHOPOPTS: u32 = 39; +pub const IPV6_RECVDSTOPTS: u32 = 40; +pub const IPV6_USE_MIN_MTU: u32 = 42; +pub const IPV6_RECVPATHMTU: u32 = 43; +pub const IPV6_PATHMTU: u32 = 44; +pub const IPV6_PKTINFO: u32 = 46; +pub const IPV6_HOPLIMIT: u32 = 47; +pub const IPV6_NEXTHOP: u32 = 48; +pub const IPV6_HOPOPTS: u32 = 49; +pub const IPV6_DSTOPTS: u32 = 50; +pub const IPV6_RTHDR: u32 = 51; +pub const IPV6_AUTH_LEVEL: u32 = 53; +pub const IPV6_ESP_TRANS_LEVEL: u32 = 54; +pub const IPV6_ESP_NETWORK_LEVEL: u32 = 55; +pub const IPSEC6_OUTSA: u32 = 56; +pub const IPV6_RECVTCLASS: u32 = 57; +pub const IPV6_AUTOFLOWLABEL: u32 = 59; +pub const IPV6_IPCOMP_LEVEL: u32 = 60; +pub const IPV6_TCLASS: u32 = 61; +pub const IPV6_DONTFRAG: u32 = 62; +pub const IPV6_PIPEX: u32 = 63; +pub const IPV6_RECVDSTPORT: u32 = 64; +pub const IPV6_MINHOPCOUNT: u32 = 65; +pub const IPV6_RTABLE: u32 = 4129; +pub const IPV6_RTHDR_LOOSE: u32 = 0; +pub const IPV6_RTHDR_TYPE_0: u32 = 0; +pub const IPV6_DEFAULT_MULTICAST_HOPS: u32 = 1; +pub const IPV6_DEFAULT_MULTICAST_LOOP: u32 = 1; +pub const IPV6_PORTRANGE_DEFAULT: u32 = 0; +pub const IPV6_PORTRANGE_HIGH: u32 = 1; +pub const IPV6_PORTRANGE_LOW: u32 = 2; +pub const IPV6PROTO_MAXID: u32 = 259; +pub const IPV6CTL_FORWARDING: u32 = 1; +pub const IPV6CTL_SENDREDIRECTS: u32 = 2; +pub const IPV6CTL_DEFHLIM: u32 = 3; +pub const IPV6CTL_FORWSRCRT: u32 = 5; +pub const IPV6CTL_STATS: u32 = 6; +pub const IPV6CTL_MRTSTATS: u32 = 7; +pub const IPV6CTL_MRTPROTO: u32 = 8; +pub const IPV6CTL_MAXFRAGPACKETS: u32 = 9; +pub const IPV6CTL_SOURCECHECK: u32 = 10; +pub const IPV6CTL_SOURCECHECK_LOGINT: u32 = 11; +pub const IPV6CTL_ACCEPT_RTADV: u32 = 12; +pub const IPV6CTL_LOG_INTERVAL: u32 = 14; +pub const IPV6CTL_HDRNESTLIMIT: u32 = 15; +pub const IPV6CTL_DAD_COUNT: u32 = 16; +pub const IPV6CTL_AUTO_FLOWLABEL: u32 = 17; +pub const IPV6CTL_DEFMCASTHLIM: u32 = 18; +pub const IPV6CTL_USE_DEPRECATED: u32 = 21; +pub const IPV6CTL_MAXFRAGS: u32 = 41; +pub const IPV6CTL_MFORWARDING: u32 = 42; +pub const IPV6CTL_MULTIPATH: u32 = 43; +pub const IPV6CTL_MCAST_PMTU: u32 = 44; +pub const IPV6CTL_NEIGHBORGCTHRESH: u32 = 45; +pub const IPV6CTL_MAXDYNROUTES: u32 = 48; +pub const IPV6CTL_DAD_PENDING: u32 = 49; +pub const IPV6CTL_MTUDISCTIMEOUT: u32 = 50; +pub const IPV6CTL_IFQUEUE: u32 = 51; +pub const IPV6CTL_MRTMIF: u32 = 52; +pub const IPV6CTL_MRTMFC: u32 = 53; +pub const IPV6CTL_SOIIKEY: u32 = 54; +pub const IPV6CTL_MAXID: u32 = 55; +pub const RNF_NORMAL: u32 = 1; +pub const RNF_ROOT: u32 = 2; +pub const RNF_ACTIVE: u32 = 4; +pub const RTF_UP: u32 = 1; +pub const RTF_GATEWAY: u32 = 2; +pub const RTF_HOST: u32 = 4; +pub const RTF_REJECT: u32 = 8; +pub const RTF_DYNAMIC: u32 = 16; +pub const RTF_MODIFIED: u32 = 32; +pub const RTF_DONE: u32 = 64; +pub const RTF_CLONING: u32 = 256; +pub const RTF_MULTICAST: u32 = 512; +pub const RTF_LLINFO: u32 = 1024; +pub const RTF_STATIC: u32 = 2048; +pub const RTF_BLACKHOLE: u32 = 4096; +pub const RTF_PROTO3: u32 = 8192; +pub const RTF_PROTO2: u32 = 16384; +pub const RTF_ANNOUNCE: u32 = 16384; +pub const RTF_PROTO1: u32 = 32768; +pub const RTF_CLONED: u32 = 65536; +pub const RTF_CACHED: u32 = 131072; +pub const RTF_MPATH: u32 = 262144; +pub const RTF_MPLS: u32 = 1048576; +pub const RTF_LOCAL: u32 = 2097152; +pub const RTF_BROADCAST: u32 = 4194304; +pub const RTF_CONNECTED: u32 = 8388608; +pub const RTF_BFD: u32 = 16777216; +pub const RTF_FMASK: u32 = 17890312; +pub const RTP_NONE: u32 = 0; +pub const RTP_LOCAL: u32 = 1; +pub const RTP_CONNECTED: u32 = 4; +pub const RTP_STATIC: u32 = 8; +pub const RTP_EIGRP: u32 = 28; +pub const RTP_OSPF: u32 = 32; +pub const RTP_ISIS: u32 = 36; +pub const RTP_RIP: u32 = 40; +pub const RTP_BGP: u32 = 48; +pub const RTP_DEFAULT: u32 = 56; +pub const RTP_PROPOSAL_STATIC: u32 = 57; +pub const RTP_PROPOSAL_DHCLIENT: u32 = 58; +pub const RTP_PROPOSAL_SLAAC: u32 = 59; +pub const RTP_PROPOSAL_UMB: u32 = 60; +pub const RTP_PROPOSAL_PPP: u32 = 61; +pub const RTP_PROPOSAL_SOLICIT: u32 = 62; +pub const RTP_MAX: u32 = 63; +pub const RTP_ANY: u32 = 64; +pub const RTP_MASK: u32 = 127; +pub const RTP_DOWN: u32 = 128; +pub const RTM_VERSION: u32 = 5; +pub const RTM_MAXSIZE: u32 = 2048; +pub const RTM_ADD: u32 = 1; +pub const RTM_DELETE: u32 = 2; +pub const RTM_CHANGE: u32 = 3; +pub const RTM_GET: u32 = 4; +pub const RTM_LOSING: u32 = 5; +pub const RTM_REDIRECT: u32 = 6; +pub const RTM_MISS: u32 = 7; +pub const RTM_RESOLVE: u32 = 11; +pub const RTM_NEWADDR: u32 = 12; +pub const RTM_DELADDR: u32 = 13; +pub const RTM_IFINFO: u32 = 14; +pub const RTM_IFANNOUNCE: u32 = 15; +pub const RTM_DESYNC: u32 = 16; +pub const RTM_INVALIDATE: u32 = 17; +pub const RTM_BFD: u32 = 18; +pub const RTM_PROPOSAL: u32 = 19; +pub const RTM_CHGADDRATTR: u32 = 20; +pub const RTM_80211INFO: u32 = 21; +pub const RTM_SOURCE: u32 = 22; +pub const RTV_MTU: u32 = 1; +pub const RTV_HOPCOUNT: u32 = 2; +pub const RTV_EXPIRE: u32 = 4; +pub const RTV_RPIPE: u32 = 8; +pub const RTV_SPIPE: u32 = 16; +pub const RTV_SSTHRESH: u32 = 32; +pub const RTV_RTT: u32 = 64; +pub const RTV_RTTVAR: u32 = 128; +pub const RTA_DST: u32 = 1; +pub const RTA_GATEWAY: u32 = 2; +pub const RTA_NETMASK: u32 = 4; +pub const RTA_GENMASK: u32 = 8; +pub const RTA_IFP: u32 = 16; +pub const RTA_IFA: u32 = 32; +pub const RTA_AUTHOR: u32 = 64; +pub const RTA_BRD: u32 = 128; +pub const RTA_SRC: u32 = 256; +pub const RTA_SRCMASK: u32 = 512; +pub const RTA_LABEL: u32 = 1024; +pub const RTA_BFD: u32 = 2048; +pub const RTA_DNS: u32 = 4096; +pub const RTA_STATIC: u32 = 8192; +pub const RTA_SEARCH: u32 = 16384; +pub const RTAX_DST: u32 = 0; +pub const RTAX_GATEWAY: u32 = 1; +pub const RTAX_NETMASK: u32 = 2; +pub const RTAX_GENMASK: u32 = 3; +pub const RTAX_IFP: u32 = 4; +pub const RTAX_IFA: u32 = 5; +pub const RTAX_AUTHOR: u32 = 6; +pub const RTAX_BRD: u32 = 7; +pub const RTAX_SRC: u32 = 8; +pub const RTAX_SRCMASK: u32 = 9; +pub const RTAX_LABEL: u32 = 10; +pub const RTAX_BFD: u32 = 11; +pub const RTAX_DNS: u32 = 12; +pub const RTAX_STATIC: u32 = 13; +pub const RTAX_SEARCH: u32 = 14; +pub const RTAX_MAX: u32 = 15; +pub const ROUTE_MSGFILTER: u32 = 1; +pub const ROUTE_TABLEFILTER: u32 = 2; +pub const ROUTE_PRIOFILTER: u32 = 3; +pub const ROUTE_FLAGFILTER: u32 = 4; +pub const RTABLE_ANY: u32 = 4294967295; +pub const RTLABEL_LEN: u32 = 32; +pub const RTDNS_LEN: u32 = 128; +pub const RTSTATIC_LEN: u32 = 128; +pub const RTSEARCH_LEN: u32 = 128; +pub const PF_MD5_DIGEST_LENGTH: u32 = 16; +pub const PFTM_TCP_FIRST_PACKET_VAL: u32 = 120; +pub const PFTM_TCP_OPENING_VAL: u32 = 30; +pub const PFTM_TCP_ESTABLISHED_VAL: u32 = 86400; +pub const PFTM_TCP_CLOSING_VAL: u32 = 900; +pub const PFTM_TCP_FIN_WAIT_VAL: u32 = 45; +pub const PFTM_TCP_CLOSED_VAL: u32 = 90; +pub const PFTM_UDP_FIRST_PACKET_VAL: u32 = 60; +pub const PFTM_UDP_SINGLE_VAL: u32 = 30; +pub const PFTM_UDP_MULTIPLE_VAL: u32 = 60; +pub const PFTM_ICMP_FIRST_PACKET_VAL: u32 = 20; +pub const PFTM_ICMP_ERROR_REPLY_VAL: u32 = 10; +pub const PFTM_OTHER_FIRST_PACKET_VAL: u32 = 60; +pub const PFTM_OTHER_SINGLE_VAL: u32 = 30; +pub const PFTM_OTHER_MULTIPLE_VAL: u32 = 60; +pub const PFTM_FRAG_VAL: u32 = 60; +pub const PFTM_INTERVAL_VAL: u32 = 10; +pub const PFTM_SRC_NODE_VAL: u32 = 0; +pub const PFTM_TS_DIFF_VAL: u32 = 30; +pub const PF_FRAG_STALE: u32 = 200; +pub const PF_FRAG_ENTRY_POINTS: u32 = 16; +pub const PF_FRAG_ENTRY_LIMIT: u32 = 64; +pub const PF_POOL_IDMASK: u32 = 15; +pub const PF_POOL_TYPEMASK: u32 = 15; +pub const PF_POOL_STICKYADDR: u32 = 32; +pub const PF_WSCALE_FLAG: u32 = 128; +pub const PF_WSCALE_MASK: u32 = 15; +pub const PF_LOG: u32 = 1; +pub const PF_LOG_ALL: u32 = 2; +pub const PF_LOG_USER: u32 = 4; +pub const PF_LOG_FORCE: u32 = 8; +pub const PF_LOG_MATCHES: u32 = 16; +pub const PF_TABLE_NAME_SIZE: u32 = 32; +pub const PFI_AFLAG_NETWORK: u32 = 1; +pub const PFI_AFLAG_BROADCAST: u32 = 2; +pub const PFI_AFLAG_PEER: u32 = 4; +pub const PFI_AFLAG_MODEMASK: u32 = 7; +pub const PFI_AFLAG_NOALIAS: u32 = 8; +pub const PF_DEBUGNAME: &[u8; 5] = b"pf: \0"; +pub const PF_THRESHOLD_MULT: u32 = 1000; +pub const PF_THRESHOLD_MAX: u32 = 4294967; +pub const PF_OSFP_EXPANDED: u32 = 1; +pub const PF_OSFP_GENERIC: u32 = 2; +pub const PF_OSFP_NODETAIL: u32 = 4; +pub const PF_OSFP_LEN: u32 = 32; +pub const _FP_RESERVED_BIT: u32 = 1; +pub const _FP_UNUSED_BITS: u32 = 1; +pub const _FP_CLASS_BITS: u32 = 10; +pub const _FP_VERSION_BITS: u32 = 10; +pub const _FP_SUBTYPE_BITS: u32 = 10; +pub const PF_OSFP_WSIZE_MOD: u32 = 1; +pub const PF_OSFP_WSIZE_DC: u32 = 2; +pub const PF_OSFP_WSIZE_MSS: u32 = 4; +pub const PF_OSFP_WSIZE_MTU: u32 = 8; +pub const PF_OSFP_PSIZE_MOD: u32 = 16; +pub const PF_OSFP_PSIZE_DC: u32 = 32; +pub const PF_OSFP_WSCALE: u32 = 64; +pub const PF_OSFP_WSCALE_MOD: u32 = 128; +pub const PF_OSFP_WSCALE_DC: u32 = 256; +pub const PF_OSFP_MSS: u32 = 512; +pub const PF_OSFP_MSS_MOD: u32 = 1024; +pub const PF_OSFP_MSS_DC: u32 = 2048; +pub const PF_OSFP_DF: u32 = 4096; +pub const PF_OSFP_TS0: u32 = 8192; +pub const PF_OSFP_INET6: u32 = 16384; +pub const PF_OSFP_MAXTTL_OFFSET: u32 = 40; +pub const PF_OSFP_TCPOPT_NOP: u32 = 0; +pub const PF_OSFP_TCPOPT_WSCALE: u32 = 1; +pub const PF_OSFP_TCPOPT_MSS: u32 = 2; +pub const PF_OSFP_TCPOPT_SACK: u32 = 3; +pub const PF_OSFP_TCPOPT_TS: u32 = 4; +pub const PF_OSFP_TCPOPT_BITS: u32 = 3; +pub const PF_ANCHOR_STACK_MAX: u32 = 64; +pub const PF_ANCHOR_NAME_SIZE: u32 = 64; +pub const PF_ANCHOR_MAXPATH: u32 = 959; +pub const PF_ANCHOR_HIWAT: u32 = 512; +pub const PF_OPTIMIZER_TABLE_PFX: &[u8; 13] = b"__automatic_\0"; +pub const PF_SKIP_IFP: u32 = 0; +pub const PF_SKIP_DIR: u32 = 1; +pub const PF_SKIP_RDOM: u32 = 2; +pub const PF_SKIP_AF: u32 = 3; +pub const PF_SKIP_PROTO: u32 = 4; +pub const PF_SKIP_SRC_ADDR: u32 = 5; +pub const PF_SKIP_DST_ADDR: u32 = 6; +pub const PF_SKIP_SRC_PORT: u32 = 7; +pub const PF_SKIP_DST_PORT: u32 = 8; +pub const PF_SKIP_COUNT: u32 = 9; +pub const PF_RULE_LABEL_SIZE: u32 = 64; +pub const PF_QNAME_SIZE: u32 = 64; +pub const PF_TAG_NAME_SIZE: u32 = 64; +pub const PF_STATE_NORMAL: u32 = 1; +pub const PF_STATE_MODULATE: u32 = 2; +pub const PF_STATE_SYNPROXY: u32 = 3; +pub const PF_FLUSH: u32 = 1; +pub const PF_FLUSH_GLOBAL: u32 = 2; +pub const PFRULE_DROP: u32 = 0; +pub const PFRULE_RETURNRST: u32 = 1; +pub const PFRULE_FRAGMENT: u32 = 2; +pub const PFRULE_RETURNICMP: u32 = 4; +pub const PFRULE_RETURN: u32 = 8; +pub const PFRULE_NOSYNC: u32 = 16; +pub const PFRULE_SRCTRACK: u32 = 32; +pub const PFRULE_RULESRCTRACK: u32 = 64; +pub const PFRULE_SETDELAY: u32 = 128; +pub const PFRULE_IFBOUND: u32 = 65536; +pub const PFRULE_STATESLOPPY: u32 = 131072; +pub const PFRULE_PFLOW: u32 = 262144; +pub const PFRULE_ONCE: u32 = 1048576; +pub const PFRULE_AFTO: u32 = 2097152; +pub const PFRULE_EXPIRED: u32 = 4194304; +pub const PFSTATE_HIWAT: u32 = 100000; +pub const PFSTATE_ADAPT_START: u32 = 60000; +pub const PFSTATE_ADAPT_END: u32 = 120000; +pub const PF_PKTDELAY_MAXPKTS: u32 = 10000; +pub const PFSNODE_HIWAT: u32 = 10000; +pub const PFSS_TIMESTAMP: u32 = 1; +pub const PFSS_PAWS: u32 = 16; +pub const PFSS_PAWS_IDLED: u32 = 32; +pub const PFSS_DATA_TS: u32 = 64; +pub const PFSS_DATA_NOTS: u32 = 128; +pub const PFSTATE_ALLOWOPTS: u32 = 1; +pub const PFSTATE_SLOPPY: u32 = 2; +pub const PFSTATE_PFLOW: u32 = 4; +pub const PFSTATE_NOSYNC: u32 = 8; +pub const PFSTATE_ACK: u32 = 16; +pub const PFSTATE_NODF: u32 = 32; +pub const PFSTATE_SETTOS: u32 = 64; +pub const PFSTATE_RANDOMID: u32 = 128; +pub const PFSTATE_SCRUB_TCP: u32 = 256; +pub const PFSTATE_SETPRIO: u32 = 512; +pub const PFSTATE_INP_UNLINKED: u32 = 1024; +pub const PFSTATE_SCRUBMASK: u32 = 416; +pub const PFSTATE_SETMASK: u32 = 576; +pub const PFSYNC_SCRUB_FLAG_VALID: u32 = 1; +pub const PFSYNC_FLAG_SRCNODE: u32 = 4; +pub const PFSYNC_FLAG_NATSRCNODE: u32 = 8; +pub const PF_RESERVED_ANCHOR: &[u8; 4] = b"_pf\0"; +pub const PFR_TFLAG_PERSIST: u32 = 1; +pub const PFR_TFLAG_CONST: u32 = 2; +pub const PFR_TFLAG_ACTIVE: u32 = 4; +pub const PFR_TFLAG_INACTIVE: u32 = 8; +pub const PFR_TFLAG_REFERENCED: u32 = 16; +pub const PFR_TFLAG_REFDANCHOR: u32 = 32; +pub const PFR_TFLAG_COUNTERS: u32 = 64; +pub const PFR_TFLAG_USRMASK: u32 = 67; +pub const PFR_TFLAG_SETMASK: u32 = 60; +pub const PFR_TFLAG_ALLMASK: u32 = 127; +pub const PFRKE_FLAG_NOT: u32 = 1; +pub const PFRKE_FLAG_MARK: u32 = 2; +pub const PFI_IFLAG_SKIP: u32 = 256; +pub const PFI_IFLAG_ANY: u32 = 512; +pub const PF_DPORT_RANGE: u32 = 1; +pub const PF_RPORT_RANGE: u32 = 2; +pub const PFRES_MATCH: u32 = 0; +pub const PFRES_BADOFF: u32 = 1; +pub const PFRES_FRAG: u32 = 2; +pub const PFRES_SHORT: u32 = 3; +pub const PFRES_NORM: u32 = 4; +pub const PFRES_MEMORY: u32 = 5; +pub const PFRES_TS: u32 = 6; +pub const PFRES_CONGEST: u32 = 7; +pub const PFRES_IPOPTIONS: u32 = 8; +pub const PFRES_PROTCKSUM: u32 = 9; +pub const PFRES_BADSTATE: u32 = 10; +pub const PFRES_STATEINS: u32 = 11; +pub const PFRES_MAXSTATES: u32 = 12; +pub const PFRES_SRCLIMIT: u32 = 13; +pub const PFRES_SYNPROXY: u32 = 14; +pub const PFRES_TRANSLATE: u32 = 15; +pub const PFRES_NOROUTE: u32 = 16; +pub const PFRES_MAX: u32 = 17; +pub const LCNT_STATES: u32 = 0; +pub const LCNT_SRCSTATES: u32 = 1; +pub const LCNT_SRCNODES: u32 = 2; +pub const LCNT_SRCCONN: u32 = 3; +pub const LCNT_SRCCONNRATE: u32 = 4; +pub const LCNT_OVERLOAD_TABLE: u32 = 5; +pub const LCNT_OVERLOAD_FLUSH: u32 = 6; +pub const LCNT_SYNFLOODS: u32 = 7; +pub const LCNT_SYNCOOKIES_SENT: u32 = 8; +pub const LCNT_SYNCOOKIES_VALID: u32 = 9; +pub const LCNT_MAX: u32 = 10; +pub const PFUDPS_NO_TRAFFIC: u32 = 0; +pub const PFUDPS_SINGLE: u32 = 1; +pub const PFUDPS_MULTIPLE: u32 = 2; +pub const PFUDPS_NSTATES: u32 = 3; +pub const PFOTHERS_NO_TRAFFIC: u32 = 0; +pub const PFOTHERS_SINGLE: u32 = 1; +pub const PFOTHERS_MULTIPLE: u32 = 2; +pub const PFOTHERS_NSTATES: u32 = 3; +pub const FCNT_STATE_SEARCH: u32 = 0; +pub const FCNT_STATE_INSERT: u32 = 1; +pub const FCNT_STATE_REMOVALS: u32 = 2; +pub const FCNT_MAX: u32 = 3; +pub const SCNT_SRC_NODE_SEARCH: u32 = 0; +pub const SCNT_SRC_NODE_INSERT: u32 = 1; +pub const SCNT_SRC_NODE_REMOVALS: u32 = 2; +pub const SCNT_MAX: u32 = 3; +pub const PF_REASS_ENABLED: u32 = 1; +pub const PF_REASS_NODF: u32 = 2; +pub const PF_SYNCOOKIES_NEVER: u32 = 0; +pub const PF_SYNCOOKIES_ALWAYS: u32 = 1; +pub const PF_SYNCOOKIES_ADAPTIVE: u32 = 2; +pub const PF_SYNCOOKIES_MODE_MAX: u32 = 2; +pub const PF_SYNCOOKIES_HIWATPCT: u32 = 25; +pub const PF_SYNCOOKIES_LOWATPCT: u32 = 12; +pub const PF_PRIO_ZERO: u32 = 255; +pub const PFQS_FLOWQUEUE: u32 = 1; +pub const PFQS_ROOTCLASS: u32 = 2; +pub const PFQS_DEFAULT: u32 = 4096; +pub const PFR_KTABLE_HIWAT: u32 = 1000; +pub const PFR_KENTRY_HIWAT: u32 = 200000; +pub const PFR_KENTRY_HIWAT_SMALL: u32 = 100000; +pub const PFR_FLAG_DUMMY: u32 = 2; +pub const PFR_FLAG_FEEDBACK: u32 = 4; +pub const PFR_FLAG_CLSTATS: u32 = 8; +pub const PFR_FLAG_ADDRSTOO: u32 = 16; +pub const PFR_FLAG_REPLACE: u32 = 32; +pub const PFR_FLAG_ALLRSETS: u32 = 64; +pub const PFR_FLAG_ALLMASK: u32 = 127; +pub type __int8_t = ::std::os::raw::c_schar; +pub type __uint8_t = ::std::os::raw::c_uchar; +pub type __int16_t = ::std::os::raw::c_short; +pub type __uint16_t = ::std::os::raw::c_ushort; +pub type __int32_t = ::std::os::raw::c_int; +pub type __uint32_t = ::std::os::raw::c_uint; +pub type __int64_t = ::std::os::raw::c_longlong; +pub type __uint64_t = ::std::os::raw::c_ulonglong; +pub type __int_least8_t = __int8_t; +pub type __uint_least8_t = __uint8_t; +pub type __int_least16_t = __int16_t; +pub type __uint_least16_t = __uint16_t; +pub type __int_least32_t = __int32_t; +pub type __uint_least32_t = __uint32_t; +pub type __int_least64_t = __int64_t; +pub type __uint_least64_t = __uint64_t; +pub type __int_fast8_t = __int32_t; +pub type __uint_fast8_t = __uint32_t; +pub type __int_fast16_t = __int32_t; +pub type __uint_fast16_t = __uint32_t; +pub type __int_fast32_t = __int32_t; +pub type __uint_fast32_t = __uint32_t; +pub type __int_fast64_t = __int64_t; +pub type __uint_fast64_t = __uint64_t; +pub type __intptr_t = ::std::os::raw::c_long; +pub type __uintptr_t = ::std::os::raw::c_ulong; +pub type __intmax_t = __int64_t; +pub type __uintmax_t = __uint64_t; +pub type __register_t = ::std::os::raw::c_long; +pub type __vaddr_t = ::std::os::raw::c_ulong; +pub type __paddr_t = ::std::os::raw::c_ulong; +pub type __vsize_t = ::std::os::raw::c_ulong; +pub type __psize_t = ::std::os::raw::c_ulong; +pub type __double_t = f64; +pub type __float_t = f32; +pub type __ptrdiff_t = ::std::os::raw::c_long; +pub type __size_t = ::std::os::raw::c_ulong; +pub type __ssize_t = ::std::os::raw::c_long; +pub type __va_list = __builtin_va_list; +pub type __wchar_t = ::std::os::raw::c_int; +pub type __wint_t = ::std::os::raw::c_int; +pub type __rune_t = ::std::os::raw::c_int; +pub type __wctrans_t = *mut ::std::os::raw::c_void; +pub type __wctype_t = *mut ::std::os::raw::c_void; +pub type int_least8_t = __int_least8_t; +pub type uint_least8_t = __uint_least8_t; +pub type int_least16_t = __int_least16_t; +pub type uint_least16_t = __uint_least16_t; +pub type int_least32_t = __int_least32_t; +pub type uint_least32_t = __uint_least32_t; +pub type int_least64_t = __int_least64_t; +pub type uint_least64_t = __uint_least64_t; +pub type int_fast8_t = __int_fast8_t; +pub type uint_fast8_t = __uint_fast8_t; +pub type int_fast16_t = __int_fast16_t; +pub type uint_fast16_t = __uint_fast16_t; +pub type int_fast32_t = __int_fast32_t; +pub type uint_fast32_t = __uint_fast32_t; +pub type int_fast64_t = __int_fast64_t; +pub type uint_fast64_t = __uint_fast64_t; +pub type intmax_t = __intmax_t; +pub type uintmax_t = __uintmax_t; +pub type __blkcnt_t = __int64_t; +pub type __blksize_t = __int32_t; +pub type __clock_t = __int64_t; +pub type __clockid_t = __int32_t; +pub type __cpuid_t = ::std::os::raw::c_ulong; +pub type __dev_t = __int32_t; +pub type __fixpt_t = __uint32_t; +pub type __fsblkcnt_t = __uint64_t; +pub type __fsfilcnt_t = __uint64_t; +pub type __gid_t = __uint32_t; +pub type __id_t = __uint32_t; +pub type __in_addr_t = __uint32_t; +pub type __in_port_t = __uint16_t; +pub type __ino_t = __uint64_t; +pub type __key_t = ::std::os::raw::c_long; +pub type __mode_t = __uint32_t; +pub type __nlink_t = __uint32_t; +pub type __off_t = __int64_t; +pub type __pid_t = __int32_t; +pub type __rlim_t = __uint64_t; +pub type __sa_family_t = __uint8_t; +pub type __segsz_t = __int32_t; +pub type __socklen_t = __uint32_t; +pub type __suseconds_t = ::std::os::raw::c_long; +pub type __time_t = __int64_t; +pub type __timer_t = __int32_t; +pub type __uid_t = __uint32_t; +pub type __useconds_t = __uint32_t; +#[repr(C)] +#[derive(Copy, Clone)] +pub union __mbstate_t { + pub __mbstate8: [::std::os::raw::c_char; 128usize], + pub __mbstateL: __int64_t, +} +#[test] +fn bindgen_test_layout___mbstate_t() { + const UNINIT: ::std::mem::MaybeUninit<__mbstate_t> = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<__mbstate_t>(), + 128usize, + concat!("Size of: ", stringify!(__mbstate_t)) + ); + assert_eq!( + ::std::mem::align_of::<__mbstate_t>(), + 8usize, + concat!("Alignment of ", stringify!(__mbstate_t)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).__mbstate8) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(__mbstate_t), + "::", + stringify!(__mbstate8) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).__mbstateL) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(__mbstate_t), + "::", + stringify!(__mbstateL) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct iovec { + pub iov_base: *mut ::std::os::raw::c_void, + pub iov_len: usize, +} +#[test] +fn bindgen_test_layout_iovec() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(iovec)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(iovec)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).iov_base) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(iovec), + "::", + stringify!(iov_base) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).iov_len) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(iovec), + "::", + stringify!(iov_len) + ) + ); +} +pub const uio_rw_UIO_READ: uio_rw = 0; +pub const uio_rw_UIO_WRITE: uio_rw = 1; +pub type uio_rw = ::std::os::raw::c_uint; +pub const uio_seg_UIO_USERSPACE: uio_seg = 0; +pub const uio_seg_UIO_SYSSPACE: uio_seg = 1; +pub type uio_seg = ::std::os::raw::c_uint; +extern "C" { + pub fn preadv( + arg1: ::std::os::raw::c_int, + arg2: *const iovec, + arg3: ::std::os::raw::c_int, + arg4: __off_t, + ) -> isize; +} +extern "C" { + pub fn pwritev( + arg1: ::std::os::raw::c_int, + arg2: *const iovec, + arg3: ::std::os::raw::c_int, + arg4: __off_t, + ) -> isize; +} +extern "C" { + pub fn readv( + arg1: ::std::os::raw::c_int, + arg2: *const iovec, + arg3: ::std::os::raw::c_int, + ) -> isize; +} +extern "C" { + pub fn writev( + arg1: ::std::os::raw::c_int, + arg2: *const iovec, + arg3: ::std::os::raw::c_int, + ) -> isize; +} +pub type u_char = ::std::os::raw::c_uchar; +pub type u_short = ::std::os::raw::c_ushort; +pub type u_int = ::std::os::raw::c_uint; +pub type u_long = ::std::os::raw::c_ulong; +pub type unchar = ::std::os::raw::c_uchar; +pub type ushort = ::std::os::raw::c_ushort; +pub type uint = ::std::os::raw::c_uint; +pub type ulong = ::std::os::raw::c_ulong; +pub type cpuid_t = __cpuid_t; +pub type register_t = __register_t; +pub type u_int8_t = __uint8_t; +pub type u_int16_t = __uint16_t; +pub type u_int32_t = __uint32_t; +pub type u_int64_t = __uint64_t; +pub type quad_t = __int64_t; +pub type u_quad_t = __uint64_t; +pub type vaddr_t = __vaddr_t; +pub type paddr_t = __paddr_t; +pub type vsize_t = __vsize_t; +pub type psize_t = __psize_t; +pub type blkcnt_t = __blkcnt_t; +pub type blksize_t = __blksize_t; +pub type caddr_t = *mut ::std::os::raw::c_char; +pub type daddr32_t = __int32_t; +pub type daddr_t = __int64_t; +pub type dev_t = __dev_t; +pub type fixpt_t = __fixpt_t; +pub type gid_t = __gid_t; +pub type id_t = __id_t; +pub type ino_t = __ino_t; +pub type key_t = __key_t; +pub type mode_t = __mode_t; +pub type nlink_t = __nlink_t; +pub type rlim_t = __rlim_t; +pub type segsz_t = __segsz_t; +pub type uid_t = __uid_t; +pub type useconds_t = __useconds_t; +pub type suseconds_t = __suseconds_t; +pub type fsblkcnt_t = __fsblkcnt_t; +pub type fsfilcnt_t = __fsfilcnt_t; +pub type clock_t = __clock_t; +pub type clockid_t = __clockid_t; +pub type pid_t = __pid_t; +pub type time_t = __time_t; +pub type timer_t = __timer_t; +pub type off_t = __off_t; +extern "C" { + pub fn lseek(arg1: ::std::os::raw::c_int, arg2: off_t, arg3: ::std::os::raw::c_int) -> off_t; +} +extern "C" { + pub fn ftruncate(arg1: ::std::os::raw::c_int, arg2: off_t) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn truncate(arg1: *const ::std::os::raw::c_char, arg2: off_t) -> ::std::os::raw::c_int; +} +pub type socklen_t = __socklen_t; +pub type sa_family_t = __sa_family_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct linger { + pub l_onoff: ::std::os::raw::c_int, + pub l_linger: ::std::os::raw::c_int, +} +#[test] +fn bindgen_test_layout_linger() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(linger)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(linger)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).l_onoff) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(linger), + "::", + stringify!(l_onoff) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).l_linger) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(linger), + "::", + stringify!(l_linger) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct timeval { + pub tv_sec: time_t, + pub tv_usec: suseconds_t, +} +#[test] +fn bindgen_test_layout_timeval() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(timeval)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(timeval)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).tv_sec) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(timeval), + "::", + stringify!(tv_sec) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).tv_usec) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(timeval), + "::", + stringify!(tv_usec) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct splice { + pub sp_fd: ::std::os::raw::c_int, + pub sp_max: off_t, + pub sp_idle: timeval, +} +#[test] +fn bindgen_test_layout_splice() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 32usize, + concat!("Size of: ", stringify!(splice)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(splice)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).sp_fd) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(splice), + "::", + stringify!(sp_fd) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).sp_max) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(splice), + "::", + stringify!(sp_max) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).sp_idle) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(splice), + "::", + stringify!(sp_idle) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct sockaddr { + pub sa_len: __uint8_t, + pub sa_family: sa_family_t, + pub sa_data: [::std::os::raw::c_char; 14usize], +} +#[test] +fn bindgen_test_layout_sockaddr() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(sockaddr)) + ); + assert_eq!( + ::std::mem::align_of::(), + 1usize, + concat!("Alignment of ", stringify!(sockaddr)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).sa_len) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(sockaddr), + "::", + stringify!(sa_len) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).sa_family) as usize - ptr as usize }, + 1usize, + concat!( + "Offset of field: ", + stringify!(sockaddr), + "::", + stringify!(sa_family) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).sa_data) as usize - ptr as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(sockaddr), + "::", + stringify!(sa_data) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct sockaddr_storage { + pub ss_len: __uint8_t, + pub ss_family: sa_family_t, + pub __ss_pad1: [::std::os::raw::c_uchar; 6usize], + pub __ss_pad2: __uint64_t, + pub __ss_pad3: [::std::os::raw::c_uchar; 240usize], +} +#[test] +fn bindgen_test_layout_sockaddr_storage() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 256usize, + concat!("Size of: ", stringify!(sockaddr_storage)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(sockaddr_storage)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ss_len) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(sockaddr_storage), + "::", + stringify!(ss_len) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ss_family) as usize - ptr as usize }, + 1usize, + concat!( + "Offset of field: ", + stringify!(sockaddr_storage), + "::", + stringify!(ss_family) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).__ss_pad1) as usize - ptr as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(sockaddr_storage), + "::", + stringify!(__ss_pad1) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).__ss_pad2) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(sockaddr_storage), + "::", + stringify!(__ss_pad2) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).__ss_pad3) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(sockaddr_storage), + "::", + stringify!(__ss_pad3) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct sockpeercred { + pub uid: uid_t, + pub gid: gid_t, + pub pid: pid_t, +} +#[test] +fn bindgen_test_layout_sockpeercred() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 12usize, + concat!("Size of: ", stringify!(sockpeercred)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(sockpeercred)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).uid) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(sockpeercred), + "::", + stringify!(uid) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).gid) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(sockpeercred), + "::", + stringify!(gid) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pid) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(sockpeercred), + "::", + stringify!(pid) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct msghdr { + pub msg_name: *mut ::std::os::raw::c_void, + pub msg_namelen: socklen_t, + pub msg_iov: *mut iovec, + pub msg_iovlen: ::std::os::raw::c_uint, + pub msg_control: *mut ::std::os::raw::c_void, + pub msg_controllen: socklen_t, + pub msg_flags: ::std::os::raw::c_int, +} +#[test] +fn bindgen_test_layout_msghdr() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 48usize, + concat!("Size of: ", stringify!(msghdr)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(msghdr)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).msg_name) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(msghdr), + "::", + stringify!(msg_name) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).msg_namelen) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(msghdr), + "::", + stringify!(msg_namelen) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).msg_iov) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(msghdr), + "::", + stringify!(msg_iov) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).msg_iovlen) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(msghdr), + "::", + stringify!(msg_iovlen) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).msg_control) as usize - ptr as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(msghdr), + "::", + stringify!(msg_control) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).msg_controllen) as usize - ptr as usize }, + 40usize, + concat!( + "Offset of field: ", + stringify!(msghdr), + "::", + stringify!(msg_controllen) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).msg_flags) as usize - ptr as usize }, + 44usize, + concat!( + "Offset of field: ", + stringify!(msghdr), + "::", + stringify!(msg_flags) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct mmsghdr { + pub msg_hdr: msghdr, + pub msg_len: ::std::os::raw::c_uint, +} +#[test] +fn bindgen_test_layout_mmsghdr() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 56usize, + concat!("Size of: ", stringify!(mmsghdr)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(mmsghdr)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).msg_hdr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(mmsghdr), + "::", + stringify!(msg_hdr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).msg_len) as usize - ptr as usize }, + 48usize, + concat!( + "Offset of field: ", + stringify!(mmsghdr), + "::", + stringify!(msg_len) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct cmsghdr { + pub cmsg_len: socklen_t, + pub cmsg_level: ::std::os::raw::c_int, + pub cmsg_type: ::std::os::raw::c_int, +} +#[test] +fn bindgen_test_layout_cmsghdr() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 12usize, + concat!("Size of: ", stringify!(cmsghdr)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(cmsghdr)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).cmsg_len) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(cmsghdr), + "::", + stringify!(cmsg_len) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).cmsg_level) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(cmsghdr), + "::", + stringify!(cmsg_level) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).cmsg_type) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(cmsghdr), + "::", + stringify!(cmsg_type) + ) + ); +} +extern "C" { + pub fn accept( + arg1: ::std::os::raw::c_int, + arg2: *mut sockaddr, + arg3: *mut socklen_t, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn bind( + arg1: ::std::os::raw::c_int, + arg2: *const sockaddr, + arg3: socklen_t, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn connect( + arg1: ::std::os::raw::c_int, + arg2: *const sockaddr, + arg3: socklen_t, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn getpeername( + arg1: ::std::os::raw::c_int, + arg2: *mut sockaddr, + arg3: *mut socklen_t, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn getsockname( + arg1: ::std::os::raw::c_int, + arg2: *mut sockaddr, + arg3: *mut socklen_t, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn getsockopt( + arg1: ::std::os::raw::c_int, + arg2: ::std::os::raw::c_int, + arg3: ::std::os::raw::c_int, + arg4: *mut ::std::os::raw::c_void, + arg5: *mut socklen_t, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn listen( + arg1: ::std::os::raw::c_int, + arg2: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn recv( + arg1: ::std::os::raw::c_int, + arg2: *mut ::std::os::raw::c_void, + arg3: usize, + arg4: ::std::os::raw::c_int, + ) -> isize; +} +extern "C" { + pub fn recvfrom( + arg1: ::std::os::raw::c_int, + arg2: *mut ::std::os::raw::c_void, + arg3: usize, + arg4: ::std::os::raw::c_int, + arg5: *mut sockaddr, + arg6: *mut socklen_t, + ) -> isize; +} +extern "C" { + pub fn recvmsg( + arg1: ::std::os::raw::c_int, + arg2: *mut msghdr, + arg3: ::std::os::raw::c_int, + ) -> isize; +} +extern "C" { + pub fn recvmmsg( + arg1: ::std::os::raw::c_int, + arg2: *mut mmsghdr, + arg3: ::std::os::raw::c_uint, + arg4: ::std::os::raw::c_int, + arg5: *mut timespec, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn send( + arg1: ::std::os::raw::c_int, + arg2: *const ::std::os::raw::c_void, + arg3: usize, + arg4: ::std::os::raw::c_int, + ) -> isize; +} +extern "C" { + pub fn sendto( + arg1: ::std::os::raw::c_int, + arg2: *const ::std::os::raw::c_void, + arg3: usize, + arg4: ::std::os::raw::c_int, + arg5: *const sockaddr, + arg6: socklen_t, + ) -> isize; +} +extern "C" { + pub fn sendmsg( + arg1: ::std::os::raw::c_int, + arg2: *const msghdr, + arg3: ::std::os::raw::c_int, + ) -> isize; +} +extern "C" { + pub fn sendmmsg( + arg1: ::std::os::raw::c_int, + arg2: *mut mmsghdr, + arg3: ::std::os::raw::c_uint, + arg4: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn setsockopt( + arg1: ::std::os::raw::c_int, + arg2: ::std::os::raw::c_int, + arg3: ::std::os::raw::c_int, + arg4: *const ::std::os::raw::c_void, + arg5: socklen_t, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn shutdown( + arg1: ::std::os::raw::c_int, + arg2: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn sockatmark(arg1: ::std::os::raw::c_int) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn socket( + arg1: ::std::os::raw::c_int, + arg2: ::std::os::raw::c_int, + arg3: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn socketpair( + arg1: ::std::os::raw::c_int, + arg2: ::std::os::raw::c_int, + arg3: ::std::os::raw::c_int, + arg4: *mut ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn accept4( + arg1: ::std::os::raw::c_int, + arg2: *mut sockaddr, + arg3: *mut socklen_t, + arg4: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn getpeereid( + arg1: ::std::os::raw::c_int, + arg2: *mut uid_t, + arg3: *mut gid_t, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn getrtable() -> ::std::os::raw::c_int; +} +extern "C" { + pub fn setrtable(arg1: ::std::os::raw::c_int) -> ::std::os::raw::c_int; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct if_nameindex { + pub if_index: ::std::os::raw::c_uint, + pub if_name: *mut ::std::os::raw::c_char, +} +#[test] +fn bindgen_test_layout_if_nameindex() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(if_nameindex)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(if_nameindex)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).if_index) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(if_nameindex), + "::", + stringify!(if_index) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).if_name) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(if_nameindex), + "::", + stringify!(if_name) + ) + ); +} +extern "C" { + pub fn if_nametoindex(arg1: *const ::std::os::raw::c_char) -> ::std::os::raw::c_uint; +} +extern "C" { + pub fn if_indextoname( + arg1: ::std::os::raw::c_uint, + arg2: *mut ::std::os::raw::c_char, + ) -> *mut ::std::os::raw::c_char; +} +extern "C" { + pub fn if_nameindex() -> *mut if_nameindex; +} +extern "C" { + pub fn if_freenameindex(arg1: *mut if_nameindex); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct timespec { + pub tv_sec: time_t, + pub tv_nsec: ::std::os::raw::c_long, +} +#[test] +fn bindgen_test_layout_timespec() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(timespec)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(timespec)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).tv_sec) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(timespec), + "::", + stringify!(tv_sec) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).tv_nsec) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(timespec), + "::", + stringify!(tv_nsec) + ) + ); +} +pub type __fd_mask = u32; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct fd_set { + pub fds_bits: [__fd_mask; 32usize], +} +#[test] +fn bindgen_test_layout_fd_set() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 128usize, + concat!("Size of: ", stringify!(fd_set)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(fd_set)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).fds_bits) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(fd_set), + "::", + stringify!(fds_bits) + ) + ); +} +pub type sigset_t = ::std::os::raw::c_uint; +extern "C" { + pub fn select( + arg1: ::std::os::raw::c_int, + arg2: *mut fd_set, + arg3: *mut fd_set, + arg4: *mut fd_set, + arg5: *mut timeval, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn pselect( + arg1: ::std::os::raw::c_int, + arg2: *mut fd_set, + arg3: *mut fd_set, + arg4: *mut fd_set, + arg5: *const timespec, + arg6: *const sigset_t, + ) -> ::std::os::raw::c_int; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct timezone { + pub tz_minuteswest: ::std::os::raw::c_int, + pub tz_dsttime: ::std::os::raw::c_int, +} +#[test] +fn bindgen_test_layout_timezone() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(timezone)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(timezone)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).tz_minuteswest) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(timezone), + "::", + stringify!(tz_minuteswest) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).tz_dsttime) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(timezone), + "::", + stringify!(tz_dsttime) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct itimerval { + pub it_interval: timeval, + pub it_value: timeval, +} +#[test] +fn bindgen_test_layout_itimerval() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 32usize, + concat!("Size of: ", stringify!(itimerval)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(itimerval)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).it_interval) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(itimerval), + "::", + stringify!(it_interval) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).it_value) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(itimerval), + "::", + stringify!(it_value) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct clockinfo { + pub hz: ::std::os::raw::c_int, + pub tick: ::std::os::raw::c_int, + pub stathz: ::std::os::raw::c_int, + pub profhz: ::std::os::raw::c_int, +} +#[test] +fn bindgen_test_layout_clockinfo() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(clockinfo)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(clockinfo)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).hz) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(clockinfo), + "::", + stringify!(hz) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).tick) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(clockinfo), + "::", + stringify!(tick) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).stathz) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(clockinfo), + "::", + stringify!(stathz) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).profhz) as usize - ptr as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(clockinfo), + "::", + stringify!(profhz) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct itimerspec { + pub it_interval: timespec, + pub it_value: timespec, +} +#[test] +fn bindgen_test_layout_itimerspec() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 32usize, + concat!("Size of: ", stringify!(itimerspec)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(itimerspec)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).it_interval) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(itimerspec), + "::", + stringify!(it_interval) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).it_value) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(itimerspec), + "::", + stringify!(it_value) + ) + ); +} +pub type locale_t = *mut ::std::os::raw::c_void; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct tm { + pub tm_sec: ::std::os::raw::c_int, + pub tm_min: ::std::os::raw::c_int, + pub tm_hour: ::std::os::raw::c_int, + pub tm_mday: ::std::os::raw::c_int, + pub tm_mon: ::std::os::raw::c_int, + pub tm_year: ::std::os::raw::c_int, + pub tm_wday: ::std::os::raw::c_int, + pub tm_yday: ::std::os::raw::c_int, + pub tm_isdst: ::std::os::raw::c_int, + pub tm_gmtoff: ::std::os::raw::c_long, + pub tm_zone: *mut ::std::os::raw::c_char, +} +#[test] +fn bindgen_test_layout_tm() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 56usize, + concat!("Size of: ", stringify!(tm)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(tm)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).tm_sec) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(tm), + "::", + stringify!(tm_sec) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).tm_min) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(tm), + "::", + stringify!(tm_min) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).tm_hour) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(tm), + "::", + stringify!(tm_hour) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).tm_mday) as usize - ptr as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(tm), + "::", + stringify!(tm_mday) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).tm_mon) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(tm), + "::", + stringify!(tm_mon) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).tm_year) as usize - ptr as usize }, + 20usize, + concat!( + "Offset of field: ", + stringify!(tm), + "::", + stringify!(tm_year) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).tm_wday) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(tm), + "::", + stringify!(tm_wday) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).tm_yday) as usize - ptr as usize }, + 28usize, + concat!( + "Offset of field: ", + stringify!(tm), + "::", + stringify!(tm_yday) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).tm_isdst) as usize - ptr as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(tm), + "::", + stringify!(tm_isdst) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).tm_gmtoff) as usize - ptr as usize }, + 40usize, + concat!( + "Offset of field: ", + stringify!(tm), + "::", + stringify!(tm_gmtoff) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).tm_zone) as usize - ptr as usize }, + 48usize, + concat!( + "Offset of field: ", + stringify!(tm), + "::", + stringify!(tm_zone) + ) + ); +} +extern "C" { + pub fn asctime(arg1: *const tm) -> *mut ::std::os::raw::c_char; +} +extern "C" { + pub fn clock() -> clock_t; +} +extern "C" { + pub fn ctime(arg1: *const time_t) -> *mut ::std::os::raw::c_char; +} +extern "C" { + pub fn difftime(arg1: time_t, arg2: time_t) -> f64; +} +extern "C" { + pub fn gmtime(arg1: *const time_t) -> *mut tm; +} +extern "C" { + pub fn localtime(arg1: *const time_t) -> *mut tm; +} +extern "C" { + pub fn mktime(arg1: *mut tm) -> time_t; +} +extern "C" { + pub fn strftime( + arg1: *mut ::std::os::raw::c_char, + arg2: usize, + arg3: *const ::std::os::raw::c_char, + arg4: *const tm, + ) -> usize; +} +extern "C" { + pub fn time(arg1: *mut time_t) -> time_t; +} +extern "C" { + pub static mut daylight: ::std::os::raw::c_int; +} +extern "C" { + pub static mut timezone: ::std::os::raw::c_long; +} +extern "C" { + pub fn strptime( + arg1: *const ::std::os::raw::c_char, + arg2: *const ::std::os::raw::c_char, + arg3: *mut tm, + ) -> *mut ::std::os::raw::c_char; +} +extern "C" { + pub fn asctime_r( + arg1: *const tm, + arg2: *mut ::std::os::raw::c_char, + ) -> *mut ::std::os::raw::c_char; +} +extern "C" { + pub fn ctime_r( + arg1: *const time_t, + arg2: *mut ::std::os::raw::c_char, + ) -> *mut ::std::os::raw::c_char; +} +extern "C" { + pub fn gmtime_r(arg1: *const time_t, arg2: *mut tm) -> *mut tm; +} +extern "C" { + pub fn localtime_r(arg1: *const time_t, arg2: *mut tm) -> *mut tm; +} +extern "C" { + pub static mut tzname: [*mut ::std::os::raw::c_char; 2usize]; +} +extern "C" { + pub fn tzset(); +} +extern "C" { + pub fn clock_getres(arg1: clockid_t, arg2: *mut timespec) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn clock_gettime(arg1: clockid_t, arg2: *mut timespec) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn clock_settime(arg1: clockid_t, arg2: *const timespec) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn nanosleep(arg1: *const timespec, arg2: *mut timespec) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn clock_getcpuclockid(arg1: pid_t, arg2: *mut clockid_t) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn strftime_l( + arg1: *mut ::std::os::raw::c_char, + arg2: usize, + arg3: *const ::std::os::raw::c_char, + arg4: *const tm, + arg5: locale_t, + ) -> usize; +} +extern "C" { + pub fn timespec_get(_ts: *mut timespec, _base: ::std::os::raw::c_int) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn tzsetwall(); +} +extern "C" { + pub fn timelocal(arg1: *mut tm) -> time_t; +} +extern "C" { + pub fn timegm(arg1: *mut tm) -> time_t; +} +extern "C" { + pub fn timeoff(arg1: *mut tm, arg2: ::std::os::raw::c_long) -> time_t; +} +extern "C" { + pub fn adjtime(arg1: *const timeval, arg2: *mut timeval) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn adjfreq(arg1: *const i64, arg2: *mut i64) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn futimes(arg1: ::std::os::raw::c_int, arg2: *const timeval) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn getitimer(arg1: ::std::os::raw::c_int, arg2: *mut itimerval) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn gettimeofday(arg1: *mut timeval, arg2: *mut timezone) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn setitimer( + arg1: ::std::os::raw::c_int, + arg2: *const itimerval, + arg3: *mut itimerval, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn settimeofday(arg1: *const timeval, arg2: *const timezone) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn utimes( + arg1: *const ::std::os::raw::c_char, + arg2: *const timeval, + ) -> ::std::os::raw::c_int; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct if_clonereq { + pub ifcr_total: ::std::os::raw::c_int, + pub ifcr_count: ::std::os::raw::c_int, + pub ifcr_buffer: *mut ::std::os::raw::c_char, +} +#[test] +fn bindgen_test_layout_if_clonereq() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(if_clonereq)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(if_clonereq)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifcr_total) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(if_clonereq), + "::", + stringify!(ifcr_total) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifcr_count) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(if_clonereq), + "::", + stringify!(ifcr_count) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifcr_buffer) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(if_clonereq), + "::", + stringify!(ifcr_buffer) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct if_rxring { + pub rxr_adjusted: ::std::os::raw::c_int, + pub rxr_alive: u_int, + pub rxr_cwm: u_int, + pub rxr_lwm: u_int, + pub rxr_hwm: u_int, +} +#[test] +fn bindgen_test_layout_if_rxring() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 20usize, + concat!("Size of: ", stringify!(if_rxring)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(if_rxring)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rxr_adjusted) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(if_rxring), + "::", + stringify!(rxr_adjusted) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rxr_alive) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(if_rxring), + "::", + stringify!(rxr_alive) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rxr_cwm) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(if_rxring), + "::", + stringify!(rxr_cwm) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rxr_lwm) as usize - ptr as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(if_rxring), + "::", + stringify!(rxr_lwm) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rxr_hwm) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(if_rxring), + "::", + stringify!(rxr_hwm) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct if_rxring_info { + pub ifr_name: [::std::os::raw::c_char; 16usize], + pub ifr_size: u_int, + pub ifr_info: if_rxring, +} +#[test] +fn bindgen_test_layout_if_rxring_info() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 40usize, + concat!("Size of: ", stringify!(if_rxring_info)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(if_rxring_info)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifr_name) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(if_rxring_info), + "::", + stringify!(ifr_name) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifr_size) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(if_rxring_info), + "::", + stringify!(ifr_size) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifr_info) as usize - ptr as usize }, + 20usize, + concat!( + "Offset of field: ", + stringify!(if_rxring_info), + "::", + stringify!(ifr_info) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct if_rxrinfo { + pub ifri_total: u_int, + pub ifri_entries: *mut if_rxring_info, +} +#[test] +fn bindgen_test_layout_if_rxrinfo() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(if_rxrinfo)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(if_rxrinfo)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifri_total) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(if_rxrinfo), + "::", + stringify!(ifri_total) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifri_entries) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(if_rxrinfo), + "::", + stringify!(ifri_entries) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct if_data { + pub ifi_type: u_char, + pub ifi_addrlen: u_char, + pub ifi_hdrlen: u_char, + pub ifi_link_state: u_char, + pub ifi_mtu: u_int32_t, + pub ifi_metric: u_int32_t, + pub ifi_rdomain: u_int32_t, + pub ifi_baudrate: u_int64_t, + pub ifi_ipackets: u_int64_t, + pub ifi_ierrors: u_int64_t, + pub ifi_opackets: u_int64_t, + pub ifi_oerrors: u_int64_t, + pub ifi_collisions: u_int64_t, + pub ifi_ibytes: u_int64_t, + pub ifi_obytes: u_int64_t, + pub ifi_imcasts: u_int64_t, + pub ifi_omcasts: u_int64_t, + pub ifi_iqdrops: u_int64_t, + pub ifi_oqdrops: u_int64_t, + pub ifi_noproto: u_int64_t, + pub ifi_capabilities: u_int32_t, + pub ifi_lastchange: timeval, +} +#[test] +fn bindgen_test_layout_if_data() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 144usize, + concat!("Size of: ", stringify!(if_data)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(if_data)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifi_type) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(if_data), + "::", + stringify!(ifi_type) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifi_addrlen) as usize - ptr as usize }, + 1usize, + concat!( + "Offset of field: ", + stringify!(if_data), + "::", + stringify!(ifi_addrlen) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifi_hdrlen) as usize - ptr as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(if_data), + "::", + stringify!(ifi_hdrlen) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifi_link_state) as usize - ptr as usize }, + 3usize, + concat!( + "Offset of field: ", + stringify!(if_data), + "::", + stringify!(ifi_link_state) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifi_mtu) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(if_data), + "::", + stringify!(ifi_mtu) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifi_metric) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(if_data), + "::", + stringify!(ifi_metric) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifi_rdomain) as usize - ptr as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(if_data), + "::", + stringify!(ifi_rdomain) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifi_baudrate) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(if_data), + "::", + stringify!(ifi_baudrate) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifi_ipackets) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(if_data), + "::", + stringify!(ifi_ipackets) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifi_ierrors) as usize - ptr as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(if_data), + "::", + stringify!(ifi_ierrors) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifi_opackets) as usize - ptr as usize }, + 40usize, + concat!( + "Offset of field: ", + stringify!(if_data), + "::", + stringify!(ifi_opackets) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifi_oerrors) as usize - ptr as usize }, + 48usize, + concat!( + "Offset of field: ", + stringify!(if_data), + "::", + stringify!(ifi_oerrors) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifi_collisions) as usize - ptr as usize }, + 56usize, + concat!( + "Offset of field: ", + stringify!(if_data), + "::", + stringify!(ifi_collisions) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifi_ibytes) as usize - ptr as usize }, + 64usize, + concat!( + "Offset of field: ", + stringify!(if_data), + "::", + stringify!(ifi_ibytes) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifi_obytes) as usize - ptr as usize }, + 72usize, + concat!( + "Offset of field: ", + stringify!(if_data), + "::", + stringify!(ifi_obytes) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifi_imcasts) as usize - ptr as usize }, + 80usize, + concat!( + "Offset of field: ", + stringify!(if_data), + "::", + stringify!(ifi_imcasts) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifi_omcasts) as usize - ptr as usize }, + 88usize, + concat!( + "Offset of field: ", + stringify!(if_data), + "::", + stringify!(ifi_omcasts) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifi_iqdrops) as usize - ptr as usize }, + 96usize, + concat!( + "Offset of field: ", + stringify!(if_data), + "::", + stringify!(ifi_iqdrops) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifi_oqdrops) as usize - ptr as usize }, + 104usize, + concat!( + "Offset of field: ", + stringify!(if_data), + "::", + stringify!(ifi_oqdrops) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifi_noproto) as usize - ptr as usize }, + 112usize, + concat!( + "Offset of field: ", + stringify!(if_data), + "::", + stringify!(ifi_noproto) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifi_capabilities) as usize - ptr as usize }, + 120usize, + concat!( + "Offset of field: ", + stringify!(if_data), + "::", + stringify!(ifi_capabilities) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifi_lastchange) as usize - ptr as usize }, + 128usize, + concat!( + "Offset of field: ", + stringify!(if_data), + "::", + stringify!(ifi_lastchange) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct if_status_description { + pub ifs_type: u_char, + pub ifs_state: u_char, + pub ifs_string: *const ::std::os::raw::c_char, +} +#[test] +fn bindgen_test_layout_if_status_description() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(if_status_description)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(if_status_description)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifs_type) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(if_status_description), + "::", + stringify!(ifs_type) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifs_state) as usize - ptr as usize }, + 1usize, + concat!( + "Offset of field: ", + stringify!(if_status_description), + "::", + stringify!(ifs_state) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifs_string) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(if_status_description), + "::", + stringify!(ifs_string) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct if_msghdr { + pub ifm_msglen: u_short, + pub ifm_version: u_char, + pub ifm_type: u_char, + pub ifm_hdrlen: u_short, + pub ifm_index: u_short, + pub ifm_tableid: u_short, + pub ifm_pad1: u_char, + pub ifm_pad2: u_char, + pub ifm_addrs: ::std::os::raw::c_int, + pub ifm_flags: ::std::os::raw::c_int, + pub ifm_xflags: ::std::os::raw::c_int, + pub ifm_data: if_data, +} +#[test] +fn bindgen_test_layout_if_msghdr() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 168usize, + concat!("Size of: ", stringify!(if_msghdr)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(if_msghdr)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifm_msglen) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(if_msghdr), + "::", + stringify!(ifm_msglen) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifm_version) as usize - ptr as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(if_msghdr), + "::", + stringify!(ifm_version) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifm_type) as usize - ptr as usize }, + 3usize, + concat!( + "Offset of field: ", + stringify!(if_msghdr), + "::", + stringify!(ifm_type) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifm_hdrlen) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(if_msghdr), + "::", + stringify!(ifm_hdrlen) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifm_index) as usize - ptr as usize }, + 6usize, + concat!( + "Offset of field: ", + stringify!(if_msghdr), + "::", + stringify!(ifm_index) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifm_tableid) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(if_msghdr), + "::", + stringify!(ifm_tableid) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifm_pad1) as usize - ptr as usize }, + 10usize, + concat!( + "Offset of field: ", + stringify!(if_msghdr), + "::", + stringify!(ifm_pad1) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifm_pad2) as usize - ptr as usize }, + 11usize, + concat!( + "Offset of field: ", + stringify!(if_msghdr), + "::", + stringify!(ifm_pad2) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifm_addrs) as usize - ptr as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(if_msghdr), + "::", + stringify!(ifm_addrs) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifm_flags) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(if_msghdr), + "::", + stringify!(ifm_flags) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifm_xflags) as usize - ptr as usize }, + 20usize, + concat!( + "Offset of field: ", + stringify!(if_msghdr), + "::", + stringify!(ifm_xflags) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifm_data) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(if_msghdr), + "::", + stringify!(ifm_data) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct ifa_msghdr { + pub ifam_msglen: u_short, + pub ifam_version: u_char, + pub ifam_type: u_char, + pub ifam_hdrlen: u_short, + pub ifam_index: u_short, + pub ifam_tableid: u_short, + pub ifam_pad1: u_char, + pub ifam_pad2: u_char, + pub ifam_addrs: ::std::os::raw::c_int, + pub ifam_flags: ::std::os::raw::c_int, + pub ifam_metric: ::std::os::raw::c_int, +} +#[test] +fn bindgen_test_layout_ifa_msghdr() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 24usize, + concat!("Size of: ", stringify!(ifa_msghdr)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(ifa_msghdr)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifam_msglen) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(ifa_msghdr), + "::", + stringify!(ifam_msglen) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifam_version) as usize - ptr as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(ifa_msghdr), + "::", + stringify!(ifam_version) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifam_type) as usize - ptr as usize }, + 3usize, + concat!( + "Offset of field: ", + stringify!(ifa_msghdr), + "::", + stringify!(ifam_type) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifam_hdrlen) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(ifa_msghdr), + "::", + stringify!(ifam_hdrlen) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifam_index) as usize - ptr as usize }, + 6usize, + concat!( + "Offset of field: ", + stringify!(ifa_msghdr), + "::", + stringify!(ifam_index) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifam_tableid) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(ifa_msghdr), + "::", + stringify!(ifam_tableid) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifam_pad1) as usize - ptr as usize }, + 10usize, + concat!( + "Offset of field: ", + stringify!(ifa_msghdr), + "::", + stringify!(ifam_pad1) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifam_pad2) as usize - ptr as usize }, + 11usize, + concat!( + "Offset of field: ", + stringify!(ifa_msghdr), + "::", + stringify!(ifam_pad2) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifam_addrs) as usize - ptr as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(ifa_msghdr), + "::", + stringify!(ifam_addrs) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifam_flags) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(ifa_msghdr), + "::", + stringify!(ifam_flags) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifam_metric) as usize - ptr as usize }, + 20usize, + concat!( + "Offset of field: ", + stringify!(ifa_msghdr), + "::", + stringify!(ifam_metric) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct if_announcemsghdr { + pub ifan_msglen: u_short, + pub ifan_version: u_char, + pub ifan_type: u_char, + pub ifan_hdrlen: u_short, + pub ifan_index: u_short, + pub ifan_what: u_short, + pub ifan_name: [::std::os::raw::c_char; 16usize], +} +#[test] +fn bindgen_test_layout_if_announcemsghdr() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 26usize, + concat!("Size of: ", stringify!(if_announcemsghdr)) + ); + assert_eq!( + ::std::mem::align_of::(), + 2usize, + concat!("Alignment of ", stringify!(if_announcemsghdr)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifan_msglen) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(if_announcemsghdr), + "::", + stringify!(ifan_msglen) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifan_version) as usize - ptr as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(if_announcemsghdr), + "::", + stringify!(ifan_version) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifan_type) as usize - ptr as usize }, + 3usize, + concat!( + "Offset of field: ", + stringify!(if_announcemsghdr), + "::", + stringify!(ifan_type) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifan_hdrlen) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(if_announcemsghdr), + "::", + stringify!(ifan_hdrlen) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifan_index) as usize - ptr as usize }, + 6usize, + concat!( + "Offset of field: ", + stringify!(if_announcemsghdr), + "::", + stringify!(ifan_index) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifan_what) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(if_announcemsghdr), + "::", + stringify!(ifan_what) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifan_name) as usize - ptr as usize }, + 10usize, + concat!( + "Offset of field: ", + stringify!(if_announcemsghdr), + "::", + stringify!(ifan_name) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct if_ieee80211_data { + pub ifie_channel: u8, + pub ifie_nwid_len: u8, + pub ifie_flags: u32, + pub ifie_xflags: u32, + pub ifie_nwid: [u8; 32usize], + pub ifie_addr: [u8; 6usize], +} +#[test] +fn bindgen_test_layout_if_ieee80211_data() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 52usize, + concat!("Size of: ", stringify!(if_ieee80211_data)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(if_ieee80211_data)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifie_channel) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(if_ieee80211_data), + "::", + stringify!(ifie_channel) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifie_nwid_len) as usize - ptr as usize }, + 1usize, + concat!( + "Offset of field: ", + stringify!(if_ieee80211_data), + "::", + stringify!(ifie_nwid_len) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifie_flags) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(if_ieee80211_data), + "::", + stringify!(ifie_flags) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifie_xflags) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(if_ieee80211_data), + "::", + stringify!(ifie_xflags) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifie_nwid) as usize - ptr as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(if_ieee80211_data), + "::", + stringify!(ifie_nwid) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifie_addr) as usize - ptr as usize }, + 44usize, + concat!( + "Offset of field: ", + stringify!(if_ieee80211_data), + "::", + stringify!(ifie_addr) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct if_ieee80211_msghdr { + pub ifim_msglen: u16, + pub ifim_version: u8, + pub ifim_type: u8, + pub ifim_hdrlen: u16, + pub ifim_index: u16, + pub ifim_tableid: u16, + pub ifim_ifie: if_ieee80211_data, +} +#[test] +fn bindgen_test_layout_if_ieee80211_msghdr() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 64usize, + concat!("Size of: ", stringify!(if_ieee80211_msghdr)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(if_ieee80211_msghdr)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifim_msglen) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(if_ieee80211_msghdr), + "::", + stringify!(ifim_msglen) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifim_version) as usize - ptr as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(if_ieee80211_msghdr), + "::", + stringify!(ifim_version) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifim_type) as usize - ptr as usize }, + 3usize, + concat!( + "Offset of field: ", + stringify!(if_ieee80211_msghdr), + "::", + stringify!(ifim_type) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifim_hdrlen) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(if_ieee80211_msghdr), + "::", + stringify!(ifim_hdrlen) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifim_index) as usize - ptr as usize }, + 6usize, + concat!( + "Offset of field: ", + stringify!(if_ieee80211_msghdr), + "::", + stringify!(ifim_index) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifim_tableid) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(if_ieee80211_msghdr), + "::", + stringify!(ifim_tableid) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifim_ifie) as usize - ptr as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(if_ieee80211_msghdr), + "::", + stringify!(ifim_ifie) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct if_nameindex_msg { + pub if_index: ::std::os::raw::c_uint, + pub if_name: [::std::os::raw::c_char; 16usize], +} +#[test] +fn bindgen_test_layout_if_nameindex_msg() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 20usize, + concat!("Size of: ", stringify!(if_nameindex_msg)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(if_nameindex_msg)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).if_index) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(if_nameindex_msg), + "::", + stringify!(if_index) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).if_name) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(if_nameindex_msg), + "::", + stringify!(if_name) + ) + ); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct ifg_req { + pub ifgrq_ifgrqu: ifg_req__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union ifg_req__bindgen_ty_1 { + pub ifgrqu_group: [::std::os::raw::c_char; 16usize], + pub ifgrqu_member: [::std::os::raw::c_char; 16usize], +} +#[test] +fn bindgen_test_layout_ifg_req__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(ifg_req__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 1usize, + concat!("Alignment of ", stringify!(ifg_req__bindgen_ty_1)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifgrqu_group) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(ifg_req__bindgen_ty_1), + "::", + stringify!(ifgrqu_group) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifgrqu_member) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(ifg_req__bindgen_ty_1), + "::", + stringify!(ifgrqu_member) + ) + ); +} +#[test] +fn bindgen_test_layout_ifg_req() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(ifg_req)) + ); + assert_eq!( + ::std::mem::align_of::(), + 1usize, + concat!("Alignment of ", stringify!(ifg_req)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifgrq_ifgrqu) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(ifg_req), + "::", + stringify!(ifgrq_ifgrqu) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct ifg_attrib { + pub ifg_carp_demoted: ::std::os::raw::c_int, +} +#[test] +fn bindgen_test_layout_ifg_attrib() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 4usize, + concat!("Size of: ", stringify!(ifg_attrib)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(ifg_attrib)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifg_carp_demoted) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(ifg_attrib), + "::", + stringify!(ifg_carp_demoted) + ) + ); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct ifgroupreq { + pub ifgr_name: [::std::os::raw::c_char; 16usize], + pub ifgr_len: u_int, + pub ifgr_ifgru: ifgroupreq__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union ifgroupreq__bindgen_ty_1 { + pub ifgru_group: [::std::os::raw::c_char; 16usize], + pub ifgru_groups: *mut ifg_req, + pub ifgru_attrib: ifg_attrib, +} +#[test] +fn bindgen_test_layout_ifgroupreq__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(ifgroupreq__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(ifgroupreq__bindgen_ty_1)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifgru_group) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(ifgroupreq__bindgen_ty_1), + "::", + stringify!(ifgru_group) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifgru_groups) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(ifgroupreq__bindgen_ty_1), + "::", + stringify!(ifgru_groups) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifgru_attrib) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(ifgroupreq__bindgen_ty_1), + "::", + stringify!(ifgru_attrib) + ) + ); +} +#[test] +fn bindgen_test_layout_ifgroupreq() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 40usize, + concat!("Size of: ", stringify!(ifgroupreq)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(ifgroupreq)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifgr_name) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(ifgroupreq), + "::", + stringify!(ifgr_name) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifgr_len) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(ifgroupreq), + "::", + stringify!(ifgr_len) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifgr_ifgru) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(ifgroupreq), + "::", + stringify!(ifgr_ifgru) + ) + ); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct ifreq { + pub ifr_name: [::std::os::raw::c_char; 16usize], + pub ifr_ifru: ifreq__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union ifreq__bindgen_ty_1 { + pub ifru_addr: sockaddr, + pub ifru_dstaddr: sockaddr, + pub ifru_broadaddr: sockaddr, + pub ifru_flags: ::std::os::raw::c_short, + pub ifru_metric: ::std::os::raw::c_int, + pub ifru_vnetid: i64, + pub ifru_media: u64, + pub ifru_data: caddr_t, + pub ifru_index: ::std::os::raw::c_uint, +} +#[test] +fn bindgen_test_layout_ifreq__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(ifreq__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(ifreq__bindgen_ty_1)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifru_addr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(ifreq__bindgen_ty_1), + "::", + stringify!(ifru_addr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifru_dstaddr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(ifreq__bindgen_ty_1), + "::", + stringify!(ifru_dstaddr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifru_broadaddr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(ifreq__bindgen_ty_1), + "::", + stringify!(ifru_broadaddr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifru_flags) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(ifreq__bindgen_ty_1), + "::", + stringify!(ifru_flags) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifru_metric) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(ifreq__bindgen_ty_1), + "::", + stringify!(ifru_metric) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifru_vnetid) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(ifreq__bindgen_ty_1), + "::", + stringify!(ifru_vnetid) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifru_media) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(ifreq__bindgen_ty_1), + "::", + stringify!(ifru_media) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifru_data) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(ifreq__bindgen_ty_1), + "::", + stringify!(ifru_data) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifru_index) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(ifreq__bindgen_ty_1), + "::", + stringify!(ifru_index) + ) + ); +} +#[test] +fn bindgen_test_layout_ifreq() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 32usize, + concat!("Size of: ", stringify!(ifreq)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(ifreq)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifr_name) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(ifreq), + "::", + stringify!(ifr_name) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifr_ifru) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(ifreq), + "::", + stringify!(ifr_ifru) + ) + ); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct ifaliasreq { + pub ifra_name: [::std::os::raw::c_char; 16usize], + pub ifra_ifrau: ifaliasreq__bindgen_ty_1, + pub ifra_dstaddr: sockaddr, + pub ifra_mask: sockaddr, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union ifaliasreq__bindgen_ty_1 { + pub ifrau_addr: sockaddr, + pub ifrau_align: ::std::os::raw::c_int, +} +#[test] +fn bindgen_test_layout_ifaliasreq__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(ifaliasreq__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(ifaliasreq__bindgen_ty_1)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifrau_addr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(ifaliasreq__bindgen_ty_1), + "::", + stringify!(ifrau_addr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifrau_align) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(ifaliasreq__bindgen_ty_1), + "::", + stringify!(ifrau_align) + ) + ); +} +#[test] +fn bindgen_test_layout_ifaliasreq() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 64usize, + concat!("Size of: ", stringify!(ifaliasreq)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(ifaliasreq)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifra_name) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(ifaliasreq), + "::", + stringify!(ifra_name) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifra_ifrau) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(ifaliasreq), + "::", + stringify!(ifra_ifrau) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifra_dstaddr) as usize - ptr as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(ifaliasreq), + "::", + stringify!(ifra_dstaddr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifra_mask) as usize - ptr as usize }, + 48usize, + concat!( + "Offset of field: ", + stringify!(ifaliasreq), + "::", + stringify!(ifra_mask) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct ifmediareq { + pub ifm_name: [::std::os::raw::c_char; 16usize], + pub ifm_current: u64, + pub ifm_mask: u64, + pub ifm_status: u64, + pub ifm_active: u64, + pub ifm_count: ::std::os::raw::c_int, + pub ifm_ulist: *mut u64, +} +#[test] +fn bindgen_test_layout_ifmediareq() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 64usize, + concat!("Size of: ", stringify!(ifmediareq)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(ifmediareq)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifm_name) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(ifmediareq), + "::", + stringify!(ifm_name) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifm_current) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(ifmediareq), + "::", + stringify!(ifm_current) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifm_mask) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(ifmediareq), + "::", + stringify!(ifm_mask) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifm_status) as usize - ptr as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(ifmediareq), + "::", + stringify!(ifm_status) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifm_active) as usize - ptr as usize }, + 40usize, + concat!( + "Offset of field: ", + stringify!(ifmediareq), + "::", + stringify!(ifm_active) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifm_count) as usize - ptr as usize }, + 48usize, + concat!( + "Offset of field: ", + stringify!(ifmediareq), + "::", + stringify!(ifm_count) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifm_ulist) as usize - ptr as usize }, + 56usize, + concat!( + "Offset of field: ", + stringify!(ifmediareq), + "::", + stringify!(ifm_ulist) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct ifkalivereq { + pub ikar_name: [::std::os::raw::c_char; 16usize], + pub ikar_timeo: ::std::os::raw::c_int, + pub ikar_cnt: ::std::os::raw::c_int, +} +#[test] +fn bindgen_test_layout_ifkalivereq() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 24usize, + concat!("Size of: ", stringify!(ifkalivereq)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(ifkalivereq)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ikar_name) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(ifkalivereq), + "::", + stringify!(ikar_name) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ikar_timeo) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(ifkalivereq), + "::", + stringify!(ikar_timeo) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ikar_cnt) as usize - ptr as usize }, + 20usize, + concat!( + "Offset of field: ", + stringify!(ifkalivereq), + "::", + stringify!(ikar_cnt) + ) + ); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct ifconf { + pub ifc_len: ::std::os::raw::c_int, + pub ifc_ifcu: ifconf__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union ifconf__bindgen_ty_1 { + pub ifcu_buf: caddr_t, + pub ifcu_req: *mut ifreq, +} +#[test] +fn bindgen_test_layout_ifconf__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(ifconf__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(ifconf__bindgen_ty_1)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifcu_buf) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(ifconf__bindgen_ty_1), + "::", + stringify!(ifcu_buf) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifcu_req) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(ifconf__bindgen_ty_1), + "::", + stringify!(ifcu_req) + ) + ); +} +#[test] +fn bindgen_test_layout_ifconf() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(ifconf)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(ifconf)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifc_len) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(ifconf), + "::", + stringify!(ifc_len) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifc_ifcu) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(ifconf), + "::", + stringify!(ifc_ifcu) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct if_laddrreq { + pub iflr_name: [::std::os::raw::c_char; 16usize], + pub flags: ::std::os::raw::c_uint, + pub prefixlen: ::std::os::raw::c_uint, + pub addr: sockaddr_storage, + pub dstaddr: sockaddr_storage, +} +#[test] +fn bindgen_test_layout_if_laddrreq() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 536usize, + concat!("Size of: ", stringify!(if_laddrreq)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(if_laddrreq)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).iflr_name) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(if_laddrreq), + "::", + stringify!(iflr_name) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(if_laddrreq), + "::", + stringify!(flags) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).prefixlen) as usize - ptr as usize }, + 20usize, + concat!( + "Offset of field: ", + stringify!(if_laddrreq), + "::", + stringify!(prefixlen) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).addr) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(if_laddrreq), + "::", + stringify!(addr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).dstaddr) as usize - ptr as usize }, + 280usize, + concat!( + "Offset of field: ", + stringify!(if_laddrreq), + "::", + stringify!(dstaddr) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct if_afreq { + pub ifar_name: [::std::os::raw::c_char; 16usize], + pub ifar_af: sa_family_t, +} +#[test] +fn bindgen_test_layout_if_afreq() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 17usize, + concat!("Size of: ", stringify!(if_afreq)) + ); + assert_eq!( + ::std::mem::align_of::(), + 1usize, + concat!("Alignment of ", stringify!(if_afreq)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifar_name) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(if_afreq), + "::", + stringify!(ifar_name) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifar_af) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(if_afreq), + "::", + stringify!(ifar_af) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct if_parent { + pub ifp_name: [::std::os::raw::c_char; 16usize], + pub ifp_parent: [::std::os::raw::c_char; 16usize], +} +#[test] +fn bindgen_test_layout_if_parent() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 32usize, + concat!("Size of: ", stringify!(if_parent)) + ); + assert_eq!( + ::std::mem::align_of::(), + 1usize, + concat!("Alignment of ", stringify!(if_parent)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifp_name) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(if_parent), + "::", + stringify!(ifp_name) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifp_parent) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(if_parent), + "::", + stringify!(ifp_parent) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct if_sffpage { + pub sff_ifname: [::std::os::raw::c_char; 16usize], + pub sff_addr: u8, + pub sff_page: u8, + pub sff_data: [u8; 256usize], +} +#[test] +fn bindgen_test_layout_if_sffpage() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 274usize, + concat!("Size of: ", stringify!(if_sffpage)) + ); + assert_eq!( + ::std::mem::align_of::(), + 1usize, + concat!("Alignment of ", stringify!(if_sffpage)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).sff_ifname) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(if_sffpage), + "::", + stringify!(sff_ifname) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).sff_addr) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(if_sffpage), + "::", + stringify!(sff_addr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).sff_page) as usize - ptr as usize }, + 17usize, + concat!( + "Offset of field: ", + stringify!(if_sffpage), + "::", + stringify!(sff_page) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).sff_data) as usize - ptr as usize }, + 18usize, + concat!( + "Offset of field: ", + stringify!(if_sffpage), + "::", + stringify!(sff_data) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct arphdr { + pub ar_hrd: u_int16_t, + pub ar_pro: u_int16_t, + pub ar_hln: u_int8_t, + pub ar_pln: u_int8_t, + pub ar_op: u_int16_t, +} +#[test] +fn bindgen_test_layout_arphdr() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(arphdr)) + ); + assert_eq!( + ::std::mem::align_of::(), + 2usize, + concat!("Alignment of ", stringify!(arphdr)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ar_hrd) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(arphdr), + "::", + stringify!(ar_hrd) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ar_pro) as usize - ptr as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(arphdr), + "::", + stringify!(ar_pro) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ar_hln) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(arphdr), + "::", + stringify!(ar_hln) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ar_pln) as usize - ptr as usize }, + 5usize, + concat!( + "Offset of field: ", + stringify!(arphdr), + "::", + stringify!(ar_pln) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ar_op) as usize - ptr as usize }, + 6usize, + concat!( + "Offset of field: ", + stringify!(arphdr), + "::", + stringify!(ar_op) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct arpreq { + pub arp_pa: sockaddr, + pub arp_ha: sockaddr, + pub arp_flags: ::std::os::raw::c_int, +} +#[test] +fn bindgen_test_layout_arpreq() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 36usize, + concat!("Size of: ", stringify!(arpreq)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(arpreq)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).arp_pa) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(arpreq), + "::", + stringify!(arp_pa) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).arp_ha) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(arpreq), + "::", + stringify!(arp_ha) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).arp_flags) as usize - ptr as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(arpreq), + "::", + stringify!(arp_flags) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct rb_type { + pub t_compare: ::std::option::Option< + unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_void, + arg2: *const ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, + pub t_augment: ::std::option::Option, + pub t_offset: ::std::os::raw::c_uint, +} +#[test] +fn bindgen_test_layout_rb_type() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 24usize, + concat!("Size of: ", stringify!(rb_type)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(rb_type)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).t_compare) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rb_type), + "::", + stringify!(t_compare) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).t_augment) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rb_type), + "::", + stringify!(t_augment) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).t_offset) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(rb_type), + "::", + stringify!(t_offset) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct rb_tree { + pub rbt_root: *mut rb_entry, +} +#[test] +fn bindgen_test_layout_rb_tree() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(rb_tree)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(rb_tree)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rbt_root) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rb_tree), + "::", + stringify!(rbt_root) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct rb_entry { + pub rbt_parent: *mut rb_entry, + pub rbt_left: *mut rb_entry, + pub rbt_right: *mut rb_entry, + pub rbt_color: ::std::os::raw::c_uint, +} +#[test] +fn bindgen_test_layout_rb_entry() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 32usize, + concat!("Size of: ", stringify!(rb_entry)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(rb_entry)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rbt_parent) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rb_entry), + "::", + stringify!(rbt_parent) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rbt_left) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rb_entry), + "::", + stringify!(rbt_left) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rbt_right) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(rb_entry), + "::", + stringify!(rbt_right) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rbt_color) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(rb_entry), + "::", + stringify!(rbt_color) + ) + ); +} +extern "C" { + pub fn _rb_insert( + arg1: *const rb_type, + arg2: *mut rb_tree, + arg3: *mut ::std::os::raw::c_void, + ) -> *mut ::std::os::raw::c_void; +} +extern "C" { + pub fn _rb_remove( + arg1: *const rb_type, + arg2: *mut rb_tree, + arg3: *mut ::std::os::raw::c_void, + ) -> *mut ::std::os::raw::c_void; +} +extern "C" { + pub fn _rb_find( + arg1: *const rb_type, + arg2: *mut rb_tree, + arg3: *const ::std::os::raw::c_void, + ) -> *mut ::std::os::raw::c_void; +} +extern "C" { + pub fn _rb_nfind( + arg1: *const rb_type, + arg2: *mut rb_tree, + arg3: *const ::std::os::raw::c_void, + ) -> *mut ::std::os::raw::c_void; +} +extern "C" { + pub fn _rb_root(arg1: *const rb_type, arg2: *mut rb_tree) -> *mut ::std::os::raw::c_void; +} +extern "C" { + pub fn _rb_min(arg1: *const rb_type, arg2: *mut rb_tree) -> *mut ::std::os::raw::c_void; +} +extern "C" { + pub fn _rb_max(arg1: *const rb_type, arg2: *mut rb_tree) -> *mut ::std::os::raw::c_void; +} +extern "C" { + pub fn _rb_next( + arg1: *const rb_type, + arg2: *mut ::std::os::raw::c_void, + ) -> *mut ::std::os::raw::c_void; +} +extern "C" { + pub fn _rb_prev( + arg1: *const rb_type, + arg2: *mut ::std::os::raw::c_void, + ) -> *mut ::std::os::raw::c_void; +} +extern "C" { + pub fn _rb_left( + arg1: *const rb_type, + arg2: *mut ::std::os::raw::c_void, + ) -> *mut ::std::os::raw::c_void; +} +extern "C" { + pub fn _rb_right( + arg1: *const rb_type, + arg2: *mut ::std::os::raw::c_void, + ) -> *mut ::std::os::raw::c_void; +} +extern "C" { + pub fn _rb_parent( + arg1: *const rb_type, + arg2: *mut ::std::os::raw::c_void, + ) -> *mut ::std::os::raw::c_void; +} +extern "C" { + pub fn _rb_set_left( + arg1: *const rb_type, + arg2: *mut ::std::os::raw::c_void, + arg3: *mut ::std::os::raw::c_void, + ); +} +extern "C" { + pub fn _rb_set_right( + arg1: *const rb_type, + arg2: *mut ::std::os::raw::c_void, + arg3: *mut ::std::os::raw::c_void, + ); +} +extern "C" { + pub fn _rb_set_parent( + arg1: *const rb_type, + arg2: *mut ::std::os::raw::c_void, + arg3: *mut ::std::os::raw::c_void, + ); +} +extern "C" { + pub fn _rb_poison( + arg1: *const rb_type, + arg2: *mut ::std::os::raw::c_void, + arg3: ::std::os::raw::c_ulong, + ); +} +extern "C" { + pub fn _rb_check( + arg1: *const rb_type, + arg2: *mut ::std::os::raw::c_void, + arg3: ::std::os::raw::c_ulong, + ) -> ::std::os::raw::c_int; +} +pub const lock_class_index_LO_CLASS_KERNEL_LOCK: lock_class_index = 0; +pub const lock_class_index_LO_CLASS_SCHED_LOCK: lock_class_index = 1; +pub const lock_class_index_LO_CLASS_MUTEX: lock_class_index = 2; +pub const lock_class_index_LO_CLASS_RWLOCK: lock_class_index = 3; +pub const lock_class_index_LO_CLASS_RRWLOCK: lock_class_index = 4; +pub type lock_class_index = ::std::os::raw::c_uint; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct lock_object { + pub lo_type: *const lock_type, + pub lo_name: *const ::std::os::raw::c_char, + pub lo_witness: *mut witness, + pub lo_flags: ::std::os::raw::c_uint, +} +#[test] +fn bindgen_test_layout_lock_object() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 32usize, + concat!("Size of: ", stringify!(lock_object)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(lock_object)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).lo_type) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(lock_object), + "::", + stringify!(lo_type) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).lo_name) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(lock_object), + "::", + stringify!(lo_name) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).lo_witness) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(lock_object), + "::", + stringify!(lo_witness) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).lo_flags) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(lock_object), + "::", + stringify!(lo_flags) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct lock_type { + pub lt_name: *const ::std::os::raw::c_char, +} +#[test] +fn bindgen_test_layout_lock_type() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(lock_type)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(lock_type)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).lt_name) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(lock_type), + "::", + stringify!(lt_name) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct proc_ { + _unused: [u8; 0], +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct rwlock { + pub rwl_owner: ::std::os::raw::c_ulong, + pub rwl_name: *const ::std::os::raw::c_char, +} +#[test] +fn bindgen_test_layout_rwlock() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(rwlock)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(rwlock)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rwl_owner) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rwlock), + "::", + stringify!(rwl_owner) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rwl_name) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rwlock), + "::", + stringify!(rwl_name) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct rrwlock { + pub rrwl_lock: rwlock, + pub rrwl_wcnt: u32, +} +#[test] +fn bindgen_test_layout_rrwlock() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 24usize, + concat!("Size of: ", stringify!(rrwlock)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(rrwlock)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rrwl_lock) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rrwlock), + "::", + stringify!(rrwl_lock) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rrwl_wcnt) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(rrwlock), + "::", + stringify!(rrwl_wcnt) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct refcnt { + pub r_refs: ::std::os::raw::c_uint, + pub r_traceidx: ::std::os::raw::c_int, +} +#[test] +fn bindgen_test_layout_refcnt() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(refcnt)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(refcnt)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).r_refs) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(refcnt), + "::", + stringify!(r_refs) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).r_traceidx) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(refcnt), + "::", + stringify!(r_traceidx) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct circq { + pub next: *mut circq, + pub prev: *mut circq, +} +#[test] +fn bindgen_test_layout_circq() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(circq)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(circq)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).next) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(circq), + "::", + stringify!(next) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).prev) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(circq), + "::", + stringify!(prev) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct timeout { + pub to_list: circq, + pub to_abstime: timespec, + pub to_func: ::std::option::Option, + pub to_arg: *mut ::std::os::raw::c_void, + pub to_process: *mut process, + pub to_time: ::std::os::raw::c_int, + pub to_flags: ::std::os::raw::c_int, + pub to_kclock: ::std::os::raw::c_int, +} +#[test] +fn bindgen_test_layout_timeout() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 72usize, + concat!("Size of: ", stringify!(timeout)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(timeout)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).to_list) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(timeout), + "::", + stringify!(to_list) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).to_abstime) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(timeout), + "::", + stringify!(to_abstime) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).to_func) as usize - ptr as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(timeout), + "::", + stringify!(to_func) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).to_arg) as usize - ptr as usize }, + 40usize, + concat!( + "Offset of field: ", + stringify!(timeout), + "::", + stringify!(to_arg) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).to_process) as usize - ptr as usize }, + 48usize, + concat!( + "Offset of field: ", + stringify!(timeout), + "::", + stringify!(to_process) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).to_time) as usize - ptr as usize }, + 56usize, + concat!( + "Offset of field: ", + stringify!(timeout), + "::", + stringify!(to_time) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).to_flags) as usize - ptr as usize }, + 60usize, + concat!( + "Offset of field: ", + stringify!(timeout), + "::", + stringify!(to_flags) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).to_kclock) as usize - ptr as usize }, + 64usize, + concat!( + "Offset of field: ", + stringify!(timeout), + "::", + stringify!(to_kclock) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct timeoutstat { + pub tos_added: u64, + pub tos_cancelled: u64, + pub tos_deleted: u64, + pub tos_late: u64, + pub tos_pending: u64, + pub tos_readded: u64, + pub tos_rescheduled: u64, + pub tos_run_softclock: u64, + pub tos_run_thread: u64, + pub tos_scheduled: u64, + pub tos_softclocks: u64, + pub tos_thread_wakeups: u64, +} +#[test] +fn bindgen_test_layout_timeoutstat() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 96usize, + concat!("Size of: ", stringify!(timeoutstat)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(timeoutstat)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).tos_added) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(timeoutstat), + "::", + stringify!(tos_added) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).tos_cancelled) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(timeoutstat), + "::", + stringify!(tos_cancelled) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).tos_deleted) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(timeoutstat), + "::", + stringify!(tos_deleted) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).tos_late) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(timeoutstat), + "::", + stringify!(tos_late) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).tos_pending) as usize - ptr as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(timeoutstat), + "::", + stringify!(tos_pending) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).tos_readded) as usize - ptr as usize }, + 40usize, + concat!( + "Offset of field: ", + stringify!(timeoutstat), + "::", + stringify!(tos_readded) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).tos_rescheduled) as usize - ptr as usize }, + 48usize, + concat!( + "Offset of field: ", + stringify!(timeoutstat), + "::", + stringify!(tos_rescheduled) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).tos_run_softclock) as usize - ptr as usize }, + 56usize, + concat!( + "Offset of field: ", + stringify!(timeoutstat), + "::", + stringify!(tos_run_softclock) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).tos_run_thread) as usize - ptr as usize }, + 64usize, + concat!( + "Offset of field: ", + stringify!(timeoutstat), + "::", + stringify!(tos_run_thread) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).tos_scheduled) as usize - ptr as usize }, + 72usize, + concat!( + "Offset of field: ", + stringify!(timeoutstat), + "::", + stringify!(tos_scheduled) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).tos_softclocks) as usize - ptr as usize }, + 80usize, + concat!( + "Offset of field: ", + stringify!(timeoutstat), + "::", + stringify!(tos_softclocks) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).tos_thread_wakeups) as usize - ptr as usize }, + 88usize, + concat!( + "Offset of field: ", + stringify!(timeoutstat), + "::", + stringify!(tos_thread_wakeups) + ) + ); +} +pub type in_addr_t = __in_addr_t; +pub type in_port_t = __in_port_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct in_addr { + pub s_addr: in_addr_t, +} +#[test] +fn bindgen_test_layout_in_addr() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 4usize, + concat!("Size of: ", stringify!(in_addr)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(in_addr)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).s_addr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(in_addr), + "::", + stringify!(s_addr) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct sockaddr_in { + pub sin_len: u_int8_t, + pub sin_family: sa_family_t, + pub sin_port: in_port_t, + pub sin_addr: in_addr, + pub sin_zero: [i8; 8usize], +} +#[test] +fn bindgen_test_layout_sockaddr_in() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(sockaddr_in)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(sockaddr_in)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).sin_len) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(sockaddr_in), + "::", + stringify!(sin_len) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).sin_family) as usize - ptr as usize }, + 1usize, + concat!( + "Offset of field: ", + stringify!(sockaddr_in), + "::", + stringify!(sin_family) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).sin_port) as usize - ptr as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(sockaddr_in), + "::", + stringify!(sin_port) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).sin_addr) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(sockaddr_in), + "::", + stringify!(sin_addr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).sin_zero) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(sockaddr_in), + "::", + stringify!(sin_zero) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct ip_opts { + pub ip_dst: in_addr, + pub ip_opts: [i8; 40usize], +} +#[test] +fn bindgen_test_layout_ip_opts() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 44usize, + concat!("Size of: ", stringify!(ip_opts)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(ip_opts)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ip_dst) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(ip_opts), + "::", + stringify!(ip_dst) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ip_opts) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(ip_opts), + "::", + stringify!(ip_opts) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct ip_mreq { + pub imr_multiaddr: in_addr, + pub imr_interface: in_addr, +} +#[test] +fn bindgen_test_layout_ip_mreq() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(ip_mreq)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(ip_mreq)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).imr_multiaddr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(ip_mreq), + "::", + stringify!(imr_multiaddr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).imr_interface) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(ip_mreq), + "::", + stringify!(imr_interface) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct ip_mreqn { + pub imr_multiaddr: in_addr, + pub imr_address: in_addr, + pub imr_ifindex: ::std::os::raw::c_int, +} +#[test] +fn bindgen_test_layout_ip_mreqn() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 12usize, + concat!("Size of: ", stringify!(ip_mreqn)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(ip_mreqn)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).imr_multiaddr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(ip_mreqn), + "::", + stringify!(imr_multiaddr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).imr_address) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(ip_mreqn), + "::", + stringify!(imr_address) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).imr_ifindex) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(ip_mreqn), + "::", + stringify!(imr_ifindex) + ) + ); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct in6_addr { + pub __u6_addr: in6_addr__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union in6_addr__bindgen_ty_1 { + pub __u6_addr8: [u_int8_t; 16usize], + pub __u6_addr16: [u_int16_t; 8usize], + pub __u6_addr32: [u_int32_t; 4usize], +} +#[test] +fn bindgen_test_layout_in6_addr__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(in6_addr__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(in6_addr__bindgen_ty_1)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).__u6_addr8) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(in6_addr__bindgen_ty_1), + "::", + stringify!(__u6_addr8) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).__u6_addr16) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(in6_addr__bindgen_ty_1), + "::", + stringify!(__u6_addr16) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).__u6_addr32) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(in6_addr__bindgen_ty_1), + "::", + stringify!(__u6_addr32) + ) + ); +} +#[test] +fn bindgen_test_layout_in6_addr() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(in6_addr)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(in6_addr)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).__u6_addr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(in6_addr), + "::", + stringify!(__u6_addr) + ) + ); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct sockaddr_in6 { + pub sin6_len: u_int8_t, + pub sin6_family: sa_family_t, + pub sin6_port: in_port_t, + pub sin6_flowinfo: u_int32_t, + pub sin6_addr: in6_addr, + pub sin6_scope_id: u_int32_t, +} +#[test] +fn bindgen_test_layout_sockaddr_in6() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 28usize, + concat!("Size of: ", stringify!(sockaddr_in6)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(sockaddr_in6)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).sin6_len) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(sockaddr_in6), + "::", + stringify!(sin6_len) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).sin6_family) as usize - ptr as usize }, + 1usize, + concat!( + "Offset of field: ", + stringify!(sockaddr_in6), + "::", + stringify!(sin6_family) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).sin6_port) as usize - ptr as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(sockaddr_in6), + "::", + stringify!(sin6_port) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).sin6_flowinfo) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(sockaddr_in6), + "::", + stringify!(sin6_flowinfo) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).sin6_addr) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(sockaddr_in6), + "::", + stringify!(sin6_addr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).sin6_scope_id) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(sockaddr_in6), + "::", + stringify!(sin6_scope_id) + ) + ); +} +extern "C" { + pub static in6addr_any: in6_addr; +} +extern "C" { + pub static in6addr_loopback: in6_addr; +} +extern "C" { + pub static in6addr_intfacelocal_allnodes: in6_addr; +} +extern "C" { + pub static in6addr_linklocal_allnodes: in6_addr; +} +extern "C" { + pub static in6addr_linklocal_allrouters: in6_addr; +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct ipv6_mreq { + pub ipv6mr_multiaddr: in6_addr, + pub ipv6mr_interface: ::std::os::raw::c_uint, +} +#[test] +fn bindgen_test_layout_ipv6_mreq() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 20usize, + concat!("Size of: ", stringify!(ipv6_mreq)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(ipv6_mreq)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ipv6mr_multiaddr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(ipv6_mreq), + "::", + stringify!(ipv6mr_multiaddr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ipv6mr_interface) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(ipv6_mreq), + "::", + stringify!(ipv6mr_interface) + ) + ); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct in6_pktinfo { + pub ipi6_addr: in6_addr, + pub ipi6_ifindex: ::std::os::raw::c_uint, +} +#[test] +fn bindgen_test_layout_in6_pktinfo() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 20usize, + concat!("Size of: ", stringify!(in6_pktinfo)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(in6_pktinfo)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ipi6_addr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(in6_pktinfo), + "::", + stringify!(ipi6_addr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ipi6_ifindex) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(in6_pktinfo), + "::", + stringify!(ipi6_ifindex) + ) + ); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct ip6_mtuinfo { + pub ip6m_addr: sockaddr_in6, + pub ip6m_mtu: u_int32_t, +} +#[test] +fn bindgen_test_layout_ip6_mtuinfo() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 32usize, + concat!("Size of: ", stringify!(ip6_mtuinfo)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(ip6_mtuinfo)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ip6m_addr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(ip6_mtuinfo), + "::", + stringify!(ip6m_addr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ip6m_mtu) as usize - ptr as usize }, + 28usize, + concat!( + "Offset of field: ", + stringify!(ip6_mtuinfo), + "::", + stringify!(ip6m_mtu) + ) + ); +} +extern "C" { + pub fn inet6_opt_init( + arg1: *mut ::std::os::raw::c_void, + arg2: socklen_t, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn inet6_opt_append( + arg1: *mut ::std::os::raw::c_void, + arg2: socklen_t, + arg3: ::std::os::raw::c_int, + arg4: u_int8_t, + arg5: socklen_t, + arg6: u_int8_t, + arg7: *mut *mut ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn inet6_opt_finish( + arg1: *mut ::std::os::raw::c_void, + arg2: socklen_t, + arg3: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn inet6_opt_set_val( + arg1: *mut ::std::os::raw::c_void, + arg2: ::std::os::raw::c_int, + arg3: *mut ::std::os::raw::c_void, + arg4: socklen_t, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn inet6_opt_next( + arg1: *mut ::std::os::raw::c_void, + arg2: socklen_t, + arg3: ::std::os::raw::c_int, + arg4: *mut u_int8_t, + arg5: *mut socklen_t, + arg6: *mut *mut ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn inet6_opt_find( + arg1: *mut ::std::os::raw::c_void, + arg2: socklen_t, + arg3: ::std::os::raw::c_int, + arg4: u_int8_t, + arg5: *mut socklen_t, + arg6: *mut *mut ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn inet6_opt_get_val( + arg1: *mut ::std::os::raw::c_void, + arg2: ::std::os::raw::c_int, + arg3: *mut ::std::os::raw::c_void, + arg4: socklen_t, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn inet6_rth_space(arg1: ::std::os::raw::c_int, arg2: ::std::os::raw::c_int) -> socklen_t; +} +extern "C" { + pub fn inet6_rth_init( + arg1: *mut ::std::os::raw::c_void, + arg2: socklen_t, + arg3: ::std::os::raw::c_int, + arg4: ::std::os::raw::c_int, + ) -> *mut ::std::os::raw::c_void; +} +extern "C" { + pub fn inet6_rth_add( + arg1: *mut ::std::os::raw::c_void, + arg2: *const in6_addr, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn inet6_rth_reverse( + arg1: *const ::std::os::raw::c_void, + arg2: *mut ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn inet6_rth_segments(arg1: *const ::std::os::raw::c_void) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn inet6_rth_getaddr( + arg1: *const ::std::os::raw::c_void, + arg2: ::std::os::raw::c_int, + ) -> *mut in6_addr; +} +extern "C" { + pub fn bindresvport( + arg1: ::std::os::raw::c_int, + arg2: *mut sockaddr_in, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn bindresvport_sa( + arg1: ::std::os::raw::c_int, + arg2: *mut sockaddr, + ) -> ::std::os::raw::c_int; +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct radix_node { + pub rn_mklist: *mut radix_mask, + pub rn_p: *mut radix_node, + pub rn_b: ::std::os::raw::c_short, + pub rn_bmask: ::std::os::raw::c_char, + pub rn_flags: u_char, + pub rn_u: radix_node__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union radix_node__bindgen_ty_1 { + pub rn_leaf: radix_node__bindgen_ty_1__bindgen_ty_1, + pub rn_node: radix_node__bindgen_ty_1__bindgen_ty_2, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct radix_node__bindgen_ty_1__bindgen_ty_1 { + pub rn_Key: caddr_t, + pub rn_Mask: caddr_t, + pub rn_Dupedkey: *mut radix_node, +} +#[test] +fn bindgen_test_layout_radix_node__bindgen_ty_1__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 24usize, + concat!( + "Size of: ", + stringify!(radix_node__bindgen_ty_1__bindgen_ty_1) + ) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!( + "Alignment of ", + stringify!(radix_node__bindgen_ty_1__bindgen_ty_1) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rn_Key) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(radix_node__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(rn_Key) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rn_Mask) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(radix_node__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(rn_Mask) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rn_Dupedkey) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(radix_node__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(rn_Dupedkey) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct radix_node__bindgen_ty_1__bindgen_ty_2 { + pub rn_Off: ::std::os::raw::c_int, + pub rn_L: *mut radix_node, + pub rn_R: *mut radix_node, +} +#[test] +fn bindgen_test_layout_radix_node__bindgen_ty_1__bindgen_ty_2() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 24usize, + concat!( + "Size of: ", + stringify!(radix_node__bindgen_ty_1__bindgen_ty_2) + ) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!( + "Alignment of ", + stringify!(radix_node__bindgen_ty_1__bindgen_ty_2) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rn_Off) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(radix_node__bindgen_ty_1__bindgen_ty_2), + "::", + stringify!(rn_Off) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rn_L) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(radix_node__bindgen_ty_1__bindgen_ty_2), + "::", + stringify!(rn_L) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rn_R) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(radix_node__bindgen_ty_1__bindgen_ty_2), + "::", + stringify!(rn_R) + ) + ); +} +#[test] +fn bindgen_test_layout_radix_node__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 24usize, + concat!("Size of: ", stringify!(radix_node__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(radix_node__bindgen_ty_1)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rn_leaf) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(radix_node__bindgen_ty_1), + "::", + stringify!(rn_leaf) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rn_node) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(radix_node__bindgen_ty_1), + "::", + stringify!(rn_node) + ) + ); +} +#[test] +fn bindgen_test_layout_radix_node() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 48usize, + concat!("Size of: ", stringify!(radix_node)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(radix_node)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rn_mklist) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(radix_node), + "::", + stringify!(rn_mklist) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rn_p) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(radix_node), + "::", + stringify!(rn_p) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rn_b) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(radix_node), + "::", + stringify!(rn_b) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rn_bmask) as usize - ptr as usize }, + 18usize, + concat!( + "Offset of field: ", + stringify!(radix_node), + "::", + stringify!(rn_bmask) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rn_flags) as usize - ptr as usize }, + 19usize, + concat!( + "Offset of field: ", + stringify!(radix_node), + "::", + stringify!(rn_flags) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rn_u) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(radix_node), + "::", + stringify!(rn_u) + ) + ); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct radix_mask { + pub rm_b: ::std::os::raw::c_short, + pub rm_unused: ::std::os::raw::c_char, + pub rm_flags: u_char, + pub rm_mklist: *mut radix_mask, + pub rm_rmu: radix_mask__bindgen_ty_1, + pub rm_refs: ::std::os::raw::c_int, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union radix_mask__bindgen_ty_1 { + pub rmu_mask: caddr_t, + pub rmu_leaf: *mut radix_node, +} +#[test] +fn bindgen_test_layout_radix_mask__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(radix_mask__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(radix_mask__bindgen_ty_1)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rmu_mask) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(radix_mask__bindgen_ty_1), + "::", + stringify!(rmu_mask) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rmu_leaf) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(radix_mask__bindgen_ty_1), + "::", + stringify!(rmu_leaf) + ) + ); +} +#[test] +fn bindgen_test_layout_radix_mask() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 32usize, + concat!("Size of: ", stringify!(radix_mask)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(radix_mask)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rm_b) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(radix_mask), + "::", + stringify!(rm_b) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rm_unused) as usize - ptr as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(radix_mask), + "::", + stringify!(rm_unused) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rm_flags) as usize - ptr as usize }, + 3usize, + concat!( + "Offset of field: ", + stringify!(radix_mask), + "::", + stringify!(rm_flags) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rm_mklist) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(radix_mask), + "::", + stringify!(rm_mklist) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rm_rmu) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(radix_mask), + "::", + stringify!(rm_rmu) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rm_refs) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(radix_mask), + "::", + stringify!(rm_refs) + ) + ); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct radix_node_head { + pub rnh_treetop: *mut radix_node, + pub rnh_addrsize: ::std::os::raw::c_int, + pub rnh_pktsize: ::std::os::raw::c_int, + pub rnh_nodes: [radix_node; 3usize], + pub rnh_rtableid: u_int, +} +#[test] +fn bindgen_test_layout_radix_node_head() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 168usize, + concat!("Size of: ", stringify!(radix_node_head)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(radix_node_head)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rnh_treetop) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(radix_node_head), + "::", + stringify!(rnh_treetop) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rnh_addrsize) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(radix_node_head), + "::", + stringify!(rnh_addrsize) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rnh_pktsize) as usize - ptr as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(radix_node_head), + "::", + stringify!(rnh_pktsize) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rnh_nodes) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(radix_node_head), + "::", + stringify!(rnh_nodes) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rnh_rtableid) as usize - ptr as usize }, + 160usize, + concat!( + "Offset of field: ", + stringify!(radix_node_head), + "::", + stringify!(rnh_rtableid) + ) + ); +} +extern "C" { + pub fn rn_init(arg1: ::std::os::raw::c_uint); +} +extern "C" { + pub fn rn_inithead( + arg1: *mut *mut ::std::os::raw::c_void, + arg2: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn rn_walktree( + arg1: *mut radix_node_head, + arg2: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut radix_node, + arg2: *mut ::std::os::raw::c_void, + arg3: u_int, + ) -> ::std::os::raw::c_int, + >, + arg3: *mut ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn rn_addroute( + arg1: *mut ::std::os::raw::c_void, + arg2: *mut ::std::os::raw::c_void, + arg3: *mut radix_node_head, + arg4: *mut radix_node, + arg5: u_int8_t, + ) -> *mut radix_node; +} +extern "C" { + pub fn rn_delete( + arg1: *mut ::std::os::raw::c_void, + arg2: *mut ::std::os::raw::c_void, + arg3: *mut radix_node_head, + arg4: *mut radix_node, + ) -> *mut radix_node; +} +extern "C" { + pub fn rn_lookup( + arg1: *mut ::std::os::raw::c_void, + arg2: *mut ::std::os::raw::c_void, + arg3: *mut radix_node_head, + ) -> *mut radix_node; +} +extern "C" { + pub fn rn_match( + arg1: *mut ::std::os::raw::c_void, + arg2: *mut radix_node_head, + ) -> *mut radix_node; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct rt_metrics { + pub rmx_pksent: u_int64_t, + pub rmx_expire: i64, + pub rmx_locks: u_int, + pub rmx_mtu: u_int, + pub rmx_refcnt: u_int, + pub rmx_hopcount: u_int, + pub rmx_recvpipe: u_int, + pub rmx_sendpipe: u_int, + pub rmx_ssthresh: u_int, + pub rmx_rtt: u_int, + pub rmx_rttvar: u_int, + pub rmx_pad: u_int, +} +#[test] +fn bindgen_test_layout_rt_metrics() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 56usize, + concat!("Size of: ", stringify!(rt_metrics)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(rt_metrics)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rmx_pksent) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rt_metrics), + "::", + stringify!(rmx_pksent) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rmx_expire) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rt_metrics), + "::", + stringify!(rmx_expire) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rmx_locks) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(rt_metrics), + "::", + stringify!(rmx_locks) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rmx_mtu) as usize - ptr as usize }, + 20usize, + concat!( + "Offset of field: ", + stringify!(rt_metrics), + "::", + stringify!(rmx_mtu) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rmx_refcnt) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(rt_metrics), + "::", + stringify!(rmx_refcnt) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rmx_hopcount) as usize - ptr as usize }, + 28usize, + concat!( + "Offset of field: ", + stringify!(rt_metrics), + "::", + stringify!(rmx_hopcount) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rmx_recvpipe) as usize - ptr as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(rt_metrics), + "::", + stringify!(rmx_recvpipe) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rmx_sendpipe) as usize - ptr as usize }, + 36usize, + concat!( + "Offset of field: ", + stringify!(rt_metrics), + "::", + stringify!(rmx_sendpipe) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rmx_ssthresh) as usize - ptr as usize }, + 40usize, + concat!( + "Offset of field: ", + stringify!(rt_metrics), + "::", + stringify!(rmx_ssthresh) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rmx_rtt) as usize - ptr as usize }, + 44usize, + concat!( + "Offset of field: ", + stringify!(rt_metrics), + "::", + stringify!(rmx_rtt) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rmx_rttvar) as usize - ptr as usize }, + 48usize, + concat!( + "Offset of field: ", + stringify!(rt_metrics), + "::", + stringify!(rmx_rttvar) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rmx_pad) as usize - ptr as usize }, + 52usize, + concat!( + "Offset of field: ", + stringify!(rt_metrics), + "::", + stringify!(rmx_pad) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct rtstat { + pub rts_badredirect: u_int32_t, + pub rts_dynamic: u_int32_t, + pub rts_newgateway: u_int32_t, + pub rts_unreach: u_int32_t, + pub rts_wildcard: u_int32_t, +} +#[test] +fn bindgen_test_layout_rtstat() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 20usize, + concat!("Size of: ", stringify!(rtstat)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(rtstat)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rts_badredirect) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rtstat), + "::", + stringify!(rts_badredirect) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rts_dynamic) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(rtstat), + "::", + stringify!(rts_dynamic) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rts_newgateway) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rtstat), + "::", + stringify!(rts_newgateway) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rts_unreach) as usize - ptr as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(rtstat), + "::", + stringify!(rts_unreach) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rts_wildcard) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(rtstat), + "::", + stringify!(rts_wildcard) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct rt_tableinfo { + pub rti_tableid: u_short, + pub rti_domainid: u_short, +} +#[test] +fn bindgen_test_layout_rt_tableinfo() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 4usize, + concat!("Size of: ", stringify!(rt_tableinfo)) + ); + assert_eq!( + ::std::mem::align_of::(), + 2usize, + concat!("Alignment of ", stringify!(rt_tableinfo)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rti_tableid) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rt_tableinfo), + "::", + stringify!(rti_tableid) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rti_domainid) as usize - ptr as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(rt_tableinfo), + "::", + stringify!(rti_domainid) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct rt_msghdr { + pub rtm_msglen: u_short, + pub rtm_version: u_char, + pub rtm_type: u_char, + pub rtm_hdrlen: u_short, + pub rtm_index: u_short, + pub rtm_tableid: u_short, + pub rtm_priority: u_char, + pub rtm_mpls: u_char, + pub rtm_addrs: ::std::os::raw::c_int, + pub rtm_flags: ::std::os::raw::c_int, + pub rtm_fmask: ::std::os::raw::c_int, + pub rtm_pid: pid_t, + pub rtm_seq: ::std::os::raw::c_int, + pub rtm_errno: ::std::os::raw::c_int, + pub rtm_inits: u_int, + pub rtm_rmx: rt_metrics, +} +#[test] +fn bindgen_test_layout_rt_msghdr() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 96usize, + concat!("Size of: ", stringify!(rt_msghdr)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(rt_msghdr)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rtm_msglen) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rt_msghdr), + "::", + stringify!(rtm_msglen) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rtm_version) as usize - ptr as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(rt_msghdr), + "::", + stringify!(rtm_version) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rtm_type) as usize - ptr as usize }, + 3usize, + concat!( + "Offset of field: ", + stringify!(rt_msghdr), + "::", + stringify!(rtm_type) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rtm_hdrlen) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(rt_msghdr), + "::", + stringify!(rtm_hdrlen) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rtm_index) as usize - ptr as usize }, + 6usize, + concat!( + "Offset of field: ", + stringify!(rt_msghdr), + "::", + stringify!(rtm_index) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rtm_tableid) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rt_msghdr), + "::", + stringify!(rtm_tableid) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rtm_priority) as usize - ptr as usize }, + 10usize, + concat!( + "Offset of field: ", + stringify!(rt_msghdr), + "::", + stringify!(rtm_priority) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rtm_mpls) as usize - ptr as usize }, + 11usize, + concat!( + "Offset of field: ", + stringify!(rt_msghdr), + "::", + stringify!(rtm_mpls) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rtm_addrs) as usize - ptr as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(rt_msghdr), + "::", + stringify!(rtm_addrs) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rtm_flags) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(rt_msghdr), + "::", + stringify!(rtm_flags) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rtm_fmask) as usize - ptr as usize }, + 20usize, + concat!( + "Offset of field: ", + stringify!(rt_msghdr), + "::", + stringify!(rtm_fmask) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rtm_pid) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(rt_msghdr), + "::", + stringify!(rtm_pid) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rtm_seq) as usize - ptr as usize }, + 28usize, + concat!( + "Offset of field: ", + stringify!(rt_msghdr), + "::", + stringify!(rtm_seq) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rtm_errno) as usize - ptr as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(rt_msghdr), + "::", + stringify!(rtm_errno) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rtm_inits) as usize - ptr as usize }, + 36usize, + concat!( + "Offset of field: ", + stringify!(rt_msghdr), + "::", + stringify!(rtm_inits) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rtm_rmx) as usize - ptr as usize }, + 40usize, + concat!( + "Offset of field: ", + stringify!(rt_msghdr), + "::", + stringify!(rtm_rmx) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct sockaddr_rtlabel { + pub sr_len: u_int8_t, + pub sr_family: sa_family_t, + pub sr_label: [::std::os::raw::c_char; 32usize], +} +#[test] +fn bindgen_test_layout_sockaddr_rtlabel() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 34usize, + concat!("Size of: ", stringify!(sockaddr_rtlabel)) + ); + assert_eq!( + ::std::mem::align_of::(), + 1usize, + concat!("Alignment of ", stringify!(sockaddr_rtlabel)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).sr_len) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(sockaddr_rtlabel), + "::", + stringify!(sr_len) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).sr_family) as usize - ptr as usize }, + 1usize, + concat!( + "Offset of field: ", + stringify!(sockaddr_rtlabel), + "::", + stringify!(sr_family) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).sr_label) as usize - ptr as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(sockaddr_rtlabel), + "::", + stringify!(sr_label) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct sockaddr_rtdns { + pub sr_len: u_int8_t, + pub sr_family: sa_family_t, + pub sr_dns: [::std::os::raw::c_char; 128usize], +} +#[test] +fn bindgen_test_layout_sockaddr_rtdns() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 130usize, + concat!("Size of: ", stringify!(sockaddr_rtdns)) + ); + assert_eq!( + ::std::mem::align_of::(), + 1usize, + concat!("Alignment of ", stringify!(sockaddr_rtdns)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).sr_len) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(sockaddr_rtdns), + "::", + stringify!(sr_len) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).sr_family) as usize - ptr as usize }, + 1usize, + concat!( + "Offset of field: ", + stringify!(sockaddr_rtdns), + "::", + stringify!(sr_family) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).sr_dns) as usize - ptr as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(sockaddr_rtdns), + "::", + stringify!(sr_dns) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct sockaddr_rtstatic { + pub sr_len: u_int8_t, + pub sr_family: sa_family_t, + pub sr_static: [::std::os::raw::c_char; 128usize], +} +#[test] +fn bindgen_test_layout_sockaddr_rtstatic() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 130usize, + concat!("Size of: ", stringify!(sockaddr_rtstatic)) + ); + assert_eq!( + ::std::mem::align_of::(), + 1usize, + concat!("Alignment of ", stringify!(sockaddr_rtstatic)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).sr_len) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(sockaddr_rtstatic), + "::", + stringify!(sr_len) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).sr_family) as usize - ptr as usize }, + 1usize, + concat!( + "Offset of field: ", + stringify!(sockaddr_rtstatic), + "::", + stringify!(sr_family) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).sr_static) as usize - ptr as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(sockaddr_rtstatic), + "::", + stringify!(sr_static) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct sockaddr_rtsearch { + pub sr_len: u_int8_t, + pub sr_family: sa_family_t, + pub sr_search: [::std::os::raw::c_char; 128usize], +} +#[test] +fn bindgen_test_layout_sockaddr_rtsearch() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 130usize, + concat!("Size of: ", stringify!(sockaddr_rtsearch)) + ); + assert_eq!( + ::std::mem::align_of::(), + 1usize, + concat!("Alignment of ", stringify!(sockaddr_rtsearch)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).sr_len) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(sockaddr_rtsearch), + "::", + stringify!(sr_len) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).sr_family) as usize - ptr as usize }, + 1usize, + concat!( + "Offset of field: ", + stringify!(sockaddr_rtsearch), + "::", + stringify!(sr_family) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).sr_search) as usize - ptr as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(sockaddr_rtsearch), + "::", + stringify!(sr_search) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct rt_addrinfo { + pub rti_addrs: ::std::os::raw::c_int, + pub rti_info: [*const sockaddr; 15usize], + pub rti_flags: ::std::os::raw::c_int, + pub rti_ifa: *mut ifaddr, + pub rti_rtm: *mut rt_msghdr, + pub rti_mpls: u_char, +} +#[test] +fn bindgen_test_layout_rt_addrinfo() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 160usize, + concat!("Size of: ", stringify!(rt_addrinfo)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(rt_addrinfo)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rti_addrs) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(rt_addrinfo), + "::", + stringify!(rti_addrs) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rti_info) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(rt_addrinfo), + "::", + stringify!(rti_info) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rti_flags) as usize - ptr as usize }, + 128usize, + concat!( + "Offset of field: ", + stringify!(rt_addrinfo), + "::", + stringify!(rti_flags) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rti_ifa) as usize - ptr as usize }, + 136usize, + concat!( + "Offset of field: ", + stringify!(rt_addrinfo), + "::", + stringify!(rti_ifa) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rti_rtm) as usize - ptr as usize }, + 144usize, + concat!( + "Offset of field: ", + stringify!(rt_addrinfo), + "::", + stringify!(rti_rtm) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rti_mpls) as usize - ptr as usize }, + 152usize, + concat!( + "Offset of field: ", + stringify!(rt_addrinfo), + "::", + stringify!(rti_mpls) + ) + ); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct route { + pub ro_rt: *mut rtentry, + pub ro_generation: u_long, + pub ro_tableid: u_long, + pub __bindgen_anon_1: route__bindgen_ty_1, + pub __bindgen_anon_2: route__bindgen_ty_2, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union route__bindgen_ty_1 { + pub ro_dstsa: sockaddr, + pub ro_dstsin: sockaddr_in, + pub ro_dstsin6: sockaddr_in6, +} +#[test] +fn bindgen_test_layout_route__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 28usize, + concat!("Size of: ", stringify!(route__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(route__bindgen_ty_1)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ro_dstsa) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(route__bindgen_ty_1), + "::", + stringify!(ro_dstsa) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ro_dstsin) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(route__bindgen_ty_1), + "::", + stringify!(ro_dstsin) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ro_dstsin6) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(route__bindgen_ty_1), + "::", + stringify!(ro_dstsin6) + ) + ); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union route__bindgen_ty_2 { + pub ro_srcin: in_addr, + pub ro_srcin6: in6_addr, +} +#[test] +fn bindgen_test_layout_route__bindgen_ty_2() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(route__bindgen_ty_2)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(route__bindgen_ty_2)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ro_srcin) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(route__bindgen_ty_2), + "::", + stringify!(ro_srcin) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ro_srcin6) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(route__bindgen_ty_2), + "::", + stringify!(ro_srcin6) + ) + ); +} +#[test] +fn bindgen_test_layout_route() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 72usize, + concat!("Size of: ", stringify!(route)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(route)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ro_rt) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(route), + "::", + stringify!(ro_rt) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ro_generation) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(route), + "::", + stringify!(ro_generation) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ro_tableid) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(route), + "::", + stringify!(ro_tableid) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct ip { + _unused: [u8; 0], +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct ip6_hdr { + _unused: [u8; 0], +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct mbuf_list { + _unused: [u8; 0], +} +pub type pf_refcnt_t = refcnt; +pub const PF_INOUT: _bindgen_ty_1 = 0; +pub const PF_IN: _bindgen_ty_1 = 1; +pub const PF_OUT: _bindgen_ty_1 = 2; +pub const PF_FWD: _bindgen_ty_1 = 3; +pub type _bindgen_ty_1 = ::std::os::raw::c_uint; +pub const PF_PASS: _bindgen_ty_2 = 0; +pub const PF_DROP: _bindgen_ty_2 = 1; +pub const PF_SCRUB: _bindgen_ty_2 = 2; +pub const PF_NOSCRUB: _bindgen_ty_2 = 3; +pub const PF_NAT: _bindgen_ty_2 = 4; +pub const PF_NONAT: _bindgen_ty_2 = 5; +pub const PF_BINAT: _bindgen_ty_2 = 6; +pub const PF_NOBINAT: _bindgen_ty_2 = 7; +pub const PF_RDR: _bindgen_ty_2 = 8; +pub const PF_NORDR: _bindgen_ty_2 = 9; +pub const PF_SYNPROXY_DROP: _bindgen_ty_2 = 10; +pub const PF_DEFER: _bindgen_ty_2 = 11; +pub const PF_MATCH: _bindgen_ty_2 = 12; +pub const PF_DIVERT: _bindgen_ty_2 = 13; +pub const PF_RT: _bindgen_ty_2 = 14; +pub const PF_AFRT: _bindgen_ty_2 = 15; +pub type _bindgen_ty_2 = ::std::os::raw::c_uint; +pub const PF_TRANS_RULESET: _bindgen_ty_3 = 0; +pub const PF_TRANS_TABLE: _bindgen_ty_3 = 1; +pub type _bindgen_ty_3 = ::std::os::raw::c_uint; +pub const PF_OP_NONE: _bindgen_ty_4 = 0; +pub const PF_OP_IRG: _bindgen_ty_4 = 1; +pub const PF_OP_EQ: _bindgen_ty_4 = 2; +pub const PF_OP_NE: _bindgen_ty_4 = 3; +pub const PF_OP_LT: _bindgen_ty_4 = 4; +pub const PF_OP_LE: _bindgen_ty_4 = 5; +pub const PF_OP_GT: _bindgen_ty_4 = 6; +pub const PF_OP_GE: _bindgen_ty_4 = 7; +pub const PF_OP_XRG: _bindgen_ty_4 = 8; +pub const PF_OP_RRG: _bindgen_ty_4 = 9; +pub type _bindgen_ty_4 = ::std::os::raw::c_uint; +pub const PF_CHANGE_NONE: _bindgen_ty_5 = 0; +pub const PF_CHANGE_ADD_HEAD: _bindgen_ty_5 = 1; +pub const PF_CHANGE_ADD_TAIL: _bindgen_ty_5 = 2; +pub const PF_CHANGE_ADD_BEFORE: _bindgen_ty_5 = 3; +pub const PF_CHANGE_ADD_AFTER: _bindgen_ty_5 = 4; +pub const PF_CHANGE_REMOVE: _bindgen_ty_5 = 5; +pub const PF_CHANGE_GET_TICKET: _bindgen_ty_5 = 6; +pub type _bindgen_ty_5 = ::std::os::raw::c_uint; +pub const PF_GET_NONE: _bindgen_ty_6 = 0; +pub const PF_GET_CLR_CNTR: _bindgen_ty_6 = 1; +pub type _bindgen_ty_6 = ::std::os::raw::c_uint; +pub const PF_SK_WIRE: _bindgen_ty_7 = 0; +pub const PF_SK_STACK: _bindgen_ty_7 = 1; +pub const PF_SK_BOTH: _bindgen_ty_7 = 2; +pub type _bindgen_ty_7 = ::std::os::raw::c_uint; +pub const PF_PEER_SRC: _bindgen_ty_8 = 0; +pub const PF_PEER_DST: _bindgen_ty_8 = 1; +pub const PF_PEER_BOTH: _bindgen_ty_8 = 2; +pub type _bindgen_ty_8 = ::std::os::raw::c_uint; +pub const PFTM_TCP_FIRST_PACKET: _bindgen_ty_9 = 0; +pub const PFTM_TCP_OPENING: _bindgen_ty_9 = 1; +pub const PFTM_TCP_ESTABLISHED: _bindgen_ty_9 = 2; +pub const PFTM_TCP_CLOSING: _bindgen_ty_9 = 3; +pub const PFTM_TCP_FIN_WAIT: _bindgen_ty_9 = 4; +pub const PFTM_TCP_CLOSED: _bindgen_ty_9 = 5; +pub const PFTM_UDP_FIRST_PACKET: _bindgen_ty_9 = 6; +pub const PFTM_UDP_SINGLE: _bindgen_ty_9 = 7; +pub const PFTM_UDP_MULTIPLE: _bindgen_ty_9 = 8; +pub const PFTM_ICMP_FIRST_PACKET: _bindgen_ty_9 = 9; +pub const PFTM_ICMP_ERROR_REPLY: _bindgen_ty_9 = 10; +pub const PFTM_OTHER_FIRST_PACKET: _bindgen_ty_9 = 11; +pub const PFTM_OTHER_SINGLE: _bindgen_ty_9 = 12; +pub const PFTM_OTHER_MULTIPLE: _bindgen_ty_9 = 13; +pub const PFTM_FRAG: _bindgen_ty_9 = 14; +pub const PFTM_INTERVAL: _bindgen_ty_9 = 15; +pub const PFTM_ADAPTIVE_START: _bindgen_ty_9 = 16; +pub const PFTM_ADAPTIVE_END: _bindgen_ty_9 = 17; +pub const PFTM_SRC_NODE: _bindgen_ty_9 = 18; +pub const PFTM_TS_DIFF: _bindgen_ty_9 = 19; +pub const PFTM_MAX: _bindgen_ty_9 = 20; +pub const PFTM_PURGE: _bindgen_ty_9 = 21; +pub const PFTM_UNLINKED: _bindgen_ty_9 = 22; +pub type _bindgen_ty_9 = ::std::os::raw::c_uint; +pub const PF_NOPFROUTE: _bindgen_ty_10 = 0; +pub const PF_ROUTETO: _bindgen_ty_10 = 1; +pub const PF_DUPTO: _bindgen_ty_10 = 2; +pub const PF_REPLYTO: _bindgen_ty_10 = 3; +pub type _bindgen_ty_10 = ::std::os::raw::c_uint; +pub const PF_LIMIT_STATES: _bindgen_ty_11 = 0; +pub const PF_LIMIT_SRC_NODES: _bindgen_ty_11 = 1; +pub const PF_LIMIT_FRAGS: _bindgen_ty_11 = 2; +pub const PF_LIMIT_TABLES: _bindgen_ty_11 = 3; +pub const PF_LIMIT_TABLE_ENTRIES: _bindgen_ty_11 = 4; +pub const PF_LIMIT_PKTDELAY_PKTS: _bindgen_ty_11 = 5; +pub const PF_LIMIT_ANCHORS: _bindgen_ty_11 = 6; +pub const PF_LIMIT_MAX: _bindgen_ty_11 = 7; +pub type _bindgen_ty_11 = ::std::os::raw::c_uint; +pub const PF_POOL_NONE: _bindgen_ty_12 = 0; +pub const PF_POOL_BITMASK: _bindgen_ty_12 = 1; +pub const PF_POOL_RANDOM: _bindgen_ty_12 = 2; +pub const PF_POOL_SRCHASH: _bindgen_ty_12 = 3; +pub const PF_POOL_ROUNDROBIN: _bindgen_ty_12 = 4; +pub const PF_POOL_LEASTSTATES: _bindgen_ty_12 = 5; +pub type _bindgen_ty_12 = ::std::os::raw::c_uint; +pub const PF_ADDR_ADDRMASK: _bindgen_ty_13 = 0; +pub const PF_ADDR_NOROUTE: _bindgen_ty_13 = 1; +pub const PF_ADDR_DYNIFTL: _bindgen_ty_13 = 2; +pub const PF_ADDR_TABLE: _bindgen_ty_13 = 3; +pub const PF_ADDR_RTLABEL: _bindgen_ty_13 = 4; +pub const PF_ADDR_URPFFAILED: _bindgen_ty_13 = 5; +pub const PF_ADDR_RANGE: _bindgen_ty_13 = 6; +pub const PF_ADDR_NONE: _bindgen_ty_13 = 7; +pub type _bindgen_ty_13 = ::std::os::raw::c_uint; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct pf_addr { + pub pfa: pf_addr__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union pf_addr__bindgen_ty_1 { + pub v4: in_addr, + pub v6: in6_addr, + pub addr8: [u_int8_t; 16usize], + pub addr16: [u_int16_t; 8usize], + pub addr32: [u_int32_t; 4usize], +} +#[test] +fn bindgen_test_layout_pf_addr__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(pf_addr__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(pf_addr__bindgen_ty_1)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).v4) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pf_addr__bindgen_ty_1), + "::", + stringify!(v4) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).v6) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pf_addr__bindgen_ty_1), + "::", + stringify!(v6) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).addr8) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pf_addr__bindgen_ty_1), + "::", + stringify!(addr8) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).addr16) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pf_addr__bindgen_ty_1), + "::", + stringify!(addr16) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).addr32) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pf_addr__bindgen_ty_1), + "::", + stringify!(addr32) + ) + ); +} +#[test] +fn bindgen_test_layout_pf_addr() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(pf_addr)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(pf_addr)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfa) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pf_addr), + "::", + stringify!(pfa) + ) + ); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct pf_addr_wrap { + pub v: pf_addr_wrap__bindgen_ty_1, + pub p: pf_addr_wrap__bindgen_ty_2, + pub type_: u_int8_t, + pub iflags: u_int8_t, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union pf_addr_wrap__bindgen_ty_1 { + pub a: pf_addr_wrap__bindgen_ty_1__bindgen_ty_1, + pub ifname: [::std::os::raw::c_char; 16usize], + pub tblname: [::std::os::raw::c_char; 32usize], + pub rtlabelname: [::std::os::raw::c_char; 32usize], + pub rtlabel: u_int32_t, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct pf_addr_wrap__bindgen_ty_1__bindgen_ty_1 { + pub addr: pf_addr, + pub mask: pf_addr, +} +#[test] +fn bindgen_test_layout_pf_addr_wrap__bindgen_ty_1__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 32usize, + concat!( + "Size of: ", + stringify!(pf_addr_wrap__bindgen_ty_1__bindgen_ty_1) + ) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!( + "Alignment of ", + stringify!(pf_addr_wrap__bindgen_ty_1__bindgen_ty_1) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).addr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pf_addr_wrap__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(addr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).mask) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(pf_addr_wrap__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(mask) + ) + ); +} +#[test] +fn bindgen_test_layout_pf_addr_wrap__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 32usize, + concat!("Size of: ", stringify!(pf_addr_wrap__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(pf_addr_wrap__bindgen_ty_1)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).a) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pf_addr_wrap__bindgen_ty_1), + "::", + stringify!(a) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifname) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pf_addr_wrap__bindgen_ty_1), + "::", + stringify!(ifname) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).tblname) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pf_addr_wrap__bindgen_ty_1), + "::", + stringify!(tblname) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rtlabelname) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pf_addr_wrap__bindgen_ty_1), + "::", + stringify!(rtlabelname) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rtlabel) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pf_addr_wrap__bindgen_ty_1), + "::", + stringify!(rtlabel) + ) + ); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union pf_addr_wrap__bindgen_ty_2 { + pub dyn_: *mut pfi_dynaddr, + pub tbl: *mut pfr_ktable, + pub dyncnt: ::std::os::raw::c_int, + pub tblcnt: ::std::os::raw::c_int, +} +#[test] +fn bindgen_test_layout_pf_addr_wrap__bindgen_ty_2() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(pf_addr_wrap__bindgen_ty_2)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(pf_addr_wrap__bindgen_ty_2)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).dyn_) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pf_addr_wrap__bindgen_ty_2), + "::", + stringify!(dyn_) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).tbl) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pf_addr_wrap__bindgen_ty_2), + "::", + stringify!(tbl) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).dyncnt) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pf_addr_wrap__bindgen_ty_2), + "::", + stringify!(dyncnt) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).tblcnt) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pf_addr_wrap__bindgen_ty_2), + "::", + stringify!(tblcnt) + ) + ); +} +#[test] +fn bindgen_test_layout_pf_addr_wrap() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 48usize, + concat!("Size of: ", stringify!(pf_addr_wrap)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(pf_addr_wrap)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).v) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pf_addr_wrap), + "::", + stringify!(v) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).p) as usize - ptr as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(pf_addr_wrap), + "::", + stringify!(p) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).type_) as usize - ptr as usize }, + 40usize, + concat!( + "Offset of field: ", + stringify!(pf_addr_wrap), + "::", + stringify!(type_) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).iflags) as usize - ptr as usize }, + 41usize, + concat!( + "Offset of field: ", + stringify!(pf_addr_wrap), + "::", + stringify!(iflags) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct pf_rule_uid { + pub uid: [uid_t; 2usize], + pub op: u_int8_t, +} +#[test] +fn bindgen_test_layout_pf_rule_uid() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 12usize, + concat!("Size of: ", stringify!(pf_rule_uid)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(pf_rule_uid)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).uid) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pf_rule_uid), + "::", + stringify!(uid) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).op) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(pf_rule_uid), + "::", + stringify!(op) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct pf_rule_gid { + pub gid: [uid_t; 2usize], + pub op: u_int8_t, +} +#[test] +fn bindgen_test_layout_pf_rule_gid() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 12usize, + concat!("Size of: ", stringify!(pf_rule_gid)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(pf_rule_gid)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).gid) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pf_rule_gid), + "::", + stringify!(gid) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).op) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(pf_rule_gid), + "::", + stringify!(op) + ) + ); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct pf_rule_addr { + pub addr: pf_addr_wrap, + pub port: [u_int16_t; 2usize], + pub neg: u_int8_t, + pub port_op: u_int8_t, + pub weight: u_int16_t, +} +#[test] +fn bindgen_test_layout_pf_rule_addr() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 56usize, + concat!("Size of: ", stringify!(pf_rule_addr)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(pf_rule_addr)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).addr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pf_rule_addr), + "::", + stringify!(addr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).port) as usize - ptr as usize }, + 48usize, + concat!( + "Offset of field: ", + stringify!(pf_rule_addr), + "::", + stringify!(port) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).neg) as usize - ptr as usize }, + 52usize, + concat!( + "Offset of field: ", + stringify!(pf_rule_addr), + "::", + stringify!(neg) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).port_op) as usize - ptr as usize }, + 53usize, + concat!( + "Offset of field: ", + stringify!(pf_rule_addr), + "::", + stringify!(port_op) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).weight) as usize - ptr as usize }, + 54usize, + concat!( + "Offset of field: ", + stringify!(pf_rule_addr), + "::", + stringify!(weight) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct pf_threshold { + pub limit: u_int32_t, + pub seconds: u_int32_t, + pub count: u_int32_t, + pub last: u_int32_t, +} +#[test] +fn bindgen_test_layout_pf_threshold() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(pf_threshold)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(pf_threshold)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).limit) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pf_threshold), + "::", + stringify!(limit) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).seconds) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(pf_threshold), + "::", + stringify!(seconds) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).count) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(pf_threshold), + "::", + stringify!(count) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).last) as usize - ptr as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(pf_threshold), + "::", + stringify!(last) + ) + ); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct pf_poolhashkey { + pub pfk: pf_poolhashkey__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union pf_poolhashkey__bindgen_ty_1 { + pub key8: [u_int8_t; 16usize], + pub key16: [u_int16_t; 8usize], + pub key32: [u_int32_t; 4usize], +} +#[test] +fn bindgen_test_layout_pf_poolhashkey__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(pf_poolhashkey__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(pf_poolhashkey__bindgen_ty_1)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).key8) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pf_poolhashkey__bindgen_ty_1), + "::", + stringify!(key8) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).key16) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pf_poolhashkey__bindgen_ty_1), + "::", + stringify!(key16) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).key32) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pf_poolhashkey__bindgen_ty_1), + "::", + stringify!(key32) + ) + ); +} +#[test] +fn bindgen_test_layout_pf_poolhashkey() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(pf_poolhashkey)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(pf_poolhashkey)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfk) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pf_poolhashkey), + "::", + stringify!(pfk) + ) + ); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct pf_pool { + pub addr: pf_addr_wrap, + pub key: pf_poolhashkey, + pub counter: pf_addr, + pub ifname: [::std::os::raw::c_char; 16usize], + pub kif: *mut pfi_kif, + pub tblidx: ::std::os::raw::c_int, + pub states: u_int64_t, + pub curweight: ::std::os::raw::c_int, + pub weight: u_int16_t, + pub proxy_port: [u_int16_t; 2usize], + pub port_op: u_int8_t, + pub opts: u_int8_t, +} +#[test] +fn bindgen_test_layout_pf_pool() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 136usize, + concat!("Size of: ", stringify!(pf_pool)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(pf_pool)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).addr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pf_pool), + "::", + stringify!(addr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).key) as usize - ptr as usize }, + 48usize, + concat!( + "Offset of field: ", + stringify!(pf_pool), + "::", + stringify!(key) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).counter) as usize - ptr as usize }, + 64usize, + concat!( + "Offset of field: ", + stringify!(pf_pool), + "::", + stringify!(counter) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifname) as usize - ptr as usize }, + 80usize, + concat!( + "Offset of field: ", + stringify!(pf_pool), + "::", + stringify!(ifname) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).kif) as usize - ptr as usize }, + 96usize, + concat!( + "Offset of field: ", + stringify!(pf_pool), + "::", + stringify!(kif) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).tblidx) as usize - ptr as usize }, + 104usize, + concat!( + "Offset of field: ", + stringify!(pf_pool), + "::", + stringify!(tblidx) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).states) as usize - ptr as usize }, + 112usize, + concat!( + "Offset of field: ", + stringify!(pf_pool), + "::", + stringify!(states) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).curweight) as usize - ptr as usize }, + 120usize, + concat!( + "Offset of field: ", + stringify!(pf_pool), + "::", + stringify!(curweight) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).weight) as usize - ptr as usize }, + 124usize, + concat!( + "Offset of field: ", + stringify!(pf_pool), + "::", + stringify!(weight) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).proxy_port) as usize - ptr as usize }, + 126usize, + concat!( + "Offset of field: ", + stringify!(pf_pool), + "::", + stringify!(proxy_port) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).port_op) as usize - ptr as usize }, + 130usize, + concat!( + "Offset of field: ", + stringify!(pf_pool), + "::", + stringify!(port_op) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).opts) as usize - ptr as usize }, + 131usize, + concat!( + "Offset of field: ", + stringify!(pf_pool), + "::", + stringify!(opts) + ) + ); +} +pub type pf_osfp_t = u_int32_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct pf_osfp_entry { + pub fp_entry: pf_osfp_entry__bindgen_ty_1, + pub fp_os: pf_osfp_t, + pub fp_enflags: ::std::os::raw::c_int, + pub fp_class_nm: [u_char; 32usize], + pub fp_version_nm: [u_char; 32usize], + pub fp_subtype_nm: [u_char; 32usize], +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct pf_osfp_entry__bindgen_ty_1 { + pub sle_next: *mut pf_osfp_entry, +} +#[test] +fn bindgen_test_layout_pf_osfp_entry__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(pf_osfp_entry__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(pf_osfp_entry__bindgen_ty_1)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).sle_next) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pf_osfp_entry__bindgen_ty_1), + "::", + stringify!(sle_next) + ) + ); +} +#[test] +fn bindgen_test_layout_pf_osfp_entry() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 112usize, + concat!("Size of: ", stringify!(pf_osfp_entry)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(pf_osfp_entry)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).fp_entry) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pf_osfp_entry), + "::", + stringify!(fp_entry) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).fp_os) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(pf_osfp_entry), + "::", + stringify!(fp_os) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).fp_enflags) as usize - ptr as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(pf_osfp_entry), + "::", + stringify!(fp_enflags) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).fp_class_nm) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(pf_osfp_entry), + "::", + stringify!(fp_class_nm) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).fp_version_nm) as usize - ptr as usize }, + 48usize, + concat!( + "Offset of field: ", + stringify!(pf_osfp_entry), + "::", + stringify!(fp_version_nm) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).fp_subtype_nm) as usize - ptr as usize }, + 80usize, + concat!( + "Offset of field: ", + stringify!(pf_osfp_entry), + "::", + stringify!(fp_subtype_nm) + ) + ); +} +pub type pf_tcpopts_t = u_int64_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct pf_os_fingerprint { + pub fp_oses: pf_os_fingerprint_pf_osfp_enlist, + pub fp_tcpopts: pf_tcpopts_t, + pub fp_wsize: u_int16_t, + pub fp_psize: u_int16_t, + pub fp_mss: u_int16_t, + pub fp_flags: u_int16_t, + pub fp_optcnt: u_int8_t, + pub fp_wscale: u_int8_t, + pub fp_ttl: u_int8_t, + pub fp_next: pf_os_fingerprint__bindgen_ty_1, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct pf_os_fingerprint_pf_osfp_enlist { + pub slh_first: *mut pf_osfp_entry, +} +#[test] +fn bindgen_test_layout_pf_os_fingerprint_pf_osfp_enlist() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(pf_os_fingerprint_pf_osfp_enlist)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!( + "Alignment of ", + stringify!(pf_os_fingerprint_pf_osfp_enlist) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).slh_first) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pf_os_fingerprint_pf_osfp_enlist), + "::", + stringify!(slh_first) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct pf_os_fingerprint__bindgen_ty_1 { + pub sle_next: *mut pf_os_fingerprint, +} +#[test] +fn bindgen_test_layout_pf_os_fingerprint__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(pf_os_fingerprint__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(pf_os_fingerprint__bindgen_ty_1)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).sle_next) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pf_os_fingerprint__bindgen_ty_1), + "::", + stringify!(sle_next) + ) + ); +} +#[test] +fn bindgen_test_layout_pf_os_fingerprint() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 40usize, + concat!("Size of: ", stringify!(pf_os_fingerprint)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(pf_os_fingerprint)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).fp_oses) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pf_os_fingerprint), + "::", + stringify!(fp_oses) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).fp_tcpopts) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(pf_os_fingerprint), + "::", + stringify!(fp_tcpopts) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).fp_wsize) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(pf_os_fingerprint), + "::", + stringify!(fp_wsize) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).fp_psize) as usize - ptr as usize }, + 18usize, + concat!( + "Offset of field: ", + stringify!(pf_os_fingerprint), + "::", + stringify!(fp_psize) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).fp_mss) as usize - ptr as usize }, + 20usize, + concat!( + "Offset of field: ", + stringify!(pf_os_fingerprint), + "::", + stringify!(fp_mss) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).fp_flags) as usize - ptr as usize }, + 22usize, + concat!( + "Offset of field: ", + stringify!(pf_os_fingerprint), + "::", + stringify!(fp_flags) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).fp_optcnt) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(pf_os_fingerprint), + "::", + stringify!(fp_optcnt) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).fp_wscale) as usize - ptr as usize }, + 25usize, + concat!( + "Offset of field: ", + stringify!(pf_os_fingerprint), + "::", + stringify!(fp_wscale) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).fp_ttl) as usize - ptr as usize }, + 26usize, + concat!( + "Offset of field: ", + stringify!(pf_os_fingerprint), + "::", + stringify!(fp_ttl) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).fp_next) as usize - ptr as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(pf_os_fingerprint), + "::", + stringify!(fp_next) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct pf_osfp_ioctl { + pub fp_os: pf_osfp_entry, + pub fp_tcpopts: pf_tcpopts_t, + pub fp_wsize: u_int16_t, + pub fp_psize: u_int16_t, + pub fp_mss: u_int16_t, + pub fp_flags: u_int16_t, + pub fp_optcnt: u_int8_t, + pub fp_wscale: u_int8_t, + pub fp_ttl: u_int8_t, + pub fp_getnum: ::std::os::raw::c_int, +} +#[test] +fn bindgen_test_layout_pf_osfp_ioctl() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 136usize, + concat!("Size of: ", stringify!(pf_osfp_ioctl)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(pf_osfp_ioctl)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).fp_os) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pf_osfp_ioctl), + "::", + stringify!(fp_os) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).fp_tcpopts) as usize - ptr as usize }, + 112usize, + concat!( + "Offset of field: ", + stringify!(pf_osfp_ioctl), + "::", + stringify!(fp_tcpopts) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).fp_wsize) as usize - ptr as usize }, + 120usize, + concat!( + "Offset of field: ", + stringify!(pf_osfp_ioctl), + "::", + stringify!(fp_wsize) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).fp_psize) as usize - ptr as usize }, + 122usize, + concat!( + "Offset of field: ", + stringify!(pf_osfp_ioctl), + "::", + stringify!(fp_psize) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).fp_mss) as usize - ptr as usize }, + 124usize, + concat!( + "Offset of field: ", + stringify!(pf_osfp_ioctl), + "::", + stringify!(fp_mss) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).fp_flags) as usize - ptr as usize }, + 126usize, + concat!( + "Offset of field: ", + stringify!(pf_osfp_ioctl), + "::", + stringify!(fp_flags) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).fp_optcnt) as usize - ptr as usize }, + 128usize, + concat!( + "Offset of field: ", + stringify!(pf_osfp_ioctl), + "::", + stringify!(fp_optcnt) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).fp_wscale) as usize - ptr as usize }, + 129usize, + concat!( + "Offset of field: ", + stringify!(pf_osfp_ioctl), + "::", + stringify!(fp_wscale) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).fp_ttl) as usize - ptr as usize }, + 130usize, + concat!( + "Offset of field: ", + stringify!(pf_osfp_ioctl), + "::", + stringify!(fp_ttl) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).fp_getnum) as usize - ptr as usize }, + 132usize, + concat!( + "Offset of field: ", + stringify!(pf_osfp_ioctl), + "::", + stringify!(fp_getnum) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct pf_rule_actions { + pub rtableid: ::std::os::raw::c_int, + pub qid: u_int16_t, + pub pqid: u_int16_t, + pub max_mss: u_int16_t, + pub flags: u_int16_t, + pub delay: u_int16_t, + pub log: u_int8_t, + pub set_tos: u_int8_t, + pub min_ttl: u_int8_t, + pub set_prio: [u_int8_t; 2usize], + pub pad: [u_int8_t; 1usize], +} +#[test] +fn bindgen_test_layout_pf_rule_actions() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 20usize, + concat!("Size of: ", stringify!(pf_rule_actions)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(pf_rule_actions)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rtableid) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pf_rule_actions), + "::", + stringify!(rtableid) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).qid) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(pf_rule_actions), + "::", + stringify!(qid) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pqid) as usize - ptr as usize }, + 6usize, + concat!( + "Offset of field: ", + stringify!(pf_rule_actions), + "::", + stringify!(pqid) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).max_mss) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(pf_rule_actions), + "::", + stringify!(max_mss) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, + 10usize, + concat!( + "Offset of field: ", + stringify!(pf_rule_actions), + "::", + stringify!(flags) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).delay) as usize - ptr as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(pf_rule_actions), + "::", + stringify!(delay) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).log) as usize - ptr as usize }, + 14usize, + concat!( + "Offset of field: ", + stringify!(pf_rule_actions), + "::", + stringify!(log) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).set_tos) as usize - ptr as usize }, + 15usize, + concat!( + "Offset of field: ", + stringify!(pf_rule_actions), + "::", + stringify!(set_tos) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).min_ttl) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(pf_rule_actions), + "::", + stringify!(min_ttl) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).set_prio) as usize - ptr as usize }, + 17usize, + concat!( + "Offset of field: ", + stringify!(pf_rule_actions), + "::", + stringify!(set_prio) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pad) as usize - ptr as usize }, + 19usize, + concat!( + "Offset of field: ", + stringify!(pf_rule_actions), + "::", + stringify!(pad) + ) + ); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union pf_rule_ptr { + pub ptr: *mut pf_rule, + pub nr: u_int32_t, +} +#[test] +fn bindgen_test_layout_pf_rule_ptr() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(pf_rule_ptr)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(pf_rule_ptr)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ptr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pf_rule_ptr), + "::", + stringify!(ptr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).nr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pf_rule_ptr), + "::", + stringify!(nr) + ) + ); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct pf_rule { + pub src: pf_rule_addr, + pub dst: pf_rule_addr, + pub skip: [pf_rule_ptr; 9usize], + pub label: [::std::os::raw::c_char; 64usize], + pub ifname: [::std::os::raw::c_char; 16usize], + pub rcv_ifname: [::std::os::raw::c_char; 16usize], + pub qname: [::std::os::raw::c_char; 64usize], + pub pqname: [::std::os::raw::c_char; 64usize], + pub tagname: [::std::os::raw::c_char; 64usize], + pub match_tagname: [::std::os::raw::c_char; 64usize], + pub overload_tblname: [::std::os::raw::c_char; 32usize], + pub entries: pf_rule__bindgen_ty_1, + pub nat: pf_pool, + pub rdr: pf_pool, + pub route: pf_pool, + pub pktrate: pf_threshold, + pub evaluations: u_int64_t, + pub packets: [u_int64_t; 2usize], + pub bytes: [u_int64_t; 2usize], + pub kif: *mut pfi_kif, + pub rcv_kif: *mut pfi_kif, + pub anchor: *mut pf_anchor, + pub overload_tbl: *mut pfr_ktable, + pub os_fingerprint: pf_osfp_t, + pub rtableid: ::std::os::raw::c_int, + pub onrdomain: ::std::os::raw::c_int, + pub timeout: [u_int32_t; 20usize], + pub states_cur: u_int32_t, + pub states_tot: u_int32_t, + pub max_states: u_int32_t, + pub src_nodes: u_int32_t, + pub max_src_nodes: u_int32_t, + pub max_src_states: u_int32_t, + pub max_src_conn: u_int32_t, + pub max_src_conn_rate: pf_rule__bindgen_ty_2, + pub qid: u_int32_t, + pub pqid: u_int32_t, + pub rt_listid: u_int32_t, + pub nr: u_int32_t, + pub prob: u_int32_t, + pub cuid: uid_t, + pub cpid: pid_t, + pub return_icmp: u_int16_t, + pub return_icmp6: u_int16_t, + pub max_mss: u_int16_t, + pub tag: u_int16_t, + pub match_tag: u_int16_t, + pub scrub_flags: u_int16_t, + pub delay: u_int16_t, + pub uid: pf_rule_uid, + pub gid: pf_rule_gid, + pub rule_flag: u_int32_t, + pub action: u_int8_t, + pub direction: u_int8_t, + pub log: u_int8_t, + pub logif: u_int8_t, + pub quick: u_int8_t, + pub ifnot: u_int8_t, + pub match_tag_not: u_int8_t, + pub keep_state: u_int8_t, + pub af: sa_family_t, + pub proto: u_int8_t, + pub type_: u_int16_t, + pub code: u_int16_t, + pub flags: u_int8_t, + pub flagset: u_int8_t, + pub min_ttl: u_int8_t, + pub allow_opts: u_int8_t, + pub rt: u_int8_t, + pub return_ttl: u_int8_t, + pub tos: u_int8_t, + pub set_tos: u_int8_t, + pub anchor_relative: u_int8_t, + pub anchor_wildcard: u_int8_t, + pub flush: u_int8_t, + pub prio: u_int8_t, + pub set_prio: [u_int8_t; 2usize], + pub naf: sa_family_t, + pub rcvifnot: u_int8_t, + pub divert: pf_rule__bindgen_ty_3, + pub exptime: time_t, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct pf_rule__bindgen_ty_1 { + pub tqe_next: *mut pf_rule, + pub tqe_prev: *mut *mut pf_rule, +} +#[test] +fn bindgen_test_layout_pf_rule__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(pf_rule__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(pf_rule__bindgen_ty_1)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).tqe_next) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pf_rule__bindgen_ty_1), + "::", + stringify!(tqe_next) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).tqe_prev) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(pf_rule__bindgen_ty_1), + "::", + stringify!(tqe_prev) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct pf_rule__bindgen_ty_2 { + pub limit: u_int32_t, + pub seconds: u_int32_t, +} +#[test] +fn bindgen_test_layout_pf_rule__bindgen_ty_2() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(pf_rule__bindgen_ty_2)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(pf_rule__bindgen_ty_2)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).limit) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pf_rule__bindgen_ty_2), + "::", + stringify!(limit) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).seconds) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(pf_rule__bindgen_ty_2), + "::", + stringify!(seconds) + ) + ); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct pf_rule__bindgen_ty_3 { + pub addr: pf_addr, + pub port: u_int16_t, + pub type_: u_int8_t, +} +#[test] +fn bindgen_test_layout_pf_rule__bindgen_ty_3() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 20usize, + concat!("Size of: ", stringify!(pf_rule__bindgen_ty_3)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(pf_rule__bindgen_ty_3)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).addr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pf_rule__bindgen_ty_3), + "::", + stringify!(addr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).port) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(pf_rule__bindgen_ty_3), + "::", + stringify!(port) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).type_) as usize - ptr as usize }, + 18usize, + concat!( + "Offset of field: ", + stringify!(pf_rule__bindgen_ty_3), + "::", + stringify!(type_) + ) + ); +} +#[test] +fn bindgen_test_layout_pf_rule() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 1344usize, + concat!("Size of: ", stringify!(pf_rule)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(pf_rule)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).src) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pf_rule), + "::", + stringify!(src) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).dst) as usize - ptr as usize }, + 56usize, + concat!( + "Offset of field: ", + stringify!(pf_rule), + "::", + stringify!(dst) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).skip) as usize - ptr as usize }, + 112usize, + concat!( + "Offset of field: ", + stringify!(pf_rule), + "::", + stringify!(skip) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).label) as usize - ptr as usize }, + 184usize, + concat!( + "Offset of field: ", + stringify!(pf_rule), + "::", + stringify!(label) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifname) as usize - ptr as usize }, + 248usize, + concat!( + "Offset of field: ", + stringify!(pf_rule), + "::", + stringify!(ifname) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rcv_ifname) as usize - ptr as usize }, + 264usize, + concat!( + "Offset of field: ", + stringify!(pf_rule), + "::", + stringify!(rcv_ifname) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).qname) as usize - ptr as usize }, + 280usize, + concat!( + "Offset of field: ", + stringify!(pf_rule), + "::", + stringify!(qname) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pqname) as usize - ptr as usize }, + 344usize, + concat!( + "Offset of field: ", + stringify!(pf_rule), + "::", + stringify!(pqname) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).tagname) as usize - ptr as usize }, + 408usize, + concat!( + "Offset of field: ", + stringify!(pf_rule), + "::", + stringify!(tagname) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).match_tagname) as usize - ptr as usize }, + 472usize, + concat!( + "Offset of field: ", + stringify!(pf_rule), + "::", + stringify!(match_tagname) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).overload_tblname) as usize - ptr as usize }, + 536usize, + concat!( + "Offset of field: ", + stringify!(pf_rule), + "::", + stringify!(overload_tblname) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).entries) as usize - ptr as usize }, + 568usize, + concat!( + "Offset of field: ", + stringify!(pf_rule), + "::", + stringify!(entries) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).nat) as usize - ptr as usize }, + 584usize, + concat!( + "Offset of field: ", + stringify!(pf_rule), + "::", + stringify!(nat) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rdr) as usize - ptr as usize }, + 720usize, + concat!( + "Offset of field: ", + stringify!(pf_rule), + "::", + stringify!(rdr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).route) as usize - ptr as usize }, + 856usize, + concat!( + "Offset of field: ", + stringify!(pf_rule), + "::", + stringify!(route) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pktrate) as usize - ptr as usize }, + 992usize, + concat!( + "Offset of field: ", + stringify!(pf_rule), + "::", + stringify!(pktrate) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).evaluations) as usize - ptr as usize }, + 1008usize, + concat!( + "Offset of field: ", + stringify!(pf_rule), + "::", + stringify!(evaluations) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).packets) as usize - ptr as usize }, + 1016usize, + concat!( + "Offset of field: ", + stringify!(pf_rule), + "::", + stringify!(packets) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).bytes) as usize - ptr as usize }, + 1032usize, + concat!( + "Offset of field: ", + stringify!(pf_rule), + "::", + stringify!(bytes) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).kif) as usize - ptr as usize }, + 1048usize, + concat!( + "Offset of field: ", + stringify!(pf_rule), + "::", + stringify!(kif) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rcv_kif) as usize - ptr as usize }, + 1056usize, + concat!( + "Offset of field: ", + stringify!(pf_rule), + "::", + stringify!(rcv_kif) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).anchor) as usize - ptr as usize }, + 1064usize, + concat!( + "Offset of field: ", + stringify!(pf_rule), + "::", + stringify!(anchor) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).overload_tbl) as usize - ptr as usize }, + 1072usize, + concat!( + "Offset of field: ", + stringify!(pf_rule), + "::", + stringify!(overload_tbl) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).os_fingerprint) as usize - ptr as usize }, + 1080usize, + concat!( + "Offset of field: ", + stringify!(pf_rule), + "::", + stringify!(os_fingerprint) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rtableid) as usize - ptr as usize }, + 1084usize, + concat!( + "Offset of field: ", + stringify!(pf_rule), + "::", + stringify!(rtableid) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).onrdomain) as usize - ptr as usize }, + 1088usize, + concat!( + "Offset of field: ", + stringify!(pf_rule), + "::", + stringify!(onrdomain) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).timeout) as usize - ptr as usize }, + 1092usize, + concat!( + "Offset of field: ", + stringify!(pf_rule), + "::", + stringify!(timeout) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).states_cur) as usize - ptr as usize }, + 1172usize, + concat!( + "Offset of field: ", + stringify!(pf_rule), + "::", + stringify!(states_cur) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).states_tot) as usize - ptr as usize }, + 1176usize, + concat!( + "Offset of field: ", + stringify!(pf_rule), + "::", + stringify!(states_tot) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).max_states) as usize - ptr as usize }, + 1180usize, + concat!( + "Offset of field: ", + stringify!(pf_rule), + "::", + stringify!(max_states) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).src_nodes) as usize - ptr as usize }, + 1184usize, + concat!( + "Offset of field: ", + stringify!(pf_rule), + "::", + stringify!(src_nodes) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).max_src_nodes) as usize - ptr as usize }, + 1188usize, + concat!( + "Offset of field: ", + stringify!(pf_rule), + "::", + stringify!(max_src_nodes) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).max_src_states) as usize - ptr as usize }, + 1192usize, + concat!( + "Offset of field: ", + stringify!(pf_rule), + "::", + stringify!(max_src_states) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).max_src_conn) as usize - ptr as usize }, + 1196usize, + concat!( + "Offset of field: ", + stringify!(pf_rule), + "::", + stringify!(max_src_conn) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).max_src_conn_rate) as usize - ptr as usize }, + 1200usize, + concat!( + "Offset of field: ", + stringify!(pf_rule), + "::", + stringify!(max_src_conn_rate) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).qid) as usize - ptr as usize }, + 1208usize, + concat!( + "Offset of field: ", + stringify!(pf_rule), + "::", + stringify!(qid) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pqid) as usize - ptr as usize }, + 1212usize, + concat!( + "Offset of field: ", + stringify!(pf_rule), + "::", + stringify!(pqid) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rt_listid) as usize - ptr as usize }, + 1216usize, + concat!( + "Offset of field: ", + stringify!(pf_rule), + "::", + stringify!(rt_listid) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).nr) as usize - ptr as usize }, + 1220usize, + concat!( + "Offset of field: ", + stringify!(pf_rule), + "::", + stringify!(nr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).prob) as usize - ptr as usize }, + 1224usize, + concat!( + "Offset of field: ", + stringify!(pf_rule), + "::", + stringify!(prob) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).cuid) as usize - ptr as usize }, + 1228usize, + concat!( + "Offset of field: ", + stringify!(pf_rule), + "::", + stringify!(cuid) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).cpid) as usize - ptr as usize }, + 1232usize, + concat!( + "Offset of field: ", + stringify!(pf_rule), + "::", + stringify!(cpid) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).return_icmp) as usize - ptr as usize }, + 1236usize, + concat!( + "Offset of field: ", + stringify!(pf_rule), + "::", + stringify!(return_icmp) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).return_icmp6) as usize - ptr as usize }, + 1238usize, + concat!( + "Offset of field: ", + stringify!(pf_rule), + "::", + stringify!(return_icmp6) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).max_mss) as usize - ptr as usize }, + 1240usize, + concat!( + "Offset of field: ", + stringify!(pf_rule), + "::", + stringify!(max_mss) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).tag) as usize - ptr as usize }, + 1242usize, + concat!( + "Offset of field: ", + stringify!(pf_rule), + "::", + stringify!(tag) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).match_tag) as usize - ptr as usize }, + 1244usize, + concat!( + "Offset of field: ", + stringify!(pf_rule), + "::", + stringify!(match_tag) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).scrub_flags) as usize - ptr as usize }, + 1246usize, + concat!( + "Offset of field: ", + stringify!(pf_rule), + "::", + stringify!(scrub_flags) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).delay) as usize - ptr as usize }, + 1248usize, + concat!( + "Offset of field: ", + stringify!(pf_rule), + "::", + stringify!(delay) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).uid) as usize - ptr as usize }, + 1252usize, + concat!( + "Offset of field: ", + stringify!(pf_rule), + "::", + stringify!(uid) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).gid) as usize - ptr as usize }, + 1264usize, + concat!( + "Offset of field: ", + stringify!(pf_rule), + "::", + stringify!(gid) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rule_flag) as usize - ptr as usize }, + 1276usize, + concat!( + "Offset of field: ", + stringify!(pf_rule), + "::", + stringify!(rule_flag) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).action) as usize - ptr as usize }, + 1280usize, + concat!( + "Offset of field: ", + stringify!(pf_rule), + "::", + stringify!(action) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).direction) as usize - ptr as usize }, + 1281usize, + concat!( + "Offset of field: ", + stringify!(pf_rule), + "::", + stringify!(direction) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).log) as usize - ptr as usize }, + 1282usize, + concat!( + "Offset of field: ", + stringify!(pf_rule), + "::", + stringify!(log) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).logif) as usize - ptr as usize }, + 1283usize, + concat!( + "Offset of field: ", + stringify!(pf_rule), + "::", + stringify!(logif) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).quick) as usize - ptr as usize }, + 1284usize, + concat!( + "Offset of field: ", + stringify!(pf_rule), + "::", + stringify!(quick) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifnot) as usize - ptr as usize }, + 1285usize, + concat!( + "Offset of field: ", + stringify!(pf_rule), + "::", + stringify!(ifnot) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).match_tag_not) as usize - ptr as usize }, + 1286usize, + concat!( + "Offset of field: ", + stringify!(pf_rule), + "::", + stringify!(match_tag_not) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).keep_state) as usize - ptr as usize }, + 1287usize, + concat!( + "Offset of field: ", + stringify!(pf_rule), + "::", + stringify!(keep_state) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).af) as usize - ptr as usize }, + 1288usize, + concat!( + "Offset of field: ", + stringify!(pf_rule), + "::", + stringify!(af) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).proto) as usize - ptr as usize }, + 1289usize, + concat!( + "Offset of field: ", + stringify!(pf_rule), + "::", + stringify!(proto) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).type_) as usize - ptr as usize }, + 1290usize, + concat!( + "Offset of field: ", + stringify!(pf_rule), + "::", + stringify!(type_) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).code) as usize - ptr as usize }, + 1292usize, + concat!( + "Offset of field: ", + stringify!(pf_rule), + "::", + stringify!(code) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, + 1294usize, + concat!( + "Offset of field: ", + stringify!(pf_rule), + "::", + stringify!(flags) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).flagset) as usize - ptr as usize }, + 1295usize, + concat!( + "Offset of field: ", + stringify!(pf_rule), + "::", + stringify!(flagset) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).min_ttl) as usize - ptr as usize }, + 1296usize, + concat!( + "Offset of field: ", + stringify!(pf_rule), + "::", + stringify!(min_ttl) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).allow_opts) as usize - ptr as usize }, + 1297usize, + concat!( + "Offset of field: ", + stringify!(pf_rule), + "::", + stringify!(allow_opts) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rt) as usize - ptr as usize }, + 1298usize, + concat!( + "Offset of field: ", + stringify!(pf_rule), + "::", + stringify!(rt) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).return_ttl) as usize - ptr as usize }, + 1299usize, + concat!( + "Offset of field: ", + stringify!(pf_rule), + "::", + stringify!(return_ttl) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).tos) as usize - ptr as usize }, + 1300usize, + concat!( + "Offset of field: ", + stringify!(pf_rule), + "::", + stringify!(tos) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).set_tos) as usize - ptr as usize }, + 1301usize, + concat!( + "Offset of field: ", + stringify!(pf_rule), + "::", + stringify!(set_tos) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).anchor_relative) as usize - ptr as usize }, + 1302usize, + concat!( + "Offset of field: ", + stringify!(pf_rule), + "::", + stringify!(anchor_relative) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).anchor_wildcard) as usize - ptr as usize }, + 1303usize, + concat!( + "Offset of field: ", + stringify!(pf_rule), + "::", + stringify!(anchor_wildcard) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).flush) as usize - ptr as usize }, + 1304usize, + concat!( + "Offset of field: ", + stringify!(pf_rule), + "::", + stringify!(flush) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).prio) as usize - ptr as usize }, + 1305usize, + concat!( + "Offset of field: ", + stringify!(pf_rule), + "::", + stringify!(prio) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).set_prio) as usize - ptr as usize }, + 1306usize, + concat!( + "Offset of field: ", + stringify!(pf_rule), + "::", + stringify!(set_prio) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).naf) as usize - ptr as usize }, + 1308usize, + concat!( + "Offset of field: ", + stringify!(pf_rule), + "::", + stringify!(naf) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rcvifnot) as usize - ptr as usize }, + 1309usize, + concat!( + "Offset of field: ", + stringify!(pf_rule), + "::", + stringify!(rcvifnot) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).divert) as usize - ptr as usize }, + 1312usize, + concat!( + "Offset of field: ", + stringify!(pf_rule), + "::", + stringify!(divert) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).exptime) as usize - ptr as usize }, + 1336usize, + concat!( + "Offset of field: ", + stringify!(pf_rule), + "::", + stringify!(exptime) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct pf_rule_item { + pub entry: pf_rule_item__bindgen_ty_1, + pub r: *mut pf_rule, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct pf_rule_item__bindgen_ty_1 { + pub sle_next: *mut pf_rule_item, +} +#[test] +fn bindgen_test_layout_pf_rule_item__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(pf_rule_item__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(pf_rule_item__bindgen_ty_1)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).sle_next) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pf_rule_item__bindgen_ty_1), + "::", + stringify!(sle_next) + ) + ); +} +#[test] +fn bindgen_test_layout_pf_rule_item() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(pf_rule_item)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(pf_rule_item)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).entry) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pf_rule_item), + "::", + stringify!(entry) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).r) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(pf_rule_item), + "::", + stringify!(r) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct pf_rule_slist { + pub slh_first: *mut pf_rule_item, +} +#[test] +fn bindgen_test_layout_pf_rule_slist() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(pf_rule_slist)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(pf_rule_slist)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).slh_first) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pf_rule_slist), + "::", + stringify!(slh_first) + ) + ); +} +pub const pf_sn_types_PF_SN_NONE: pf_sn_types = 0; +pub const pf_sn_types_PF_SN_NAT: pf_sn_types = 1; +pub const pf_sn_types_PF_SN_RDR: pf_sn_types = 2; +pub const pf_sn_types_PF_SN_ROUTE: pf_sn_types = 3; +pub const pf_sn_types_PF_SN_MAX: pf_sn_types = 4; +pub type pf_sn_types = ::std::os::raw::c_uint; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct pf_src_node { + pub entry: pf_src_node__bindgen_ty_1, + pub addr: pf_addr, + pub raddr: pf_addr, + pub rule: pf_rule_ptr, + pub kif: *mut pfi_kif, + pub bytes: [u_int64_t; 2usize], + pub packets: [u_int64_t; 2usize], + pub states: u_int32_t, + pub conn: u_int32_t, + pub conn_rate: pf_threshold, + pub creation: i32, + pub expire: i32, + pub af: sa_family_t, + pub naf: sa_family_t, + pub type_: u_int8_t, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct pf_src_node__bindgen_ty_1 { + pub rbe_left: *mut pf_src_node, + pub rbe_right: *mut pf_src_node, + pub rbe_parent: *mut pf_src_node, + pub rbe_color: ::std::os::raw::c_int, +} +#[test] +fn bindgen_test_layout_pf_src_node__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 32usize, + concat!("Size of: ", stringify!(pf_src_node__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(pf_src_node__bindgen_ty_1)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rbe_left) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pf_src_node__bindgen_ty_1), + "::", + stringify!(rbe_left) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rbe_right) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(pf_src_node__bindgen_ty_1), + "::", + stringify!(rbe_right) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rbe_parent) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(pf_src_node__bindgen_ty_1), + "::", + stringify!(rbe_parent) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rbe_color) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(pf_src_node__bindgen_ty_1), + "::", + stringify!(rbe_color) + ) + ); +} +#[test] +fn bindgen_test_layout_pf_src_node() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 152usize, + concat!("Size of: ", stringify!(pf_src_node)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(pf_src_node)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).entry) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pf_src_node), + "::", + stringify!(entry) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).addr) as usize - ptr as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(pf_src_node), + "::", + stringify!(addr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).raddr) as usize - ptr as usize }, + 48usize, + concat!( + "Offset of field: ", + stringify!(pf_src_node), + "::", + stringify!(raddr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rule) as usize - ptr as usize }, + 64usize, + concat!( + "Offset of field: ", + stringify!(pf_src_node), + "::", + stringify!(rule) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).kif) as usize - ptr as usize }, + 72usize, + concat!( + "Offset of field: ", + stringify!(pf_src_node), + "::", + stringify!(kif) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).bytes) as usize - ptr as usize }, + 80usize, + concat!( + "Offset of field: ", + stringify!(pf_src_node), + "::", + stringify!(bytes) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).packets) as usize - ptr as usize }, + 96usize, + concat!( + "Offset of field: ", + stringify!(pf_src_node), + "::", + stringify!(packets) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).states) as usize - ptr as usize }, + 112usize, + concat!( + "Offset of field: ", + stringify!(pf_src_node), + "::", + stringify!(states) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).conn) as usize - ptr as usize }, + 116usize, + concat!( + "Offset of field: ", + stringify!(pf_src_node), + "::", + stringify!(conn) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).conn_rate) as usize - ptr as usize }, + 120usize, + concat!( + "Offset of field: ", + stringify!(pf_src_node), + "::", + stringify!(conn_rate) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).creation) as usize - ptr as usize }, + 136usize, + concat!( + "Offset of field: ", + stringify!(pf_src_node), + "::", + stringify!(creation) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).expire) as usize - ptr as usize }, + 140usize, + concat!( + "Offset of field: ", + stringify!(pf_src_node), + "::", + stringify!(expire) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).af) as usize - ptr as usize }, + 144usize, + concat!( + "Offset of field: ", + stringify!(pf_src_node), + "::", + stringify!(af) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).naf) as usize - ptr as usize }, + 145usize, + concat!( + "Offset of field: ", + stringify!(pf_src_node), + "::", + stringify!(naf) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).type_) as usize - ptr as usize }, + 146usize, + concat!( + "Offset of field: ", + stringify!(pf_src_node), + "::", + stringify!(type_) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct pf_sn_item { + pub next: pf_sn_item__bindgen_ty_1, + pub sn: *mut pf_src_node, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct pf_sn_item__bindgen_ty_1 { + pub sle_next: *mut pf_sn_item, +} +#[test] +fn bindgen_test_layout_pf_sn_item__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(pf_sn_item__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(pf_sn_item__bindgen_ty_1)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).sle_next) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pf_sn_item__bindgen_ty_1), + "::", + stringify!(sle_next) + ) + ); +} +#[test] +fn bindgen_test_layout_pf_sn_item() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(pf_sn_item)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(pf_sn_item)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).next) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pf_sn_item), + "::", + stringify!(next) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).sn) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(pf_sn_item), + "::", + stringify!(sn) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct pf_sn_head { + pub slh_first: *mut pf_sn_item, +} +#[test] +fn bindgen_test_layout_pf_sn_head() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(pf_sn_head)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(pf_sn_head)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).slh_first) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pf_sn_head), + "::", + stringify!(slh_first) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct pf_state_scrub { + pub pfss_last: timeval, + pub pfss_tsecr: u_int32_t, + pub pfss_tsval: u_int32_t, + pub pfss_tsval0: u_int32_t, + pub pfss_flags: u_int16_t, + pub pfss_ttl: u_int8_t, + pub pad: u_int8_t, + pub pfss_ts_mod: u_int32_t, +} +#[test] +fn bindgen_test_layout_pf_state_scrub() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 40usize, + concat!("Size of: ", stringify!(pf_state_scrub)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(pf_state_scrub)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfss_last) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pf_state_scrub), + "::", + stringify!(pfss_last) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfss_tsecr) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(pf_state_scrub), + "::", + stringify!(pfss_tsecr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfss_tsval) as usize - ptr as usize }, + 20usize, + concat!( + "Offset of field: ", + stringify!(pf_state_scrub), + "::", + stringify!(pfss_tsval) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfss_tsval0) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(pf_state_scrub), + "::", + stringify!(pfss_tsval0) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfss_flags) as usize - ptr as usize }, + 28usize, + concat!( + "Offset of field: ", + stringify!(pf_state_scrub), + "::", + stringify!(pfss_flags) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfss_ttl) as usize - ptr as usize }, + 30usize, + concat!( + "Offset of field: ", + stringify!(pf_state_scrub), + "::", + stringify!(pfss_ttl) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pad) as usize - ptr as usize }, + 31usize, + concat!( + "Offset of field: ", + stringify!(pf_state_scrub), + "::", + stringify!(pad) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfss_ts_mod) as usize - ptr as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(pf_state_scrub), + "::", + stringify!(pfss_ts_mod) + ) + ); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct pf_state_host { + pub addr: pf_addr, + pub port: u_int16_t, + pub pad: u_int16_t, +} +#[test] +fn bindgen_test_layout_pf_state_host() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 20usize, + concat!("Size of: ", stringify!(pf_state_host)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(pf_state_host)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).addr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pf_state_host), + "::", + stringify!(addr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).port) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(pf_state_host), + "::", + stringify!(port) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pad) as usize - ptr as usize }, + 18usize, + concat!( + "Offset of field: ", + stringify!(pf_state_host), + "::", + stringify!(pad) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct pf_state_peer { + pub scrub: *mut pf_state_scrub, + pub seqlo: u_int32_t, + pub seqhi: u_int32_t, + pub seqdiff: u_int32_t, + pub max_win: u_int16_t, + pub mss: u_int16_t, + pub state: u_int8_t, + pub wscale: u_int8_t, + pub tcp_est: u_int8_t, + pub pad: [u_int8_t; 1usize], +} +#[test] +fn bindgen_test_layout_pf_state_peer() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 32usize, + concat!("Size of: ", stringify!(pf_state_peer)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(pf_state_peer)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).scrub) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pf_state_peer), + "::", + stringify!(scrub) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).seqlo) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(pf_state_peer), + "::", + stringify!(seqlo) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).seqhi) as usize - ptr as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(pf_state_peer), + "::", + stringify!(seqhi) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).seqdiff) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(pf_state_peer), + "::", + stringify!(seqdiff) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).max_win) as usize - ptr as usize }, + 20usize, + concat!( + "Offset of field: ", + stringify!(pf_state_peer), + "::", + stringify!(max_win) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).mss) as usize - ptr as usize }, + 22usize, + concat!( + "Offset of field: ", + stringify!(pf_state_peer), + "::", + stringify!(mss) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).state) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(pf_state_peer), + "::", + stringify!(state) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).wscale) as usize - ptr as usize }, + 25usize, + concat!( + "Offset of field: ", + stringify!(pf_state_peer), + "::", + stringify!(wscale) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).tcp_est) as usize - ptr as usize }, + 26usize, + concat!( + "Offset of field: ", + stringify!(pf_state_peer), + "::", + stringify!(tcp_est) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pad) as usize - ptr as usize }, + 27usize, + concat!( + "Offset of field: ", + stringify!(pf_state_peer), + "::", + stringify!(pad) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct pf_state_queue { + pub tqh_first: *mut pf_state, + pub tqh_last: *mut *mut pf_state, +} +#[test] +fn bindgen_test_layout_pf_state_queue() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(pf_state_queue)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(pf_state_queue)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).tqh_first) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pf_state_queue), + "::", + stringify!(tqh_first) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).tqh_last) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(pf_state_queue), + "::", + stringify!(tqh_last) + ) + ); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct pf_state_key_cmp { + pub addr: [pf_addr; 2usize], + pub port: [u_int16_t; 2usize], + pub rdomain: u_int16_t, + pub hash: u_int16_t, + pub af: sa_family_t, + pub proto: u_int8_t, +} +#[test] +fn bindgen_test_layout_pf_state_key_cmp() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 44usize, + concat!("Size of: ", stringify!(pf_state_key_cmp)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(pf_state_key_cmp)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).addr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pf_state_key_cmp), + "::", + stringify!(addr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).port) as usize - ptr as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(pf_state_key_cmp), + "::", + stringify!(port) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rdomain) as usize - ptr as usize }, + 36usize, + concat!( + "Offset of field: ", + stringify!(pf_state_key_cmp), + "::", + stringify!(rdomain) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).hash) as usize - ptr as usize }, + 38usize, + concat!( + "Offset of field: ", + stringify!(pf_state_key_cmp), + "::", + stringify!(hash) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).af) as usize - ptr as usize }, + 40usize, + concat!( + "Offset of field: ", + stringify!(pf_state_key_cmp), + "::", + stringify!(af) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).proto) as usize - ptr as usize }, + 41usize, + concat!( + "Offset of field: ", + stringify!(pf_state_key_cmp), + "::", + stringify!(proto) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct pf_state_cmp { + pub id: u_int64_t, + pub creatorid: u_int32_t, + pub direction: u_int8_t, + pub pad: [u_int8_t; 3usize], +} +#[test] +fn bindgen_test_layout_pf_state_cmp() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(pf_state_cmp)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(pf_state_cmp)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).id) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pf_state_cmp), + "::", + stringify!(id) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).creatorid) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(pf_state_cmp), + "::", + stringify!(creatorid) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).direction) as usize - ptr as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(pf_state_cmp), + "::", + stringify!(direction) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pad) as usize - ptr as usize }, + 13usize, + concat!( + "Offset of field: ", + stringify!(pf_state_cmp), + "::", + stringify!(pad) + ) + ); +} +#[repr(C, packed)] +#[derive(Debug, Copy, Clone)] +pub struct pfsync_state_scrub { + pub pfss_flags: u_int16_t, + pub pfss_ttl: u_int8_t, + pub scrub_flag: u_int8_t, + pub pfss_ts_mod: u_int32_t, +} +#[test] +fn bindgen_test_layout_pfsync_state_scrub() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(pfsync_state_scrub)) + ); + assert_eq!( + ::std::mem::align_of::(), + 1usize, + concat!("Alignment of ", stringify!(pfsync_state_scrub)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfss_flags) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pfsync_state_scrub), + "::", + stringify!(pfss_flags) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfss_ttl) as usize - ptr as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(pfsync_state_scrub), + "::", + stringify!(pfss_ttl) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).scrub_flag) as usize - ptr as usize }, + 3usize, + concat!( + "Offset of field: ", + stringify!(pfsync_state_scrub), + "::", + stringify!(scrub_flag) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfss_ts_mod) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(pfsync_state_scrub), + "::", + stringify!(pfss_ts_mod) + ) + ); +} +#[repr(C, packed)] +#[derive(Debug, Copy, Clone)] +pub struct pfsync_state_peer { + pub scrub: pfsync_state_scrub, + pub seqlo: u_int32_t, + pub seqhi: u_int32_t, + pub seqdiff: u_int32_t, + pub max_win: u_int16_t, + pub mss: u_int16_t, + pub state: u_int8_t, + pub wscale: u_int8_t, + pub pad: [u_int8_t; 6usize], +} +#[test] +fn bindgen_test_layout_pfsync_state_peer() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 32usize, + concat!("Size of: ", stringify!(pfsync_state_peer)) + ); + assert_eq!( + ::std::mem::align_of::(), + 1usize, + concat!("Alignment of ", stringify!(pfsync_state_peer)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).scrub) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pfsync_state_peer), + "::", + stringify!(scrub) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).seqlo) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(pfsync_state_peer), + "::", + stringify!(seqlo) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).seqhi) as usize - ptr as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(pfsync_state_peer), + "::", + stringify!(seqhi) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).seqdiff) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(pfsync_state_peer), + "::", + stringify!(seqdiff) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).max_win) as usize - ptr as usize }, + 20usize, + concat!( + "Offset of field: ", + stringify!(pfsync_state_peer), + "::", + stringify!(max_win) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).mss) as usize - ptr as usize }, + 22usize, + concat!( + "Offset of field: ", + stringify!(pfsync_state_peer), + "::", + stringify!(mss) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).state) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(pfsync_state_peer), + "::", + stringify!(state) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).wscale) as usize - ptr as usize }, + 25usize, + concat!( + "Offset of field: ", + stringify!(pfsync_state_peer), + "::", + stringify!(wscale) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pad) as usize - ptr as usize }, + 26usize, + concat!( + "Offset of field: ", + stringify!(pfsync_state_peer), + "::", + stringify!(pad) + ) + ); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct pfsync_state_key { + pub addr: [pf_addr; 2usize], + pub port: [u_int16_t; 2usize], + pub rdomain: u_int16_t, + pub af: sa_family_t, + pub pad: u_int8_t, +} +#[test] +fn bindgen_test_layout_pfsync_state_key() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 40usize, + concat!("Size of: ", stringify!(pfsync_state_key)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(pfsync_state_key)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).addr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pfsync_state_key), + "::", + stringify!(addr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).port) as usize - ptr as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(pfsync_state_key), + "::", + stringify!(port) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rdomain) as usize - ptr as usize }, + 36usize, + concat!( + "Offset of field: ", + stringify!(pfsync_state_key), + "::", + stringify!(rdomain) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).af) as usize - ptr as usize }, + 38usize, + concat!( + "Offset of field: ", + stringify!(pfsync_state_key), + "::", + stringify!(af) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pad) as usize - ptr as usize }, + 39usize, + concat!( + "Offset of field: ", + stringify!(pfsync_state_key), + "::", + stringify!(pad) + ) + ); +} +#[repr(C, packed)] +#[derive(Copy, Clone)] +pub struct pfsync_state { + pub id: u_int64_t, + pub ifname: [::std::os::raw::c_char; 16usize], + pub key: [pfsync_state_key; 2usize], + pub src: pfsync_state_peer, + pub dst: pfsync_state_peer, + pub rt_addr: pf_addr, + pub rule: u_int32_t, + pub anchor: u_int32_t, + pub nat_rule: u_int32_t, + pub creation: u_int32_t, + pub expire: u_int32_t, + pub packets: [[u_int32_t; 2usize]; 2usize], + pub bytes: [[u_int32_t; 2usize]; 2usize], + pub creatorid: u_int32_t, + pub rtableid: [i32; 2usize], + pub max_mss: u_int16_t, + pub af: sa_family_t, + pub proto: u_int8_t, + pub direction: u_int8_t, + pub log: u_int8_t, + pub rt: u_int8_t, + pub timeout: u_int8_t, + pub sync_flags: u_int8_t, + pub updates: u_int8_t, + pub min_ttl: u_int8_t, + pub set_tos: u_int8_t, + pub state_flags: u_int16_t, + pub set_prio: [u_int8_t; 2usize], +} +#[test] +fn bindgen_test_layout_pfsync_state() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 264usize, + concat!("Size of: ", stringify!(pfsync_state)) + ); + assert_eq!( + ::std::mem::align_of::(), + 1usize, + concat!("Alignment of ", stringify!(pfsync_state)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).id) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pfsync_state), + "::", + stringify!(id) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifname) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(pfsync_state), + "::", + stringify!(ifname) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).key) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(pfsync_state), + "::", + stringify!(key) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).src) as usize - ptr as usize }, + 104usize, + concat!( + "Offset of field: ", + stringify!(pfsync_state), + "::", + stringify!(src) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).dst) as usize - ptr as usize }, + 136usize, + concat!( + "Offset of field: ", + stringify!(pfsync_state), + "::", + stringify!(dst) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rt_addr) as usize - ptr as usize }, + 168usize, + concat!( + "Offset of field: ", + stringify!(pfsync_state), + "::", + stringify!(rt_addr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rule) as usize - ptr as usize }, + 184usize, + concat!( + "Offset of field: ", + stringify!(pfsync_state), + "::", + stringify!(rule) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).anchor) as usize - ptr as usize }, + 188usize, + concat!( + "Offset of field: ", + stringify!(pfsync_state), + "::", + stringify!(anchor) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).nat_rule) as usize - ptr as usize }, + 192usize, + concat!( + "Offset of field: ", + stringify!(pfsync_state), + "::", + stringify!(nat_rule) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).creation) as usize - ptr as usize }, + 196usize, + concat!( + "Offset of field: ", + stringify!(pfsync_state), + "::", + stringify!(creation) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).expire) as usize - ptr as usize }, + 200usize, + concat!( + "Offset of field: ", + stringify!(pfsync_state), + "::", + stringify!(expire) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).packets) as usize - ptr as usize }, + 204usize, + concat!( + "Offset of field: ", + stringify!(pfsync_state), + "::", + stringify!(packets) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).bytes) as usize - ptr as usize }, + 220usize, + concat!( + "Offset of field: ", + stringify!(pfsync_state), + "::", + stringify!(bytes) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).creatorid) as usize - ptr as usize }, + 236usize, + concat!( + "Offset of field: ", + stringify!(pfsync_state), + "::", + stringify!(creatorid) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rtableid) as usize - ptr as usize }, + 240usize, + concat!( + "Offset of field: ", + stringify!(pfsync_state), + "::", + stringify!(rtableid) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).max_mss) as usize - ptr as usize }, + 248usize, + concat!( + "Offset of field: ", + stringify!(pfsync_state), + "::", + stringify!(max_mss) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).af) as usize - ptr as usize }, + 250usize, + concat!( + "Offset of field: ", + stringify!(pfsync_state), + "::", + stringify!(af) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).proto) as usize - ptr as usize }, + 251usize, + concat!( + "Offset of field: ", + stringify!(pfsync_state), + "::", + stringify!(proto) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).direction) as usize - ptr as usize }, + 252usize, + concat!( + "Offset of field: ", + stringify!(pfsync_state), + "::", + stringify!(direction) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).log) as usize - ptr as usize }, + 253usize, + concat!( + "Offset of field: ", + stringify!(pfsync_state), + "::", + stringify!(log) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rt) as usize - ptr as usize }, + 254usize, + concat!( + "Offset of field: ", + stringify!(pfsync_state), + "::", + stringify!(rt) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).timeout) as usize - ptr as usize }, + 255usize, + concat!( + "Offset of field: ", + stringify!(pfsync_state), + "::", + stringify!(timeout) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).sync_flags) as usize - ptr as usize }, + 256usize, + concat!( + "Offset of field: ", + stringify!(pfsync_state), + "::", + stringify!(sync_flags) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).updates) as usize - ptr as usize }, + 257usize, + concat!( + "Offset of field: ", + stringify!(pfsync_state), + "::", + stringify!(updates) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).min_ttl) as usize - ptr as usize }, + 258usize, + concat!( + "Offset of field: ", + stringify!(pfsync_state), + "::", + stringify!(min_ttl) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).set_tos) as usize - ptr as usize }, + 259usize, + concat!( + "Offset of field: ", + stringify!(pfsync_state), + "::", + stringify!(set_tos) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).state_flags) as usize - ptr as usize }, + 260usize, + concat!( + "Offset of field: ", + stringify!(pfsync_state), + "::", + stringify!(state_flags) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).set_prio) as usize - ptr as usize }, + 262usize, + concat!( + "Offset of field: ", + stringify!(pfsync_state), + "::", + stringify!(set_prio) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct pf_rulequeue { + pub tqh_first: *mut pf_rule, + pub tqh_last: *mut *mut pf_rule, +} +#[test] +fn bindgen_test_layout_pf_rulequeue() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(pf_rulequeue)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(pf_rulequeue)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).tqh_first) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pf_rulequeue), + "::", + stringify!(tqh_first) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).tqh_last) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(pf_rulequeue), + "::", + stringify!(tqh_last) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct pf_ruleset { + pub rules: pf_ruleset__bindgen_ty_1, + pub anchor: *mut pf_anchor, + pub tticket: u_int32_t, + pub tables: ::std::os::raw::c_int, + pub topen: ::std::os::raw::c_int, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct pf_ruleset__bindgen_ty_1 { + pub queues: [pf_rulequeue; 2usize], + pub active: pf_ruleset__bindgen_ty_1__bindgen_ty_1, + pub inactive: pf_ruleset__bindgen_ty_1__bindgen_ty_1, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct pf_ruleset__bindgen_ty_1__bindgen_ty_1 { + pub ptr: *mut pf_rulequeue, + pub rcount: u_int32_t, + pub version: u_int32_t, + pub open: ::std::os::raw::c_int, +} +#[test] +fn bindgen_test_layout_pf_ruleset__bindgen_ty_1__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 24usize, + concat!( + "Size of: ", + stringify!(pf_ruleset__bindgen_ty_1__bindgen_ty_1) + ) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!( + "Alignment of ", + stringify!(pf_ruleset__bindgen_ty_1__bindgen_ty_1) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ptr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pf_ruleset__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(ptr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rcount) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(pf_ruleset__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(rcount) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).version) as usize - ptr as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(pf_ruleset__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(version) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).open) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(pf_ruleset__bindgen_ty_1__bindgen_ty_1), + "::", + stringify!(open) + ) + ); +} +#[test] +fn bindgen_test_layout_pf_ruleset__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 80usize, + concat!("Size of: ", stringify!(pf_ruleset__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(pf_ruleset__bindgen_ty_1)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).queues) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pf_ruleset__bindgen_ty_1), + "::", + stringify!(queues) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).active) as usize - ptr as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(pf_ruleset__bindgen_ty_1), + "::", + stringify!(active) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).inactive) as usize - ptr as usize }, + 56usize, + concat!( + "Offset of field: ", + stringify!(pf_ruleset__bindgen_ty_1), + "::", + stringify!(inactive) + ) + ); +} +#[test] +fn bindgen_test_layout_pf_ruleset() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 104usize, + concat!("Size of: ", stringify!(pf_ruleset)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(pf_ruleset)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rules) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pf_ruleset), + "::", + stringify!(rules) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).anchor) as usize - ptr as usize }, + 80usize, + concat!( + "Offset of field: ", + stringify!(pf_ruleset), + "::", + stringify!(anchor) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).tticket) as usize - ptr as usize }, + 88usize, + concat!( + "Offset of field: ", + stringify!(pf_ruleset), + "::", + stringify!(tticket) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).tables) as usize - ptr as usize }, + 92usize, + concat!( + "Offset of field: ", + stringify!(pf_ruleset), + "::", + stringify!(tables) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).topen) as usize - ptr as usize }, + 96usize, + concat!( + "Offset of field: ", + stringify!(pf_ruleset), + "::", + stringify!(topen) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct pf_anchor_global { + pub rbh_root: *mut pf_anchor, +} +#[test] +fn bindgen_test_layout_pf_anchor_global() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(pf_anchor_global)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(pf_anchor_global)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rbh_root) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pf_anchor_global), + "::", + stringify!(rbh_root) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct pf_anchor_node { + pub rbh_root: *mut pf_anchor, +} +#[test] +fn bindgen_test_layout_pf_anchor_node() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(pf_anchor_node)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(pf_anchor_node)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rbh_root) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pf_anchor_node), + "::", + stringify!(rbh_root) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct pf_anchor { + pub entry_global: pf_anchor__bindgen_ty_1, + pub entry_node: pf_anchor__bindgen_ty_2, + pub parent: *mut pf_anchor, + pub children: pf_anchor_node, + pub name: [::std::os::raw::c_char; 64usize], + pub path: [::std::os::raw::c_char; 1024usize], + pub ruleset: pf_ruleset, + pub refcnt: ::std::os::raw::c_int, + pub match_: ::std::os::raw::c_int, + pub ref_: refcnt, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct pf_anchor__bindgen_ty_1 { + pub rbe_left: *mut pf_anchor, + pub rbe_right: *mut pf_anchor, + pub rbe_parent: *mut pf_anchor, + pub rbe_color: ::std::os::raw::c_int, +} +#[test] +fn bindgen_test_layout_pf_anchor__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 32usize, + concat!("Size of: ", stringify!(pf_anchor__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(pf_anchor__bindgen_ty_1)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rbe_left) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pf_anchor__bindgen_ty_1), + "::", + stringify!(rbe_left) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rbe_right) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(pf_anchor__bindgen_ty_1), + "::", + stringify!(rbe_right) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rbe_parent) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(pf_anchor__bindgen_ty_1), + "::", + stringify!(rbe_parent) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rbe_color) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(pf_anchor__bindgen_ty_1), + "::", + stringify!(rbe_color) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct pf_anchor__bindgen_ty_2 { + pub rbe_left: *mut pf_anchor, + pub rbe_right: *mut pf_anchor, + pub rbe_parent: *mut pf_anchor, + pub rbe_color: ::std::os::raw::c_int, +} +#[test] +fn bindgen_test_layout_pf_anchor__bindgen_ty_2() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 32usize, + concat!("Size of: ", stringify!(pf_anchor__bindgen_ty_2)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(pf_anchor__bindgen_ty_2)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rbe_left) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pf_anchor__bindgen_ty_2), + "::", + stringify!(rbe_left) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rbe_right) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(pf_anchor__bindgen_ty_2), + "::", + stringify!(rbe_right) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rbe_parent) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(pf_anchor__bindgen_ty_2), + "::", + stringify!(rbe_parent) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rbe_color) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(pf_anchor__bindgen_ty_2), + "::", + stringify!(rbe_color) + ) + ); +} +#[test] +fn bindgen_test_layout_pf_anchor() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 1288usize, + concat!("Size of: ", stringify!(pf_anchor)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(pf_anchor)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).entry_global) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pf_anchor), + "::", + stringify!(entry_global) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).entry_node) as usize - ptr as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(pf_anchor), + "::", + stringify!(entry_node) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).parent) as usize - ptr as usize }, + 64usize, + concat!( + "Offset of field: ", + stringify!(pf_anchor), + "::", + stringify!(parent) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).children) as usize - ptr as usize }, + 72usize, + concat!( + "Offset of field: ", + stringify!(pf_anchor), + "::", + stringify!(children) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).name) as usize - ptr as usize }, + 80usize, + concat!( + "Offset of field: ", + stringify!(pf_anchor), + "::", + stringify!(name) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).path) as usize - ptr as usize }, + 144usize, + concat!( + "Offset of field: ", + stringify!(pf_anchor), + "::", + stringify!(path) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ruleset) as usize - ptr as usize }, + 1168usize, + concat!( + "Offset of field: ", + stringify!(pf_anchor), + "::", + stringify!(ruleset) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).refcnt) as usize - ptr as usize }, + 1272usize, + concat!( + "Offset of field: ", + stringify!(pf_anchor), + "::", + stringify!(refcnt) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).match_) as usize - ptr as usize }, + 1276usize, + concat!( + "Offset of field: ", + stringify!(pf_anchor), + "::", + stringify!(match_) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ref_) as usize - ptr as usize }, + 1280usize, + concat!( + "Offset of field: ", + stringify!(pf_anchor), + "::", + stringify!(ref_) + ) + ); +} +extern "C" { + pub fn pf_anchor_global_RB_INSERT_COLOR(arg1: *mut pf_anchor_global, arg2: *mut pf_anchor); +} +extern "C" { + pub fn pf_anchor_global_RB_REMOVE_COLOR( + arg1: *mut pf_anchor_global, + arg2: *mut pf_anchor, + arg3: *mut pf_anchor, + ); +} +extern "C" { + pub fn pf_anchor_global_RB_REMOVE( + arg1: *mut pf_anchor_global, + arg2: *mut pf_anchor, + ) -> *mut pf_anchor; +} +extern "C" { + pub fn pf_anchor_global_RB_INSERT( + arg1: *mut pf_anchor_global, + arg2: *mut pf_anchor, + ) -> *mut pf_anchor; +} +extern "C" { + pub fn pf_anchor_global_RB_FIND( + arg1: *mut pf_anchor_global, + arg2: *mut pf_anchor, + ) -> *mut pf_anchor; +} +extern "C" { + pub fn pf_anchor_global_RB_NFIND( + arg1: *mut pf_anchor_global, + arg2: *mut pf_anchor, + ) -> *mut pf_anchor; +} +extern "C" { + pub fn pf_anchor_global_RB_NEXT(arg1: *mut pf_anchor) -> *mut pf_anchor; +} +extern "C" { + pub fn pf_anchor_global_RB_PREV(arg1: *mut pf_anchor) -> *mut pf_anchor; +} +extern "C" { + pub fn pf_anchor_global_RB_MINMAX( + arg1: *mut pf_anchor_global, + arg2: ::std::os::raw::c_int, + ) -> *mut pf_anchor; +} +extern "C" { + pub fn pf_anchor_node_RB_INSERT_COLOR(arg1: *mut pf_anchor_node, arg2: *mut pf_anchor); +} +extern "C" { + pub fn pf_anchor_node_RB_REMOVE_COLOR( + arg1: *mut pf_anchor_node, + arg2: *mut pf_anchor, + arg3: *mut pf_anchor, + ); +} +extern "C" { + pub fn pf_anchor_node_RB_REMOVE( + arg1: *mut pf_anchor_node, + arg2: *mut pf_anchor, + ) -> *mut pf_anchor; +} +extern "C" { + pub fn pf_anchor_node_RB_INSERT( + arg1: *mut pf_anchor_node, + arg2: *mut pf_anchor, + ) -> *mut pf_anchor; +} +extern "C" { + pub fn pf_anchor_node_RB_FIND( + arg1: *mut pf_anchor_node, + arg2: *mut pf_anchor, + ) -> *mut pf_anchor; +} +extern "C" { + pub fn pf_anchor_node_RB_NFIND( + arg1: *mut pf_anchor_node, + arg2: *mut pf_anchor, + ) -> *mut pf_anchor; +} +extern "C" { + pub fn pf_anchor_node_RB_NEXT(arg1: *mut pf_anchor) -> *mut pf_anchor; +} +extern "C" { + pub fn pf_anchor_node_RB_PREV(arg1: *mut pf_anchor) -> *mut pf_anchor; +} +extern "C" { + pub fn pf_anchor_node_RB_MINMAX( + arg1: *mut pf_anchor_node, + arg2: ::std::os::raw::c_int, + ) -> *mut pf_anchor; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct pfr_table { + pub pfrt_anchor: [::std::os::raw::c_char; 1024usize], + pub pfrt_name: [::std::os::raw::c_char; 32usize], + pub pfrt_flags: u_int32_t, + pub pfrt_fback: u_int8_t, +} +#[test] +fn bindgen_test_layout_pfr_table() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 1064usize, + concat!("Size of: ", stringify!(pfr_table)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(pfr_table)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfrt_anchor) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pfr_table), + "::", + stringify!(pfrt_anchor) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfrt_name) as usize - ptr as usize }, + 1024usize, + concat!( + "Offset of field: ", + stringify!(pfr_table), + "::", + stringify!(pfrt_name) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfrt_flags) as usize - ptr as usize }, + 1056usize, + concat!( + "Offset of field: ", + stringify!(pfr_table), + "::", + stringify!(pfrt_flags) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfrt_fback) as usize - ptr as usize }, + 1060usize, + concat!( + "Offset of field: ", + stringify!(pfr_table), + "::", + stringify!(pfrt_fback) + ) + ); +} +pub const PFR_FB_NONE: _bindgen_ty_14 = 0; +pub const PFR_FB_MATCH: _bindgen_ty_14 = 1; +pub const PFR_FB_ADDED: _bindgen_ty_14 = 2; +pub const PFR_FB_DELETED: _bindgen_ty_14 = 3; +pub const PFR_FB_CHANGED: _bindgen_ty_14 = 4; +pub const PFR_FB_CLEARED: _bindgen_ty_14 = 5; +pub const PFR_FB_DUPLICATE: _bindgen_ty_14 = 6; +pub const PFR_FB_NOTMATCH: _bindgen_ty_14 = 7; +pub const PFR_FB_CONFLICT: _bindgen_ty_14 = 8; +pub const PFR_FB_NOCOUNT: _bindgen_ty_14 = 9; +pub const PFR_FB_MAX: _bindgen_ty_14 = 10; +pub type _bindgen_ty_14 = ::std::os::raw::c_uint; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct pfr_addr { + pub pfra_u: pfr_addr__bindgen_ty_1, + pub pfra_ifname: [::std::os::raw::c_char; 16usize], + pub pfra_states: u_int32_t, + pub pfra_weight: u_int16_t, + pub pfra_af: u_int8_t, + pub pfra_net: u_int8_t, + pub pfra_not: u_int8_t, + pub pfra_fback: u_int8_t, + pub pfra_type: u_int8_t, + pub pad: [u_int8_t; 7usize], +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union pfr_addr__bindgen_ty_1 { + pub _pfra_ip4addr: in_addr, + pub _pfra_ip6addr: in6_addr, +} +#[test] +fn bindgen_test_layout_pfr_addr__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(pfr_addr__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(pfr_addr__bindgen_ty_1)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr)._pfra_ip4addr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pfr_addr__bindgen_ty_1), + "::", + stringify!(_pfra_ip4addr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr)._pfra_ip6addr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pfr_addr__bindgen_ty_1), + "::", + stringify!(_pfra_ip6addr) + ) + ); +} +#[test] +fn bindgen_test_layout_pfr_addr() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 52usize, + concat!("Size of: ", stringify!(pfr_addr)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(pfr_addr)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfra_u) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pfr_addr), + "::", + stringify!(pfra_u) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfra_ifname) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(pfr_addr), + "::", + stringify!(pfra_ifname) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfra_states) as usize - ptr as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(pfr_addr), + "::", + stringify!(pfra_states) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfra_weight) as usize - ptr as usize }, + 36usize, + concat!( + "Offset of field: ", + stringify!(pfr_addr), + "::", + stringify!(pfra_weight) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfra_af) as usize - ptr as usize }, + 38usize, + concat!( + "Offset of field: ", + stringify!(pfr_addr), + "::", + stringify!(pfra_af) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfra_net) as usize - ptr as usize }, + 39usize, + concat!( + "Offset of field: ", + stringify!(pfr_addr), + "::", + stringify!(pfra_net) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfra_not) as usize - ptr as usize }, + 40usize, + concat!( + "Offset of field: ", + stringify!(pfr_addr), + "::", + stringify!(pfra_not) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfra_fback) as usize - ptr as usize }, + 41usize, + concat!( + "Offset of field: ", + stringify!(pfr_addr), + "::", + stringify!(pfra_fback) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfra_type) as usize - ptr as usize }, + 42usize, + concat!( + "Offset of field: ", + stringify!(pfr_addr), + "::", + stringify!(pfra_type) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pad) as usize - ptr as usize }, + 43usize, + concat!( + "Offset of field: ", + stringify!(pfr_addr), + "::", + stringify!(pad) + ) + ); +} +pub const PFR_DIR_IN: _bindgen_ty_15 = 0; +pub const PFR_DIR_OUT: _bindgen_ty_15 = 1; +pub const PFR_DIR_MAX: _bindgen_ty_15 = 2; +pub type _bindgen_ty_15 = ::std::os::raw::c_uint; +pub const PFR_OP_BLOCK: _bindgen_ty_16 = 0; +pub const PFR_OP_MATCH: _bindgen_ty_16 = 1; +pub const PFR_OP_PASS: _bindgen_ty_16 = 2; +pub const PFR_OP_ADDR_MAX: _bindgen_ty_16 = 3; +pub const PFR_OP_TABLE_MAX: _bindgen_ty_16 = 4; +pub type _bindgen_ty_16 = ::std::os::raw::c_uint; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct pfr_astats { + pub pfras_a: pfr_addr, + pub pfras_packets: [[u_int64_t; 3usize]; 2usize], + pub pfras_bytes: [[u_int64_t; 3usize]; 2usize], + pub pfras_tzero: time_t, +} +#[test] +fn bindgen_test_layout_pfr_astats() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 160usize, + concat!("Size of: ", stringify!(pfr_astats)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(pfr_astats)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfras_a) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pfr_astats), + "::", + stringify!(pfras_a) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfras_packets) as usize - ptr as usize }, + 56usize, + concat!( + "Offset of field: ", + stringify!(pfr_astats), + "::", + stringify!(pfras_packets) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfras_bytes) as usize - ptr as usize }, + 104usize, + concat!( + "Offset of field: ", + stringify!(pfr_astats), + "::", + stringify!(pfras_bytes) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfras_tzero) as usize - ptr as usize }, + 152usize, + concat!( + "Offset of field: ", + stringify!(pfr_astats), + "::", + stringify!(pfras_tzero) + ) + ); +} +pub const PFR_REFCNT_RULE: _bindgen_ty_17 = 0; +pub const PFR_REFCNT_ANCHOR: _bindgen_ty_17 = 1; +pub const PFR_REFCNT_MAX: _bindgen_ty_17 = 2; +pub type _bindgen_ty_17 = ::std::os::raw::c_uint; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct pfr_tstats { + pub pfrts_t: pfr_table, + pub pfrts_packets: [[u_int64_t; 4usize]; 2usize], + pub pfrts_bytes: [[u_int64_t; 4usize]; 2usize], + pub pfrts_match: u_int64_t, + pub pfrts_nomatch: u_int64_t, + pub pfrts_tzero: time_t, + pub pfrts_cnt: ::std::os::raw::c_int, + pub pfrts_refcnt: [::std::os::raw::c_int; 2usize], +} +#[test] +fn bindgen_test_layout_pfr_tstats() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 1232usize, + concat!("Size of: ", stringify!(pfr_tstats)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(pfr_tstats)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfrts_t) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pfr_tstats), + "::", + stringify!(pfrts_t) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfrts_packets) as usize - ptr as usize }, + 1064usize, + concat!( + "Offset of field: ", + stringify!(pfr_tstats), + "::", + stringify!(pfrts_packets) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfrts_bytes) as usize - ptr as usize }, + 1128usize, + concat!( + "Offset of field: ", + stringify!(pfr_tstats), + "::", + stringify!(pfrts_bytes) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfrts_match) as usize - ptr as usize }, + 1192usize, + concat!( + "Offset of field: ", + stringify!(pfr_tstats), + "::", + stringify!(pfrts_match) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfrts_nomatch) as usize - ptr as usize }, + 1200usize, + concat!( + "Offset of field: ", + stringify!(pfr_tstats), + "::", + stringify!(pfrts_nomatch) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfrts_tzero) as usize - ptr as usize }, + 1208usize, + concat!( + "Offset of field: ", + stringify!(pfr_tstats), + "::", + stringify!(pfrts_tzero) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfrts_cnt) as usize - ptr as usize }, + 1216usize, + concat!( + "Offset of field: ", + stringify!(pfr_tstats), + "::", + stringify!(pfrts_cnt) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfrts_refcnt) as usize - ptr as usize }, + 1220usize, + concat!( + "Offset of field: ", + stringify!(pfr_tstats), + "::", + stringify!(pfrts_refcnt) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct pfr_kcounters { + pub pfrkc_packets: [[u_int64_t; 3usize]; 2usize], + pub pfrkc_bytes: [[u_int64_t; 3usize]; 2usize], + pub states: u_int64_t, +} +#[test] +fn bindgen_test_layout_pfr_kcounters() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 104usize, + concat!("Size of: ", stringify!(pfr_kcounters)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(pfr_kcounters)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfrkc_packets) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pfr_kcounters), + "::", + stringify!(pfrkc_packets) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfrkc_bytes) as usize - ptr as usize }, + 48usize, + concat!( + "Offset of field: ", + stringify!(pfr_kcounters), + "::", + stringify!(pfrkc_bytes) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).states) as usize - ptr as usize }, + 96usize, + concat!( + "Offset of field: ", + stringify!(pfr_kcounters), + "::", + stringify!(states) + ) + ); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union pfsockaddr_union { + pub sa: sockaddr, + pub sin: sockaddr_in, + pub sin6: sockaddr_in6, +} +#[test] +fn bindgen_test_layout_pfsockaddr_union() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 28usize, + concat!("Size of: ", stringify!(pfsockaddr_union)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(pfsockaddr_union)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).sa) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pfsockaddr_union), + "::", + stringify!(sa) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).sin) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pfsockaddr_union), + "::", + stringify!(sin) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).sin6) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pfsockaddr_union), + "::", + stringify!(sin6) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct pfr_kentryworkq { + pub slh_first: *mut pfr_kentry, +} +#[test] +fn bindgen_test_layout_pfr_kentryworkq() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(pfr_kentryworkq)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(pfr_kentryworkq)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).slh_first) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pfr_kentryworkq), + "::", + stringify!(slh_first) + ) + ); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _pfr_kentry { + pub _pfrke_node: [radix_node; 2usize], + pub _pfrke_sa: pfsockaddr_union, + pub _pfrke_workq: _pfr_kentry__bindgen_ty_1, + pub _pfrke_ioq: _pfr_kentry__bindgen_ty_2, + pub _pfrke_counters: *mut pfr_kcounters, + pub _pfrke_tzero: time_t, + pub _pfrke_af: u_int8_t, + pub _pfrke_net: u_int8_t, + pub _pfrke_flags: u_int8_t, + pub _pfrke_type: u_int8_t, + pub _pfrke_fb: u_int8_t, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _pfr_kentry__bindgen_ty_1 { + pub sle_next: *mut pfr_kentry, +} +#[test] +fn bindgen_test_layout__pfr_kentry__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit<_pfr_kentry__bindgen_ty_1> = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<_pfr_kentry__bindgen_ty_1>(), + 8usize, + concat!("Size of: ", stringify!(_pfr_kentry__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::<_pfr_kentry__bindgen_ty_1>(), + 8usize, + concat!("Alignment of ", stringify!(_pfr_kentry__bindgen_ty_1)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).sle_next) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_pfr_kentry__bindgen_ty_1), + "::", + stringify!(sle_next) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _pfr_kentry__bindgen_ty_2 { + pub sle_next: *mut pfr_kentry, +} +#[test] +fn bindgen_test_layout__pfr_kentry__bindgen_ty_2() { + const UNINIT: ::std::mem::MaybeUninit<_pfr_kentry__bindgen_ty_2> = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<_pfr_kentry__bindgen_ty_2>(), + 8usize, + concat!("Size of: ", stringify!(_pfr_kentry__bindgen_ty_2)) + ); + assert_eq!( + ::std::mem::align_of::<_pfr_kentry__bindgen_ty_2>(), + 8usize, + concat!("Alignment of ", stringify!(_pfr_kentry__bindgen_ty_2)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).sle_next) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_pfr_kentry__bindgen_ty_2), + "::", + stringify!(sle_next) + ) + ); +} +#[test] +fn bindgen_test_layout__pfr_kentry() { + const UNINIT: ::std::mem::MaybeUninit<_pfr_kentry> = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<_pfr_kentry>(), + 168usize, + concat!("Size of: ", stringify!(_pfr_kentry)) + ); + assert_eq!( + ::std::mem::align_of::<_pfr_kentry>(), + 8usize, + concat!("Alignment of ", stringify!(_pfr_kentry)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr)._pfrke_node) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_pfr_kentry), + "::", + stringify!(_pfrke_node) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr)._pfrke_sa) as usize - ptr as usize }, + 96usize, + concat!( + "Offset of field: ", + stringify!(_pfr_kentry), + "::", + stringify!(_pfrke_sa) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr)._pfrke_workq) as usize - ptr as usize }, + 128usize, + concat!( + "Offset of field: ", + stringify!(_pfr_kentry), + "::", + stringify!(_pfrke_workq) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr)._pfrke_ioq) as usize - ptr as usize }, + 136usize, + concat!( + "Offset of field: ", + stringify!(_pfr_kentry), + "::", + stringify!(_pfrke_ioq) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr)._pfrke_counters) as usize - ptr as usize }, + 144usize, + concat!( + "Offset of field: ", + stringify!(_pfr_kentry), + "::", + stringify!(_pfrke_counters) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr)._pfrke_tzero) as usize - ptr as usize }, + 152usize, + concat!( + "Offset of field: ", + stringify!(_pfr_kentry), + "::", + stringify!(_pfrke_tzero) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr)._pfrke_af) as usize - ptr as usize }, + 160usize, + concat!( + "Offset of field: ", + stringify!(_pfr_kentry), + "::", + stringify!(_pfrke_af) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr)._pfrke_net) as usize - ptr as usize }, + 161usize, + concat!( + "Offset of field: ", + stringify!(_pfr_kentry), + "::", + stringify!(_pfrke_net) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr)._pfrke_flags) as usize - ptr as usize }, + 162usize, + concat!( + "Offset of field: ", + stringify!(_pfr_kentry), + "::", + stringify!(_pfrke_flags) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr)._pfrke_type) as usize - ptr as usize }, + 163usize, + concat!( + "Offset of field: ", + stringify!(_pfr_kentry), + "::", + stringify!(_pfrke_type) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr)._pfrke_fb) as usize - ptr as usize }, + 164usize, + concat!( + "Offset of field: ", + stringify!(_pfr_kentry), + "::", + stringify!(_pfrke_fb) + ) + ); +} +pub const PFRKE_PLAIN: _bindgen_ty_18 = 0; +pub const PFRKE_ROUTE: _bindgen_ty_18 = 1; +pub const PFRKE_COST: _bindgen_ty_18 = 2; +pub const PFRKE_MAX: _bindgen_ty_18 = 3; +pub type _bindgen_ty_18 = ::std::os::raw::c_uint; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct pfr_kentry { + pub u: pfr_kentry__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union pfr_kentry__bindgen_ty_1 { + pub _ke: _pfr_kentry, +} +#[test] +fn bindgen_test_layout_pfr_kentry__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 168usize, + concat!("Size of: ", stringify!(pfr_kentry__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(pfr_kentry__bindgen_ty_1)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr)._ke) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pfr_kentry__bindgen_ty_1), + "::", + stringify!(_ke) + ) + ); +} +#[test] +fn bindgen_test_layout_pfr_kentry() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 168usize, + concat!("Size of: ", stringify!(pfr_kentry)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(pfr_kentry)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).u) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pfr_kentry), + "::", + stringify!(u) + ) + ); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct pfr_kentry_route { + pub u: pfr_kentry_route__bindgen_ty_1, + pub kif: *mut pfi_kif, + pub ifname: [::std::os::raw::c_char; 16usize], +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union pfr_kentry_route__bindgen_ty_1 { + pub _ke: _pfr_kentry, +} +#[test] +fn bindgen_test_layout_pfr_kentry_route__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 168usize, + concat!("Size of: ", stringify!(pfr_kentry_route__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(pfr_kentry_route__bindgen_ty_1)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr)._ke) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pfr_kentry_route__bindgen_ty_1), + "::", + stringify!(_ke) + ) + ); +} +#[test] +fn bindgen_test_layout_pfr_kentry_route() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 192usize, + concat!("Size of: ", stringify!(pfr_kentry_route)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(pfr_kentry_route)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).u) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pfr_kentry_route), + "::", + stringify!(u) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).kif) as usize - ptr as usize }, + 168usize, + concat!( + "Offset of field: ", + stringify!(pfr_kentry_route), + "::", + stringify!(kif) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifname) as usize - ptr as usize }, + 176usize, + concat!( + "Offset of field: ", + stringify!(pfr_kentry_route), + "::", + stringify!(ifname) + ) + ); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct pfr_kentry_cost { + pub u: pfr_kentry_cost__bindgen_ty_1, + pub kif: *mut pfi_kif, + pub ifname: [::std::os::raw::c_char; 16usize], + pub weight: u_int16_t, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union pfr_kentry_cost__bindgen_ty_1 { + pub _ke: _pfr_kentry, +} +#[test] +fn bindgen_test_layout_pfr_kentry_cost__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 168usize, + concat!("Size of: ", stringify!(pfr_kentry_cost__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(pfr_kentry_cost__bindgen_ty_1)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr)._ke) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pfr_kentry_cost__bindgen_ty_1), + "::", + stringify!(_ke) + ) + ); +} +#[test] +fn bindgen_test_layout_pfr_kentry_cost() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 200usize, + concat!("Size of: ", stringify!(pfr_kentry_cost)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(pfr_kentry_cost)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).u) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pfr_kentry_cost), + "::", + stringify!(u) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).kif) as usize - ptr as usize }, + 168usize, + concat!( + "Offset of field: ", + stringify!(pfr_kentry_cost), + "::", + stringify!(kif) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifname) as usize - ptr as usize }, + 176usize, + concat!( + "Offset of field: ", + stringify!(pfr_kentry_cost), + "::", + stringify!(ifname) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).weight) as usize - ptr as usize }, + 192usize, + concat!( + "Offset of field: ", + stringify!(pfr_kentry_cost), + "::", + stringify!(weight) + ) + ); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct pfr_kentry_all { + pub u: pfr_kentry_all__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union pfr_kentry_all__bindgen_ty_1 { + pub _ke: _pfr_kentry, + pub kr: pfr_kentry_route, + pub kc: pfr_kentry_cost, +} +#[test] +fn bindgen_test_layout_pfr_kentry_all__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 200usize, + concat!("Size of: ", stringify!(pfr_kentry_all__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(pfr_kentry_all__bindgen_ty_1)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr)._ke) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pfr_kentry_all__bindgen_ty_1), + "::", + stringify!(_ke) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).kr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pfr_kentry_all__bindgen_ty_1), + "::", + stringify!(kr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).kc) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pfr_kentry_all__bindgen_ty_1), + "::", + stringify!(kc) + ) + ); +} +#[test] +fn bindgen_test_layout_pfr_kentry_all() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 200usize, + concat!("Size of: ", stringify!(pfr_kentry_all)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(pfr_kentry_all)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).u) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pfr_kentry_all), + "::", + stringify!(u) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct pfr_ktableworkq { + pub slh_first: *mut pfr_ktable, +} +#[test] +fn bindgen_test_layout_pfr_ktableworkq() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(pfr_ktableworkq)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(pfr_ktableworkq)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).slh_first) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pfr_ktableworkq), + "::", + stringify!(slh_first) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct pfr_ktablehead { + pub rbh_root: *mut pfr_ktable, +} +#[test] +fn bindgen_test_layout_pfr_ktablehead() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(pfr_ktablehead)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(pfr_ktablehead)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rbh_root) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pfr_ktablehead), + "::", + stringify!(rbh_root) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct pfr_ktable { + pub pfrkt_ts: pfr_tstats, + pub pfrkt_tree: pfr_ktable__bindgen_ty_1, + pub pfrkt_workq: pfr_ktable__bindgen_ty_2, + pub pfrkt_ip4: *mut radix_node_head, + pub pfrkt_ip6: *mut radix_node_head, + pub pfrkt_shadow: *mut pfr_ktable, + pub pfrkt_root: *mut pfr_ktable, + pub pfrkt_rs: *mut pf_ruleset, + pub pfrkt_larg: ::std::os::raw::c_long, + pub pfrkt_nflags: ::std::os::raw::c_int, + pub pfrkt_refcntcost: u_int64_t, + pub pfrkt_gcdweight: u_int16_t, + pub pfrkt_maxweight: u_int16_t, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct pfr_ktable__bindgen_ty_1 { + pub rbe_left: *mut pfr_ktable, + pub rbe_right: *mut pfr_ktable, + pub rbe_parent: *mut pfr_ktable, + pub rbe_color: ::std::os::raw::c_int, +} +#[test] +fn bindgen_test_layout_pfr_ktable__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 32usize, + concat!("Size of: ", stringify!(pfr_ktable__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(pfr_ktable__bindgen_ty_1)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rbe_left) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pfr_ktable__bindgen_ty_1), + "::", + stringify!(rbe_left) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rbe_right) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(pfr_ktable__bindgen_ty_1), + "::", + stringify!(rbe_right) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rbe_parent) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(pfr_ktable__bindgen_ty_1), + "::", + stringify!(rbe_parent) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rbe_color) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(pfr_ktable__bindgen_ty_1), + "::", + stringify!(rbe_color) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct pfr_ktable__bindgen_ty_2 { + pub sle_next: *mut pfr_ktable, +} +#[test] +fn bindgen_test_layout_pfr_ktable__bindgen_ty_2() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(pfr_ktable__bindgen_ty_2)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(pfr_ktable__bindgen_ty_2)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).sle_next) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pfr_ktable__bindgen_ty_2), + "::", + stringify!(sle_next) + ) + ); +} +#[test] +fn bindgen_test_layout_pfr_ktable() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 1344usize, + concat!("Size of: ", stringify!(pfr_ktable)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(pfr_ktable)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfrkt_ts) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pfr_ktable), + "::", + stringify!(pfrkt_ts) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfrkt_tree) as usize - ptr as usize }, + 1232usize, + concat!( + "Offset of field: ", + stringify!(pfr_ktable), + "::", + stringify!(pfrkt_tree) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfrkt_workq) as usize - ptr as usize }, + 1264usize, + concat!( + "Offset of field: ", + stringify!(pfr_ktable), + "::", + stringify!(pfrkt_workq) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfrkt_ip4) as usize - ptr as usize }, + 1272usize, + concat!( + "Offset of field: ", + stringify!(pfr_ktable), + "::", + stringify!(pfrkt_ip4) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfrkt_ip6) as usize - ptr as usize }, + 1280usize, + concat!( + "Offset of field: ", + stringify!(pfr_ktable), + "::", + stringify!(pfrkt_ip6) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfrkt_shadow) as usize - ptr as usize }, + 1288usize, + concat!( + "Offset of field: ", + stringify!(pfr_ktable), + "::", + stringify!(pfrkt_shadow) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfrkt_root) as usize - ptr as usize }, + 1296usize, + concat!( + "Offset of field: ", + stringify!(pfr_ktable), + "::", + stringify!(pfrkt_root) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfrkt_rs) as usize - ptr as usize }, + 1304usize, + concat!( + "Offset of field: ", + stringify!(pfr_ktable), + "::", + stringify!(pfrkt_rs) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfrkt_larg) as usize - ptr as usize }, + 1312usize, + concat!( + "Offset of field: ", + stringify!(pfr_ktable), + "::", + stringify!(pfrkt_larg) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfrkt_nflags) as usize - ptr as usize }, + 1320usize, + concat!( + "Offset of field: ", + stringify!(pfr_ktable), + "::", + stringify!(pfrkt_nflags) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfrkt_refcntcost) as usize - ptr as usize }, + 1328usize, + concat!( + "Offset of field: ", + stringify!(pfr_ktable), + "::", + stringify!(pfrkt_refcntcost) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfrkt_gcdweight) as usize - ptr as usize }, + 1336usize, + concat!( + "Offset of field: ", + stringify!(pfr_ktable), + "::", + stringify!(pfrkt_gcdweight) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfrkt_maxweight) as usize - ptr as usize }, + 1338usize, + concat!( + "Offset of field: ", + stringify!(pfr_ktable), + "::", + stringify!(pfrkt_maxweight) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct pf_state_tree_ext_gwy { + pub rbh_root: *mut pf_state_key, +} +#[test] +fn bindgen_test_layout_pf_state_tree_ext_gwy() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(pf_state_tree_ext_gwy)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(pf_state_tree_ext_gwy)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rbh_root) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pf_state_tree_ext_gwy), + "::", + stringify!(rbh_root) + ) + ); +} +extern "C" { + pub fn pf_state_tree_ext_gwy_RB_INSERT_COLOR( + arg1: *mut pf_state_tree_ext_gwy, + arg2: *mut pf_state_key, + ); +} +extern "C" { + pub fn pf_state_tree_ext_gwy_RB_REMOVE_COLOR( + arg1: *mut pf_state_tree_ext_gwy, + arg2: *mut pf_state_key, + arg3: *mut pf_state_key, + ); +} +extern "C" { + pub fn pf_state_tree_ext_gwy_RB_REMOVE( + arg1: *mut pf_state_tree_ext_gwy, + arg2: *mut pf_state_key, + ) -> *mut pf_state_key; +} +extern "C" { + pub fn pf_state_tree_ext_gwy_RB_INSERT( + arg1: *mut pf_state_tree_ext_gwy, + arg2: *mut pf_state_key, + ) -> *mut pf_state_key; +} +extern "C" { + pub fn pf_state_tree_ext_gwy_RB_FIND( + arg1: *mut pf_state_tree_ext_gwy, + arg2: *mut pf_state_key, + ) -> *mut pf_state_key; +} +extern "C" { + pub fn pf_state_tree_ext_gwy_RB_NFIND( + arg1: *mut pf_state_tree_ext_gwy, + arg2: *mut pf_state_key, + ) -> *mut pf_state_key; +} +extern "C" { + pub fn pf_state_tree_ext_gwy_RB_NEXT(arg1: *mut pf_state_key) -> *mut pf_state_key; +} +extern "C" { + pub fn pf_state_tree_ext_gwy_RB_PREV(arg1: *mut pf_state_key) -> *mut pf_state_key; +} +extern "C" { + pub fn pf_state_tree_ext_gwy_RB_MINMAX( + arg1: *mut pf_state_tree_ext_gwy, + arg2: ::std::os::raw::c_int, + ) -> *mut pf_state_key; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct pfi_ifhead { + pub rbh_root: *mut pfi_kif, +} +#[test] +fn bindgen_test_layout_pfi_ifhead() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(pfi_ifhead)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(pfi_ifhead)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rbh_root) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pfi_ifhead), + "::", + stringify!(rbh_root) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct pf_state_tree { + _unused: [u8; 0], +} +extern "C" { + pub static mut pf_statetbl: pf_state_tree; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct pfi_kif_cmp { + pub pfik_name: [::std::os::raw::c_char; 16usize], +} +#[test] +fn bindgen_test_layout_pfi_kif_cmp() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(pfi_kif_cmp)) + ); + assert_eq!( + ::std::mem::align_of::(), + 1usize, + concat!("Alignment of ", stringify!(pfi_kif_cmp)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfik_name) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pfi_kif_cmp), + "::", + stringify!(pfik_name) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct ifnet { + _unused: [u8; 0], +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct ifg_group { + _unused: [u8; 0], +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct pfi_kif { + pub pfik_name: [::std::os::raw::c_char; 16usize], + pub pfik_tree: pfi_kif__bindgen_ty_1, + pub pfik_packets: [[[u_int64_t; 2usize]; 2usize]; 2usize], + pub pfik_bytes: [[[u_int64_t; 2usize]; 2usize]; 2usize], + pub pfik_tzero: time_t, + pub pfik_flags: ::std::os::raw::c_int, + pub pfik_flags_new: ::std::os::raw::c_int, + pub pfik_ah_cookie: *mut ::std::os::raw::c_void, + pub pfik_ifp: *mut ifnet, + pub pfik_group: *mut ifg_group, + pub pfik_states: ::std::os::raw::c_int, + pub pfik_rules: ::std::os::raw::c_int, + pub pfik_routes: ::std::os::raw::c_int, + pub pfik_srcnodes: ::std::os::raw::c_int, + pub pfik_flagrefs: ::std::os::raw::c_int, + pub pfik_dynaddrs: pfi_kif__bindgen_ty_2, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct pfi_kif__bindgen_ty_1 { + pub rbe_left: *mut pfi_kif, + pub rbe_right: *mut pfi_kif, + pub rbe_parent: *mut pfi_kif, + pub rbe_color: ::std::os::raw::c_int, +} +#[test] +fn bindgen_test_layout_pfi_kif__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 32usize, + concat!("Size of: ", stringify!(pfi_kif__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(pfi_kif__bindgen_ty_1)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rbe_left) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pfi_kif__bindgen_ty_1), + "::", + stringify!(rbe_left) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rbe_right) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(pfi_kif__bindgen_ty_1), + "::", + stringify!(rbe_right) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rbe_parent) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(pfi_kif__bindgen_ty_1), + "::", + stringify!(rbe_parent) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rbe_color) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(pfi_kif__bindgen_ty_1), + "::", + stringify!(rbe_color) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct pfi_kif__bindgen_ty_2 { + pub tqh_first: *mut pfi_dynaddr, + pub tqh_last: *mut *mut pfi_dynaddr, +} +#[test] +fn bindgen_test_layout_pfi_kif__bindgen_ty_2() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(pfi_kif__bindgen_ty_2)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(pfi_kif__bindgen_ty_2)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).tqh_first) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pfi_kif__bindgen_ty_2), + "::", + stringify!(tqh_first) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).tqh_last) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(pfi_kif__bindgen_ty_2), + "::", + stringify!(tqh_last) + ) + ); +} +#[test] +fn bindgen_test_layout_pfi_kif() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 256usize, + concat!("Size of: ", stringify!(pfi_kif)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(pfi_kif)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfik_name) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pfi_kif), + "::", + stringify!(pfik_name) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfik_tree) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(pfi_kif), + "::", + stringify!(pfik_tree) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfik_packets) as usize - ptr as usize }, + 48usize, + concat!( + "Offset of field: ", + stringify!(pfi_kif), + "::", + stringify!(pfik_packets) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfik_bytes) as usize - ptr as usize }, + 112usize, + concat!( + "Offset of field: ", + stringify!(pfi_kif), + "::", + stringify!(pfik_bytes) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfik_tzero) as usize - ptr as usize }, + 176usize, + concat!( + "Offset of field: ", + stringify!(pfi_kif), + "::", + stringify!(pfik_tzero) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfik_flags) as usize - ptr as usize }, + 184usize, + concat!( + "Offset of field: ", + stringify!(pfi_kif), + "::", + stringify!(pfik_flags) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfik_flags_new) as usize - ptr as usize }, + 188usize, + concat!( + "Offset of field: ", + stringify!(pfi_kif), + "::", + stringify!(pfik_flags_new) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfik_ah_cookie) as usize - ptr as usize }, + 192usize, + concat!( + "Offset of field: ", + stringify!(pfi_kif), + "::", + stringify!(pfik_ah_cookie) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfik_ifp) as usize - ptr as usize }, + 200usize, + concat!( + "Offset of field: ", + stringify!(pfi_kif), + "::", + stringify!(pfik_ifp) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfik_group) as usize - ptr as usize }, + 208usize, + concat!( + "Offset of field: ", + stringify!(pfi_kif), + "::", + stringify!(pfik_group) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfik_states) as usize - ptr as usize }, + 216usize, + concat!( + "Offset of field: ", + stringify!(pfi_kif), + "::", + stringify!(pfik_states) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfik_rules) as usize - ptr as usize }, + 220usize, + concat!( + "Offset of field: ", + stringify!(pfi_kif), + "::", + stringify!(pfik_rules) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfik_routes) as usize - ptr as usize }, + 224usize, + concat!( + "Offset of field: ", + stringify!(pfi_kif), + "::", + stringify!(pfik_routes) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfik_srcnodes) as usize - ptr as usize }, + 228usize, + concat!( + "Offset of field: ", + stringify!(pfi_kif), + "::", + stringify!(pfik_srcnodes) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfik_flagrefs) as usize - ptr as usize }, + 232usize, + concat!( + "Offset of field: ", + stringify!(pfi_kif), + "::", + stringify!(pfik_flagrefs) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfik_dynaddrs) as usize - ptr as usize }, + 240usize, + concat!( + "Offset of field: ", + stringify!(pfi_kif), + "::", + stringify!(pfik_dynaddrs) + ) + ); +} +pub const pfi_kif_refs_PFI_KIF_REF_NONE: pfi_kif_refs = 0; +pub const pfi_kif_refs_PFI_KIF_REF_STATE: pfi_kif_refs = 1; +pub const pfi_kif_refs_PFI_KIF_REF_RULE: pfi_kif_refs = 2; +pub const pfi_kif_refs_PFI_KIF_REF_ROUTE: pfi_kif_refs = 3; +pub const pfi_kif_refs_PFI_KIF_REF_SRCNODE: pfi_kif_refs = 4; +pub const pfi_kif_refs_PFI_KIF_REF_FLAG: pfi_kif_refs = 5; +pub type pfi_kif_refs = ::std::os::raw::c_uint; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct pf_status { + pub counters: [u_int64_t; 17usize], + pub lcounters: [u_int64_t; 10usize], + pub fcounters: [u_int64_t; 3usize], + pub scounters: [u_int64_t; 3usize], + pub pcounters: [[[u_int64_t; 3usize]; 2usize]; 2usize], + pub bcounters: [[u_int64_t; 2usize]; 2usize], + pub stateid: u_int64_t, + pub syncookies_inflight: [u_int64_t; 2usize], + pub since: time_t, + pub running: u_int32_t, + pub states: u_int32_t, + pub states_halfopen: u_int32_t, + pub src_nodes: u_int32_t, + pub debug: u_int32_t, + pub hostid: u_int32_t, + pub reass: u_int32_t, + pub syncookies_active: u_int8_t, + pub syncookies_mode: u_int8_t, + pub pad: [u_int8_t; 2usize], + pub ifname: [::std::os::raw::c_char; 16usize], + pub pf_chksum: [u_int8_t; 16usize], +} +#[test] +fn bindgen_test_layout_pf_status() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 488usize, + concat!("Size of: ", stringify!(pf_status)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(pf_status)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).counters) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pf_status), + "::", + stringify!(counters) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).lcounters) as usize - ptr as usize }, + 136usize, + concat!( + "Offset of field: ", + stringify!(pf_status), + "::", + stringify!(lcounters) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).fcounters) as usize - ptr as usize }, + 216usize, + concat!( + "Offset of field: ", + stringify!(pf_status), + "::", + stringify!(fcounters) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).scounters) as usize - ptr as usize }, + 240usize, + concat!( + "Offset of field: ", + stringify!(pf_status), + "::", + stringify!(scounters) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pcounters) as usize - ptr as usize }, + 264usize, + concat!( + "Offset of field: ", + stringify!(pf_status), + "::", + stringify!(pcounters) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).bcounters) as usize - ptr as usize }, + 360usize, + concat!( + "Offset of field: ", + stringify!(pf_status), + "::", + stringify!(bcounters) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).stateid) as usize - ptr as usize }, + 392usize, + concat!( + "Offset of field: ", + stringify!(pf_status), + "::", + stringify!(stateid) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).syncookies_inflight) as usize - ptr as usize }, + 400usize, + concat!( + "Offset of field: ", + stringify!(pf_status), + "::", + stringify!(syncookies_inflight) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).since) as usize - ptr as usize }, + 416usize, + concat!( + "Offset of field: ", + stringify!(pf_status), + "::", + stringify!(since) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).running) as usize - ptr as usize }, + 424usize, + concat!( + "Offset of field: ", + stringify!(pf_status), + "::", + stringify!(running) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).states) as usize - ptr as usize }, + 428usize, + concat!( + "Offset of field: ", + stringify!(pf_status), + "::", + stringify!(states) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).states_halfopen) as usize - ptr as usize }, + 432usize, + concat!( + "Offset of field: ", + stringify!(pf_status), + "::", + stringify!(states_halfopen) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).src_nodes) as usize - ptr as usize }, + 436usize, + concat!( + "Offset of field: ", + stringify!(pf_status), + "::", + stringify!(src_nodes) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).debug) as usize - ptr as usize }, + 440usize, + concat!( + "Offset of field: ", + stringify!(pf_status), + "::", + stringify!(debug) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).hostid) as usize - ptr as usize }, + 444usize, + concat!( + "Offset of field: ", + stringify!(pf_status), + "::", + stringify!(hostid) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).reass) as usize - ptr as usize }, + 448usize, + concat!( + "Offset of field: ", + stringify!(pf_status), + "::", + stringify!(reass) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).syncookies_active) as usize - ptr as usize }, + 452usize, + concat!( + "Offset of field: ", + stringify!(pf_status), + "::", + stringify!(syncookies_active) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).syncookies_mode) as usize - ptr as usize }, + 453usize, + concat!( + "Offset of field: ", + stringify!(pf_status), + "::", + stringify!(syncookies_mode) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pad) as usize - ptr as usize }, + 454usize, + concat!( + "Offset of field: ", + stringify!(pf_status), + "::", + stringify!(pad) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifname) as usize - ptr as usize }, + 456usize, + concat!( + "Offset of field: ", + stringify!(pf_status), + "::", + stringify!(ifname) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pf_chksum) as usize - ptr as usize }, + 472usize, + concat!( + "Offset of field: ", + stringify!(pf_status), + "::", + stringify!(pf_chksum) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct pf_queue_bwspec { + pub absolute: u_int, + pub percent: u_int, +} +#[test] +fn bindgen_test_layout_pf_queue_bwspec() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(pf_queue_bwspec)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(pf_queue_bwspec)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).absolute) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pf_queue_bwspec), + "::", + stringify!(absolute) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).percent) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(pf_queue_bwspec), + "::", + stringify!(percent) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct pf_queue_scspec { + pub m1: pf_queue_bwspec, + pub m2: pf_queue_bwspec, + pub d: u_int, +} +#[test] +fn bindgen_test_layout_pf_queue_scspec() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 20usize, + concat!("Size of: ", stringify!(pf_queue_scspec)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(pf_queue_scspec)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).m1) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pf_queue_scspec), + "::", + stringify!(m1) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).m2) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(pf_queue_scspec), + "::", + stringify!(m2) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).d) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(pf_queue_scspec), + "::", + stringify!(d) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct pf_queue_fqspec { + pub flows: u_int, + pub quantum: u_int, + pub target: u_int, + pub interval: u_int, +} +#[test] +fn bindgen_test_layout_pf_queue_fqspec() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(pf_queue_fqspec)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(pf_queue_fqspec)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).flows) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pf_queue_fqspec), + "::", + stringify!(flows) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).quantum) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(pf_queue_fqspec), + "::", + stringify!(quantum) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).target) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(pf_queue_fqspec), + "::", + stringify!(target) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).interval) as usize - ptr as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(pf_queue_fqspec), + "::", + stringify!(interval) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct pf_queuespec { + pub entries: pf_queuespec__bindgen_ty_1, + pub qname: [::std::os::raw::c_char; 64usize], + pub parent: [::std::os::raw::c_char; 64usize], + pub ifname: [::std::os::raw::c_char; 16usize], + pub realtime: pf_queue_scspec, + pub linkshare: pf_queue_scspec, + pub upperlimit: pf_queue_scspec, + pub flowqueue: pf_queue_fqspec, + pub kif: *mut pfi_kif, + pub flags: u_int, + pub qlimit: u_int, + pub qid: u_int32_t, + pub parent_qid: u_int32_t, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct pf_queuespec__bindgen_ty_1 { + pub tqe_next: *mut pf_queuespec, + pub tqe_prev: *mut *mut pf_queuespec, +} +#[test] +fn bindgen_test_layout_pf_queuespec__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(pf_queuespec__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(pf_queuespec__bindgen_ty_1)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).tqe_next) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pf_queuespec__bindgen_ty_1), + "::", + stringify!(tqe_next) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).tqe_prev) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(pf_queuespec__bindgen_ty_1), + "::", + stringify!(tqe_prev) + ) + ); +} +#[test] +fn bindgen_test_layout_pf_queuespec() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 264usize, + concat!("Size of: ", stringify!(pf_queuespec)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(pf_queuespec)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).entries) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pf_queuespec), + "::", + stringify!(entries) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).qname) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(pf_queuespec), + "::", + stringify!(qname) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).parent) as usize - ptr as usize }, + 80usize, + concat!( + "Offset of field: ", + stringify!(pf_queuespec), + "::", + stringify!(parent) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifname) as usize - ptr as usize }, + 144usize, + concat!( + "Offset of field: ", + stringify!(pf_queuespec), + "::", + stringify!(ifname) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).realtime) as usize - ptr as usize }, + 160usize, + concat!( + "Offset of field: ", + stringify!(pf_queuespec), + "::", + stringify!(realtime) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).linkshare) as usize - ptr as usize }, + 180usize, + concat!( + "Offset of field: ", + stringify!(pf_queuespec), + "::", + stringify!(linkshare) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).upperlimit) as usize - ptr as usize }, + 200usize, + concat!( + "Offset of field: ", + stringify!(pf_queuespec), + "::", + stringify!(upperlimit) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).flowqueue) as usize - ptr as usize }, + 220usize, + concat!( + "Offset of field: ", + stringify!(pf_queuespec), + "::", + stringify!(flowqueue) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).kif) as usize - ptr as usize }, + 240usize, + concat!( + "Offset of field: ", + stringify!(pf_queuespec), + "::", + stringify!(kif) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, + 248usize, + concat!( + "Offset of field: ", + stringify!(pf_queuespec), + "::", + stringify!(flags) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).qlimit) as usize - ptr as usize }, + 252usize, + concat!( + "Offset of field: ", + stringify!(pf_queuespec), + "::", + stringify!(qlimit) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).qid) as usize - ptr as usize }, + 256usize, + concat!( + "Offset of field: ", + stringify!(pf_queuespec), + "::", + stringify!(qid) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).parent_qid) as usize - ptr as usize }, + 260usize, + concat!( + "Offset of field: ", + stringify!(pf_queuespec), + "::", + stringify!(parent_qid) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct priq_opts { + pub flags: ::std::os::raw::c_int, +} +#[test] +fn bindgen_test_layout_priq_opts() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 4usize, + concat!("Size of: ", stringify!(priq_opts)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(priq_opts)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(priq_opts), + "::", + stringify!(flags) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct hfsc_opts { + pub rtsc_m1: u_int, + pub rtsc_d: u_int, + pub rtsc_m2: u_int, + pub lssc_m1: u_int, + pub lssc_d: u_int, + pub lssc_m2: u_int, + pub ulsc_m1: u_int, + pub ulsc_d: u_int, + pub ulsc_m2: u_int, + pub flags: ::std::os::raw::c_int, +} +#[test] +fn bindgen_test_layout_hfsc_opts() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 40usize, + concat!("Size of: ", stringify!(hfsc_opts)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(hfsc_opts)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rtsc_m1) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(hfsc_opts), + "::", + stringify!(rtsc_m1) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rtsc_d) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(hfsc_opts), + "::", + stringify!(rtsc_d) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rtsc_m2) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(hfsc_opts), + "::", + stringify!(rtsc_m2) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).lssc_m1) as usize - ptr as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(hfsc_opts), + "::", + stringify!(lssc_m1) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).lssc_d) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(hfsc_opts), + "::", + stringify!(lssc_d) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).lssc_m2) as usize - ptr as usize }, + 20usize, + concat!( + "Offset of field: ", + stringify!(hfsc_opts), + "::", + stringify!(lssc_m2) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ulsc_m1) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(hfsc_opts), + "::", + stringify!(ulsc_m1) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ulsc_d) as usize - ptr as usize }, + 28usize, + concat!( + "Offset of field: ", + stringify!(hfsc_opts), + "::", + stringify!(ulsc_d) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ulsc_m2) as usize - ptr as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(hfsc_opts), + "::", + stringify!(ulsc_m2) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).flags) as usize - ptr as usize }, + 36usize, + concat!( + "Offset of field: ", + stringify!(hfsc_opts), + "::", + stringify!(flags) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct pfq_ops { + pub pfq_alloc: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ifnet) -> *mut ::std::os::raw::c_void, + >, + pub pfq_addqueue: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: *mut pf_queuespec, + ) -> ::std::os::raw::c_int, + >, + pub pfq_free: ::std::option::Option, + pub pfq_qstats: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut pf_queuespec, + arg2: *mut ::std::os::raw::c_void, + arg3: *mut ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub pfq_qlength: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void) -> ::std::os::raw::c_uint, + >, + pub pfq_enqueue: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void, arg2: *mut mbuf) -> *mut mbuf, + >, + pub pfq_deq_begin: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: *mut *mut ::std::os::raw::c_void, + arg3: *mut mbuf_list, + ) -> *mut mbuf, + >, + pub pfq_deq_commit: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: *mut mbuf, + arg3: *mut ::std::os::raw::c_void, + ), + >, + pub pfq_purge: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void, arg2: *mut mbuf_list), + >, +} +#[test] +fn bindgen_test_layout_pfq_ops() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 72usize, + concat!("Size of: ", stringify!(pfq_ops)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(pfq_ops)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfq_alloc) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pfq_ops), + "::", + stringify!(pfq_alloc) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfq_addqueue) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(pfq_ops), + "::", + stringify!(pfq_addqueue) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfq_free) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(pfq_ops), + "::", + stringify!(pfq_free) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfq_qstats) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(pfq_ops), + "::", + stringify!(pfq_qstats) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfq_qlength) as usize - ptr as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(pfq_ops), + "::", + stringify!(pfq_qlength) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfq_enqueue) as usize - ptr as usize }, + 40usize, + concat!( + "Offset of field: ", + stringify!(pfq_ops), + "::", + stringify!(pfq_enqueue) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfq_deq_begin) as usize - ptr as usize }, + 48usize, + concat!( + "Offset of field: ", + stringify!(pfq_ops), + "::", + stringify!(pfq_deq_begin) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfq_deq_commit) as usize - ptr as usize }, + 56usize, + concat!( + "Offset of field: ", + stringify!(pfq_ops), + "::", + stringify!(pfq_deq_commit) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfq_purge) as usize - ptr as usize }, + 64usize, + concat!( + "Offset of field: ", + stringify!(pfq_ops), + "::", + stringify!(pfq_purge) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct pf_tagname { + pub entries: pf_tagname__bindgen_ty_1, + pub name: [::std::os::raw::c_char; 64usize], + pub tag: u_int16_t, + pub ref_: ::std::os::raw::c_int, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct pf_tagname__bindgen_ty_1 { + pub tqe_next: *mut pf_tagname, + pub tqe_prev: *mut *mut pf_tagname, +} +#[test] +fn bindgen_test_layout_pf_tagname__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(pf_tagname__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(pf_tagname__bindgen_ty_1)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).tqe_next) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pf_tagname__bindgen_ty_1), + "::", + stringify!(tqe_next) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).tqe_prev) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(pf_tagname__bindgen_ty_1), + "::", + stringify!(tqe_prev) + ) + ); +} +#[test] +fn bindgen_test_layout_pf_tagname() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 88usize, + concat!("Size of: ", stringify!(pf_tagname)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(pf_tagname)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).entries) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pf_tagname), + "::", + stringify!(entries) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).name) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(pf_tagname), + "::", + stringify!(name) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).tag) as usize - ptr as usize }, + 80usize, + concat!( + "Offset of field: ", + stringify!(pf_tagname), + "::", + stringify!(tag) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ref_) as usize - ptr as usize }, + 84usize, + concat!( + "Offset of field: ", + stringify!(pf_tagname), + "::", + stringify!(ref_) + ) + ); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct pf_divert { + pub addr: pf_addr, + pub port: u_int16_t, + pub rdomain: u_int16_t, + pub type_: u_int8_t, +} +#[test] +fn bindgen_test_layout_pf_divert() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 24usize, + concat!("Size of: ", stringify!(pf_divert)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(pf_divert)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).addr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pf_divert), + "::", + stringify!(addr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).port) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(pf_divert), + "::", + stringify!(port) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rdomain) as usize - ptr as usize }, + 18usize, + concat!( + "Offset of field: ", + stringify!(pf_divert), + "::", + stringify!(rdomain) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).type_) as usize - ptr as usize }, + 20usize, + concat!( + "Offset of field: ", + stringify!(pf_divert), + "::", + stringify!(type_) + ) + ); +} +pub const pf_divert_types_PF_DIVERT_NONE: pf_divert_types = 0; +pub const pf_divert_types_PF_DIVERT_TO: pf_divert_types = 1; +pub const pf_divert_types_PF_DIVERT_REPLY: pf_divert_types = 2; +pub const pf_divert_types_PF_DIVERT_PACKET: pf_divert_types = 3; +pub type pf_divert_types = ::std::os::raw::c_uint; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct pf_pktdelay { + pub to: timeout, + pub m: *mut mbuf, + pub ifidx: u_int, +} +#[test] +fn bindgen_test_layout_pf_pktdelay() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 88usize, + concat!("Size of: ", stringify!(pf_pktdelay)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(pf_pktdelay)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).to) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pf_pktdelay), + "::", + stringify!(to) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).m) as usize - ptr as usize }, + 72usize, + concat!( + "Offset of field: ", + stringify!(pf_pktdelay), + "::", + stringify!(m) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ifidx) as usize - ptr as usize }, + 80usize, + concat!( + "Offset of field: ", + stringify!(pf_pktdelay), + "::", + stringify!(ifidx) + ) + ); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct pfioc_rule { + pub action: u_int32_t, + pub ticket: u_int32_t, + pub nr: u_int32_t, + pub anchor: [::std::os::raw::c_char; 1024usize], + pub anchor_call: [::std::os::raw::c_char; 1024usize], + pub rule: pf_rule, +} +#[test] +fn bindgen_test_layout_pfioc_rule() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 3408usize, + concat!("Size of: ", stringify!(pfioc_rule)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(pfioc_rule)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).action) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pfioc_rule), + "::", + stringify!(action) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ticket) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(pfioc_rule), + "::", + stringify!(ticket) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).nr) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(pfioc_rule), + "::", + stringify!(nr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).anchor) as usize - ptr as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(pfioc_rule), + "::", + stringify!(anchor) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).anchor_call) as usize - ptr as usize }, + 1036usize, + concat!( + "Offset of field: ", + stringify!(pfioc_rule), + "::", + stringify!(anchor_call) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rule) as usize - ptr as usize }, + 2064usize, + concat!( + "Offset of field: ", + stringify!(pfioc_rule), + "::", + stringify!(rule) + ) + ); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct pfioc_natlook { + pub saddr: pf_addr, + pub daddr: pf_addr, + pub rsaddr: pf_addr, + pub rdaddr: pf_addr, + pub rdomain: u_int16_t, + pub rrdomain: u_int16_t, + pub sport: u_int16_t, + pub dport: u_int16_t, + pub rsport: u_int16_t, + pub rdport: u_int16_t, + pub af: sa_family_t, + pub proto: u_int8_t, + pub direction: u_int8_t, +} +#[test] +fn bindgen_test_layout_pfioc_natlook() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 80usize, + concat!("Size of: ", stringify!(pfioc_natlook)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(pfioc_natlook)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).saddr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pfioc_natlook), + "::", + stringify!(saddr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).daddr) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(pfioc_natlook), + "::", + stringify!(daddr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rsaddr) as usize - ptr as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(pfioc_natlook), + "::", + stringify!(rsaddr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rdaddr) as usize - ptr as usize }, + 48usize, + concat!( + "Offset of field: ", + stringify!(pfioc_natlook), + "::", + stringify!(rdaddr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rdomain) as usize - ptr as usize }, + 64usize, + concat!( + "Offset of field: ", + stringify!(pfioc_natlook), + "::", + stringify!(rdomain) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rrdomain) as usize - ptr as usize }, + 66usize, + concat!( + "Offset of field: ", + stringify!(pfioc_natlook), + "::", + stringify!(rrdomain) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).sport) as usize - ptr as usize }, + 68usize, + concat!( + "Offset of field: ", + stringify!(pfioc_natlook), + "::", + stringify!(sport) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).dport) as usize - ptr as usize }, + 70usize, + concat!( + "Offset of field: ", + stringify!(pfioc_natlook), + "::", + stringify!(dport) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rsport) as usize - ptr as usize }, + 72usize, + concat!( + "Offset of field: ", + stringify!(pfioc_natlook), + "::", + stringify!(rsport) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).rdport) as usize - ptr as usize }, + 74usize, + concat!( + "Offset of field: ", + stringify!(pfioc_natlook), + "::", + stringify!(rdport) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).af) as usize - ptr as usize }, + 76usize, + concat!( + "Offset of field: ", + stringify!(pfioc_natlook), + "::", + stringify!(af) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).proto) as usize - ptr as usize }, + 77usize, + concat!( + "Offset of field: ", + stringify!(pfioc_natlook), + "::", + stringify!(proto) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).direction) as usize - ptr as usize }, + 78usize, + concat!( + "Offset of field: ", + stringify!(pfioc_natlook), + "::", + stringify!(direction) + ) + ); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct pfioc_state { + pub state: pfsync_state, +} +#[test] +fn bindgen_test_layout_pfioc_state() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 264usize, + concat!("Size of: ", stringify!(pfioc_state)) + ); + assert_eq!( + ::std::mem::align_of::(), + 1usize, + concat!("Alignment of ", stringify!(pfioc_state)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).state) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pfioc_state), + "::", + stringify!(state) + ) + ); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct pfioc_src_node_kill { + pub psnk_af: sa_family_t, + pub psnk_src: pf_rule_addr, + pub psnk_dst: pf_rule_addr, + pub psnk_killed: u_int, +} +#[test] +fn bindgen_test_layout_pfioc_src_node_kill() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 128usize, + concat!("Size of: ", stringify!(pfioc_src_node_kill)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(pfioc_src_node_kill)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).psnk_af) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pfioc_src_node_kill), + "::", + stringify!(psnk_af) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).psnk_src) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(pfioc_src_node_kill), + "::", + stringify!(psnk_src) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).psnk_dst) as usize - ptr as usize }, + 64usize, + concat!( + "Offset of field: ", + stringify!(pfioc_src_node_kill), + "::", + stringify!(psnk_dst) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).psnk_killed) as usize - ptr as usize }, + 120usize, + concat!( + "Offset of field: ", + stringify!(pfioc_src_node_kill), + "::", + stringify!(psnk_killed) + ) + ); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct pfioc_state_kill { + pub psk_pfcmp: pf_state_cmp, + pub psk_af: sa_family_t, + pub psk_proto: ::std::os::raw::c_int, + pub psk_src: pf_rule_addr, + pub psk_dst: pf_rule_addr, + pub psk_ifname: [::std::os::raw::c_char; 16usize], + pub psk_label: [::std::os::raw::c_char; 64usize], + pub psk_killed: u_int, + pub psk_rdomain: u_int16_t, +} +#[test] +fn bindgen_test_layout_pfioc_state_kill() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 224usize, + concat!("Size of: ", stringify!(pfioc_state_kill)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(pfioc_state_kill)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).psk_pfcmp) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pfioc_state_kill), + "::", + stringify!(psk_pfcmp) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).psk_af) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(pfioc_state_kill), + "::", + stringify!(psk_af) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).psk_proto) as usize - ptr as usize }, + 20usize, + concat!( + "Offset of field: ", + stringify!(pfioc_state_kill), + "::", + stringify!(psk_proto) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).psk_src) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(pfioc_state_kill), + "::", + stringify!(psk_src) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).psk_dst) as usize - ptr as usize }, + 80usize, + concat!( + "Offset of field: ", + stringify!(pfioc_state_kill), + "::", + stringify!(psk_dst) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).psk_ifname) as usize - ptr as usize }, + 136usize, + concat!( + "Offset of field: ", + stringify!(pfioc_state_kill), + "::", + stringify!(psk_ifname) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).psk_label) as usize - ptr as usize }, + 152usize, + concat!( + "Offset of field: ", + stringify!(pfioc_state_kill), + "::", + stringify!(psk_label) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).psk_killed) as usize - ptr as usize }, + 216usize, + concat!( + "Offset of field: ", + stringify!(pfioc_state_kill), + "::", + stringify!(psk_killed) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).psk_rdomain) as usize - ptr as usize }, + 220usize, + concat!( + "Offset of field: ", + stringify!(pfioc_state_kill), + "::", + stringify!(psk_rdomain) + ) + ); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct pfioc_states { + pub ps_len: usize, + pub ps_u: pfioc_states__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union pfioc_states__bindgen_ty_1 { + pub psu_buf: caddr_t, + pub psu_states: *mut pfsync_state, +} +#[test] +fn bindgen_test_layout_pfioc_states__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(pfioc_states__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(pfioc_states__bindgen_ty_1)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).psu_buf) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pfioc_states__bindgen_ty_1), + "::", + stringify!(psu_buf) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).psu_states) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pfioc_states__bindgen_ty_1), + "::", + stringify!(psu_states) + ) + ); +} +#[test] +fn bindgen_test_layout_pfioc_states() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(pfioc_states)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(pfioc_states)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ps_len) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pfioc_states), + "::", + stringify!(ps_len) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ps_u) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(pfioc_states), + "::", + stringify!(ps_u) + ) + ); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct pfioc_src_nodes { + pub psn_len: usize, + pub psn_u: pfioc_src_nodes__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union pfioc_src_nodes__bindgen_ty_1 { + pub psu_buf: caddr_t, + pub psu_src_nodes: *mut pf_src_node, +} +#[test] +fn bindgen_test_layout_pfioc_src_nodes__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(pfioc_src_nodes__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(pfioc_src_nodes__bindgen_ty_1)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).psu_buf) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pfioc_src_nodes__bindgen_ty_1), + "::", + stringify!(psu_buf) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).psu_src_nodes) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pfioc_src_nodes__bindgen_ty_1), + "::", + stringify!(psu_src_nodes) + ) + ); +} +#[test] +fn bindgen_test_layout_pfioc_src_nodes() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(pfioc_src_nodes)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(pfioc_src_nodes)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).psn_len) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pfioc_src_nodes), + "::", + stringify!(psn_len) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).psn_u) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(pfioc_src_nodes), + "::", + stringify!(psn_u) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct pfioc_tm { + pub timeout: ::std::os::raw::c_int, + pub seconds: ::std::os::raw::c_int, +} +#[test] +fn bindgen_test_layout_pfioc_tm() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(pfioc_tm)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(pfioc_tm)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).timeout) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pfioc_tm), + "::", + stringify!(timeout) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).seconds) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(pfioc_tm), + "::", + stringify!(seconds) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct pfioc_limit { + pub index: ::std::os::raw::c_int, + pub limit: ::std::os::raw::c_uint, +} +#[test] +fn bindgen_test_layout_pfioc_limit() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(pfioc_limit)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(pfioc_limit)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).index) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pfioc_limit), + "::", + stringify!(index) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).limit) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(pfioc_limit), + "::", + stringify!(limit) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct pfioc_ruleset { + pub nr: u_int32_t, + pub path: [::std::os::raw::c_char; 1024usize], + pub name: [::std::os::raw::c_char; 64usize], +} +#[test] +fn bindgen_test_layout_pfioc_ruleset() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 1092usize, + concat!("Size of: ", stringify!(pfioc_ruleset)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(pfioc_ruleset)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).nr) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pfioc_ruleset), + "::", + stringify!(nr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).path) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(pfioc_ruleset), + "::", + stringify!(path) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).name) as usize - ptr as usize }, + 1028usize, + concat!( + "Offset of field: ", + stringify!(pfioc_ruleset), + "::", + stringify!(name) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct pfioc_trans { + pub size: ::std::os::raw::c_int, + pub esize: ::std::os::raw::c_int, + pub array: *mut pfioc_trans_pfioc_trans_e, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct pfioc_trans_pfioc_trans_e { + pub type_: ::std::os::raw::c_int, + pub anchor: [::std::os::raw::c_char; 1024usize], + pub ticket: u_int32_t, +} +#[test] +fn bindgen_test_layout_pfioc_trans_pfioc_trans_e() { + const UNINIT: ::std::mem::MaybeUninit = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 1032usize, + concat!("Size of: ", stringify!(pfioc_trans_pfioc_trans_e)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(pfioc_trans_pfioc_trans_e)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).type_) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pfioc_trans_pfioc_trans_e), + "::", + stringify!(type_) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).anchor) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(pfioc_trans_pfioc_trans_e), + "::", + stringify!(anchor) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ticket) as usize - ptr as usize }, + 1028usize, + concat!( + "Offset of field: ", + stringify!(pfioc_trans_pfioc_trans_e), + "::", + stringify!(ticket) + ) + ); +} +#[test] +fn bindgen_test_layout_pfioc_trans() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(pfioc_trans)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(pfioc_trans)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).size) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pfioc_trans), + "::", + stringify!(size) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).esize) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(pfioc_trans), + "::", + stringify!(esize) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).array) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(pfioc_trans), + "::", + stringify!(array) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct pfioc_queue { + pub ticket: u_int32_t, + pub nr: u_int, + pub queue: pf_queuespec, +} +#[test] +fn bindgen_test_layout_pfioc_queue() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 272usize, + concat!("Size of: ", stringify!(pfioc_queue)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(pfioc_queue)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ticket) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pfioc_queue), + "::", + stringify!(ticket) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).nr) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(pfioc_queue), + "::", + stringify!(nr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).queue) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(pfioc_queue), + "::", + stringify!(queue) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct pfioc_qstats { + pub ticket: u_int32_t, + pub nr: u_int32_t, + pub queue: pf_queuespec, + pub buf: *mut ::std::os::raw::c_void, + pub nbytes: ::std::os::raw::c_int, +} +#[test] +fn bindgen_test_layout_pfioc_qstats() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 288usize, + concat!("Size of: ", stringify!(pfioc_qstats)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(pfioc_qstats)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).ticket) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pfioc_qstats), + "::", + stringify!(ticket) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).nr) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(pfioc_qstats), + "::", + stringify!(nr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).queue) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(pfioc_qstats), + "::", + stringify!(queue) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).buf) as usize - ptr as usize }, + 272usize, + concat!( + "Offset of field: ", + stringify!(pfioc_qstats), + "::", + stringify!(buf) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).nbytes) as usize - ptr as usize }, + 280usize, + concat!( + "Offset of field: ", + stringify!(pfioc_qstats), + "::", + stringify!(nbytes) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct pfioc_table { + pub pfrio_table: pfr_table, + pub pfrio_buffer: *mut ::std::os::raw::c_void, + pub pfrio_esize: ::std::os::raw::c_int, + pub pfrio_size: ::std::os::raw::c_int, + pub pfrio_size2: ::std::os::raw::c_int, + pub pfrio_nadd: ::std::os::raw::c_int, + pub pfrio_ndel: ::std::os::raw::c_int, + pub pfrio_nchange: ::std::os::raw::c_int, + pub pfrio_flags: ::std::os::raw::c_int, + pub pfrio_ticket: u_int32_t, +} +#[test] +fn bindgen_test_layout_pfioc_table() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 1104usize, + concat!("Size of: ", stringify!(pfioc_table)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(pfioc_table)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfrio_table) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pfioc_table), + "::", + stringify!(pfrio_table) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfrio_buffer) as usize - ptr as usize }, + 1064usize, + concat!( + "Offset of field: ", + stringify!(pfioc_table), + "::", + stringify!(pfrio_buffer) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfrio_esize) as usize - ptr as usize }, + 1072usize, + concat!( + "Offset of field: ", + stringify!(pfioc_table), + "::", + stringify!(pfrio_esize) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfrio_size) as usize - ptr as usize }, + 1076usize, + concat!( + "Offset of field: ", + stringify!(pfioc_table), + "::", + stringify!(pfrio_size) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfrio_size2) as usize - ptr as usize }, + 1080usize, + concat!( + "Offset of field: ", + stringify!(pfioc_table), + "::", + stringify!(pfrio_size2) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfrio_nadd) as usize - ptr as usize }, + 1084usize, + concat!( + "Offset of field: ", + stringify!(pfioc_table), + "::", + stringify!(pfrio_nadd) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfrio_ndel) as usize - ptr as usize }, + 1088usize, + concat!( + "Offset of field: ", + stringify!(pfioc_table), + "::", + stringify!(pfrio_ndel) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfrio_nchange) as usize - ptr as usize }, + 1092usize, + concat!( + "Offset of field: ", + stringify!(pfioc_table), + "::", + stringify!(pfrio_nchange) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfrio_flags) as usize - ptr as usize }, + 1096usize, + concat!( + "Offset of field: ", + stringify!(pfioc_table), + "::", + stringify!(pfrio_flags) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfrio_ticket) as usize - ptr as usize }, + 1100usize, + concat!( + "Offset of field: ", + stringify!(pfioc_table), + "::", + stringify!(pfrio_ticket) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct pfioc_iface { + pub pfiio_name: [::std::os::raw::c_char; 16usize], + pub pfiio_buffer: *mut ::std::os::raw::c_void, + pub pfiio_esize: ::std::os::raw::c_int, + pub pfiio_size: ::std::os::raw::c_int, + pub pfiio_nzero: ::std::os::raw::c_int, + pub pfiio_flags: ::std::os::raw::c_int, +} +#[test] +fn bindgen_test_layout_pfioc_iface() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 40usize, + concat!("Size of: ", stringify!(pfioc_iface)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(pfioc_iface)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfiio_name) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pfioc_iface), + "::", + stringify!(pfiio_name) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfiio_buffer) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(pfioc_iface), + "::", + stringify!(pfiio_buffer) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfiio_esize) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(pfioc_iface), + "::", + stringify!(pfiio_esize) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfiio_size) as usize - ptr as usize }, + 28usize, + concat!( + "Offset of field: ", + stringify!(pfioc_iface), + "::", + stringify!(pfiio_size) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfiio_nzero) as usize - ptr as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(pfioc_iface), + "::", + stringify!(pfiio_nzero) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).pfiio_flags) as usize - ptr as usize }, + 36usize, + concat!( + "Offset of field: ", + stringify!(pfioc_iface), + "::", + stringify!(pfiio_flags) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct pfioc_synflwats { + pub hiwat: u_int32_t, + pub lowat: u_int32_t, +} +#[test] +fn bindgen_test_layout_pfioc_synflwats() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(pfioc_synflwats)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(pfioc_synflwats)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).hiwat) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(pfioc_synflwats), + "::", + stringify!(hiwat) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).lowat) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(pfioc_synflwats), + "::", + stringify!(lowat) + ) + ); +} +extern "C" { + pub static mut pf_anchors: pf_anchor_global; +} +extern "C" { + pub static mut pf_main_anchor: pf_anchor; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct tcphdr { + _unused: [u8; 0], +} +extern "C" { + pub fn pf_init_ruleset(arg1: *mut pf_ruleset); +} +extern "C" { + pub fn pf_anchor_setup( + arg1: *mut pf_rule, + arg2: *const pf_ruleset, + arg3: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn pf_anchor_copyout( + arg1: *const pf_ruleset, + arg2: *const pf_rule, + arg3: *mut pfioc_rule, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn pf_remove_anchor(arg1: *mut pf_rule); +} +extern "C" { + pub fn pf_remove_if_empty_ruleset(arg1: *mut pf_ruleset); +} +extern "C" { + pub fn pf_find_anchor(arg1: *const ::std::os::raw::c_char) -> *mut pf_anchor; +} +extern "C" { + pub fn pf_find_ruleset(arg1: *const ::std::os::raw::c_char) -> *mut pf_ruleset; +} +extern "C" { + pub fn pf_get_leaf_ruleset( + arg1: *mut ::std::os::raw::c_char, + arg2: *mut *mut ::std::os::raw::c_char, + ) -> *mut pf_ruleset; +} +extern "C" { + pub fn pf_create_anchor( + arg1: *mut pf_anchor, + arg2: *const ::std::os::raw::c_char, + ) -> *mut pf_anchor; +} +extern "C" { + pub fn pf_find_or_create_ruleset(arg1: *const ::std::os::raw::c_char) -> *mut pf_ruleset; +} +extern "C" { + pub fn pf_rs_initialize(); +} +extern "C" { + pub fn pf_anchor_rele(arg1: *mut pf_anchor); +} +extern "C" { + pub fn pf_anchor_take(arg1: *mut pf_anchor) -> *mut pf_anchor; +} +extern "C" { + pub fn pf_osfp_add(arg1: *mut pf_osfp_ioctl) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn pf_osfp_fingerprint_hdr( + arg1: *const ip, + arg2: *const ip6_hdr, + arg3: *const tcphdr, + ) -> *mut pf_os_fingerprint_pf_osfp_enlist; +} +extern "C" { + pub fn pf_osfp_flush(); +} +extern "C" { + pub fn pf_osfp_get(arg1: *mut pf_osfp_ioctl) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn pf_osfp_initialize(); +} +extern "C" { + pub fn pf_osfp_match( + arg1: *mut pf_os_fingerprint_pf_osfp_enlist, + arg2: pf_osfp_t, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn pf_osfp_validate() -> *mut pf_os_fingerprint; +} +pub type __builtin_va_list = [__va_list_tag; 1usize]; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct __va_list_tag { + pub gp_offset: ::std::os::raw::c_uint, + pub fp_offset: ::std::os::raw::c_uint, + pub overflow_arg_area: *mut ::std::os::raw::c_void, + pub reg_save_area: *mut ::std::os::raw::c_void, +} +#[test] +fn bindgen_test_layout___va_list_tag() { + const UNINIT: ::std::mem::MaybeUninit<__va_list_tag> = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<__va_list_tag>(), + 24usize, + concat!("Size of: ", stringify!(__va_list_tag)) + ); + assert_eq!( + ::std::mem::align_of::<__va_list_tag>(), + 8usize, + concat!("Alignment of ", stringify!(__va_list_tag)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).gp_offset) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(__va_list_tag), + "::", + stringify!(gp_offset) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).fp_offset) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(__va_list_tag), + "::", + stringify!(fp_offset) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).overflow_arg_area) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(__va_list_tag), + "::", + stringify!(overflow_arg_area) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).reg_save_area) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(__va_list_tag), + "::", + stringify!(reg_save_area) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct witness { + pub _address: u8, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct process { + pub _address: u8, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct ifaddr { + pub _address: u8, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct rtentry { + pub _address: u8, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct pfi_dynaddr { + pub _address: u8, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct pf_state { + pub _address: u8, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct pf_state_key { + pub _address: u8, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct mbuf { + _unused: [u8; 0], +} diff --git a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/redir/tcprelay/sys/unix/bsd.rs b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/redir/tcprelay/sys/unix/bsd.rs index 1c57302798..1c011f4251 100644 --- a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/redir/tcprelay/sys/unix/bsd.rs +++ b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/redir/tcprelay/sys/unix/bsd.rs @@ -21,7 +21,7 @@ use crate::{ impl TcpListenerRedirExt for TcpListener { async fn bind_redir(ty: RedirType, addr: SocketAddr, accept_opts: AcceptOpts) -> io::Result { match ty { - #[cfg(any(target_os = "freebsd", target_os = "macos", target_os = "ios"))] + #[cfg(any(target_os = "freebsd", target_os = "openbsd", target_os = "macos", target_os = "ios"))] RedirType::PacketFilter => {} #[cfg(any(target_os = "freebsd", target_os = "macos", target_os = "ios"))] @@ -108,6 +108,8 @@ impl TcpStreamRedirExt for TcpStream { PF.natlook(&bind_addr, &peer_addr, Protocol::TCP) } + #[cfg(target_os = "openbsd")] //in OpenBSD, we can get TCP destination address with getsockname() + RedirType::PacketFilter => self.local_addr(), #[cfg(any(target_os = "freebsd", target_os = "macos", target_os = "ios"))] RedirType::IpFirewall => { // ## IPFW diff --git a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/redir/tcprelay/sys/unix/mod.rs b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/redir/tcprelay/sys/unix/mod.rs index bb679c4822..5f9e7c10f6 100644 --- a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/redir/tcprelay/sys/unix/mod.rs +++ b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/redir/tcprelay/sys/unix/mod.rs @@ -6,7 +6,8 @@ cfg_if! { pub use self::linux::*; } else if #[cfg(any(target_os = "macos", target_os = "ios", - target_os = "freebsd"))] { + target_os = "freebsd", + target_os = "openbsd"))] { mod bsd; pub use self::bsd::*; } diff --git a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/redir/udprelay/sys/unix/bsd.rs b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/redir/udprelay/sys/unix/freebsd.rs similarity index 90% rename from shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/redir/udprelay/sys/unix/bsd.rs rename to shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/redir/udprelay/sys/unix/freebsd.rs index 2ac63c636c..cde8912fb9 100644 --- a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/redir/udprelay/sys/unix/bsd.rs +++ b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/redir/udprelay/sys/unix/freebsd.rs @@ -55,16 +55,8 @@ impl UdpRedirSocket { socket.set_reuse_address(true)?; if reuse_port { if let Err(err) = socket.set_reuse_port(true) { - if let Some(errno) = err.raw_os_error() { - match errno { - libc::ENOPROTOOPT => { - trace!("failed to set SO_REUSEPORT, error: {}", err); - } - _ => { - error!("failed to set SO_REUSEPORT, error: {}", err); - return Err(err); - } - } + if let Some(libc::ENOPROTOOPT) = err.raw_os_error() { + trace!("failed to set SO_REUSEPORT, error: {}", err); } else { error!("failed to set SO_REUSEPORT, error: {}", err); return Err(err); @@ -159,7 +151,6 @@ impl UdpSocketRedir for UdpRedirSocket { } } -#[cfg(target_os = "freebsd")] fn set_bindany(level: libc::c_int, socket: &Socket) -> io::Result<()> { let fd = socket.as_raw_fd(); @@ -188,29 +179,6 @@ fn set_bindany(level: libc::c_int, socket: &Socket) -> io::Result<()> { Ok(()) } -// #[cfg(target_os = "openbsd")] -// fn set_bindany(_level: libc::c_int, socket: &Socket) -> io::Result<()> { -// let fd = socket.as_raw_fd(); -// -// let enable: libc::c_int = 1; -// -// // https://man.openbsd.org/getsockopt.2 -// unsafe { -// let ret = libc::setsockopt( -// fd, -// libc::SOL_SOCKET, -// libc::SO_BINDANY, -// &enable as *const _ as *const _, -// mem::size_of_val(&enable) as libc::socklen_t, -// ); -// if ret != 0 { -// return Err(Error::last_os_error()); -// } -// } -// -// Ok(()) -// } - fn set_ip_origdstaddr(level: libc::c_int, socket: &Socket) -> io::Result<()> { // https://www.freebsd.org/cgi/man.cgi?query=ip&sektion=4&manpath=FreeBSD+9.0-RELEASE diff --git a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/redir/udprelay/sys/unix/linux.rs b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/redir/udprelay/sys/unix/linux.rs index 1a4906a06b..ef84f3fac5 100644 --- a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/redir/udprelay/sys/unix/linux.rs +++ b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/redir/udprelay/sys/unix/linux.rs @@ -73,17 +73,9 @@ impl UdpRedirSocket { socket.set_reuse_address(true)?; if reuse_port { if let Err(err) = socket.set_reuse_port(true) { - if let Some(errno) = err.raw_os_error() { - match errno { - libc::ENOPROTOOPT => { - // SO_REUSEPORT is supported after 3.9 - trace!("failed to set SO_REUSEPORT, error: {}", err); - } - _ => { - error!("failed to set SO_REUSEPORT, error: {}", err); - return Err(err); - } - } + if let Some(libc::ENOPROTOOPT) = err.raw_os_error() { + // SO_REUSEPORT is supported after 3.9 + trace!("failed to set SO_REUSEPORT, error: {}", err); } else { error!("failed to set SO_REUSEPORT, error: {}", err); return Err(err); diff --git a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/redir/udprelay/sys/unix/macos.rs b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/redir/udprelay/sys/unix/macos.rs index 5d5c51cf87..5bafa099c0 100644 --- a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/redir/udprelay/sys/unix/macos.rs +++ b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/redir/udprelay/sys/unix/macos.rs @@ -54,16 +54,8 @@ impl UdpRedirSocket { socket.set_reuse_address(true)?; if reuse_port { if let Err(err) = socket.set_reuse_port(true) { - if let Some(errno) = err.raw_os_error() { - match errno { - libc::ENOPROTOOPT => { - trace!("failed to set SO_REUSEPORT, error: {}", err); - } - _ => { - error!("failed to set SO_REUSEPORT, error: {}", err); - return Err(err); - } - } + if let Some(libc::ENOPROTOOPT) = err.raw_os_error() { + trace!("failed to set SO_REUSEPORT, error: {}", err); } else { error!("failed to set SO_REUSEPORT, error: {}", err); return Err(err); diff --git a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/redir/udprelay/sys/unix/mod.rs b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/redir/udprelay/sys/unix/mod.rs index a0bfe2202d..cc0f0749d2 100644 --- a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/redir/udprelay/sys/unix/mod.rs +++ b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/redir/udprelay/sys/unix/mod.rs @@ -8,8 +8,11 @@ cfg_if! { mod macos; pub use self::macos::*; } else if #[cfg(any(target_os = "freebsd"))] { - mod bsd; - pub use self::bsd::*; + mod freebsd; + pub use self::freebsd::*; + } else if #[cfg(target_os = "openbsd")] { + mod openbsd; + pub use self::openbsd::*; } else { mod not_supported; pub use self::not_supported::*; diff --git a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/redir/udprelay/sys/unix/openbsd.rs b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/redir/udprelay/sys/unix/openbsd.rs new file mode 100644 index 0000000000..87b771259a --- /dev/null +++ b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/redir/udprelay/sys/unix/openbsd.rs @@ -0,0 +1,352 @@ +use std::{ + io::{self, Error, ErrorKind}, + mem, + net::{SocketAddr, UdpSocket}, + os::unix::io::AsRawFd, + ptr, + task::{Context, Poll}, +}; + +use futures::{future::poll_fn, ready}; +use log::{error, trace, warn}; +use shadowsocks::net::is_dual_stack_addr; +use socket2::{Domain, Protocol, SockAddr, Socket, Type}; +use tokio::io::unix::AsyncFd; + +use crate::{ + config::RedirType, + local::redir::{ + redir_ext::{RedirSocketOpts, UdpSocketRedir}, + sys::set_ipv6_only, + }, +}; +const IP_RECVDSTPORT: i32 = 33; //Temporary workaround until libc supports this +const IPV6_RECVDSTPORT: i32 = 64; //Temporary workaround until libc supports this + +pub struct UdpRedirSocket { + io: AsyncFd, +} + +impl UdpRedirSocket { + /// Create a new UDP socket binded to `addr` + /// + /// This will allow listening to `addr` that is not in local host + pub fn listen(ty: RedirType, addr: SocketAddr) -> io::Result { + UdpRedirSocket::bind(ty, addr, false) + } + + /// Create a new UDP socket binded to `addr` + /// + /// This will allow binding to `addr` that is not in local host + pub fn bind_nonlocal(ty: RedirType, addr: SocketAddr, _: &RedirSocketOpts) -> io::Result { + UdpRedirSocket::bind(ty, addr, true) + } + + fn bind(ty: RedirType, addr: SocketAddr, reuse_port: bool) -> io::Result { + if ty == RedirType::NotSupported { + return Err(Error::new( + ErrorKind::InvalidInput, + "not supported udp transparent proxy type", + )); + } + + let socket = Socket::new(Domain::for_address(addr), Type::DGRAM, Some(Protocol::UDP))?; + set_socket_before_bind(&addr, &socket)?; + + socket.set_nonblocking(true)?; + socket.set_reuse_address(true)?; + if reuse_port { + if let Err(err) = socket.set_reuse_port(true) { + if let Some(libc::ENOPROTOOPT) = err.raw_os_error() { + trace!("failed to set SO_REUSEPORT, error: {}", err); + } else { + error!("failed to set SO_REUSEPORT, error: {}", err); + return Err(err); + } + } + } + + let sock_addr = SockAddr::from(addr); + + if is_dual_stack_addr(&addr) { + // set IP_ORIGDSTADDR before bind() + + // NOTE: FreeBSD doesn't allow setting IPPROTO_IP level on an IPv6 socket + // + // set_ip_origdstaddr(libc::IPPROTO_IP, &socket)?; + // set_disable_ip_fragmentation(libc::IPPROTO_IP, &socket)?; + + match set_ipv6_only(&socket, false) { + Ok(..) => { + if let Err(err) = socket.bind(&sock_addr) { + warn!( + "bind() dual-stack address {} failed, error: {}, fallback to IPV6_V6ONLY=true", + addr, err + ); + + if let Err(err) = set_ipv6_only(&socket, true) { + warn!( + "set IPV6_V6ONLY=true failed, error: {}, bind() to {} directly", + err, addr + ); + } + + socket.bind(&sock_addr)?; + } + } + Err(err) => { + warn!( + "set IPV6_V6ONLY=false failed, error: {}, bind() to {} directly", + err, addr + ); + socket.bind(&sock_addr)?; + } + } + } else { + socket.bind(&sock_addr)?; + } + + let io = AsyncFd::new(socket.into())?; + Ok(UdpRedirSocket { io }) + } + + /// Send data to the socket to the given target address + pub async fn send_to(&self, buf: &[u8], target: SocketAddr) -> io::Result { + poll_fn(|cx| self.poll_send_to(cx, buf, target)).await + } + + fn poll_send_to(&self, cx: &mut Context<'_>, buf: &[u8], target: SocketAddr) -> Poll> { + loop { + let mut write_guard = ready!(self.io.poll_write_ready(cx))?; + + match self.io.get_ref().send_to(buf, target) { + Err(ref e) if e.kind() == ErrorKind::WouldBlock => { + write_guard.clear_ready(); + } + x => return Poll::Ready(x), + } + } + } + + /// Returns the local address that this socket is bound to. + pub fn local_addr(&self) -> io::Result { + self.io.get_ref().local_addr() + } +} + +impl UdpSocketRedir for UdpRedirSocket { + fn poll_recv_dest_from( + &self, + cx: &mut Context<'_>, + buf: &mut [u8], + ) -> Poll> { + loop { + let mut read_guard = ready!(self.io.poll_read_ready(cx))?; + + match recv_dest_from(self.io.get_ref(), buf) { + Err(ref e) if e.kind() == ErrorKind::WouldBlock => { + read_guard.clear_ready(); + } + x => return Poll::Ready(x), + } + } + } +} + +fn set_bindany(_level: libc::c_int, socket: &Socket) -> io::Result<()> { + let fd = socket.as_raw_fd(); + + let enable: libc::c_int = 1; + + // https://man.openbsd.org/getsockopt.2 + unsafe { + let ret = libc::setsockopt( + fd, + libc::SOL_SOCKET, + libc::SO_BINDANY, + &enable as *const _ as *const _, + mem::size_of_val(&enable) as libc::socklen_t, + ); + if ret != 0 { + return Err(Error::last_os_error()); + } + } + + Ok(()) +} + +fn set_ip_origdstaddr(level: libc::c_int, socket: &Socket) -> io::Result<()> { + // https://man.openbsd.org/pf.conf + let fd = socket.as_raw_fd(); + + let enable: libc::c_int = 1; + + let opt = match level { + libc::IPPROTO_IP => libc::IP_RECVDSTADDR, + libc::IPPROTO_IPV6 => libc::IPV6_RECVPKTINFO, + _ => unreachable!("level can only be IPPROTO_IP or IPPROTO_IPV6"), + }; + + unsafe { + let ret = libc::setsockopt( + fd, + level, + opt, + &enable as *const _ as *const _, + mem::size_of_val(&enable) as libc::socklen_t, + ); + if ret != 0 { + return Err(Error::last_os_error()); + } + } + + let opt2 = match level { + libc::IPPROTO_IP => IP_RECVDSTPORT, + libc::IPPROTO_IPV6 => IPV6_RECVDSTPORT, + _ => unreachable!("level can only be IPPROTO_IP or IPPROTO_IPV6"), + }; + unsafe { + let ret = libc::setsockopt( + fd, + level, + opt2, + &enable as *const _ as *const _, + mem::size_of_val(&enable) as libc::socklen_t, + ); + if ret != 0 { + return Err(Error::last_os_error()); + } + } + Ok(()) +} + +fn set_socket_before_bind(addr: &SocketAddr, socket: &Socket) -> io::Result<()> { + // https://www.freebsd.org/cgi/man.cgi?query=ip&sektion=4&manpath=FreeBSD+9.0-RELEASE + let level = match *addr { + SocketAddr::V4(..) => libc::IPPROTO_IP, + SocketAddr::V6(..) => libc::IPPROTO_IPV6, + }; + + // 1. BINDANY + set_bindany(level, socket)?; + + // 2. set ORIGDSTADDR for retrieving original destination address + set_ip_origdstaddr(level, socket)?; + + Ok(()) +} + +fn get_destination_addr(msg: &libc::msghdr) -> io::Result { + unsafe { + let (_, addr) = SockAddr::try_init(|dst_addr, dst_addr_len| { + let mut cmsg: *mut libc::cmsghdr = libc::CMSG_FIRSTHDR(msg); + let mut addr_or_port_received = false; //The address should come first and then the port, but we use a flag just in case. https://github.com/openbsd/src/blob/3d310523b415eeee9db46a5b67eecf8f9fdd5c8f/sys/netinet/udp_usrreq.c#L662-L687 + while !cmsg.is_null() { + let rcmsg = &*cmsg; + match (rcmsg.cmsg_level, rcmsg.cmsg_type) { + (libc::IPPROTO_IP, libc::IP_RECVDSTADDR) => { + let toaddr_in = &mut *(dst_addr as *mut libc::sockaddr_in); + ptr::copy_nonoverlapping( + libc::CMSG_DATA(cmsg), + &(*toaddr_in).sin_addr as *const _ as *mut _, + mem::size_of::(), + ); + toaddr_in.sin_family = libc::AF_INET as u8; + *dst_addr_len = mem::size_of::() as libc::socklen_t; + if addr_or_port_received { + return Ok(()); + } else { + addr_or_port_received = true + } + } + (libc::IPPROTO_IP, IP_RECVDSTPORT) => { + let toaddr_in = &mut *(dst_addr as *mut libc::sockaddr_in); + ptr::copy_nonoverlapping( + libc::CMSG_DATA(cmsg), + &(*toaddr_in).sin_port as *const _ as *mut _, + mem::size_of::(), + ); + if addr_or_port_received { + return Ok(()); + } else { + addr_or_port_received = true + } + } + (libc::IPPROTO_IPV6, libc::IPV6_PKTINFO) => { + let toaddr_in = &mut *(dst_addr as *mut libc::sockaddr_in6); + ptr::copy_nonoverlapping( + libc::CMSG_DATA(cmsg), + &(*toaddr_in).sin6_addr as *const _ as *mut _, + mem::size_of::(), + ); + toaddr_in.sin6_family = libc::AF_INET6 as u8; + *dst_addr_len = mem::size_of::() as libc::socklen_t; + if addr_or_port_received { + return Ok(()); + } else { + addr_or_port_received = true + } + } + (libc::IPPROTO_IPV6, IPV6_RECVDSTPORT) => { + let toaddr_in = &mut *(dst_addr as *mut libc::sockaddr_in6); + ptr::copy_nonoverlapping( + libc::CMSG_DATA(cmsg), + &(*toaddr_in).sin6_port as *const _ as *mut _, + mem::size_of::(), + ); + if addr_or_port_received { + return Ok(()); + } else { + addr_or_port_received = true + } + } + _ => {} + } + cmsg = libc::CMSG_NXTHDR(msg, cmsg); + } + let err = Error::new(ErrorKind::InvalidData, "missing destination address in msghdr"); + Err(err) + })?; + + Ok(addr.as_socket().expect("SocketAddr")) + } +} + +fn recv_dest_from(socket: &UdpSocket, buf: &mut [u8]) -> io::Result<(usize, SocketAddr, SocketAddr)> { + unsafe { + let mut control_buf = [0u8; 64]; + let mut src_addr: libc::sockaddr_storage = mem::zeroed(); + + let mut msg: libc::msghdr = mem::zeroed(); + msg.msg_name = &mut src_addr as *mut _ as *mut _; + msg.msg_namelen = mem::size_of_val(&src_addr) as libc::socklen_t; + + let mut iov = libc::iovec { + iov_base: buf.as_mut_ptr() as *mut _, + iov_len: buf.len() as libc::size_t, + }; + msg.msg_iov = &mut iov; + msg.msg_iovlen = 1; + + msg.msg_control = control_buf.as_mut_ptr() as *mut _; + msg.msg_controllen = control_buf.len() as libc::socklen_t; + + let fd = socket.as_raw_fd(); + let ret = libc::recvmsg(fd, &mut msg, 0); + if ret < 0 { + return Err(Error::last_os_error()); + } + + let (_, src_saddr) = SockAddr::try_init(|a, l| { + ptr::copy_nonoverlapping(msg.msg_name, a as *mut _, msg.msg_namelen as usize); + *l = msg.msg_namelen; + Ok(()) + })?; + + Ok(( + ret as usize, + src_saddr.as_socket().expect("SocketAddr"), + get_destination_addr(&msg)?, + )) + } +} diff --git a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/socks/server/mod.rs b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/socks/server/mod.rs index 84baa7c96f..fa6663440b 100644 --- a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/socks/server/mod.rs +++ b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/socks/server/mod.rs @@ -114,8 +114,8 @@ impl SocksBuilder { let udp_associate_addr: ServerAddr = self .udp_associate_addr .as_ref() - .or_else(|| self.udp_bind_addr.as_ref()) - .unwrap_or_else(|| &self.client_config) + .or(self.udp_bind_addr.as_ref()) + .unwrap_or(&self.client_config) .clone(); let mut udp_server = None; diff --git a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/tun/fake_tun.rs b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/tun/fake_tun.rs index b374847ba1..0e563f3e5b 100644 --- a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/tun/fake_tun.rs +++ b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/tun/fake_tun.rs @@ -3,6 +3,7 @@ use std::{ io::{self, Read, Write}, net::IpAddr, + ops::{Deref, DerefMut}, pin::Pin, task::{Context, Poll}, }; @@ -118,6 +119,20 @@ impl AsMut for AsyncDevice { } } +impl Deref for AsyncDevice { + type Target = FakeDevice; + + fn deref(&self) -> &Self::Target { + &self.0 + } +} + +impl DerefMut for AsyncDevice { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.0 + } +} + impl AsyncRead for AsyncDevice { fn poll_read(self: Pin<&mut Self>, _cx: &mut Context<'_>, _buf: &mut ReadBuf<'_>) -> Poll> { Err(io::Error::new(io::ErrorKind::Other, "not implemented")).into() diff --git a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/tun/mod.rs b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/tun/mod.rs index 53dc2d183c..a60b089f47 100644 --- a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/tun/mod.rs +++ b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/tun/mod.rs @@ -128,11 +128,7 @@ impl TunBuilder { self.udp_capacity, ); - let tcp = TcpTun::new( - self.context, - self.balancer, - device.as_ref().mtu().unwrap_or(1500) as u32, - ); + let tcp = TcpTun::new(self.context, self.balancer, device.mtu().unwrap_or(1500) as u32); Ok(Tun { device, @@ -160,15 +156,11 @@ impl Tun { pub async fn run(mut self) -> io::Result<()> { info!( "shadowsocks tun device {}, mode {}", - self.device - .as_ref() - .tun_name() - .or_else(|r| Ok::<_, ()>(r.to_string())) - .unwrap(), + self.device.tun_name().or_else(|r| Ok::<_, ()>(r.to_string())).unwrap(), self.mode, ); - let address = match self.device.as_ref().address() { + let address = match self.device.address() { Ok(a) => a, Err(err) => { error!("[TUN] failed to get device address, error: {}", err); @@ -176,7 +168,7 @@ impl Tun { } }; - let netmask = match self.device.as_ref().netmask() { + let netmask = match self.device.netmask() { Ok(n) => n, Err(err) => { error!("[TUN] failed to get device netmask, error: {}", err); diff --git a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/tun/tcp.rs b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/tun/tcp.rs index 977f2952c0..0e07230d36 100644 --- a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/tun/tcp.rs +++ b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/local/tun/tcp.rs @@ -169,7 +169,7 @@ impl AsyncRead for TcpConnection { return Poll::Pending; } - let recv_buf = unsafe { mem::transmute::<_, &mut [u8]>(buf.unfilled_mut()) }; + let recv_buf = unsafe { mem::transmute::<&mut [mem::MaybeUninit], &mut [u8]>(buf.unfilled_mut()) }; let n = control.recv_buffer.dequeue_slice(recv_buf); buf.advance(n); diff --git a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/net/mon_socket.rs b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/net/mon_socket.rs index 7bf541d2fe..3ba055a4db 100644 --- a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/net/mon_socket.rs +++ b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/net/mon_socket.rs @@ -3,25 +3,44 @@ use std::{io, net::SocketAddr, sync::Arc}; use shadowsocks::{ - relay::{socks5::Address, udprelay::options::UdpSocketControlData}, + relay::{ + socks5::Address, + udprelay::{options::UdpSocketControlData, DatagramReceive, DatagramSend}, + }, ProxySocket, }; -use tokio::net::ToSocketAddrs; use super::flow::FlowStat; /// Monitored `ProxySocket` -pub struct MonProxySocket { - socket: ProxySocket, +pub struct MonProxySocket { + socket: ProxySocket, flow_stat: Arc, } -impl MonProxySocket { +impl MonProxySocket { /// Create a new socket with flow monitor - pub fn from_socket(socket: ProxySocket, flow_stat: Arc) -> MonProxySocket { + pub fn from_socket(socket: ProxySocket, flow_stat: Arc) -> MonProxySocket { MonProxySocket { socket, flow_stat } } + /// Get the underlying `ProxySocket` immutable reference + #[inline] + pub fn get_ref(&self) -> &ProxySocket { + &self.socket + } + + /// Get the flow statistic data + #[inline] + pub fn flow_stat(&self) -> &FlowStat { + &self.flow_stat + } +} + +impl MonProxySocket +where + S: DatagramSend, +{ /// Send a UDP packet to addr through proxy #[inline] pub async fn send(&self, addr: &Address, payload: &[u8]) -> io::Result<()> { @@ -47,7 +66,7 @@ impl MonProxySocket { /// Send a UDP packet to target from proxy #[inline] - pub async fn send_to(&self, target: A, addr: &Address, payload: &[u8]) -> io::Result<()> { + pub async fn send_to(&self, target: SocketAddr, addr: &Address, payload: &[u8]) -> io::Result<()> { let n = self.socket.send_to(target, addr, payload).await?; self.flow_stat.incr_tx(n as u64); @@ -56,9 +75,9 @@ impl MonProxySocket { /// Send a UDP packet to target from proxy #[inline] - pub async fn send_to_with_ctrl( + pub async fn send_to_with_ctrl( &self, - target: A, + target: SocketAddr, addr: &Address, control: &UdpSocketControlData, payload: &[u8], @@ -68,7 +87,12 @@ impl MonProxySocket { Ok(()) } +} +impl MonProxySocket +where + S: DatagramReceive, +{ /// Receive packet from Shadowsocks' UDP server /// /// This function will use `recv_buf` to store intermediate data, so it has to be big enough to store the whole shadowsocks' packet @@ -126,14 +150,4 @@ impl MonProxySocket { Ok((n, peer_addr, addr, control)) } - - #[inline] - pub fn get_ref(&self) -> &ProxySocket { - &self.socket - } - - #[inline] - pub fn flow_stat(&self) -> &FlowStat { - &self.flow_stat - } } diff --git a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/server/udprelay.rs b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/server/udprelay.rs index 32ec296468..e6835454bd 100644 --- a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/server/udprelay.rs +++ b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks-service/src/server/udprelay.rs @@ -17,7 +17,10 @@ use shadowsocks::{ config::ServerUser, crypto::CipherCategory, lookup_then, - net::{get_ip_stack_capabilities, AcceptOpts, AddrFamily, UdpSocket as OutboundUdpSocket}, + net::{ + get_ip_stack_capabilities, AcceptOpts, AddrFamily, UdpSocket as OutboundUdpSocket, + UdpSocket as InboundUdpSocket, + }, relay::{ socks5::Address, udprelay::{options::UdpSocketControlData, ProxySocket, MAXIMUM_UDP_PAYLOAD_SIZE}, @@ -25,8 +28,6 @@ use shadowsocks::{ ServerConfig, }; use tokio::{runtime::Handle, sync::mpsc, task::JoinHandle, time}; -#[cfg(windows)] -use windows_sys::Win32::Networking::WinSock::WSAEAFNOSUPPORT; use crate::net::{ packet_window::PacketWindowFilter, utils::to_ipv4_mapped, MonProxySocket, UDP_ASSOCIATION_KEEP_ALIVE_CHANNEL_SIZE, @@ -87,7 +88,7 @@ pub struct UdpServer { keepalive_tx: mpsc::Sender, keepalive_rx: mpsc::Receiver, time_to_live: Duration, - listener: Arc, + listener: Arc>, svr_cfg: ServerConfig, } @@ -276,7 +277,7 @@ impl UdpServer { async fn recv_one_packet( context: &ServiceContext, - l: &MonProxySocket, + l: &MonProxySocket, buffer: &mut [u8], ) -> Option<(usize, SocketAddr, Address, Option)> { let (n, peer_addr, target_addr, control) = match l.recv_from_with_ctrl(buffer).await { @@ -316,7 +317,7 @@ impl UdpServer { async fn send_packet( &mut self, - listener: &Arc, + listener: &Arc>, peer_addr: SocketAddr, target_addr: Address, control: Option, @@ -394,7 +395,7 @@ impl Drop for UdpAssociation { impl UdpAssociation { fn new_association( context: Arc, - inbound: Arc, + inbound: Arc>, peer_addr: SocketAddr, keepalive_tx: mpsc::Sender, ) -> UdpAssociation { @@ -405,7 +406,7 @@ impl UdpAssociation { #[cfg(feature = "aead-cipher-2022")] fn new_session( context: Arc, - inbound: Arc, + inbound: Arc>, peer_addr: SocketAddr, keepalive_tx: mpsc::Sender, client_session_id: u64, @@ -447,7 +448,7 @@ struct UdpAssociationContext { outbound_ipv6_socket: Option, keepalive_tx: mpsc::Sender, keepalive_flag: bool, - inbound: Arc, + inbound: Arc>, // AEAD 2022 client_session: Option, server_session_id: u64, @@ -472,7 +473,7 @@ fn generate_server_session_id() -> u64 { impl UdpAssociationContext { fn create( context: Arc, - inbound: Arc, + inbound: Arc>, peer_addr: SocketAddr, keepalive_tx: mpsc::Sender, client_session_id: Option, diff --git a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/Cargo.toml b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/Cargo.toml index f752f82b11..a63c4f211c 100644 --- a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/Cargo.toml +++ b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "shadowsocks" -version = "1.20.2" +version = "1.21.0" authors = ["Shadowsocks Contributors"] description = "shadowsocks is a fast tunnel proxy that helps you bypass firewalls." repository = "https://github.com/shadowsocks/shadowsocks-rust" @@ -48,7 +48,7 @@ security-replay-attack-detect = ["bloomfilter"] [dependencies] log = "0.4" -libc = "0.2.141" +libc = "~0.2.141" bytes = "1.7" cfg-if = "1" byte_string = "1.0" diff --git a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/context.rs b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/context.rs index 08cae47076..a205ce3aba 100644 --- a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/context.rs +++ b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/context.rs @@ -13,6 +13,7 @@ use crate::{ }; /// Service context +#[derive(Debug)] pub struct Context { // Protector against replay attack // The actual replay detection behavior is implemented in ReplayProtector @@ -122,7 +123,6 @@ impl Context { } /// Resolves DNS address to `SocketAddr`s - #[allow(clippy::needless_lifetimes)] pub async fn dns_resolve<'a>(&self, addr: &'a str, port: u16) -> io::Result + 'a> { self.dns_resolver.resolve(addr, port).await } @@ -142,7 +142,7 @@ impl Context { self.replay_policy = replay_policy; } - /// Get policy against replay attach + /// Get policy against replay attack pub fn replay_attack_policy(&self) -> ReplayAttackPolicy { self.replay_policy } diff --git a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/dns_resolver/resolver.rs b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/dns_resolver/resolver.rs index d2ee79919b..04bb6d15dc 100644 --- a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/dns_resolver/resolver.rs +++ b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/dns_resolver/resolver.rs @@ -38,6 +38,7 @@ pub trait DnsResolve { } #[cfg(feature = "hickory-dns")] +#[derive(Debug)] pub struct HickoryDnsSystemResolver { resolver: ArcSwap, #[cfg_attr(any(windows, target_os = "android"), allow(dead_code))] @@ -285,7 +286,6 @@ impl DnsResolver { } /// Resolve address into `SocketAddr`s - #[allow(clippy::needless_lifetimes)] pub async fn resolve<'a>(&self, addr: &'a str, port: u16) -> io::Result + 'a> { struct ResolverLogger<'x, 'y> { resolver: &'x DnsResolver, diff --git a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/manager/datagram.rs b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/manager/datagram.rs index 05131d9ecd..06106f1af7 100644 --- a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/manager/datagram.rs +++ b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/manager/datagram.rs @@ -46,6 +46,7 @@ impl fmt::Display for ManagerSocketAddr { /// Datagram socket for manager /// /// For *nix system, this is a wrapper for both UDP socket and Unix socket +#[derive(Debug)] pub enum ManagerDatagram { UdpDatagram(UdpSocket), #[cfg(unix)] diff --git a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/manager/listener.rs b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/manager/listener.rs index 004d82f2be..6f79d9d60b 100644 --- a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/manager/listener.rs +++ b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/manager/listener.rs @@ -13,6 +13,7 @@ use super::{ }; /// Manager server Listener +#[derive(Debug)] pub struct ManagerListener { socket: ManagerDatagram, } diff --git a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/net/sys/mod.rs b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/net/sys/mod.rs index b36033a797..6540508e95 100644 --- a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/net/sys/mod.rs +++ b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/net/sys/mod.rs @@ -87,7 +87,7 @@ where let sock = unsafe { Socket::from_raw_socket(handle) }; let result = socket_bind_dual_stack_inner(&sock, addr, ipv6_only); - sock.into_raw_socket(); + let _ = sock.into_raw_socket(); result } diff --git a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/net/sys/unix/bsd/macos.rs b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/net/sys/unix/bsd/macos.rs index 2c27417afc..de3717ee0a 100644 --- a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/net/sys/unix/bsd/macos.rs +++ b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/net/sys/unix/bsd/macos.rs @@ -54,6 +54,10 @@ impl TcpStream { let socket = unsafe { let fd = libc::socket(AF_MULTIPATH, libc::SOCK_STREAM, libc::IPPROTO_TCP); + if fd < 0 { + let err = io::Error::last_os_error(); + return Err(err); + } let socket = Socket::from_raw_fd(fd); socket.set_nonblocking(true)?; TcpSocket::from_raw_fd(socket.into_raw_fd()) diff --git a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/net/sys/unix/linux/mod.rs b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/net/sys/unix/linux/mod.rs index 1122f041d1..f007255a0f 100644 --- a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/net/sys/unix/linux/mod.rs +++ b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/net/sys/unix/linux/mod.rs @@ -213,12 +213,18 @@ pub fn set_tcp_fastopen(socket: &S) -> io::Result<()> { } fn create_mptcp_socket(bind_addr: &SocketAddr) -> io::Result { + // https://www.kernel.org/doc/html/next/networking/mptcp.html + unsafe { let family = match bind_addr { SocketAddr::V4(..) => libc::AF_INET, SocketAddr::V6(..) => libc::AF_INET6, }; let fd = libc::socket(family, libc::SOCK_STREAM, libc::IPPROTO_MPTCP); + if fd < 0 { + let err = io::Error::last_os_error(); + return Err(err); + } let socket = Socket::from_raw_fd(fd); socket.set_nonblocking(true)?; Ok(TcpSocket::from_raw_fd(socket.into_raw_fd())) diff --git a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/net/tcp.rs b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/net/tcp.rs index 97708ae7eb..66b797a661 100644 --- a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/net/tcp.rs +++ b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/net/tcp.rs @@ -121,6 +121,7 @@ impl AsyncWrite for TcpStream { } /// `TcpListener` for accepting inbound connections +#[derive(Debug)] pub struct TcpListener { inner: TokioTcpListener, accept_opts: AcceptOpts, diff --git a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/net/udp.rs b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/net/udp.rs index 2512be801e..d1b788d658 100644 --- a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/net/udp.rs +++ b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/net/udp.rs @@ -24,7 +24,7 @@ use std::{ ))] use futures::future; use futures::ready; -use pin_project::pin_project; + #[cfg(any( target_os = "linux", target_os = "android", @@ -85,9 +85,8 @@ fn make_mtu_error(packet_size: usize, mtu: usize) -> io::Error { } /// Wrappers for outbound `UdpSocket` -#[pin_project] +#[derive(Debug)] pub struct UdpSocket { - #[pin] socket: tokio::net::UdpSocket, mtu: Option, } diff --git a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/plugin/mod.rs b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/plugin/mod.rs index b55f7c0b83..379052f7c3 100644 --- a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/plugin/mod.rs +++ b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/plugin/mod.rs @@ -58,6 +58,7 @@ pub enum PluginMode { } /// A shadowsocks SIP004 Plugin +#[derive(Debug)] pub struct Plugin { process: Child, local_addr: SocketAddr, diff --git a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/relay/tcprelay/aead.rs b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/relay/tcprelay/aead.rs index 1d4e5a22b9..9fd19c739e 100644 --- a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/relay/tcprelay/aead.rs +++ b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/relay/tcprelay/aead.rs @@ -80,6 +80,7 @@ impl From for io::Error { } } +#[derive(Debug)] enum DecryptReadState { WaitSalt { key: Bytes }, ReadLength, @@ -320,6 +321,7 @@ impl DecryptedReader { } } +#[derive(Debug)] enum EncryptWriteState { AssemblePacket, Writing { pos: usize }, diff --git a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/relay/tcprelay/crypto_io.rs b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/relay/tcprelay/crypto_io.rs index 701503d3f3..f375517b43 100644 --- a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/relay/tcprelay/crypto_io.rs +++ b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/relay/tcprelay/crypto_io.rs @@ -1,7 +1,7 @@ //! IO facilities for TCP relay use std::{ - io, + fmt, io, marker::Unpin, pin::Pin, sync::Arc, @@ -313,6 +313,15 @@ pub struct CryptoStream { has_handshaked: bool, } +impl fmt::Debug for CryptoStream { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("CryptoStream") + .field("method", &self.method) + .field("has_handshaked", &self.has_handshaked) + .finish() + } +} + impl CryptoStream { /// Create a new CryptoStream with the underlying stream connection pub fn from_stream( diff --git a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/relay/tcprelay/proxy_listener.rs b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/relay/tcprelay/proxy_listener.rs index 055393c27a..9cac931e73 100644 --- a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/relay/tcprelay/proxy_listener.rs +++ b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/relay/tcprelay/proxy_listener.rs @@ -17,6 +17,7 @@ use crate::{ }; /// A TCP listener for accepting shadowsocks' client connection +#[derive(Debug)] pub struct ProxyListener { listener: TcpListener, method: CipherKind, diff --git a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/relay/tcprelay/proxy_stream/client.rs b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/relay/tcprelay/proxy_stream/client.rs index 953815ea27..ef5f0102cc 100644 --- a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/relay/tcprelay/proxy_stream/client.rs +++ b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/relay/tcprelay/proxy_stream/client.rs @@ -30,12 +30,14 @@ use crate::{ }, }; +#[derive(Debug)] enum ProxyClientStreamWriteState { Connect(Address), Connecting(BytesMut), Connected, } +#[derive(Debug)] enum ProxyClientStreamReadState { #[cfg(feature = "aead-cipher-2022")] CheckRequestNonce, @@ -43,6 +45,7 @@ enum ProxyClientStreamReadState { } /// A stream for sending / receiving data stream from remote server via shadowsocks' proxy server +#[derive(Debug)] #[pin_project] pub struct ProxyClientStream { #[pin] diff --git a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/relay/tcprelay/proxy_stream/protocol/mod.rs b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/relay/tcprelay/proxy_stream/protocol/mod.rs index 55e8b2a763..9a300c1299 100644 --- a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/relay/tcprelay/proxy_stream/protocol/mod.rs +++ b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/relay/tcprelay/proxy_stream/protocol/mod.rs @@ -18,6 +18,7 @@ pub mod v1; #[cfg(feature = "aead-cipher-2022")] pub mod v2; +#[derive(Debug)] pub enum TcpRequestHeader { Stream(StreamTcpRequestHeader), #[cfg(feature = "aead-cipher-2022")] @@ -74,6 +75,7 @@ impl TcpRequestHeader { } } +#[derive(Debug)] pub enum TcpRequestHeaderRef<'a> { Stream(StreamTcpRequestHeaderRef<'a>), #[cfg(feature = "aead-cipher-2022")] diff --git a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/relay/tcprelay/proxy_stream/protocol/v1.rs b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/relay/tcprelay/proxy_stream/protocol/v1.rs index 17b9b3648b..7c002923e5 100644 --- a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/relay/tcprelay/proxy_stream/protocol/v1.rs +++ b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/relay/tcprelay/proxy_stream/protocol/v1.rs @@ -7,6 +7,7 @@ use tokio::io::AsyncRead; use crate::relay::socks5::Address; +#[derive(Debug)] pub struct StreamTcpRequestHeader { pub addr: Address, } @@ -27,6 +28,7 @@ impl StreamTcpRequestHeader { } } +#[derive(Debug)] pub struct StreamTcpRequestHeaderRef<'a> { pub addr: &'a Address, } diff --git a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/relay/tcprelay/proxy_stream/protocol/v2.rs b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/relay/tcprelay/proxy_stream/protocol/v2.rs index 5b45fec34b..469488d5b4 100644 --- a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/relay/tcprelay/proxy_stream/protocol/v2.rs +++ b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/relay/tcprelay/proxy_stream/protocol/v2.rs @@ -66,6 +66,7 @@ impl Aead2022TcpRequestHeader { } } +#[derive(Debug)] pub struct Aead2022TcpRequestHeaderRef<'a> { pub addr: &'a Address, pub padding_size: u16, diff --git a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/relay/tcprelay/proxy_stream/server.rs b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/relay/tcprelay/proxy_stream/server.rs index 374d9d3ce4..784f39e478 100644 --- a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/relay/tcprelay/proxy_stream/server.rs +++ b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/relay/tcprelay/proxy_stream/server.rs @@ -25,6 +25,7 @@ use crate::{ }, }; +#[derive(Debug)] enum ProxyServerStreamWriteState { #[cfg(feature = "aead-cipher-2022")] PrepareHeader(Option), @@ -32,6 +33,7 @@ enum ProxyServerStreamWriteState { } /// A stream for communicating with shadowsocks' proxy client +#[derive(Debug)] #[pin_project] pub struct ProxyServerStream { #[pin] diff --git a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/relay/udprelay/compat.rs b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/relay/udprelay/compat.rs new file mode 100644 index 0000000000..fd17f28f13 --- /dev/null +++ b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/relay/udprelay/compat.rs @@ -0,0 +1,209 @@ +use std::{ + future::Future, + io, + net::SocketAddr, + ops::Deref, + pin::Pin, + task::{Context, Poll}, +}; + +use futures::ready; +use pin_project::pin_project; +use tokio::io::ReadBuf; + +use crate::net::UdpSocket; + +/// A socket I/O object that can transport datagram +pub trait DatagramSocket { + /// Local binded address + fn local_addr(&self) -> io::Result; +} + +/// A socket I/O object that can receive datagram +pub trait DatagramReceive { + /// `recv` data into `buf` + fn poll_recv(&self, cx: &mut Context<'_>, buf: &mut ReadBuf<'_>) -> Poll>; + /// `recv` data into `buf` with source address + fn poll_recv_from(&self, cx: &mut Context<'_>, buf: &mut ReadBuf<'_>) -> Poll>; + /// Check if the underlying I/O object is ready for `recv` + fn poll_recv_ready(&self, cx: &mut Context<'_>) -> Poll>; +} + +/// A socket I/O object that can send datagram +pub trait DatagramSend { + /// `send` data with `buf`, returning the sent bytes + fn poll_send(&self, cx: &mut Context<'_>, buf: &[u8]) -> Poll>; + /// `send` data with `buf` to `target`, returning the sent bytes + fn poll_send_to(&self, cx: &mut Context<'_>, buf: &[u8], target: SocketAddr) -> Poll>; + /// Check if the underlying I/O object is ready for `send` + fn poll_send_ready(&self, cx: &mut Context<'_>) -> Poll>; +} + +impl DatagramSocket for UdpSocket { + fn local_addr(&self) -> io::Result { + self.deref().local_addr() + } +} + +impl DatagramReceive for UdpSocket { + fn poll_recv(&self, cx: &mut Context<'_>, buf: &mut ReadBuf<'_>) -> Poll> { + UdpSocket::poll_recv(self, cx, buf) + } + + fn poll_recv_from(&self, cx: &mut Context<'_>, buf: &mut ReadBuf<'_>) -> Poll> { + UdpSocket::poll_recv_from(self, cx, buf) + } + + fn poll_recv_ready(&self, cx: &mut Context<'_>) -> Poll> { + self.deref().poll_recv_ready(cx) + } +} + +impl DatagramSend for UdpSocket { + fn poll_send(&self, cx: &mut Context<'_>, buf: &[u8]) -> Poll> { + UdpSocket::poll_send(self, cx, buf) + } + + fn poll_send_to(&self, cx: &mut Context<'_>, buf: &[u8], target: SocketAddr) -> Poll> { + UdpSocket::poll_send_to(self, cx, buf, target) + } + + fn poll_send_ready(&self, cx: &mut Context<'_>) -> Poll> { + self.deref().poll_send_ready(cx) + } +} + +/// Future for `recv` +#[pin_project] +pub struct RecvFut<'a, S: DatagramReceive + ?Sized> { + #[pin] + io: &'a S, + buf: &'a mut [u8], +} + +impl<'a, S: DatagramReceive + ?Sized> Future for RecvFut<'a, S> { + type Output = io::Result; + + fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { + let this = self.project(); + + let mut read_buf = ReadBuf::new(this.buf); + ready!(this.io.poll_recv(cx, &mut read_buf))?; + Ok(read_buf.filled().len()).into() + } +} + +/// Future for `recv_from` +#[pin_project] +pub struct RecvFromFut<'a, S: DatagramReceive + ?Sized> { + #[pin] + io: &'a S, + buf: &'a mut [u8], +} + +impl<'a, S: DatagramReceive + ?Sized> Future for RecvFromFut<'a, S> { + type Output = io::Result<(usize, SocketAddr)>; + + fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { + let this = self.project(); + + let mut read_buf = ReadBuf::new(this.buf); + let src_addr = ready!(this.io.poll_recv_from(cx, &mut read_buf))?; + Ok((read_buf.filled().len(), src_addr)).into() + } +} + +/// Future for `recv_ready` +pub struct RecvReadyFut<'a, S: DatagramReceive + ?Sized> { + io: &'a S, +} + +impl<'a, S: DatagramReceive + ?Sized> Future for RecvReadyFut<'a, S> { + type Output = io::Result<()>; + + fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { + self.io.poll_recv_ready(cx) + } +} + +/// Future for `send` +pub struct SendFut<'a, S: DatagramSend + ?Sized> { + io: &'a S, + buf: &'a [u8], +} + +impl<'a, S: DatagramSend + ?Sized> Future for SendFut<'a, S> { + type Output = io::Result; + + fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { + self.io.poll_send(cx, self.buf) + } +} + +/// Future for `send_to` +pub struct SendToFut<'a, S: DatagramSend + ?Sized> { + io: &'a S, + target: SocketAddr, + buf: &'a [u8], +} + +impl<'a, S: DatagramSend + ?Sized> Future for SendToFut<'a, S> { + type Output = io::Result; + + fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { + self.io.poll_send_to(cx, self.buf, self.target) + } +} + +/// Future for `recv_ready` +pub struct SendReadyFut<'a, S: DatagramSend + ?Sized> { + io: &'a S, +} + +impl<'a, S: DatagramSend + ?Sized> Future for SendReadyFut<'a, S> { + type Output = io::Result<()>; + + fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { + self.io.poll_send_ready(cx) + } +} + +/// Extension methods for `DatagramReceive` +pub trait DatagramReceiveExt: DatagramReceive { + /// Async method for `poll_recv` + fn recv<'a>(&'a self, buf: &'a mut [u8]) -> RecvFut<'a, Self> { + RecvFut { io: self, buf } + } + + /// Async method for `poll_recv_from` + fn recv_from<'a>(&'a self, buf: &'a mut [u8]) -> RecvFromFut<'a, Self> { + RecvFromFut { io: self, buf } + } + + /// Async method for `poll_recv_ready` + fn recv_ready(&self) -> RecvReadyFut<'_, Self> { + RecvReadyFut { io: self } + } +} + +impl DatagramReceiveExt for S {} + +/// Extension methods for `DatagramSend` +pub trait DatagramSendExt: DatagramSend { + /// Async method for `poll_send` + fn send<'a>(&'a self, buf: &'a [u8]) -> SendFut<'a, Self> { + SendFut { io: self, buf } + } + + /// Async method for `poll_send_to` + fn send_to<'a>(&'a self, buf: &'a [u8], target: SocketAddr) -> SendToFut<'a, Self> { + SendToFut { io: self, target, buf } + } + + /// Async method for `poll_send_ready` + fn send_ready(&self) -> SendReadyFut<'_, Self> { + SendReadyFut { io: self } + } +} + +impl DatagramSendExt for S {} diff --git a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/relay/udprelay/mod.rs b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/relay/udprelay/mod.rs index dc22d0d397..e7700e7ecf 100644 --- a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/relay/udprelay/mod.rs +++ b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/relay/udprelay/mod.rs @@ -50,10 +50,12 @@ use std::time::Duration; pub use self::proxy_socket::ProxySocket; +pub use compat::{DatagramReceive, DatagramReceiveExt, DatagramSend, DatagramSendExt, DatagramSocket}; mod aead; #[cfg(feature = "aead-cipher-2022")] mod aead_2022; +mod compat; pub mod crypto_io; pub mod options; pub mod proxy_socket; diff --git a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/relay/udprelay/proxy_socket.rs b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/relay/udprelay/proxy_socket.rs index 356bdd7393..5c1563ed7d 100644 --- a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/relay/udprelay/proxy_socket.rs +++ b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/relay/udprelay/proxy_socket.rs @@ -1,5 +1,9 @@ //! UDP socket for communicating with shadowsocks' proxy server +#[cfg(unix)] +use std::os::fd::{AsFd, AsRawFd, BorrowedFd, IntoRawFd, RawFd}; +#[cfg(windows)] +use std::os::windows::io::{AsRawSocket, AsSocket, BorrowedSocket, IntoRawSocket, RawSocket}; use std::{ io::{self, ErrorKind}, net::SocketAddr, @@ -12,7 +16,7 @@ use byte_string::ByteStr; use bytes::{Bytes, BytesMut}; use log::{info, trace, warn}; use once_cell::sync::Lazy; -use tokio::{io::ReadBuf, net::ToSocketAddrs, time}; +use tokio::{io::ReadBuf, time}; use crate::{ config::{ServerAddr, ServerConfig, ServerUserManager}, @@ -22,9 +26,12 @@ use crate::{ relay::{socks5::Address, udprelay::options::UdpSocketControlData}, }; -use super::crypto_io::{ - decrypt_client_payload, decrypt_server_payload, encrypt_client_payload, encrypt_server_payload, ProtocolError, - ProtocolResult, +use super::{ + compat::{DatagramReceive, DatagramReceiveExt, DatagramSend, DatagramSendExt, DatagramSocket}, + crypto_io::{ + decrypt_client_payload, decrypt_server_payload, encrypt_client_payload, encrypt_server_payload, ProtocolError, + ProtocolResult, + }, }; static DEFAULT_CONNECT_OPTS: Lazy = Lazy::new(Default::default); @@ -66,9 +73,10 @@ impl From for io::Error { pub type ProxySocketResult = Result; /// UDP client for communicating with ShadowSocks' server -pub struct ProxySocket { +#[derive(Debug)] +pub struct ProxySocket { socket_type: UdpSocketType, - socket: ShadowUdpSocket, + io: S, method: CipherKind, key: Box<[u8]>, send_timeout: Option, @@ -78,9 +86,12 @@ pub struct ProxySocket { user_manager: Option>, } -impl ProxySocket { +impl ProxySocket { /// Create a client to communicate with Shadowsocks' UDP server (outbound) - pub async fn connect(context: SharedContext, svr_cfg: &ServerConfig) -> ProxySocketResult { + pub async fn connect( + context: SharedContext, + svr_cfg: &ServerConfig, + ) -> ProxySocketResult> { ProxySocket::connect_with_opts(context, svr_cfg, &DEFAULT_CONNECT_OPTS) .await .map_err(Into::into) @@ -91,7 +102,7 @@ impl ProxySocket { context: SharedContext, svr_cfg: &ServerConfig, opts: &ConnectOpts, - ) -> ProxySocketResult { + ) -> ProxySocketResult> { // Note: Plugins doesn't support UDP relay let socket = ShadowUdpSocket::connect_server_with_opts(&context, svr_cfg.udp_external_addr(), opts).await?; @@ -111,42 +122,11 @@ impl ProxySocket { )) } - /// Create a `ProxySocket` from a `UdpSocket` - pub fn from_socket( - socket_type: UdpSocketType, + /// Create a `ProxySocket` binding to a specific address (inbound) + pub async fn bind( context: SharedContext, svr_cfg: &ServerConfig, - socket: S, - ) -> ProxySocket - where - S: Into, - { - let key = svr_cfg.key().to_vec().into_boxed_slice(); - let method = svr_cfg.method(); - - // NOTE: svr_cfg.timeout() is not for this socket, but for associations. - - ProxySocket { - socket_type, - socket: socket.into(), - method, - key, - send_timeout: None, - recv_timeout: None, - context, - identity_keys: match socket_type { - UdpSocketType::Client => svr_cfg.clone_identity_keys(), - UdpSocketType::Server => Arc::new(Vec::new()), - }, - user_manager: match socket_type { - UdpSocketType::Client => None, - UdpSocketType::Server => svr_cfg.clone_user_manager(), - }, - } - } - - /// Create a `ProxySocket` binding to a specific address (inbound) - pub async fn bind(context: SharedContext, svr_cfg: &ServerConfig) -> ProxySocketResult { + ) -> ProxySocketResult> { ProxySocket::bind_with_opts(context, svr_cfg, AcceptOpts::default()) .await .map_err(Into::into) @@ -157,7 +137,7 @@ impl ProxySocket { context: SharedContext, svr_cfg: &ServerConfig, opts: AcceptOpts, - ) -> ProxySocketResult { + ) -> ProxySocketResult> { // Plugins doesn't support UDP let socket = match svr_cfg.udp_external_addr() { ServerAddr::SocketAddr(sa) => ShadowUdpSocket::listen_with_opts(sa, opts).await?, @@ -175,7 +155,54 @@ impl ProxySocket { socket, )) } +} +impl ProxySocket { + /// Create a `ProxySocket` from a I/O object that impls `DatagramTransport` + pub fn from_socket( + socket_type: UdpSocketType, + context: SharedContext, + svr_cfg: &ServerConfig, + socket: S, + ) -> ProxySocket { + let key = svr_cfg.key().to_vec().into_boxed_slice(); + let method = svr_cfg.method(); + + // NOTE: svr_cfg.timeout() is not for this socket, but for associations. + ProxySocket { + socket_type, + io: socket, + method, + key, + send_timeout: None, + recv_timeout: None, + context, + identity_keys: match socket_type { + UdpSocketType::Client => svr_cfg.clone_identity_keys(), + UdpSocketType::Server => Arc::new(Vec::new()), + }, + user_manager: match socket_type { + UdpSocketType::Client => None, + UdpSocketType::Server => svr_cfg.clone_user_manager(), + }, + } + } + + /// Set `send` timeout, `None` will clear timeout + pub fn set_send_timeout(&mut self, t: Option) { + self.send_timeout = t; + } + + /// Set `recv` timeout, `None` will clear timeout + pub fn set_recv_timeout(&mut self, t: Option) { + self.recv_timeout = t; + } +} + +impl ProxySocket +where + S: DatagramSend, +{ fn encrypt_send_buffer( &self, addr: &Address, @@ -237,8 +264,8 @@ impl ProxySocket { ); let send_len = match self.send_timeout { - None => self.socket.send(&send_buf).await?, - Some(d) => match time::timeout(d, self.socket.send(&send_buf)).await { + None => self.io.send(&send_buf).await?, + Some(d) => match time::timeout(d, self.io.send(&send_buf)).await { Ok(Ok(l)) => l, Ok(Err(err)) => return Err(err.into()), Err(..) => return Err(io::Error::from(ErrorKind::TimedOut).into()), @@ -291,7 +318,7 @@ impl ProxySocket { let n_send_buf = send_buf.len(); - match self.socket.poll_send(cx, &send_buf).map_err(|x| x.into()) { + match self.io.poll_send(cx, &send_buf).map_err(|x| x.into()) { Poll::Ready(Ok(l)) => { if l == n_send_buf { Poll::Ready(Ok(payload.len())) @@ -336,14 +363,14 @@ impl ProxySocket { self.encrypt_send_buffer(addr, control, &self.identity_keys, payload, &mut send_buf)?; info!( - "UDP server client send to {}, payload length {} bytes, packet length {} bytes", + "UDP server client poll_send_to to {}, payload length {} bytes, packet length {} bytes", target, payload.len(), send_buf.len() ); let n_send_buf = send_buf.len(); - match self.socket.poll_send_to(cx, &send_buf, target).map_err(|x| x.into()) { + match self.io.poll_send_to(cx, &send_buf, target).map_err(|x| x.into()) { Poll::Ready(Ok(l)) => { if l == n_send_buf { Poll::Ready(Ok(payload.len())) @@ -359,25 +386,20 @@ impl ProxySocket { /// /// Check if socket is ready to `send`, or writable. pub fn poll_send_ready(&self, cx: &mut Context<'_>) -> Poll> { - self.socket.poll_send_ready(cx).map_err(|x| x.into()) + self.io.poll_send_ready(cx).map_err(|x| x.into()) } /// Send a UDP packet to target through proxy `target` - pub async fn send_to( - &self, - target: A, - addr: &Address, - payload: &[u8], - ) -> ProxySocketResult { + pub async fn send_to(&self, target: SocketAddr, addr: &Address, payload: &[u8]) -> ProxySocketResult { self.send_to_with_ctrl(target, addr, &DEFAULT_SOCKET_CONTROL, payload) .await .map_err(Into::into) } /// Send a UDP packet to target through proxy `target` - pub async fn send_to_with_ctrl( + pub async fn send_to_with_ctrl( &self, - target: A, + target: SocketAddr, addr: &Address, control: &UdpSocketControlData, payload: &[u8], @@ -386,7 +408,7 @@ impl ProxySocket { self.encrypt_send_buffer(addr, control, &self.identity_keys, payload, &mut send_buf)?; trace!( - "UDP server client send to, addr {}, control: {:?}, payload length {} bytes, packet length {} bytes", + "UDP server client send_to to, addr {}, control: {:?}, payload length {} bytes, packet length {} bytes", addr, control, payload.len(), @@ -394,8 +416,8 @@ impl ProxySocket { ); let send_len = match self.send_timeout { - None => self.socket.send_to(&send_buf, target).await?, - Some(d) => match time::timeout(d, self.socket.send_to(&send_buf, target)).await { + None => self.io.send_to(&send_buf, target).await?, + Some(d) => match time::timeout(d, self.io.send_to(&send_buf, target)).await { Ok(Ok(l)) => l, Ok(Err(err)) => return Err(err.into()), Err(..) => return Err(io::Error::from(ErrorKind::TimedOut).into()), @@ -404,7 +426,7 @@ impl ProxySocket { if send_buf.len() != send_len { warn!( - "UDP server client send {} bytes, but actually sent {} bytes", + "UDP server client send_to {} bytes, but actually sent {} bytes", send_buf.len(), send_len ); @@ -412,7 +434,12 @@ impl ProxySocket { Ok(send_len) } +} +impl ProxySocket +where + S: DatagramReceive, +{ fn decrypt_recv_buffer( &self, recv_buf: &mut [u8], @@ -444,10 +471,9 @@ impl ProxySocket { &self, recv_buf: &mut [u8], ) -> ProxySocketResult<(usize, Address, usize, Option)> { - // Waiting for response from server SERVER -> CLIENT let recv_n = match self.recv_timeout { - None => self.socket.recv(recv_buf).await?, - Some(d) => match time::timeout(d, self.socket.recv(recv_buf)).await { + None => self.io.recv(recv_buf).await?, + Some(d) => match time::timeout(d, self.io.recv(recv_buf)).await { Ok(Ok(l)) => l, Ok(Err(err)) => return Err(err.into()), Err(..) => return Err(io::Error::from(ErrorKind::TimedOut).into()), @@ -494,8 +520,8 @@ impl ProxySocket { ) -> ProxySocketResult<(usize, SocketAddr, Address, usize, Option)> { // Waiting for response from server SERVER -> CLIENT let (recv_n, target_addr) = match self.recv_timeout { - None => self.socket.recv_from(recv_buf).await?, - Some(d) => match time::timeout(d, self.socket.recv_from(recv_buf)).await { + None => self.io.recv_from(recv_buf).await?, + Some(d) => match time::timeout(d, self.io.recv_from(recv_buf)).await { Ok(Ok(l)) => l, Ok(Err(err)) => return Err(err.into()), Err(..) => return Err(io::Error::from(ErrorKind::TimedOut).into()), @@ -538,7 +564,7 @@ impl ProxySocket { cx: &mut Context<'_>, recv_buf: &mut ReadBuf, ) -> Poll)>> { - ready!(self.socket.poll_recv(cx, recv_buf))?; + ready!(self.io.poll_recv(cx, recv_buf))?; let n_recv = recv_buf.filled().len(); @@ -566,7 +592,7 @@ impl ProxySocket { cx: &mut Context<'_>, recv_buf: &mut ReadBuf, ) -> Poll)>> { - let src = ready!(self.socket.poll_recv_from(cx, recv_buf))?; + let src = ready!(self.io.poll_recv_from(cx, recv_buf))?; let n_recv = recv_buf.filled().len(); match self.decrypt_recv_buffer(recv_buf.filled_mut(), self.user_manager.as_deref()) { @@ -577,21 +603,77 @@ impl ProxySocket { /// poll family functions pub fn poll_recv_ready(&self, cx: &mut Context<'_>) -> Poll> { - self.socket.poll_recv_ready(cx).map_err(|x| x.into()) - } - - /// Get local addr of socket - pub fn local_addr(&self) -> io::Result { - self.socket.local_addr() - } - - /// Set `send` timeout, `None` will clear timeout - pub fn set_send_timeout(&mut self, t: Option) { - self.send_timeout = t; - } - - /// Set `recv` timeout, `None` will clear timeout - pub fn set_recv_timeout(&mut self, t: Option) { - self.recv_timeout = t; + self.io.poll_recv_ready(cx).map_err(|x| x.into()) + } +} + +impl ProxySocket +where + S: DatagramSocket, +{ + /// Get local addr of socket + pub fn local_addr(&self) -> io::Result { + self.io.local_addr() + } +} + +#[cfg(unix)] +impl AsRawFd for ProxySocket +where + S: AsRawFd, +{ + /// Retrieve raw fd of the outbound socket + fn as_raw_fd(&self) -> RawFd { + self.io.as_raw_fd() + } +} + +#[cfg(unix)] +impl AsFd for ProxySocket +where + S: AsFd, +{ + fn as_fd(&self) -> BorrowedFd<'_> { + self.io.as_fd() + } +} + +#[cfg(unix)] +impl IntoRawFd for ProxySocket +where + S: IntoRawFd, +{ + fn into_raw_fd(self) -> RawFd { + self.io.into_raw_fd() + } +} + +#[cfg(windows)] +impl AsRawSocket for ProxySocket +where + S: AsRawSocket, +{ + fn as_raw_socket(&self) -> RawSocket { + self.io.as_raw_socket() + } +} + +#[cfg(windows)] +impl AsSocket for ProxySocket +where + S: AsSocket, +{ + fn as_socket(&self) -> BorrowedSocket<'_> { + self.io.as_socket() + } +} + +#[cfg(windows)] +impl IntoRawSocket for ProxySocket +where + S: IntoRawSocket, +{ + fn into_raw_socket(self) -> RawSocket { + self.io.into_raw_socket() } } diff --git a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/security/replay/mod.rs b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/security/replay/mod.rs index 968f8d7b00..2848c56f65 100644 --- a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/security/replay/mod.rs +++ b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/security/replay/mod.rs @@ -1,3 +1,5 @@ +use std::fmt; + #[cfg(feature = "aead-cipher-2022")] use std::time::Duration; @@ -15,7 +17,7 @@ use self::ppbloom::PingPongBloom; #[cfg(feature = "security-replay-attack-detect")] mod ppbloom; -/// A Bloom Filter based protector against replay attach +/// A Bloom Filter based protector against replay attack pub struct ReplayProtector { // Check for duplicated IV/Nonce, for prevent replay attack // https://github.com/shadowsocks/shadowsocks-org/issues/44 @@ -29,6 +31,12 @@ pub struct ReplayProtector { nonce_set: spin::Mutex, ()>>, } +impl fmt::Debug for ReplayProtector { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("ReplayProtector").finish() + } +} + impl ReplayProtector { /// Create a new ReplayProtector #[allow(unused_variables)] diff --git a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/security/replay/ppbloom.rs b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/security/replay/ppbloom.rs index cf0be9c82c..50490ccba7 100644 --- a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/security/replay/ppbloom.rs +++ b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/src/security/replay/ppbloom.rs @@ -27,6 +27,7 @@ const BF_ERROR_RATE_FOR_CLIENT: f64 = 1e-15; // // It contains 2 bloom filters and each one holds 1/2 entries. // Use them as a ring buffer. +#[derive(Debug)] pub struct PingPongBloom { blooms: [Bloom<[u8]>; 2], bloom_count: [usize; 2], diff --git a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/tests/udp.rs b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/tests/udp.rs index 1895215d5f..69e0a4e3f7 100644 --- a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/tests/udp.rs +++ b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/crates/shadowsocks/tests/udp.rs @@ -8,6 +8,7 @@ use shadowsocks::{ config::{ServerConfig, ServerType}, context::{Context, SharedContext}, crypto::CipherKind, + net::UdpSocket as ShadowUdpSocket, relay::{socks5::Address, udprelay::ProxySocket}, }; @@ -15,7 +16,7 @@ async fn handle_udp_server_client( peer_addr: SocketAddr, remote_addr: Address, payload: &[u8], - socket: &ProxySocket, + socket: &ProxySocket, ) -> io::Result<()> { let remote_socket = UdpSocket::bind("0.0.0.0:0").await?; @@ -124,7 +125,7 @@ async fn udp_tunnel_echo( let socket = UdpSocket::bind("0.0.0.0:0").await?; socket.connect(local_addr).await?; - static SEND_PAYLOAD: &[u8] = b"HELLO WORLD. \012345"; + static SEND_PAYLOAD: &[u8] = b"HELLO WORLD. \x0012345"; socket.send(SEND_PAYLOAD).await?; let mut buffer = [0u8; 65536]; diff --git a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/debian/changelog b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/debian/changelog index adbcd06a0f..554518f09e 100644 --- a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/debian/changelog +++ b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/debian/changelog @@ -1,3 +1,26 @@ +shadowsocks-rust (1.21.2) unstable; urgency=medium + + ## Bug Fixes + + - #1730 `local-http`: HTTP Client removes Authority from Request URI only for HTTP/1.x + +shadowsocks-rust (1.21.1) unstable; urgency=medium + + ## Bug Fixes + + - #1730 `local-http`: The URI field in HTTP Request sent from `sslocal` should only contain path and query. + + ## Miscellaneous + + - #1702 Debian package build removes dependency of `pwgen` + +shadowsocks-rust (1.21.0) unstable; urgency=medium + + ## Features + + - #1641 `shadowsocks`: `ProxySocket` supports generic I/O socket type + - #1567 `shadowsocks-service`: Support OpenBSD Packet-Filter (pf) + shadowsocks-rust (1.20.4) unstable; urgency=medium ## Features diff --git a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/debian/compat b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/debian/compat index ec635144f6..f599e28b8a 100644 --- a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/debian/compat +++ b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/debian/compat @@ -1 +1 @@ -9 +10 diff --git a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/debian/config.json b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/debian/config.json index 6ab67d57f1..fecbd4b8a2 100644 --- a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/debian/config.json +++ b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/debian/config.json @@ -3,7 +3,7 @@ "server_port": 8388, "local_address": "127.0.0.1", "local_port": 1080, - "password": "barfoo!", + "password": "barfoo", "timeout": 300, "method": "chacha20-ietf-poly1305" } diff --git a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/debian/control b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/debian/control index 94d0284728..ea233796f0 100644 --- a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/debian/control +++ b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/debian/control @@ -2,7 +2,7 @@ Source: shadowsocks-rust Section: net Priority: optional Maintainer: Y. T. Chung -Build-Depends: debhelper (>=9), rustc, cargo, apg | pwgen, libcap2-bin [linux-any] +Build-Depends: debhelper (>=9), rustc, cargo, libcap2-bin [linux-any] Standards-Version: 3.9.6 Homepage: https://github.com/shadowsocks/shadowsocks-rust diff --git a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/debian/shadowsocks-rust-local@.service b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/debian/shadowsocks-rust-local@.service index 05a99643b5..ec609b92ae 100644 --- a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/debian/shadowsocks-rust-local@.service +++ b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/debian/shadowsocks-rust-local@.service @@ -13,6 +13,7 @@ After=network.target Type=simple CapabilityBoundingSet=CAP_NET_BIND_SERVICE AmbientCapabilities=CAP_NET_BIND_SERVICE +DynamicUser=yes ExecStart=/usr/bin/ssservice local --log-without-time -c /etc/shadowsocks-rust/%i.json [Install] diff --git a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/debian/shadowsocks-rust-server@.service b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/debian/shadowsocks-rust-server@.service index 0f129e782e..73f59d561d 100644 --- a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/debian/shadowsocks-rust-server@.service +++ b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/debian/shadowsocks-rust-server@.service @@ -13,6 +13,7 @@ After=network.target Type=simple CapabilityBoundingSet=CAP_NET_BIND_SERVICE AmbientCapabilities=CAP_NET_BIND_SERVICE +DynamicUser=yes ExecStart=/usr/bin/ssservice server --log-without-time -c /etc/shadowsocks-rust/%i.json [Install] diff --git a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/debian/shadowsocks-rust.postinst b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/debian/shadowsocks-rust.postinst index c39b2af27a..e8a2be7e24 100644 --- a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/debian/shadowsocks-rust.postinst +++ b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/debian/shadowsocks-rust.postinst @@ -21,20 +21,16 @@ pathfind() { case "$1" in configure|reconfigure) pathfind setcap && setcap \ - cap_net_bind_service+ep /usr/bin/ssservice \ + cap_net_bind_service+ep /usr/bin/ssservice \ cap_net_bind_service+ep /usr/bin/sslocal \ cap_net_bind_service+ep /usr/bin/ssserver if [ ! -f /etc/shadowsocks-rust/config.json ]; then set +e - pathfind apg - if [ $? -eq 0 ]; then - passwd=$(apg -n 1 -M ncl) - else - passwd=$(pwgen 12 1) - fi + passwd=$(/usr/bin/ssservice genkey -m "chacha20-ietf-poly1305") + passwd=$(echo $passwd | sed "s/+/\\\\+/g" | sed "s/\\//\\\\\\//g") set -e mkdir -p /etc/shadowsocks-rust - sed "s/barfoo!/$passwd/" /usr/share/shadowsocks-rust/config.json \ + sed "s/barfoo/$passwd/" /usr/share/shadowsocks-rust/config.json \ > /etc/shadowsocks-rust/config.json fi ;; diff --git a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/debian/shadowsocks-rust.service b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/debian/shadowsocks-rust.service index af56887d7e..f4b807d43e 100644 --- a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/debian/shadowsocks-rust.service +++ b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/debian/shadowsocks-rust.service @@ -11,8 +11,7 @@ After=network.target [Service] Type=simple EnvironmentFile=/etc/default/shadowsocks-rust -User=nobody -Group=nogroup +DynamicUser=yes LimitNOFILE=32768 ExecStart=/usr/bin/ssservice server -c ${CONFFILE} ${DAEMON_ARGS} diff --git a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/src/service/local.rs b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/src/service/local.rs index 50e977d51f..8e108e70ea 100644 --- a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/src/service/local.rs +++ b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/src/service/local.rs @@ -1,11 +1,12 @@ //! Local server launchers +#[cfg(unix)] +use std::sync::Arc; use std::{ future::Future, net::IpAddr, path::PathBuf, process::ExitCode, - sync::Arc, time::{Duration, Instant}, }; @@ -1065,7 +1066,7 @@ struct ServerReloader { } impl ServerReloader { - #[cfg_attr(not(any(unix, feature = "local-online-config")), allow(dead_code))] + #[cfg_attr(not(unix), allow(dead_code))] async fn run_once(&self) -> Result<(), Box> { let start_time = Instant::now(); diff --git a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/tests/udp.rs b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/tests/udp.rs index dba2bcabea..acccb762d3 100644 --- a/shadowsocks-android/core/src/main/rust/shadowsocks-rust/tests/udp.rs +++ b/shadowsocks-android/core/src/main/rust/shadowsocks-rust/tests/udp.rs @@ -1,4 +1,3 @@ -#![cfg_attr(clippy, allow(blacklisted_name))] #![cfg(all(feature = "local", feature = "server"))] use std::net::SocketAddr; diff --git a/shadowsocks-android/gradle/wrapper/gradle-wrapper.properties b/shadowsocks-android/gradle/wrapper/gradle-wrapper.properties index 9355b41557..df97d72b8b 100644 --- a/shadowsocks-android/gradle/wrapper/gradle-wrapper.properties +++ b/shadowsocks-android/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/shadowsocks-android/mobile/build.gradle.kts b/shadowsocks-android/mobile/build.gradle.kts index 831a488553..10d41102a1 100644 --- a/shadowsocks-android/mobile/build.gradle.kts +++ b/shadowsocks-android/mobile/build.gradle.kts @@ -15,13 +15,14 @@ android { } dependencies { - val cameraxVersion = "1.3.4" + val cameraxVersion = "1.4.0" implementation("androidx.browser:browser:1.8.0") implementation("androidx.camera:camera-camera2:$cameraxVersion") implementation("androidx.camera:camera-lifecycle:$cameraxVersion") implementation("androidx.camera:camera-view:$cameraxVersion") - implementation("androidx.constraintlayout:constraintlayout:2.1.4") + implementation("androidx.concurrent:concurrent-futures-ktx:1.2.0") + implementation("androidx.constraintlayout:constraintlayout:2.2.0") implementation("androidx.lifecycle:lifecycle-runtime-ktx:$lifecycleVersion") implementation("com.google.mlkit:barcode-scanning:17.3.0") implementation("com.google.zxing:core:3.5.3") diff --git a/shadowsocks-android/mobile/src/main/java/com/github/shadowsocks/ScannerActivity.kt b/shadowsocks-android/mobile/src/main/java/com/github/shadowsocks/ScannerActivity.kt index a53d565de5..faec1f58e4 100644 --- a/shadowsocks-android/mobile/src/main/java/com/github/shadowsocks/ScannerActivity.kt +++ b/shadowsocks-android/mobile/src/main/java/com/github/shadowsocks/ScannerActivity.kt @@ -31,14 +31,19 @@ import android.view.MenuItem import android.widget.Toast import androidx.activity.result.contract.ActivityResultContracts import androidx.appcompat.app.AppCompatActivity -import androidx.camera.core.* +import androidx.camera.core.Camera +import androidx.camera.core.CameraSelector +import androidx.camera.core.ExperimentalGetImage +import androidx.camera.core.ImageAnalysis +import androidx.camera.core.ImageProxy +import androidx.camera.core.Preview import androidx.camera.core.resolutionselector.ResolutionSelector import androidx.camera.core.resolutionselector.ResolutionStrategy import androidx.camera.lifecycle.ProcessCameraProvider import androidx.camera.view.PreviewView +import androidx.concurrent.futures.await import androidx.core.content.getSystemService import androidx.lifecycle.lifecycleScope -import androidx.work.await import com.github.shadowsocks.Core.app import com.github.shadowsocks.database.Profile import com.github.shadowsocks.database.ProfileManager @@ -50,8 +55,13 @@ import com.google.mlkit.vision.barcode.BarcodeScanning import com.google.mlkit.vision.barcode.ZoomSuggestionOptions import com.google.mlkit.vision.barcode.common.Barcode import com.google.mlkit.vision.common.InputImage -import kotlinx.coroutines.* +import kotlinx.coroutines.CancellationException +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.GlobalScope +import kotlinx.coroutines.asExecutor +import kotlinx.coroutines.launch import kotlinx.coroutines.tasks.await +import kotlinx.coroutines.withContext import timber.log.Timber class ScannerActivity : AppCompatActivity(), ImageAnalysis.Analyzer, ZoomSuggestionOptions.ZoomCallback { diff --git a/shadowsocks-android/repositories.gradle.kts b/shadowsocks-android/repositories.gradle.kts index aeaeb4a4bb..ad6f107dc0 100644 --- a/shadowsocks-android/repositories.gradle.kts +++ b/shadowsocks-android/repositories.gradle.kts @@ -1,6 +1,6 @@ rootProject.extra.apply { - set("androidPlugin", "com.android.tools.build:gradle:8.5.2") - set("kotlinVersion", "2.0.20") + set("androidPlugin", "com.android.tools.build:gradle:8.7.2") + set("kotlinVersion", "2.0.21") } repositories { diff --git a/small/luci-app-bypass/root/etc/init.d/bypass b/small/luci-app-bypass/root/etc/init.d/bypass index 062712d147..f699b8d95a 100755 --- a/small/luci-app-bypass/root/etc/init.d/bypass +++ b/small/luci-app-bypass/root/etc/init.d/bypass @@ -15,7 +15,13 @@ CON_T=$SDNS/rules.conf PID=/var/run/smartdns.pid LOG=/var/log/bypass.log BIN_DIR=/usr/share/bypass -DNS_FILE=/tmp/dnsmasq.d/dnsmasq-by.conf +# Get the default DNSMasq config ID from the UCI configuration +DEFAULT_DNSMASQ_CFGID=$(uci show dhcp.@dnsmasq[0] | awk -F '.' '{print $2}' | awk -F '=' '{print $1}' | head -1) +# Locate the dnsmasq.conf file that contains the conf-dir option +DNSMASQ_CONF_PATH=$(grep -l "^conf-dir=" "/tmp/etc/dnsmasq.conf.${DEFAULT_DNSMASQ_CFGID}") +# Extract the directory path from the conf-dir line +DNSMASQ_CONF_DIR=$(grep '^conf-dir=' "$DNSMASQ_CONF_PATH" | cut -d'=' -f2 | head -n 1) +DNS_FILE=${DNSMASQ_CONF_DIR%*/}/dnsmasq-by.conf DNS_DIR=/tmp/dnsmasq.by O=$DNS_DIR/tmp CRON="grep -q $BIN_DIR $CRON_FILE && sed -i '/\/share\/bypass/d' $CRON_FILE" @@ -698,7 +704,7 @@ gen_dns(){ for i in $dns_tmp;do ipset add ss_spec_wan_ac $i 2>/dev/null;done fi smartdns_flag=1 - mkdir -p /tmp/dnsmasq.d $SDNS $DNS_DIR + mkdir -p ${DNSMASQ_CONF_DIR%*/} $SDNS $DNS_DIR cat >$DNS_T <<-EOF force-AAAA-SOA yes speed-check-mode none diff --git a/small/luci-app-passwall/luasrc/model/cbi/passwall/client/type/ray.lua b/small/luci-app-passwall/luasrc/model/cbi/passwall/client/type/ray.lua index 8bdc199605..1872017f1a 100644 --- a/small/luci-app-passwall/luasrc/model/cbi/passwall/client/type/ray.lua +++ b/small/luci-app-passwall/luasrc/model/cbi/passwall/client/type/ray.lua @@ -574,8 +574,23 @@ o = s:option(Value, option_name("splithttp_path"), translate("SplitHTTP Path")) o.placeholder = "/" o:depends({ [option_name("transport")] = "splithttp" }) --- [[ Mux ]]-- -o = s:option(Flag, option_name("mux"), translate("Mux")) +o = s:option(Flag, option_name("splithttp_xmux"), "XMUX", translate("Enable SplitHTTP XMUX. It's not recommended to enable Mux.Cool at the same time.")) +o:depends({ [option_name("transport")] = "splithttp" }) + +o = s:option(Value, option_name("maxConcurrency"), translate("XMUX Max Concurrency")) +o:depends({ [option_name("splithttp_xmux")] = true }) + +o = s:option(Value, option_name("maxConnections"), translate("XMUX Max Connections")) +o:depends({ [option_name("splithttp_xmux")] = true }) + +o = s:option(Value, option_name("cMaxReuseTimes"), translate("XMUX Connection Max Reuse Times")) +o:depends({ [option_name("splithttp_xmux")] = true }) + +o = s:option(Value, option_name("cMaxLifetimeMs"), translate("XMUX Connection Max Lifetime (ms)")) +o:depends({ [option_name("splithttp_xmux")] = true }) + +-- [[ Mux.Cool ]]-- +o = s:option(Flag, option_name("mux"), "Mux", translate("Enable Mux.Cool")) o:depends({ [option_name("protocol")] = "vmess" }) o:depends({ [option_name("protocol")] = "vless", [option_name("flow")] = "" }) o:depends({ [option_name("protocol")] = "http" }) @@ -588,7 +603,7 @@ o.default = 8 o:depends({ [option_name("mux")] = true }) -- [[ XUDP Mux ]]-- -o = s:option(Flag, option_name("xmux"), translate("xMux")) +o = s:option(Flag, option_name("xmux"), "XUDP Mux") o.default = 1 o:depends({ [option_name("protocol")] = "vless", [option_name("flow")] = "xtls-rprx-vision" }) diff --git a/small/luci-app-passwall/luasrc/passwall/util_xray.lua b/small/luci-app-passwall/luasrc/passwall/util_xray.lua index 4a2ef63e06..b07657589c 100644 --- a/small/luci-app-passwall/luasrc/passwall/util_xray.lua +++ b/small/luci-app-passwall/luasrc/passwall/util_xray.lua @@ -288,6 +288,18 @@ function gen_outbound(flag, node, tag, proxy_table) result.streamSettings.tlsSettings.alpn = alpn end end + + local xmux = {} + if node.splithttp_xmux then + xmux.maxConcurrency = node.maxConcurrency and (string.find(node.maxConcurrency, "-") and node.maxConcurrency or tonumber(node.maxConcurrency)) or 0 + xmux.maxConnections = node.maxConnections and (string.find(node.maxConnections, "-") and node.maxConnections or tonumber(node.maxConnections)) or 0 + xmux.cMaxReuseTimes = node.cMaxReuseTimes and (string.find(node.cMaxReuseTimes, "-") and node.cMaxReuseTimes or tonumber(node.cMaxReuseTimes)) or 0 + xmux.cMaxLifetimeMs = node.cMaxLifetimeMs and (string.find(node.cMaxLifetimeMs, "-") and node.cMaxLifetimeMs or tonumber(node.cMaxLifetimeMs)) or 0 + if result.streamSettings.splithttpSettings then + result.streamSettings.splithttpSettings.xmux = xmux + end + end + end return result end diff --git a/small/luci-app-passwall/po/zh-cn/passwall.po b/small/luci-app-passwall/po/zh-cn/passwall.po index da6f05a1fd..34f991d980 100644 --- a/small/luci-app-passwall/po/zh-cn/passwall.po +++ b/small/luci-app-passwall/po/zh-cn/passwall.po @@ -1519,6 +1519,24 @@ msgstr "客户端文件不适合当前设备。" msgid "Can't move new file to path: %s" msgstr "无法移动新文件到:%s" +msgid "Enable SplitHTTP XMUX. It's not recommended to enable Mux.Cool at the same time." +msgstr "启用 SplitHTTP XMUX。不建议与 Mux.Cool 同时启用。" + +msgid "XMUX Max Concurrency" +msgstr "XMUX 连接最大复用流数" + +msgid "XMUX Max Connections" +msgstr "XMUX 最大连接数" + +msgid "XMUX Connection Max Reuse Times" +msgstr "XMUX 连接最多复用次数" + +msgid "XMUX Connection Max Lifetime (ms)" +msgstr "XMUX 连接最大存活时间(ms)" + +msgid "Enable Mux.Cool" +msgstr "启用 Mux.Cool" + msgid "Mux concurrency" msgstr "最大并发连接数" diff --git a/small/luci-app-ssr-plus/Makefile b/small/luci-app-ssr-plus/Makefile index 644ac0a6fa..735b377e6c 100644 --- a/small/luci-app-ssr-plus/Makefile +++ b/small/luci-app-ssr-plus/Makefile @@ -1,8 +1,8 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-ssr-plus -PKG_VERSION:=188 -PKG_RELEASE:=9 +PKG_VERSION:=189 +PKG_RELEASE:=1 PKG_CONFIG_DEPENDS:= \ CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_NONE_V2RAY \ diff --git a/small/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/advanced.lua b/small/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/advanced.lua index 2f56e90a23..5fc774ff14 100644 --- a/small/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/advanced.lua +++ b/small/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/advanced.lua @@ -125,8 +125,11 @@ o:depends("adblock", "1") o.description = translate("Support AdGuardHome and DNSMASQ format list") o = s:option(Button, "reset", translate("Reset to defaults")) -o.rawhtml = true -o.template = "shadowsocksr/reset" +o.inputstyle = "reload" +o.write = function() + luci.sys.call("/etc/init.d/shadowsocksr reset") + luci.http.redirect(luci.dispatcher.build_url("admin", "services", "shadowsocksr", "servers")) +end -- [[ SOCKS5 Proxy ]]-- s = m:section(TypedSection, "socks5_proxy", translate("Global SOCKS5 Proxy Server")) diff --git a/small/luci-app-ssr-plus/root/etc/init.d/shadowsocksr b/small/luci-app-ssr-plus/root/etc/init.d/shadowsocksr index 00e0448fbd..231dccc40c 100755 --- a/small/luci-app-ssr-plus/root/etc/init.d/shadowsocksr +++ b/small/luci-app-ssr-plus/root/etc/init.d/shadowsocksr @@ -1154,54 +1154,6 @@ reset() { set_lock rm -rf /etc/config/shadowsocksr $LOG_FILE touch /etc/config/shadowsocksr $LOG_FILE - uci -q batch <<-EOF >/dev/null - add shadowsocksr global - set shadowsocksr.@global[0].global_server='nil' - set shadowsocksr.@global[0].netflix_server='nil' - set shadowsocksr.@global[0].netflix_proxy='0' - set shadowsocksr.@global[0].threads='0' - set shadowsocksr.@global[0].run_mode='router' - set shadowsocksr.@global[0].dports='2' - set shadowsocksr.@global[0].custom_ports='80,443' - set shadowsocksr.@global[0].pdnsd_enable='1' - set shadowsocksr.@global[0].tunnel_forward='8.8.4.4:53' - set shadowsocksr.@global[0].monitor_enable='1' - set shadowsocksr.@global[0].enable_switch='1' - set shadowsocksr.@global[0].switch_time='667' - set shadowsocksr.@global[0].switch_timeout='5' - set shadowsocksr.@global[0].switch_try_count='3' -# set shadowsocksr.@global[0].default_packet_encoding='xudp' - set shadowsocksr.@global[0].shunt_dns='1' - set shadowsocksr.@global[0].gfwlist_url='https://fastly.jsdelivr.net/gh/YW5vbnltb3Vz/domain-list-community@release/gfwlist.txt' - set shadowsocksr.@global[0].chnroute_url='https://ispip.clang.cn/all_cn.txt' - set shadowsocksr.@global[0].nfip_url='https://fastly.jsdelivr.net/gh/QiuSimons/Netflix_IP/NF_only.txt' - set shadowsocksr.@global[0].adblock_url='https://anti-ad.net/anti-ad-for-dnsmasq.conf' - add shadowsocksr server_subscribe - set shadowsocksr.@server_subscribe[0].proxy='0' - set shadowsocksr.@server_subscribe[0].auto_update_time='2' - set shadowsocksr.@server_subscribe[0].auto_update='1' - set shadowsocksr.@server_subscribe[0].filter_words='过期时间/剩余流量/QQ群/官网/防失联地址/回国' - set shadowsocksr.@server_subscribe[0].save_words='' - add shadowsocksr access_control - set shadowsocksr.@access_control[0].lan_ac_mode='0' - set shadowsocksr.@access_control[0].router_proxy='1' - add_list shadowsocksr.@access_control[0].wan_fw_ips=149.154.160.0/20 - add_list shadowsocksr.@access_control[0].wan_fw_ips=67.198.55.0/24 - add_list shadowsocksr.@access_control[0].wan_fw_ips=91.108.4.0/22 - add_list shadowsocksr.@access_control[0].wan_fw_ips=91.108.56.0/22 - add_list shadowsocksr.@access_control[0].wan_fw_ips=109.239.140.0/24 - add_list shadowsocksr.@access_control[0].wan_fw_ips=8.8.8.8 - add_list shadowsocksr.@access_control[0].wan_fw_ips=1.1.1.1 - add_list shadowsocksr.@access_control[0].Interface='lan' - add shadowsocksr socks5_proxy - set shadowsocksr.@socks5_proxy[0].server='nil' - set shadowsocksr.@socks5_proxy[0].local_port='1080' - add shadowsocksr server_global - set shadowsocksr.@server_global[0].enable_server='0' - add shadowsocksr global_xray_fragment - set shadowsocksr.@global_xray_fragment[0].fragment='0' - set shadowsocksr.@global_xray_fragment[0].noise='0' - commit shadowsocksr - EOF + cp /usr/share/shadowsocksr/shadowsocksr.config /etc/config/shadowsocksr unset_lock } diff --git a/small/luci-app-ssr-plus/root/usr/share/shadowsocksr/shadowsocksr.config b/small/luci-app-ssr-plus/root/usr/share/shadowsocksr/shadowsocksr.config new file mode 100644 index 0000000000..6d9f287498 --- /dev/null +++ b/small/luci-app-ssr-plus/root/usr/share/shadowsocksr/shadowsocksr.config @@ -0,0 +1,51 @@ + +config global + option global_server 'nil' + option netflix_server 'nil' + option netflix_proxy '0' + option threads '0' + option run_mode 'router' + option dports '2' + option custom_ports '80,443' + option pdnsd_enable '1' + option tunnel_forward '8.8.4.4:53' + option monitor_enable '1' + option enable_switch '1' + option switch_time '667' + option switch_timeout '5' + option switch_try_count '3' + option shunt_dns '1' + option gfwlist_url 'https://fastly.jsdelivr.net/gh/YW5vbnltb3Vz/domain-list-community@release/gfwlist.txt' + option chnroute_url 'https://ispip.clang.cn/all_cn.txt' + option nfip_url 'https://fastly.jsdelivr.net/gh/QiuSimons/Netflix_IP/NF_only.txt' + option adblock_url 'https://anti-ad.net/anti-ad-for-dnsmasq.conf' + +config server_subscribe + option proxy '0' + option auto_update_time '2' + option auto_update '1' + option filter_words '过期时间/剩余流量/QQ群/官网/防失联地址/回国' + +config access_control + option lan_ac_mode '0' + option router_proxy '1' + list wan_fw_ips '149.154.160.0/20' + list wan_fw_ips '67.198.55.0/24' + list wan_fw_ips '91.108.4.0/22' + list wan_fw_ips '91.108.56.0/22' + list wan_fw_ips '109.239.140.0/24' + list wan_fw_ips '8.8.8.8' + list wan_fw_ips '1.1.1.1' + list Interface 'lan' + +config socks5_proxy + option server 'nil' + option local_port '1080' + +config server_global + option enable_server '0' + +config global_xray_fragment + option fragment '0' + option noise '0' + diff --git a/v2raya/gui/yarn.lock b/v2raya/gui/yarn.lock index cbe01de9d7..56b49faa80 100644 --- a/v2raya/gui/yarn.lock +++ b/v2raya/gui/yarn.lock @@ -4231,9 +4231,9 @@ http-parser-js@>=0.5.1: integrity sha512-SGeBX54F94Wgu5RH3X5jsDtf4eHyRogWX1XGT3b4HuW3tQPM4AaBzoUji/4AAJNXCEOWZ5O0DgZmJw1947gD5Q== http-proxy-middleware@^2.0.3: - version "2.0.6" - resolved "https://registry.npmmirror.com/http-proxy-middleware/-/http-proxy-middleware-2.0.6.tgz#e1a4dd6979572c7ab5a4e4b55095d1f32a74963f" - integrity sha512-ya/UeJ6HVBYxrgYotAZo1KvPWlgB48kUJLDePFeneHsVujFaW5WNj2NgWCAE//B1Dl02BIfYlpNgBy8Kf8Rjmw== + version "2.0.7" + resolved "https://registry.yarnpkg.com/http-proxy-middleware/-/http-proxy-middleware-2.0.7.tgz#915f236d92ae98ef48278a95dedf17e991936ec6" + integrity sha512-fgVY8AV7qU7z/MmXJ/rxwbrtQH4jBQ9m7kp3llF0liB7glmFeVZFBepQb32T3y8n8k2+AEYuMPCpinYW+/CuRA== dependencies: "@types/http-proxy" "^1.17.8" http-proxy "^1.18.1" diff --git a/v2raya/service/core/serverObj/trojan.go b/v2raya/service/core/serverObj/trojan.go index da399a805a..b7f5929a25 100644 --- a/v2raya/service/core/serverObj/trojan.go +++ b/v2raya/service/core/serverObj/trojan.go @@ -69,7 +69,7 @@ func ParseTrojanURL(u string) (data *Trojan, err error) { Sni: sni, Alpn: t.Query().Get("alpn"), Type: t.Query().Get("type"), - Path: t.Query().Get("serviceName"), + Path: t.Query().Get("path"), AllowInsecure: allowInsecure == "1" || allowInsecure == "true", Protocol: "trojan", } diff --git a/v2rayn/v2rayN/AmazTool/UpgradeApp.cs b/v2rayn/v2rayN/AmazTool/UpgradeApp.cs index 31de6a6d08..852f18da73 100644 --- a/v2rayn/v2rayN/AmazTool/UpgradeApp.cs +++ b/v2rayn/v2rayN/AmazTool/UpgradeApp.cs @@ -22,12 +22,12 @@ namespace AmazTool Console.WriteLine("Try to end the process(尝试结束进程)."); try { - var path = GetPath(V2rayN); - Console.WriteLine(path); var existing = Process.GetProcessesByName(V2rayN); - var pp = existing.FirstOrDefault(p => p.MainModule?.FileName != null && p.MainModule?.FileName.Contains(path) == true); - pp?.Kill(); - pp?.WaitForExit(1000); + foreach (var pp in existing) + { + pp?.Kill(); + pp?.WaitForExit(1000); + } } catch (Exception ex) { diff --git a/v2rayn/v2rayN/ServiceLib/Global.cs b/v2rayn/v2rayN/ServiceLib/Global.cs index e3c974cd0c..90f23a569a 100644 --- a/v2rayn/v2rayN/ServiceLib/Global.cs +++ b/v2rayn/v2rayN/ServiceLib/Global.cs @@ -46,7 +46,7 @@ public const string ClashMixinYaml = NamespaceSample + "clash_mixin_yaml"; public const string ClashTunYaml = NamespaceSample + "clash_tun_yaml"; public const string LinuxAutostartConfig = NamespaceSample + "linux_autostart_config"; - + public const string DefaultSecurity = "auto"; public const string DefaultNetwork = "tcp"; public const string TcpHeaderHttp = "http"; diff --git a/v2rayn/v2rayN/ServiceLib/Handler/AutoStartupHandler.cs b/v2rayn/v2rayN/ServiceLib/Handler/AutoStartupHandler.cs index acfd3e4135..42ec00863b 100644 --- a/v2rayn/v2rayN/ServiceLib/Handler/AutoStartupHandler.cs +++ b/v2rayn/v2rayN/ServiceLib/Handler/AutoStartupHandler.cs @@ -75,7 +75,7 @@ namespace ServiceLib.Handler { return; } - + var logonUser = WindowsIdentity.GetCurrent().Name; using var taskService = new Microsoft.Win32.TaskScheduler.TaskService(); var tasks = taskService.RootFolder.GetTasks(new Regex(taskName)); @@ -113,7 +113,14 @@ namespace ServiceLib.Handler private static async Task ClearTaskLinux() { - File.Delete(GetHomePathLinux()); + try + { + File.Delete(GetHomePathLinux()); + } + catch (Exception ex) + { + Logging.SaveLog(ex.Message, ex); + } } private static async Task SetTaskLinux() @@ -127,8 +134,6 @@ namespace ServiceLib.Handler Logging.SaveLog(linuxConfig); var homePath = GetHomePathLinux(); - Directory.CreateDirectory(Path.GetDirectoryName(homePath)); - await File.WriteAllTextAsync(homePath, linuxConfig); } } @@ -140,7 +145,9 @@ namespace ServiceLib.Handler private static string GetHomePathLinux() { - return Path.Combine(Utils.GetHomePath(), ".config", "autostart", $"{Global.AppName}.desktop"); + var homePath = Path.Combine(Utils.GetHomePath(), ".config", "autostart", $"{Global.AppName}.desktop"); + Directory.CreateDirectory(Path.GetDirectoryName(homePath)); + return homePath; } #endregion Linux diff --git a/v2rayn/v2rayN/ServiceLib/Handler/ConfigHandler.cs b/v2rayn/v2rayN/ServiceLib/Handler/ConfigHandler.cs index 9ecddc36a4..e2cc4c4522 100644 --- a/v2rayn/v2rayN/ServiceLib/Handler/ConfigHandler.cs +++ b/v2rayn/v2rayN/ServiceLib/Handler/ConfigHandler.cs @@ -1197,7 +1197,7 @@ namespace ServiceLib.Handler { await RemoveServerViaSubid(config, subid, isSub); } - + profileItem.Subid = subid; profileItem.IsSub = isSub; profileItem.PreSocksPort = preSocksPort; diff --git a/v2rayn/v2rayN/ServiceLib/Handler/CoreHandler.cs b/v2rayn/v2rayN/ServiceLib/Handler/CoreHandler.cs index 8f230a18fe..acb91c20b6 100644 --- a/v2rayn/v2rayN/ServiceLib/Handler/CoreHandler.cs +++ b/v2rayn/v2rayN/ServiceLib/Handler/CoreHandler.cs @@ -108,13 +108,11 @@ namespace ServiceLib.Handler { try { - bool hasProc = false; if (_process != null) { await KillProcess(_process); _process.Dispose(); _process = null; - hasProc = true; } if (_processPre != null) @@ -122,26 +120,6 @@ namespace ServiceLib.Handler await KillProcess(_processPre); _processPre.Dispose(); _processPre = null; - hasProc = true; - } - - if (!hasProc) - { - var coreInfo = CoreInfoHandler.Instance.GetCoreInfo(); - foreach (var it in coreInfo) - { - if (it.CoreType == ECoreType.v2rayN) - { - continue; - } - foreach (var name in it.CoreExes) - { - var path = Utils.GetBinPath(Utils.GetExeName(name), it.CoreType.ToString()); - var existing = Process.GetProcessesByName(name); - var pp = existing.FirstOrDefault(p => p.MainModule?.FileName != null && p.MainModule?.FileName.Contains(path) == true); - await KillProcess(pp); - } - } } } catch (Exception ex) diff --git a/v2rayn/v2rayN/ServiceLib/Resx/ResUI.Designer.cs b/v2rayn/v2rayN/ServiceLib/Resx/ResUI.Designer.cs index c0d3f60e2e..45fdab2f33 100644 --- a/v2rayn/v2rayN/ServiceLib/Resx/ResUI.Designer.cs +++ b/v2rayn/v2rayN/ServiceLib/Resx/ResUI.Designer.cs @@ -870,6 +870,15 @@ namespace ServiceLib.Resx { } } + /// + /// 查找类似 Are you sure to exit? 的本地化字符串。 + /// + public static string menuExitTips { + get { + return ResourceManager.GetString("menuExitTips", resourceCulture); + } + } + /// /// 查找类似 Export selected server for complete configuration 的本地化字符串。 /// diff --git a/v2rayn/v2rayN/ServiceLib/Resx/ResUI.resx b/v2rayn/v2rayN/ServiceLib/Resx/ResUI.resx index 93b3bcdb9c..2b3ea35308 100644 --- a/v2rayn/v2rayN/ServiceLib/Resx/ResUI.resx +++ b/v2rayn/v2rayN/ServiceLib/Resx/ResUI.resx @@ -1363,4 +1363,7 @@ Install the font to the system and restart the settings + + Are you sure to exit? + \ No newline at end of file diff --git a/v2rayn/v2rayN/ServiceLib/Resx/ResUI.zh-Hans.resx b/v2rayn/v2rayN/ServiceLib/Resx/ResUI.zh-Hans.resx index 318e123995..304bb38763 100644 --- a/v2rayn/v2rayN/ServiceLib/Resx/ResUI.zh-Hans.resx +++ b/v2rayn/v2rayN/ServiceLib/Resx/ResUI.zh-Hans.resx @@ -1360,4 +1360,7 @@ 安装字体到系统中,重启设置 + + 是否确定退出? + \ No newline at end of file diff --git a/v2rayn/v2rayN/ServiceLib/Resx/ResUI.zh-Hant.resx b/v2rayn/v2rayN/ServiceLib/Resx/ResUI.zh-Hant.resx index f677ea4c00..7811319559 100644 --- a/v2rayn/v2rayN/ServiceLib/Resx/ResUI.zh-Hant.resx +++ b/v2rayn/v2rayN/ServiceLib/Resx/ResUI.zh-Hant.resx @@ -1240,4 +1240,7 @@ 安裝字體到系統中,重新啟動設定 + + 是否確定退出? + \ No newline at end of file diff --git a/v2rayn/v2rayN/ServiceLib/ServiceLib.csproj b/v2rayn/v2rayN/ServiceLib/ServiceLib.csproj index 75414a5c10..89242b650a 100644 --- a/v2rayn/v2rayN/ServiceLib/ServiceLib.csproj +++ b/v2rayn/v2rayN/ServiceLib/ServiceLib.csproj @@ -4,7 +4,7 @@ net8.0 enable enable - 7.0.5 + 7.0.6 diff --git a/v2rayn/v2rayN/ServiceLib/Services/SpeedtestService.cs b/v2rayn/v2rayN/ServiceLib/Services/SpeedtestService.cs index d84119039d..e257d42124 100644 --- a/v2rayn/v2rayN/ServiceLib/Services/SpeedtestService.cs +++ b/v2rayn/v2rayN/ServiceLib/Services/SpeedtestService.cs @@ -2,6 +2,7 @@ using System.Diagnostics; using System.Net; using System.Net.Sockets; + namespace ServiceLib.Services { public class SpeedtestService @@ -85,7 +86,7 @@ namespace ServiceLib.Services private void ExitLoop(string x) { - if(_exitLoop) return; + if (_exitLoop) return; _exitLoop = true; UpdateFunc("", ResUI.SpeedtestingStop); } diff --git a/v2rayn/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs b/v2rayn/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs index 5fc22623fa..79f2d29f4f 100644 --- a/v2rayn/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs +++ b/v2rayn/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs @@ -52,6 +52,8 @@ namespace ServiceLib.ViewModels public ReactiveCommand ReloadCmd { get; } + public ReactiveCommand ExitCmd { get; } + [Reactive] public bool BlReloadEnabled { get; set; } @@ -187,6 +189,11 @@ namespace ServiceLib.ViewModels await Reload(); }); + ExitCmd = ReactiveCommand.CreateFromTask(async () => + { + await Exit(); + }); + RegionalPresetDefaultCmd = ReactiveCommand.CreateFromTask(async () => { await ApplyRegionalPreset(EPresetType.Default); @@ -266,7 +273,7 @@ namespace ServiceLib.ViewModels try { Locator.Current.GetService()?.UpdateStatistics(update); - if ((update.ProxyUp + update.ProxyDown) > 0 && DateTime.Now.Second % 3 == 0) + if ((update.ProxyUp + update.ProxyDown) > 0 && DateTime.Now.Second % 9 == 0) { Locator.Current.GetService()?.UpdateStatistics(update); } @@ -289,7 +296,7 @@ namespace ServiceLib.ViewModels await ProfileExHandler.Instance.SaveTo(); await StatisticsHandler.Instance.SaveTo(); StatisticsHandler.Instance.Close(); - CoreHandler.Instance.CoreStop(); + await CoreHandler.Instance.CoreStop(); Logging.SaveLog("MyAppExit End"); } @@ -588,6 +595,16 @@ namespace ServiceLib.ViewModels } } + private async Task Exit() + { + if (await _updateView?.Invoke(EViewAction.ShowYesNo, null) == false) + { + return; + } + + await MyAppExitAsync(false); + } + #endregion core job #region Presets diff --git a/v2rayn/v2rayN/ServiceLib/ViewModels/ProfilesViewModel.cs b/v2rayn/v2rayN/ServiceLib/ViewModels/ProfilesViewModel.cs index 66d38ddcc1..507fff0ef7 100644 --- a/v2rayn/v2rayN/ServiceLib/ViewModels/ProfilesViewModel.cs +++ b/v2rayn/v2rayN/ServiceLib/ViewModels/ProfilesViewModel.cs @@ -686,7 +686,6 @@ namespace ServiceLib.ViewModels //ClearTestResult(); _ = new SpeedtestService(_config, lstSelecteds, actionType, UpdateSpeedtestHandler); - } public void ServerSpeedtestStop() diff --git a/v2rayn/v2rayN/v2rayN.Desktop/App.axaml.cs b/v2rayn/v2rayN/v2rayN.Desktop/App.axaml.cs index 660e686519..ce405661cb 100644 --- a/v2rayn/v2rayN/v2rayN.Desktop/App.axaml.cs +++ b/v2rayn/v2rayN/v2rayN.Desktop/App.axaml.cs @@ -9,8 +9,6 @@ namespace v2rayN.Desktop; public partial class App : Application { - //public static EventWaitHandle ProgramStarted; - public override void Initialize() { if (!AppHandler.Instance.InitApp()) @@ -32,7 +30,7 @@ public partial class App : Application { if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) { - OnStartup(desktop.Args); + AppHandler.Instance.InitComponents(); desktop.Exit += OnExit; desktop.MainWindow = new MainWindow(); @@ -41,22 +39,6 @@ public partial class App : Application base.OnFrameworkInitializationCompleted(); } - private void OnStartup(string[]? Args) - { - var exePathKey = Utils.GetMd5(Utils.GetExePath()); - - var rebootas = (Args ?? new string[] { }).Any(t => t == Global.RebootAs); - //ProgramStarted = new EventWaitHandle(false, EventResetMode.AutoReset, exePathKey, out bool bCreatedNew); - //if (!rebootas && !bCreatedNew) - //{ - // ProgramStarted.Set(); - // Environment.Exit(0); - // return; - //} - - AppHandler.Instance.InitComponents(); - } - private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) { if (e.ExceptionObject != null) diff --git a/v2rayn/v2rayN/v2rayN.Desktop/Program.cs b/v2rayn/v2rayN/v2rayN.Desktop/Program.cs index 3149aab0cd..a5eefe42f8 100644 --- a/v2rayn/v2rayN/v2rayN.Desktop/Program.cs +++ b/v2rayn/v2rayN/v2rayN.Desktop/Program.cs @@ -5,12 +5,44 @@ namespace v2rayN.Desktop; internal class Program { + public static EventWaitHandle ProgramStarted; + // Initialization code. Don't use any Avalonia, third-party APIs or any // SynchronizationContext-reliant code before AppMain is called: things aren't initialized // yet and stuff might break. [STAThread] - public static void Main(string[] args) => BuildAvaloniaApp() - .StartWithClassicDesktopLifetime(args); + public static void Main(string[] args) + { + OnStartup(args); + + BuildAvaloniaApp() + .StartWithClassicDesktopLifetime(args); + } + + private static void OnStartup(string[]? Args) + { + if (Utils.IsWindows()) + { + var exePathKey = Utils.GetMd5(Utils.GetExePath()); + var rebootas = (Args ?? new string[] { }).Any(t => t == Global.RebootAs); + ProgramStarted = new EventWaitHandle(false, EventResetMode.AutoReset, exePathKey, out bool bCreatedNew); + if (!rebootas && !bCreatedNew) + { + ProgramStarted.Set(); + Environment.Exit(0); + return; + } + } + else + { + _ = new Mutex(true, "v2rayN", out var bOnlyOneInstance); + if (!bOnlyOneInstance) + { + Environment.Exit(0); + return; + } + } + } // Avalonia configuration, don't remove; also used by visual designer. public static AppBuilder BuildAvaloniaApp() diff --git a/v2rayn/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml b/v2rayn/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml index 6dd66d4035..d927b846f4 100644 --- a/v2rayn/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml +++ b/v2rayn/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml @@ -114,7 +114,7 @@ - + diff --git a/v2rayn/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml.cs b/v2rayn/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml.cs index 5e9186e0e7..d8e7867e75 100644 --- a/v2rayn/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml.cs +++ b/v2rayn/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml.cs @@ -7,6 +7,7 @@ using Avalonia.Interactivity; using Avalonia.ReactiveUI; using Avalonia.Threading; using DialogHostAvalonia; +using MsBox.Avalonia.Enums; using ReactiveUI; using Splat; using System.ComponentModel; @@ -29,13 +30,10 @@ namespace v2rayN.Desktop.Views _config = AppHandler.Instance.Config; _manager = new WindowNotificationManager(TopLevel.GetTopLevel(this)) { MaxItems = 3, Position = NotificationPosition.BottomRight }; - //ThreadPool.RegisterWaitForSingleObject(App.ProgramStarted, OnProgramStarted, null, -1, false); - this.Closing += MainWindow_Closing; this.KeyDown += MainWindow_KeyDown; menuSettingsSetUWP.Click += menuSettingsSetUWP_Click; menuPromotion.Click += menuPromotion_Click; - menuClose.Click += menuClose_Click; menuCheckUpdate.Click += MenuCheckUpdate_Click; menuBackupAndRestore.Click += MenuBackupAndRestore_Click; @@ -82,6 +80,7 @@ namespace v2rayN.Desktop.Views this.BindCommand(ViewModel, vm => vm.ReloadCmd, v => v.menuReload).DisposeWith(disposables); this.OneWayBind(ViewModel, vm => vm.BlReloadEnabled, v => v.menuReload.IsEnabled).DisposeWith(disposables); + this.BindCommand(ViewModel, vm => vm.ExitCmd, v => v.menuClose).DisposeWith(disposables); switch (_config.UiItem.MainGirdOrientation) { @@ -114,6 +113,8 @@ namespace v2rayN.Desktop.Views this.Title = $"{Utils.GetVersion()} - {(AppHandler.Instance.IsAdministrator ? ResUI.RunAsAdmin : ResUI.NotRunAsAdmin)}"; if (Utils.IsWindows()) { + ThreadPool.RegisterWaitForSingleObject(Program.ProgramStarted, OnProgramStarted, null, -1, false); + menuGlobalHotkeySetting.IsVisible = false; } else @@ -158,7 +159,9 @@ namespace v2rayN.Desktop.Views private void OnProgramStarted(object state, bool timeout) { - ShowHideWindow(true); + Dispatcher.UIThread.Post(() => + ShowHideWindow(true), + DispatcherPriority.Default); } private void DelegateSnackMsg(string content) @@ -240,6 +243,14 @@ namespace v2rayN.Desktop.Views Locator.Current.GetService()?.AutofitColumnWidthAsync(), DispatcherPriority.Default); break; + + case EViewAction.ShowYesNo: + if (await UI.ShowYesNo(this, ResUI.menuExitTips) == ButtonResult.No) + { + return false; + } + StorageUI(); + break; } return await Task.FromResult(true); @@ -302,12 +313,6 @@ namespace v2rayN.Desktop.Views } } - private void menuClose_Click(object? sender, RoutedEventArgs e) - { - StorageUI(); - ShowHideWindow(false); - } - private void menuPromotion_Click(object? sender, RoutedEventArgs e) { Utils.ProcessStart($"{Utils.Base64Decode(Global.PromotionUrl)}?t={DateTime.Now.Ticks}"); @@ -374,8 +379,16 @@ namespace v2rayN.Desktop.Views } else { - this.Hide(); + if (Utils.IsWindows()) + { + this.Hide(); + } + else + { + this.WindowState = WindowState.Minimized; + } } + _config.UiItem.ShowInTaskbar = bl; } diff --git a/v2rayn/v2rayN/v2rayN.Desktop/Views/OptionSettingWindow.axaml.cs b/v2rayn/v2rayN/v2rayN.Desktop/Views/OptionSettingWindow.axaml.cs index 66026a6a50..5fea12c02e 100644 --- a/v2rayn/v2rayN/v2rayN.Desktop/Views/OptionSettingWindow.axaml.cs +++ b/v2rayn/v2rayN/v2rayN.Desktop/Views/OptionSettingWindow.axaml.cs @@ -174,7 +174,7 @@ namespace v2rayN.Desktop.Views { switch (action) { - case EViewAction.CloseWindow: + case EViewAction.CloseWindow: this.Close(true); break; diff --git a/v2rayn/v2rayN/v2rayN/Views/MainWindow.xaml.cs b/v2rayn/v2rayN/v2rayN/Views/MainWindow.xaml.cs index c323486bec..e9a18a735a 100644 --- a/v2rayn/v2rayN/v2rayN/Views/MainWindow.xaml.cs +++ b/v2rayn/v2rayN/v2rayN/Views/MainWindow.xaml.cs @@ -367,17 +367,17 @@ namespace v2rayN.Views var bl = blShow ?? !_config.UiItem.ShowInTaskbar; if (bl) { - Application.Current.MainWindow.Show(); - if (Application.Current.MainWindow.WindowState == WindowState.Minimized) + this?.Show(); + if (this?.WindowState == WindowState.Minimized) { - Application.Current.MainWindow.WindowState = WindowState.Normal; + this.WindowState = WindowState.Normal; } - Application.Current.MainWindow.Activate(); - Application.Current.MainWindow.Focus(); + this?.Activate(); + this?.Focus(); } else { - Application.Current.MainWindow.Hide(); + this?.Hide(); } _config.UiItem.ShowInTaskbar = bl; } diff --git a/v2rayng/V2rayNG/app/src/main/kotlin/com/v2ray/ang/dto/ProfileItem.kt b/v2rayng/V2rayNG/app/src/main/kotlin/com/v2ray/ang/dto/ProfileItem.kt index 870d271605..dae7e38f79 100644 --- a/v2rayng/V2rayNG/app/src/main/kotlin/com/v2ray/ang/dto/ProfileItem.kt +++ b/v2rayng/V2rayNG/app/src/main/kotlin/com/v2ray/ang/dto/ProfileItem.kt @@ -3,7 +3,6 @@ package com.v2ray.ang.dto import com.v2ray.ang.AppConfig.TAG_BLOCKED import com.v2ray.ang.AppConfig.TAG_DIRECT import com.v2ray.ang.AppConfig.TAG_PROXY -import com.v2ray.ang.util.JsonUtil import com.v2ray.ang.util.Utils data class ProfileItem( @@ -67,9 +66,10 @@ data class ProfileItem( return Utils.getIpv6Address(server) + ":" + serverPort } - fun getKeyProperty(): String { - subscriptionId = "" - addedTime = 0L - return JsonUtil.toJson(this) + fun getKeyProperty(): ProfileItem { + val copy = this.copy() + copy.subscriptionId = "" + copy.addedTime = 0L + return copy } } \ No newline at end of file diff --git a/v2rayng/V2rayNG/app/src/main/kotlin/com/v2ray/ang/handler/AngConfigManager.kt b/v2rayng/V2rayNG/app/src/main/kotlin/com/v2ray/ang/handler/AngConfigManager.kt index 073706e1e0..7488ba7b53 100644 --- a/v2rayng/V2rayNG/app/src/main/kotlin/com/v2ray/ang/handler/AngConfigManager.kt +++ b/v2rayng/V2rayNG/app/src/main/kotlin/com/v2ray/ang/handler/AngConfigManager.kt @@ -209,6 +209,7 @@ object AngConfigManager { var count = 0 servers.lines() + .distinct() .forEach { str -> if (Utils.isValidSubUrl(str)) { count += importUrlAsSubscription(str) @@ -246,6 +247,7 @@ object AngConfigManager { val subItem = MmkvManager.decodeSubscription(subid) var count = 0 servers.lines() + .distinct() .reversed() .forEach { val resId = parseConfig(it, subid, subItem, removedSelectedServer) diff --git a/v2rayng/V2rayNG/app/src/main/kotlin/com/v2ray/ang/handler/V2rayConfigManager.kt b/v2rayng/V2rayNG/app/src/main/kotlin/com/v2ray/ang/handler/V2rayConfigManager.kt index 424e0c8200..f95e6ff99e 100644 --- a/v2rayng/V2rayNG/app/src/main/kotlin/com/v2ray/ang/handler/V2rayConfigManager.kt +++ b/v2rayng/V2rayNG/app/src/main/kotlin/com/v2ray/ang/handler/V2rayConfigManager.kt @@ -431,7 +431,7 @@ object V2rayConfigManager { outbound.mux?.concurrency = MmkvManager.decodeSettingsInt(AppConfig.PREF_MUX_CONCURRENCY, 8) outbound.mux?.xudpConcurrency = - MmkvManager.decodeSettingsInt(AppConfig.PREF_MUX_XUDP_CONCURRENCY, 8) + MmkvManager.decodeSettingsInt(AppConfig.PREF_MUX_XUDP_CONCURRENCY, 16) outbound.mux?.xudpProxyUDP443 = MmkvManager.decodeSettingsString(AppConfig.PREF_MUX_XUDP_QUIC) ?: "reject" } else { @@ -458,7 +458,7 @@ object V2rayConfigManager { val host = outbound.streamSettings?.tcpSettings?.header?.request?.headers?.Host val requestString: String by lazy { - """{"version":"1.1","method":"GET","headers":{"User-Agent":["Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36","Mozilla/5.0 (iPhone; CPU iPhone OS 10_0_2 like Mac OS X) AppleWebKit/601.1 (KHTML, like Gecko) CriOS/53.0.2785.109 Mobile/14A456 Safari/601.1.46"],"Accept-Encoding":["gzip, deflate"],"Connection":["keep-alive"],"Pragma":"no-cache"}}""" + """{"version":"1.1","method":"GET","headers":{"User-Agent":"Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.6478.122 Mobile Safari/537.36"Safari/537.36,"Accept-Encoding":["gzip, deflate"],"Connection":["keep-alive"],"Pragma":"no-cache"}}""" } outbound.streamSettings?.tcpSettings?.header?.request = JsonUtil.fromJson( requestString, @@ -522,8 +522,8 @@ object V2rayConfigManager { noises = listOf( V2rayConfig.OutboundBean.OutSettingsBean.NoiseBean( type = "rand", - packet = "100-200", - delay = "10-20", + packet = "50-150", + delay = "10-16", ) ), ) @@ -629,4 +629,4 @@ object V2rayConfigManager { } -} \ No newline at end of file +} diff --git a/v2rayng/V2rayNG/app/src/main/kotlin/com/v2ray/ang/viewmodel/MainViewModel.kt b/v2rayng/V2rayNG/app/src/main/kotlin/com/v2ray/ang/viewmodel/MainViewModel.kt index 1bd0dab8d5..aa6f34131c 100644 --- a/v2rayng/V2rayNG/app/src/main/kotlin/com/v2ray/ang/viewmodel/MainViewModel.kt +++ b/v2rayng/V2rayNG/app/src/main/kotlin/com/v2ray/ang/viewmodel/MainViewModel.kt @@ -266,7 +266,7 @@ class MainViewModel(application: Application) : AndroidViewModel(application) { serversCacheCopy.forEachIndexed { index2, it2 -> if (index2 > index) { val outbound2 = it2.second.getKeyProperty() - if (outbound == outbound2 && !deleteServer.contains(it2.first)) { + if (outbound.equals(outbound2) && !deleteServer.contains(it2.first)) { deleteServer.add(it2.first) } } diff --git a/v2rayng/V2rayNG/app/src/main/res/values-fa/strings.xml b/v2rayng/V2rayNG/app/src/main/res/values-fa/strings.xml index 0272719289..63892a6eb0 100644 --- a/v2rayng/V2rayNG/app/src/main/res/values-fa/strings.xml +++ b/v2rayng/V2rayNG/app/src/main/res/values-fa/strings.xml @@ -106,9 +106,9 @@ URL دانلود فایل‌ ها این عمل ممنوع است - Obfs password - Port Hopping - Port Hopping Interval + رمز عبور Obfs + پورت پرش (درگاه سرور را بازنویسی می کند) + فاصله پورت پرش (ثانیه) pinSHA256 diff --git a/v2rayng/V2rayNG/app/src/main/res/values-ru/strings.xml b/v2rayng/V2rayNG/app/src/main/res/values-ru/strings.xml index 10881585ae..9d0ab8f902 100644 --- a/v2rayng/V2rayNG/app/src/main/res/values-ru/strings.xml +++ b/v2rayng/V2rayNG/app/src/main/res/values-ru/strings.xml @@ -112,8 +112,8 @@ Название уже существует Это действие запрещено Пароль obfs - Port Hopping - Port Hopping Interval + Переключение портов + Интервал переключения портов pinSHA256 diff --git a/xray-core/app/dispatcher/default.go b/xray-core/app/dispatcher/default.go index 4eb39d7591..42fca674e8 100644 --- a/xray-core/app/dispatcher/default.go +++ b/xray-core/app/dispatcher/default.go @@ -181,6 +181,18 @@ func (d *DefaultDispatcher) getLink(ctx context.Context) (*transport.Link, *tran } } } + + if p.Stats.UserOnline { + name := "user>>>" + user.Email + ">>>online" + if om, _ := stats.GetOrRegisterOnlineMap(d.stats, name); om != nil { + sessionInbounds := session.InboundFromContext(ctx) + userIP := sessionInbounds.Source.Address.String() + om.AddIP(userIP) + // log Online user with ips + // errors.LogDebug(ctx, "user>>>" + user.Email + ">>>online", om.Count(), om.List()) + + } + } } return inboundLink, outboundLink diff --git a/xray-core/app/policy/config.go b/xray-core/app/policy/config.go index 267307b790..9e5ee1c2b4 100644 --- a/xray-core/app/policy/config.go +++ b/xray-core/app/policy/config.go @@ -73,6 +73,7 @@ func (p *Policy) ToCorePolicy() policy.Session { if p.Stats != nil { cp.Stats.UserUplink = p.Stats.UserUplink cp.Stats.UserDownlink = p.Stats.UserDownlink + cp.Stats.UserOnline = p.Stats.UserOnline } if p.Buffer != nil { cp.Buffer.PerConnection = p.Buffer.Connection diff --git a/xray-core/app/policy/config.pb.go b/xray-core/app/policy/config.pb.go index 2c8262a3eb..46e6f3d4b2 100644 --- a/xray-core/app/policy/config.pb.go +++ b/xray-core/app/policy/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.35.1 -// protoc v5.28.2 +// protoc-gen-go v1.34.2 +// protoc v4.25.3 // source: app/policy/config.proto package policy @@ -301,6 +301,7 @@ type Policy_Stats struct { UserUplink bool `protobuf:"varint,1,opt,name=user_uplink,json=userUplink,proto3" json:"user_uplink,omitempty"` UserDownlink bool `protobuf:"varint,2,opt,name=user_downlink,json=userDownlink,proto3" json:"user_downlink,omitempty"` + UserOnline bool `protobuf:"varint,3,opt,name=user_online,json=userOnline,proto3" json:"user_online,omitempty"` } func (x *Policy_Stats) Reset() { @@ -347,6 +348,13 @@ func (x *Policy_Stats) GetUserDownlink() bool { return false } +func (x *Policy_Stats) GetUserOnline() bool { + if x != nil { + return x.UserOnline + } + return false +} + type Policy_Buffer struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -469,7 +477,7 @@ var file_app_policy_config_proto_rawDesc = []byte{ 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0f, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x22, 0x1e, 0x0a, 0x06, 0x53, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x0d, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0xa6, 0x04, 0x0a, 0x06, 0x50, + 0x01, 0x28, 0x0d, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0xc7, 0x04, 0x0a, 0x06, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x12, 0x39, 0x0a, 0x07, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x2e, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x2e, @@ -496,49 +504,51 @@ var file_app_policy_config_proto_rawDesc = []byte{ 0x64, 0x6f, 0x77, 0x6e, 0x6c, 0x69, 0x6e, 0x6b, 0x5f, 0x6f, 0x6e, 0x6c, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x2e, 0x53, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x52, 0x0c, 0x64, 0x6f, - 0x77, 0x6e, 0x6c, 0x69, 0x6e, 0x6b, 0x4f, 0x6e, 0x6c, 0x79, 0x1a, 0x4d, 0x0a, 0x05, 0x53, 0x74, + 0x77, 0x6e, 0x6c, 0x69, 0x6e, 0x6b, 0x4f, 0x6e, 0x6c, 0x79, 0x1a, 0x6e, 0x0a, 0x05, 0x53, 0x74, 0x61, 0x74, 0x73, 0x12, 0x1f, 0x0a, 0x0b, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x75, 0x70, 0x6c, 0x69, 0x6e, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x75, 0x73, 0x65, 0x72, 0x55, 0x70, 0x6c, 0x69, 0x6e, 0x6b, 0x12, 0x23, 0x0a, 0x0d, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x64, 0x6f, 0x77, 0x6e, 0x6c, 0x69, 0x6e, 0x6b, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0c, 0x75, 0x73, 0x65, - 0x72, 0x44, 0x6f, 0x77, 0x6e, 0x6c, 0x69, 0x6e, 0x6b, 0x1a, 0x28, 0x0a, 0x06, 0x42, 0x75, 0x66, - 0x66, 0x65, 0x72, 0x12, 0x1e, 0x0a, 0x0a, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, - 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, - 0x69, 0x6f, 0x6e, 0x22, 0xfb, 0x01, 0x0a, 0x0c, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x50, 0x6f, - 0x6c, 0x69, 0x63, 0x79, 0x12, 0x39, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x74, 0x73, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, - 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x2e, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x50, 0x6f, 0x6c, 0x69, - 0x63, 0x79, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x05, 0x73, 0x74, 0x61, 0x74, 0x73, 0x1a, - 0xaf, 0x01, 0x0a, 0x05, 0x53, 0x74, 0x61, 0x74, 0x73, 0x12, 0x25, 0x0a, 0x0e, 0x69, 0x6e, 0x62, - 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x75, 0x70, 0x6c, 0x69, 0x6e, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x08, 0x52, 0x0d, 0x69, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x55, 0x70, 0x6c, 0x69, 0x6e, 0x6b, - 0x12, 0x29, 0x0a, 0x10, 0x69, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x64, 0x6f, 0x77, 0x6e, - 0x6c, 0x69, 0x6e, 0x6b, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0f, 0x69, 0x6e, 0x62, 0x6f, - 0x75, 0x6e, 0x64, 0x44, 0x6f, 0x77, 0x6e, 0x6c, 0x69, 0x6e, 0x6b, 0x12, 0x27, 0x0a, 0x0f, 0x6f, - 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x75, 0x70, 0x6c, 0x69, 0x6e, 0x6b, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x08, 0x52, 0x0e, 0x6f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x55, 0x70, - 0x6c, 0x69, 0x6e, 0x6b, 0x12, 0x2b, 0x0a, 0x11, 0x6f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, - 0x5f, 0x64, 0x6f, 0x77, 0x6e, 0x6c, 0x69, 0x6e, 0x6b, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, - 0x10, 0x6f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x44, 0x6f, 0x77, 0x6e, 0x6c, 0x69, 0x6e, - 0x6b, 0x22, 0xcc, 0x01, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x38, 0x0a, 0x05, - 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x78, 0x72, - 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x2e, 0x43, 0x6f, - 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, - 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x12, 0x35, 0x0a, 0x06, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, - 0x70, 0x2e, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x2e, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x50, - 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x06, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x1a, 0x51, 0x0a, - 0x0a, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, - 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x2d, 0x0a, - 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x78, - 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x2e, 0x50, - 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, - 0x42, 0x4f, 0x0a, 0x13, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, - 0x2e, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x50, 0x01, 0x5a, 0x24, 0x67, 0x69, 0x74, 0x68, 0x75, - 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, - 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0xaa, - 0x02, 0x0f, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x41, 0x70, 0x70, 0x2e, 0x50, 0x6f, 0x6c, 0x69, 0x63, - 0x79, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x72, 0x44, 0x6f, 0x77, 0x6e, 0x6c, 0x69, 0x6e, 0x6b, 0x12, 0x1f, 0x0a, 0x0b, 0x75, 0x73, 0x65, + 0x72, 0x5f, 0x6f, 0x6e, 0x6c, 0x69, 0x6e, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, + 0x75, 0x73, 0x65, 0x72, 0x4f, 0x6e, 0x6c, 0x69, 0x6e, 0x65, 0x1a, 0x28, 0x0a, 0x06, 0x42, 0x75, + 0x66, 0x66, 0x65, 0x72, 0x12, 0x1e, 0x0a, 0x0a, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, + 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, + 0x74, 0x69, 0x6f, 0x6e, 0x22, 0xfb, 0x01, 0x0a, 0x0c, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x50, + 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x12, 0x39, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x74, 0x73, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, + 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x2e, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x50, 0x6f, 0x6c, + 0x69, 0x63, 0x79, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x05, 0x73, 0x74, 0x61, 0x74, 0x73, + 0x1a, 0xaf, 0x01, 0x0a, 0x05, 0x53, 0x74, 0x61, 0x74, 0x73, 0x12, 0x25, 0x0a, 0x0e, 0x69, 0x6e, + 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x75, 0x70, 0x6c, 0x69, 0x6e, 0x6b, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x08, 0x52, 0x0d, 0x69, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x55, 0x70, 0x6c, 0x69, 0x6e, + 0x6b, 0x12, 0x29, 0x0a, 0x10, 0x69, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x64, 0x6f, 0x77, + 0x6e, 0x6c, 0x69, 0x6e, 0x6b, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0f, 0x69, 0x6e, 0x62, + 0x6f, 0x75, 0x6e, 0x64, 0x44, 0x6f, 0x77, 0x6e, 0x6c, 0x69, 0x6e, 0x6b, 0x12, 0x27, 0x0a, 0x0f, + 0x6f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x75, 0x70, 0x6c, 0x69, 0x6e, 0x6b, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0e, 0x6f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x55, + 0x70, 0x6c, 0x69, 0x6e, 0x6b, 0x12, 0x2b, 0x0a, 0x11, 0x6f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, + 0x64, 0x5f, 0x64, 0x6f, 0x77, 0x6e, 0x6c, 0x69, 0x6e, 0x6b, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, + 0x52, 0x10, 0x6f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x44, 0x6f, 0x77, 0x6e, 0x6c, 0x69, + 0x6e, 0x6b, 0x22, 0xcc, 0x01, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x38, 0x0a, + 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x78, + 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x2e, 0x43, + 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x45, 0x6e, 0x74, 0x72, 0x79, + 0x52, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x12, 0x35, 0x0a, 0x06, 0x73, 0x79, 0x73, 0x74, 0x65, + 0x6d, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, + 0x70, 0x70, 0x2e, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x2e, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, + 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x06, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x1a, 0x51, + 0x0a, 0x0a, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, + 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x2d, + 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, + 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x2e, + 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, + 0x01, 0x42, 0x4f, 0x0a, 0x13, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, + 0x70, 0x2e, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x50, 0x01, 0x5a, 0x24, 0x67, 0x69, 0x74, 0x68, + 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, + 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, + 0xaa, 0x02, 0x0f, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x41, 0x70, 0x70, 0x2e, 0x50, 0x6f, 0x6c, 0x69, + 0x63, 0x79, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -589,6 +599,104 @@ func file_app_policy_config_proto_init() { if File_app_policy_config_proto != nil { return } + if !protoimpl.UnsafeEnabled { + file_app_policy_config_proto_msgTypes[0].Exporter = func(v any, i int) any { + switch v := v.(*Second); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_app_policy_config_proto_msgTypes[1].Exporter = func(v any, i int) any { + switch v := v.(*Policy); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_app_policy_config_proto_msgTypes[2].Exporter = func(v any, i int) any { + switch v := v.(*SystemPolicy); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_app_policy_config_proto_msgTypes[3].Exporter = func(v any, i int) any { + switch v := v.(*Config); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_app_policy_config_proto_msgTypes[4].Exporter = func(v any, i int) any { + switch v := v.(*Policy_Timeout); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_app_policy_config_proto_msgTypes[5].Exporter = func(v any, i int) any { + switch v := v.(*Policy_Stats); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_app_policy_config_proto_msgTypes[6].Exporter = func(v any, i int) any { + switch v := v.(*Policy_Buffer); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_app_policy_config_proto_msgTypes[7].Exporter = func(v any, i int) any { + switch v := v.(*SystemPolicy_Stats); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/xray-core/app/policy/config.proto b/xray-core/app/policy/config.proto index e5f2954723..eefcc17f3a 100644 --- a/xray-core/app/policy/config.proto +++ b/xray-core/app/policy/config.proto @@ -22,6 +22,7 @@ message Policy { message Stats { bool user_uplink = 1; bool user_downlink = 2; + bool user_online = 3; } message Buffer { diff --git a/xray-core/app/proxyman/command/command.go b/xray-core/app/proxyman/command/command.go index 4554f32bfb..3c7824d2d6 100644 --- a/xray-core/app/proxyman/command/command.go +++ b/xray-core/app/proxyman/command/command.go @@ -5,6 +5,7 @@ import ( "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/errors" + "github.com/xtls/xray-core/common/protocol" "github.com/xtls/xray-core/core" "github.com/xtls/xray-core/features/inbound" "github.com/xtls/xray-core/features/outbound" @@ -98,6 +99,46 @@ func (s *handlerServer) AlterInbound(ctx context.Context, request *AlterInboundR return &AlterInboundResponse{}, operation.ApplyInbound(ctx, handler) } +func (s *handlerServer) GetInboundUsers(ctx context.Context, request *GetInboundUserRequest) (*GetInboundUserResponse, error) { + handler, err := s.ihm.GetHandler(ctx, request.Tag) + if err != nil { + return nil, errors.New("failed to get handler: ", request.Tag).Base(err) + } + p, err := getInbound(handler) + if err != nil { + return nil, err + } + um, ok := p.(proxy.UserManager) + if !ok { + return nil, errors.New("proxy is not a UserManager") + } + if len(request.Email) > 0 { + return &GetInboundUserResponse{Users: []*protocol.User{protocol.ToProtoUser(um.GetUser(ctx, request.Email))}}, nil + } + var result = make([]*protocol.User, 0, 100) + users := um.GetUsers(ctx) + for _, u := range users { + result = append(result, protocol.ToProtoUser(u)) + } + return &GetInboundUserResponse{Users: result}, nil +} + +func (s *handlerServer) GetInboundUsersCount(ctx context.Context, request *GetInboundUserRequest) (*GetInboundUsersCountResponse, error) { + handler, err := s.ihm.GetHandler(ctx, request.Tag) + if err != nil { + return nil, errors.New("failed to get handler: ", request.Tag).Base(err) + } + p, err := getInbound(handler) + if err != nil { + return nil, err + } + um, ok := p.(proxy.UserManager) + if !ok { + return nil, errors.New("proxy is not a UserManager") + } + return &GetInboundUsersCountResponse{Count: um.GetUsersCount(ctx)}, nil +} + func (s *handlerServer) AddOutbound(ctx context.Context, request *AddOutboundRequest) (*AddOutboundResponse, error) { if err := core.AddOutboundHandler(s.s, request.Outbound); err != nil { return nil, err diff --git a/xray-core/app/proxyman/command/command.pb.go b/xray-core/app/proxyman/command/command.pb.go index 32a29cc6c6..a98da103ee 100644 --- a/xray-core/app/proxyman/command/command.pb.go +++ b/xray-core/app/proxyman/command/command.pb.go @@ -364,6 +364,149 @@ func (*AlterInboundResponse) Descriptor() ([]byte, []int) { return file_app_proxyman_command_command_proto_rawDescGZIP(), []int{7} } +type GetInboundUserRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Tag string `protobuf:"bytes,1,opt,name=tag,proto3" json:"tag,omitempty"` + Email string `protobuf:"bytes,2,opt,name=email,proto3" json:"email,omitempty"` +} + +func (x *GetInboundUserRequest) Reset() { + *x = GetInboundUserRequest{} + mi := &file_app_proxyman_command_command_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetInboundUserRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetInboundUserRequest) ProtoMessage() {} + +func (x *GetInboundUserRequest) ProtoReflect() protoreflect.Message { + mi := &file_app_proxyman_command_command_proto_msgTypes[8] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetInboundUserRequest.ProtoReflect.Descriptor instead. +func (*GetInboundUserRequest) Descriptor() ([]byte, []int) { + return file_app_proxyman_command_command_proto_rawDescGZIP(), []int{8} +} + +func (x *GetInboundUserRequest) GetTag() string { + if x != nil { + return x.Tag + } + return "" +} + +func (x *GetInboundUserRequest) GetEmail() string { + if x != nil { + return x.Email + } + return "" +} + +type GetInboundUserResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Users []*protocol.User `protobuf:"bytes,1,rep,name=users,proto3" json:"users,omitempty"` +} + +func (x *GetInboundUserResponse) Reset() { + *x = GetInboundUserResponse{} + mi := &file_app_proxyman_command_command_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetInboundUserResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetInboundUserResponse) ProtoMessage() {} + +func (x *GetInboundUserResponse) ProtoReflect() protoreflect.Message { + mi := &file_app_proxyman_command_command_proto_msgTypes[9] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetInboundUserResponse.ProtoReflect.Descriptor instead. +func (*GetInboundUserResponse) Descriptor() ([]byte, []int) { + return file_app_proxyman_command_command_proto_rawDescGZIP(), []int{9} +} + +func (x *GetInboundUserResponse) GetUsers() []*protocol.User { + if x != nil { + return x.Users + } + return nil +} + +type GetInboundUsersCountResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Count int64 `protobuf:"varint,1,opt,name=count,proto3" json:"count,omitempty"` +} + +func (x *GetInboundUsersCountResponse) Reset() { + *x = GetInboundUsersCountResponse{} + mi := &file_app_proxyman_command_command_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetInboundUsersCountResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetInboundUsersCountResponse) ProtoMessage() {} + +func (x *GetInboundUsersCountResponse) ProtoReflect() protoreflect.Message { + mi := &file_app_proxyman_command_command_proto_msgTypes[10] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetInboundUsersCountResponse.ProtoReflect.Descriptor instead. +func (*GetInboundUsersCountResponse) Descriptor() ([]byte, []int) { + return file_app_proxyman_command_command_proto_rawDescGZIP(), []int{10} +} + +func (x *GetInboundUsersCountResponse) GetCount() int64 { + if x != nil { + return x.Count + } + return 0 +} + type AddOutboundRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -374,7 +517,7 @@ type AddOutboundRequest struct { func (x *AddOutboundRequest) Reset() { *x = AddOutboundRequest{} - mi := &file_app_proxyman_command_command_proto_msgTypes[8] + mi := &file_app_proxyman_command_command_proto_msgTypes[11] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -386,7 +529,7 @@ func (x *AddOutboundRequest) String() string { func (*AddOutboundRequest) ProtoMessage() {} func (x *AddOutboundRequest) ProtoReflect() protoreflect.Message { - mi := &file_app_proxyman_command_command_proto_msgTypes[8] + mi := &file_app_proxyman_command_command_proto_msgTypes[11] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -399,7 +542,7 @@ func (x *AddOutboundRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use AddOutboundRequest.ProtoReflect.Descriptor instead. func (*AddOutboundRequest) Descriptor() ([]byte, []int) { - return file_app_proxyman_command_command_proto_rawDescGZIP(), []int{8} + return file_app_proxyman_command_command_proto_rawDescGZIP(), []int{11} } func (x *AddOutboundRequest) GetOutbound() *core.OutboundHandlerConfig { @@ -417,7 +560,7 @@ type AddOutboundResponse struct { func (x *AddOutboundResponse) Reset() { *x = AddOutboundResponse{} - mi := &file_app_proxyman_command_command_proto_msgTypes[9] + mi := &file_app_proxyman_command_command_proto_msgTypes[12] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -429,7 +572,7 @@ func (x *AddOutboundResponse) String() string { func (*AddOutboundResponse) ProtoMessage() {} func (x *AddOutboundResponse) ProtoReflect() protoreflect.Message { - mi := &file_app_proxyman_command_command_proto_msgTypes[9] + mi := &file_app_proxyman_command_command_proto_msgTypes[12] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -442,7 +585,7 @@ func (x *AddOutboundResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use AddOutboundResponse.ProtoReflect.Descriptor instead. func (*AddOutboundResponse) Descriptor() ([]byte, []int) { - return file_app_proxyman_command_command_proto_rawDescGZIP(), []int{9} + return file_app_proxyman_command_command_proto_rawDescGZIP(), []int{12} } type RemoveOutboundRequest struct { @@ -455,7 +598,7 @@ type RemoveOutboundRequest struct { func (x *RemoveOutboundRequest) Reset() { *x = RemoveOutboundRequest{} - mi := &file_app_proxyman_command_command_proto_msgTypes[10] + mi := &file_app_proxyman_command_command_proto_msgTypes[13] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -467,7 +610,7 @@ func (x *RemoveOutboundRequest) String() string { func (*RemoveOutboundRequest) ProtoMessage() {} func (x *RemoveOutboundRequest) ProtoReflect() protoreflect.Message { - mi := &file_app_proxyman_command_command_proto_msgTypes[10] + mi := &file_app_proxyman_command_command_proto_msgTypes[13] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -480,7 +623,7 @@ func (x *RemoveOutboundRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use RemoveOutboundRequest.ProtoReflect.Descriptor instead. func (*RemoveOutboundRequest) Descriptor() ([]byte, []int) { - return file_app_proxyman_command_command_proto_rawDescGZIP(), []int{10} + return file_app_proxyman_command_command_proto_rawDescGZIP(), []int{13} } func (x *RemoveOutboundRequest) GetTag() string { @@ -498,7 +641,7 @@ type RemoveOutboundResponse struct { func (x *RemoveOutboundResponse) Reset() { *x = RemoveOutboundResponse{} - mi := &file_app_proxyman_command_command_proto_msgTypes[11] + mi := &file_app_proxyman_command_command_proto_msgTypes[14] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -510,7 +653,7 @@ func (x *RemoveOutboundResponse) String() string { func (*RemoveOutboundResponse) ProtoMessage() {} func (x *RemoveOutboundResponse) ProtoReflect() protoreflect.Message { - mi := &file_app_proxyman_command_command_proto_msgTypes[11] + mi := &file_app_proxyman_command_command_proto_msgTypes[14] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -523,7 +666,7 @@ func (x *RemoveOutboundResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use RemoveOutboundResponse.ProtoReflect.Descriptor instead. func (*RemoveOutboundResponse) Descriptor() ([]byte, []int) { - return file_app_proxyman_command_command_proto_rawDescGZIP(), []int{11} + return file_app_proxyman_command_command_proto_rawDescGZIP(), []int{14} } type AlterOutboundRequest struct { @@ -537,7 +680,7 @@ type AlterOutboundRequest struct { func (x *AlterOutboundRequest) Reset() { *x = AlterOutboundRequest{} - mi := &file_app_proxyman_command_command_proto_msgTypes[12] + mi := &file_app_proxyman_command_command_proto_msgTypes[15] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -549,7 +692,7 @@ func (x *AlterOutboundRequest) String() string { func (*AlterOutboundRequest) ProtoMessage() {} func (x *AlterOutboundRequest) ProtoReflect() protoreflect.Message { - mi := &file_app_proxyman_command_command_proto_msgTypes[12] + mi := &file_app_proxyman_command_command_proto_msgTypes[15] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -562,7 +705,7 @@ func (x *AlterOutboundRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use AlterOutboundRequest.ProtoReflect.Descriptor instead. func (*AlterOutboundRequest) Descriptor() ([]byte, []int) { - return file_app_proxyman_command_command_proto_rawDescGZIP(), []int{12} + return file_app_proxyman_command_command_proto_rawDescGZIP(), []int{15} } func (x *AlterOutboundRequest) GetTag() string { @@ -587,7 +730,7 @@ type AlterOutboundResponse struct { func (x *AlterOutboundResponse) Reset() { *x = AlterOutboundResponse{} - mi := &file_app_proxyman_command_command_proto_msgTypes[13] + mi := &file_app_proxyman_command_command_proto_msgTypes[16] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -599,7 +742,7 @@ func (x *AlterOutboundResponse) String() string { func (*AlterOutboundResponse) ProtoMessage() {} func (x *AlterOutboundResponse) ProtoReflect() protoreflect.Message { - mi := &file_app_proxyman_command_command_proto_msgTypes[13] + mi := &file_app_proxyman_command_command_proto_msgTypes[16] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -612,7 +755,7 @@ func (x *AlterOutboundResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use AlterOutboundResponse.ProtoReflect.Descriptor instead. func (*AlterOutboundResponse) Descriptor() ([]byte, []int) { - return file_app_proxyman_command_command_proto_rawDescGZIP(), []int{13} + return file_app_proxyman_command_command_proto_rawDescGZIP(), []int{16} } type Config struct { @@ -623,7 +766,7 @@ type Config struct { func (x *Config) Reset() { *x = Config{} - mi := &file_app_proxyman_command_command_proto_msgTypes[14] + mi := &file_app_proxyman_command_command_proto_msgTypes[17] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -635,7 +778,7 @@ func (x *Config) String() string { func (*Config) ProtoMessage() {} func (x *Config) ProtoReflect() protoreflect.Message { - mi := &file_app_proxyman_command_command_proto_msgTypes[14] + mi := &file_app_proxyman_command_command_proto_msgTypes[17] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -648,7 +791,7 @@ func (x *Config) ProtoReflect() protoreflect.Message { // Deprecated: Use Config.ProtoReflect.Descriptor instead. func (*Config) Descriptor() ([]byte, []int) { - return file_app_proxyman_command_command_proto_rawDescGZIP(), []int{14} + return file_app_proxyman_command_command_proto_rawDescGZIP(), []int{17} } var File_app_proxyman_command_command_proto protoreflect.FileDescriptor @@ -688,79 +831,107 @@ var file_app_proxyman_command_command_proto_rawDesc = []byte{ 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x09, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x16, 0x0a, 0x14, 0x41, 0x6c, 0x74, 0x65, 0x72, 0x49, 0x6e, 0x62, - 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x52, 0x0a, 0x12, - 0x41, 0x64, 0x64, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x12, 0x3c, 0x0a, 0x08, 0x6f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, - 0x2e, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x48, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, - 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x08, 0x6f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, - 0x22, 0x15, 0x0a, 0x13, 0x41, 0x64, 0x64, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x29, 0x0a, 0x15, 0x52, 0x65, 0x6d, 0x6f, 0x76, - 0x65, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x12, 0x10, 0x0a, 0x03, 0x74, 0x61, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x74, - 0x61, 0x67, 0x22, 0x18, 0x0a, 0x16, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x4f, 0x75, 0x74, 0x62, - 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x68, 0x0a, 0x14, - 0x41, 0x6c, 0x74, 0x65, 0x72, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x61, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x03, 0x74, 0x61, 0x67, 0x12, 0x3e, 0x0a, 0x09, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x78, 0x72, 0x61, 0x79, - 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x2e, 0x54, - 0x79, 0x70, 0x65, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x09, 0x6f, 0x70, 0x65, - 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x17, 0x0a, 0x15, 0x41, 0x6c, 0x74, 0x65, 0x72, 0x4f, + 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x3f, 0x0a, 0x15, + 0x47, 0x65, 0x74, 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x61, 0x67, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x03, 0x74, 0x61, 0x67, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x22, 0x4a, 0x0a, + 0x16, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x55, 0x73, 0x65, 0x72, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x30, 0x0a, 0x05, 0x75, 0x73, 0x65, 0x72, 0x73, + 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, + 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 0x55, 0x73, + 0x65, 0x72, 0x52, 0x05, 0x75, 0x73, 0x65, 0x72, 0x73, 0x22, 0x34, 0x0a, 0x1c, 0x47, 0x65, 0x74, + 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x55, 0x73, 0x65, 0x72, 0x73, 0x43, 0x6f, 0x75, 0x6e, + 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6f, 0x75, + 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, + 0x52, 0x0a, 0x12, 0x41, 0x64, 0x64, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x3c, 0x0a, 0x08, 0x6f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, + 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, + 0x6f, 0x72, 0x65, 0x2e, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x48, 0x61, 0x6e, 0x64, + 0x6c, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x08, 0x6f, 0x75, 0x74, 0x62, 0x6f, + 0x75, 0x6e, 0x64, 0x22, 0x15, 0x0a, 0x13, 0x41, 0x64, 0x64, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, + 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x29, 0x0a, 0x15, 0x52, 0x65, + 0x6d, 0x6f, 0x76, 0x65, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x61, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x03, 0x74, 0x61, 0x67, 0x22, 0x18, 0x0a, 0x16, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, - 0x08, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x32, 0xc5, 0x05, 0x0a, 0x0e, 0x48, 0x61, - 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x6b, 0x0a, 0x0a, - 0x41, 0x64, 0x64, 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x12, 0x2c, 0x2e, 0x78, 0x72, 0x61, - 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x2e, 0x63, - 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x41, 0x64, 0x64, 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, - 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, - 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x2e, 0x63, 0x6f, 0x6d, - 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x41, 0x64, 0x64, 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x74, 0x0a, 0x0d, 0x52, 0x65, 0x6d, - 0x6f, 0x76, 0x65, 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x12, 0x2f, 0x2e, 0x78, 0x72, 0x61, - 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x2e, 0x63, - 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x49, 0x6e, 0x62, - 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x30, 0x2e, 0x78, 0x72, + 0x68, 0x0a, 0x14, 0x41, 0x6c, 0x74, 0x65, 0x72, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x61, 0x67, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x74, 0x61, 0x67, 0x12, 0x3e, 0x0a, 0x09, 0x6f, 0x70, 0x65, + 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x78, + 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x73, 0x65, 0x72, 0x69, 0x61, + 0x6c, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x09, + 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x17, 0x0a, 0x15, 0x41, 0x6c, 0x74, + 0x65, 0x72, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x22, 0x08, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x32, 0xc5, 0x07, 0x0a, + 0x0e, 0x48, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, + 0x6b, 0x0a, 0x0a, 0x41, 0x64, 0x64, 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x12, 0x2c, 0x2e, + 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, + 0x6e, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x41, 0x64, 0x64, 0x49, 0x6e, 0x62, + 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x2e, - 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x49, 0x6e, - 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, - 0x71, 0x0a, 0x0c, 0x41, 0x6c, 0x74, 0x65, 0x72, 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x12, - 0x2e, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, - 0x6d, 0x61, 0x6e, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x41, 0x6c, 0x74, 0x65, - 0x72, 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x41, 0x64, 0x64, 0x49, 0x6e, 0x62, 0x6f, 0x75, + 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x74, 0x0a, 0x0d, + 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x12, 0x2f, 0x2e, + 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, + 0x6e, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, + 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x30, + 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, + 0x61, 0x6e, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x52, 0x65, 0x6d, 0x6f, 0x76, + 0x65, 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x22, 0x00, 0x12, 0x71, 0x0a, 0x0c, 0x41, 0x6c, 0x74, 0x65, 0x72, 0x49, 0x6e, 0x62, 0x6f, 0x75, + 0x6e, 0x64, 0x12, 0x2e, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, + 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x41, + 0x6c, 0x74, 0x65, 0x72, 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x2f, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, + 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x41, + 0x6c, 0x74, 0x65, 0x72, 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x78, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x62, 0x6f, + 0x75, 0x6e, 0x64, 0x55, 0x73, 0x65, 0x72, 0x73, 0x12, 0x30, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, + 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x2e, 0x63, 0x6f, 0x6d, + 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x55, + 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x31, 0x2e, 0x78, 0x72, 0x61, + 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x2e, 0x63, + 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, + 0x64, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, + 0x83, 0x01, 0x0a, 0x14, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x55, 0x73, + 0x65, 0x72, 0x73, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x30, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, + 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x2e, 0x63, 0x6f, 0x6d, + 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x55, + 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x37, 0x2e, 0x78, 0x72, 0x61, + 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x2e, 0x63, + 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, + 0x64, 0x55, 0x73, 0x65, 0x72, 0x73, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x6e, 0x0a, 0x0b, 0x41, 0x64, 0x64, 0x4f, 0x75, 0x74, 0x62, + 0x6f, 0x75, 0x6e, 0x64, 0x12, 0x2d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, + 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, + 0x2e, 0x41, 0x64, 0x64, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x2e, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, + 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, + 0x41, 0x64, 0x64, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x77, 0x0a, 0x0e, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x4f, + 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x12, 0x30, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, + 0x70, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, + 0x61, 0x6e, 0x64, 0x2e, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, + 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x31, 0x2e, 0x78, 0x72, 0x61, 0x79, + 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x2e, 0x63, 0x6f, + 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x4f, 0x75, 0x74, 0x62, + 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x74, + 0x0a, 0x0d, 0x41, 0x6c, 0x74, 0x65, 0x72, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x12, 0x2f, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x41, 0x6c, 0x74, 0x65, - 0x72, 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x22, 0x00, 0x12, 0x6e, 0x0a, 0x0b, 0x41, 0x64, 0x64, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, - 0x64, 0x12, 0x2d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, 0x6f, - 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x41, 0x64, - 0x64, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x1a, 0x2e, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x78, - 0x79, 0x6d, 0x61, 0x6e, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x41, 0x64, 0x64, - 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x22, 0x00, 0x12, 0x77, 0x0a, 0x0e, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x4f, 0x75, 0x74, 0x62, - 0x6f, 0x75, 0x6e, 0x64, 0x12, 0x30, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, - 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, - 0x2e, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x31, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, - 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, - 0x6e, 0x64, 0x2e, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, - 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x74, 0x0a, 0x0d, 0x41, - 0x6c, 0x74, 0x65, 0x72, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x12, 0x2f, 0x2e, 0x78, - 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, - 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x41, 0x6c, 0x74, 0x65, 0x72, 0x4f, 0x75, - 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x30, 0x2e, - 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, - 0x6e, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x41, 0x6c, 0x74, 0x65, 0x72, 0x4f, - 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, - 0x00, 0x42, 0x6d, 0x0a, 0x1d, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, - 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, - 0x6e, 0x64, 0x50, 0x01, 0x5a, 0x2e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, - 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, - 0x61, 0x70, 0x70, 0x2f, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x2f, 0x63, 0x6f, 0x6d, - 0x6d, 0x61, 0x6e, 0x64, 0xaa, 0x02, 0x19, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x41, 0x70, 0x70, 0x2e, - 0x50, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, - 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x72, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x30, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x78, + 0x79, 0x6d, 0x61, 0x6e, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x41, 0x6c, 0x74, + 0x65, 0x72, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x22, 0x00, 0x42, 0x6d, 0x0a, 0x1d, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, + 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x2e, 0x63, 0x6f, + 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x50, 0x01, 0x5a, 0x2e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, + 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, + 0x72, 0x65, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x2f, + 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0xaa, 0x02, 0x19, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x41, + 0x70, 0x70, 0x2e, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, + 0x61, 0x6e, 0x64, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -775,51 +946,59 @@ func file_app_proxyman_command_command_proto_rawDescGZIP() []byte { return file_app_proxyman_command_command_proto_rawDescData } -var file_app_proxyman_command_command_proto_msgTypes = make([]protoimpl.MessageInfo, 15) +var file_app_proxyman_command_command_proto_msgTypes = make([]protoimpl.MessageInfo, 18) var file_app_proxyman_command_command_proto_goTypes = []any{ - (*AddUserOperation)(nil), // 0: xray.app.proxyman.command.AddUserOperation - (*RemoveUserOperation)(nil), // 1: xray.app.proxyman.command.RemoveUserOperation - (*AddInboundRequest)(nil), // 2: xray.app.proxyman.command.AddInboundRequest - (*AddInboundResponse)(nil), // 3: xray.app.proxyman.command.AddInboundResponse - (*RemoveInboundRequest)(nil), // 4: xray.app.proxyman.command.RemoveInboundRequest - (*RemoveInboundResponse)(nil), // 5: xray.app.proxyman.command.RemoveInboundResponse - (*AlterInboundRequest)(nil), // 6: xray.app.proxyman.command.AlterInboundRequest - (*AlterInboundResponse)(nil), // 7: xray.app.proxyman.command.AlterInboundResponse - (*AddOutboundRequest)(nil), // 8: xray.app.proxyman.command.AddOutboundRequest - (*AddOutboundResponse)(nil), // 9: xray.app.proxyman.command.AddOutboundResponse - (*RemoveOutboundRequest)(nil), // 10: xray.app.proxyman.command.RemoveOutboundRequest - (*RemoveOutboundResponse)(nil), // 11: xray.app.proxyman.command.RemoveOutboundResponse - (*AlterOutboundRequest)(nil), // 12: xray.app.proxyman.command.AlterOutboundRequest - (*AlterOutboundResponse)(nil), // 13: xray.app.proxyman.command.AlterOutboundResponse - (*Config)(nil), // 14: xray.app.proxyman.command.Config - (*protocol.User)(nil), // 15: xray.common.protocol.User - (*core.InboundHandlerConfig)(nil), // 16: xray.core.InboundHandlerConfig - (*serial.TypedMessage)(nil), // 17: xray.common.serial.TypedMessage - (*core.OutboundHandlerConfig)(nil), // 18: xray.core.OutboundHandlerConfig + (*AddUserOperation)(nil), // 0: xray.app.proxyman.command.AddUserOperation + (*RemoveUserOperation)(nil), // 1: xray.app.proxyman.command.RemoveUserOperation + (*AddInboundRequest)(nil), // 2: xray.app.proxyman.command.AddInboundRequest + (*AddInboundResponse)(nil), // 3: xray.app.proxyman.command.AddInboundResponse + (*RemoveInboundRequest)(nil), // 4: xray.app.proxyman.command.RemoveInboundRequest + (*RemoveInboundResponse)(nil), // 5: xray.app.proxyman.command.RemoveInboundResponse + (*AlterInboundRequest)(nil), // 6: xray.app.proxyman.command.AlterInboundRequest + (*AlterInboundResponse)(nil), // 7: xray.app.proxyman.command.AlterInboundResponse + (*GetInboundUserRequest)(nil), // 8: xray.app.proxyman.command.GetInboundUserRequest + (*GetInboundUserResponse)(nil), // 9: xray.app.proxyman.command.GetInboundUserResponse + (*GetInboundUsersCountResponse)(nil), // 10: xray.app.proxyman.command.GetInboundUsersCountResponse + (*AddOutboundRequest)(nil), // 11: xray.app.proxyman.command.AddOutboundRequest + (*AddOutboundResponse)(nil), // 12: xray.app.proxyman.command.AddOutboundResponse + (*RemoveOutboundRequest)(nil), // 13: xray.app.proxyman.command.RemoveOutboundRequest + (*RemoveOutboundResponse)(nil), // 14: xray.app.proxyman.command.RemoveOutboundResponse + (*AlterOutboundRequest)(nil), // 15: xray.app.proxyman.command.AlterOutboundRequest + (*AlterOutboundResponse)(nil), // 16: xray.app.proxyman.command.AlterOutboundResponse + (*Config)(nil), // 17: xray.app.proxyman.command.Config + (*protocol.User)(nil), // 18: xray.common.protocol.User + (*core.InboundHandlerConfig)(nil), // 19: xray.core.InboundHandlerConfig + (*serial.TypedMessage)(nil), // 20: xray.common.serial.TypedMessage + (*core.OutboundHandlerConfig)(nil), // 21: xray.core.OutboundHandlerConfig } var file_app_proxyman_command_command_proto_depIdxs = []int32{ - 15, // 0: xray.app.proxyman.command.AddUserOperation.user:type_name -> xray.common.protocol.User - 16, // 1: xray.app.proxyman.command.AddInboundRequest.inbound:type_name -> xray.core.InboundHandlerConfig - 17, // 2: xray.app.proxyman.command.AlterInboundRequest.operation:type_name -> xray.common.serial.TypedMessage - 18, // 3: xray.app.proxyman.command.AddOutboundRequest.outbound:type_name -> xray.core.OutboundHandlerConfig - 17, // 4: xray.app.proxyman.command.AlterOutboundRequest.operation:type_name -> xray.common.serial.TypedMessage - 2, // 5: xray.app.proxyman.command.HandlerService.AddInbound:input_type -> xray.app.proxyman.command.AddInboundRequest - 4, // 6: xray.app.proxyman.command.HandlerService.RemoveInbound:input_type -> xray.app.proxyman.command.RemoveInboundRequest - 6, // 7: xray.app.proxyman.command.HandlerService.AlterInbound:input_type -> xray.app.proxyman.command.AlterInboundRequest - 8, // 8: xray.app.proxyman.command.HandlerService.AddOutbound:input_type -> xray.app.proxyman.command.AddOutboundRequest - 10, // 9: xray.app.proxyman.command.HandlerService.RemoveOutbound:input_type -> xray.app.proxyman.command.RemoveOutboundRequest - 12, // 10: xray.app.proxyman.command.HandlerService.AlterOutbound:input_type -> xray.app.proxyman.command.AlterOutboundRequest - 3, // 11: xray.app.proxyman.command.HandlerService.AddInbound:output_type -> xray.app.proxyman.command.AddInboundResponse - 5, // 12: xray.app.proxyman.command.HandlerService.RemoveInbound:output_type -> xray.app.proxyman.command.RemoveInboundResponse - 7, // 13: xray.app.proxyman.command.HandlerService.AlterInbound:output_type -> xray.app.proxyman.command.AlterInboundResponse - 9, // 14: xray.app.proxyman.command.HandlerService.AddOutbound:output_type -> xray.app.proxyman.command.AddOutboundResponse - 11, // 15: xray.app.proxyman.command.HandlerService.RemoveOutbound:output_type -> xray.app.proxyman.command.RemoveOutboundResponse - 13, // 16: xray.app.proxyman.command.HandlerService.AlterOutbound:output_type -> xray.app.proxyman.command.AlterOutboundResponse - 11, // [11:17] is the sub-list for method output_type - 5, // [5:11] is the sub-list for method input_type - 5, // [5:5] is the sub-list for extension type_name - 5, // [5:5] is the sub-list for extension extendee - 0, // [0:5] is the sub-list for field type_name + 18, // 0: xray.app.proxyman.command.AddUserOperation.user:type_name -> xray.common.protocol.User + 19, // 1: xray.app.proxyman.command.AddInboundRequest.inbound:type_name -> xray.core.InboundHandlerConfig + 20, // 2: xray.app.proxyman.command.AlterInboundRequest.operation:type_name -> xray.common.serial.TypedMessage + 18, // 3: xray.app.proxyman.command.GetInboundUserResponse.users:type_name -> xray.common.protocol.User + 21, // 4: xray.app.proxyman.command.AddOutboundRequest.outbound:type_name -> xray.core.OutboundHandlerConfig + 20, // 5: xray.app.proxyman.command.AlterOutboundRequest.operation:type_name -> xray.common.serial.TypedMessage + 2, // 6: xray.app.proxyman.command.HandlerService.AddInbound:input_type -> xray.app.proxyman.command.AddInboundRequest + 4, // 7: xray.app.proxyman.command.HandlerService.RemoveInbound:input_type -> xray.app.proxyman.command.RemoveInboundRequest + 6, // 8: xray.app.proxyman.command.HandlerService.AlterInbound:input_type -> xray.app.proxyman.command.AlterInboundRequest + 8, // 9: xray.app.proxyman.command.HandlerService.GetInboundUsers:input_type -> xray.app.proxyman.command.GetInboundUserRequest + 8, // 10: xray.app.proxyman.command.HandlerService.GetInboundUsersCount:input_type -> xray.app.proxyman.command.GetInboundUserRequest + 11, // 11: xray.app.proxyman.command.HandlerService.AddOutbound:input_type -> xray.app.proxyman.command.AddOutboundRequest + 13, // 12: xray.app.proxyman.command.HandlerService.RemoveOutbound:input_type -> xray.app.proxyman.command.RemoveOutboundRequest + 15, // 13: xray.app.proxyman.command.HandlerService.AlterOutbound:input_type -> xray.app.proxyman.command.AlterOutboundRequest + 3, // 14: xray.app.proxyman.command.HandlerService.AddInbound:output_type -> xray.app.proxyman.command.AddInboundResponse + 5, // 15: xray.app.proxyman.command.HandlerService.RemoveInbound:output_type -> xray.app.proxyman.command.RemoveInboundResponse + 7, // 16: xray.app.proxyman.command.HandlerService.AlterInbound:output_type -> xray.app.proxyman.command.AlterInboundResponse + 9, // 17: xray.app.proxyman.command.HandlerService.GetInboundUsers:output_type -> xray.app.proxyman.command.GetInboundUserResponse + 10, // 18: xray.app.proxyman.command.HandlerService.GetInboundUsersCount:output_type -> xray.app.proxyman.command.GetInboundUsersCountResponse + 12, // 19: xray.app.proxyman.command.HandlerService.AddOutbound:output_type -> xray.app.proxyman.command.AddOutboundResponse + 14, // 20: xray.app.proxyman.command.HandlerService.RemoveOutbound:output_type -> xray.app.proxyman.command.RemoveOutboundResponse + 16, // 21: xray.app.proxyman.command.HandlerService.AlterOutbound:output_type -> xray.app.proxyman.command.AlterOutboundResponse + 14, // [14:22] is the sub-list for method output_type + 6, // [6:14] is the sub-list for method input_type + 6, // [6:6] is the sub-list for extension type_name + 6, // [6:6] is the sub-list for extension extendee + 0, // [0:6] is the sub-list for field type_name } func init() { file_app_proxyman_command_command_proto_init() } @@ -833,7 +1012,7 @@ func file_app_proxyman_command_command_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_app_proxyman_command_command_proto_rawDesc, NumEnums: 0, - NumMessages: 15, + NumMessages: 18, NumExtensions: 0, NumServices: 1, }, diff --git a/xray-core/app/proxyman/command/command.proto b/xray-core/app/proxyman/command/command.proto index 5a09bd88d6..9a2d01427e 100644 --- a/xray-core/app/proxyman/command/command.proto +++ b/xray-core/app/proxyman/command/command.proto @@ -37,6 +37,19 @@ message AlterInboundRequest { message AlterInboundResponse {} +message GetInboundUserRequest { + string tag = 1; + string email = 2; +} + +message GetInboundUserResponse { + repeated xray.common.protocol.User users = 1; +} + +message GetInboundUsersCountResponse { + int64 count = 1; +} + message AddOutboundRequest { core.OutboundHandlerConfig outbound = 1; } @@ -63,6 +76,10 @@ service HandlerService { rpc AlterInbound(AlterInboundRequest) returns (AlterInboundResponse) {} + rpc GetInboundUsers(GetInboundUserRequest) returns (GetInboundUserResponse) {} + + rpc GetInboundUsersCount(GetInboundUserRequest) returns (GetInboundUsersCountResponse) {} + rpc AddOutbound(AddOutboundRequest) returns (AddOutboundResponse) {} rpc RemoveOutbound(RemoveOutboundRequest) returns (RemoveOutboundResponse) {} diff --git a/xray-core/app/proxyman/command/command_grpc.pb.go b/xray-core/app/proxyman/command/command_grpc.pb.go index 4f12836b43..7abbae8ece 100644 --- a/xray-core/app/proxyman/command/command_grpc.pb.go +++ b/xray-core/app/proxyman/command/command_grpc.pb.go @@ -19,12 +19,14 @@ import ( const _ = grpc.SupportPackageIsVersion9 const ( - HandlerService_AddInbound_FullMethodName = "/xray.app.proxyman.command.HandlerService/AddInbound" - HandlerService_RemoveInbound_FullMethodName = "/xray.app.proxyman.command.HandlerService/RemoveInbound" - HandlerService_AlterInbound_FullMethodName = "/xray.app.proxyman.command.HandlerService/AlterInbound" - HandlerService_AddOutbound_FullMethodName = "/xray.app.proxyman.command.HandlerService/AddOutbound" - HandlerService_RemoveOutbound_FullMethodName = "/xray.app.proxyman.command.HandlerService/RemoveOutbound" - HandlerService_AlterOutbound_FullMethodName = "/xray.app.proxyman.command.HandlerService/AlterOutbound" + HandlerService_AddInbound_FullMethodName = "/xray.app.proxyman.command.HandlerService/AddInbound" + HandlerService_RemoveInbound_FullMethodName = "/xray.app.proxyman.command.HandlerService/RemoveInbound" + HandlerService_AlterInbound_FullMethodName = "/xray.app.proxyman.command.HandlerService/AlterInbound" + HandlerService_GetInboundUsers_FullMethodName = "/xray.app.proxyman.command.HandlerService/GetInboundUsers" + HandlerService_GetInboundUsersCount_FullMethodName = "/xray.app.proxyman.command.HandlerService/GetInboundUsersCount" + HandlerService_AddOutbound_FullMethodName = "/xray.app.proxyman.command.HandlerService/AddOutbound" + HandlerService_RemoveOutbound_FullMethodName = "/xray.app.proxyman.command.HandlerService/RemoveOutbound" + HandlerService_AlterOutbound_FullMethodName = "/xray.app.proxyman.command.HandlerService/AlterOutbound" ) // HandlerServiceClient is the client API for HandlerService service. @@ -34,6 +36,8 @@ type HandlerServiceClient interface { AddInbound(ctx context.Context, in *AddInboundRequest, opts ...grpc.CallOption) (*AddInboundResponse, error) RemoveInbound(ctx context.Context, in *RemoveInboundRequest, opts ...grpc.CallOption) (*RemoveInboundResponse, error) AlterInbound(ctx context.Context, in *AlterInboundRequest, opts ...grpc.CallOption) (*AlterInboundResponse, error) + GetInboundUsers(ctx context.Context, in *GetInboundUserRequest, opts ...grpc.CallOption) (*GetInboundUserResponse, error) + GetInboundUsersCount(ctx context.Context, in *GetInboundUserRequest, opts ...grpc.CallOption) (*GetInboundUsersCountResponse, error) AddOutbound(ctx context.Context, in *AddOutboundRequest, opts ...grpc.CallOption) (*AddOutboundResponse, error) RemoveOutbound(ctx context.Context, in *RemoveOutboundRequest, opts ...grpc.CallOption) (*RemoveOutboundResponse, error) AlterOutbound(ctx context.Context, in *AlterOutboundRequest, opts ...grpc.CallOption) (*AlterOutboundResponse, error) @@ -77,6 +81,26 @@ func (c *handlerServiceClient) AlterInbound(ctx context.Context, in *AlterInboun return out, nil } +func (c *handlerServiceClient) GetInboundUsers(ctx context.Context, in *GetInboundUserRequest, opts ...grpc.CallOption) (*GetInboundUserResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(GetInboundUserResponse) + err := c.cc.Invoke(ctx, HandlerService_GetInboundUsers_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *handlerServiceClient) GetInboundUsersCount(ctx context.Context, in *GetInboundUserRequest, opts ...grpc.CallOption) (*GetInboundUsersCountResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(GetInboundUsersCountResponse) + err := c.cc.Invoke(ctx, HandlerService_GetInboundUsersCount_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *handlerServiceClient) AddOutbound(ctx context.Context, in *AddOutboundRequest, opts ...grpc.CallOption) (*AddOutboundResponse, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(AddOutboundResponse) @@ -114,6 +138,8 @@ type HandlerServiceServer interface { AddInbound(context.Context, *AddInboundRequest) (*AddInboundResponse, error) RemoveInbound(context.Context, *RemoveInboundRequest) (*RemoveInboundResponse, error) AlterInbound(context.Context, *AlterInboundRequest) (*AlterInboundResponse, error) + GetInboundUsers(context.Context, *GetInboundUserRequest) (*GetInboundUserResponse, error) + GetInboundUsersCount(context.Context, *GetInboundUserRequest) (*GetInboundUsersCountResponse, error) AddOutbound(context.Context, *AddOutboundRequest) (*AddOutboundResponse, error) RemoveOutbound(context.Context, *RemoveOutboundRequest) (*RemoveOutboundResponse, error) AlterOutbound(context.Context, *AlterOutboundRequest) (*AlterOutboundResponse, error) @@ -136,6 +162,12 @@ func (UnimplementedHandlerServiceServer) RemoveInbound(context.Context, *RemoveI func (UnimplementedHandlerServiceServer) AlterInbound(context.Context, *AlterInboundRequest) (*AlterInboundResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method AlterInbound not implemented") } +func (UnimplementedHandlerServiceServer) GetInboundUsers(context.Context, *GetInboundUserRequest) (*GetInboundUserResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetInboundUsers not implemented") +} +func (UnimplementedHandlerServiceServer) GetInboundUsersCount(context.Context, *GetInboundUserRequest) (*GetInboundUsersCountResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetInboundUsersCount not implemented") +} func (UnimplementedHandlerServiceServer) AddOutbound(context.Context, *AddOutboundRequest) (*AddOutboundResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method AddOutbound not implemented") } @@ -220,6 +252,42 @@ func _HandlerService_AlterInbound_Handler(srv interface{}, ctx context.Context, return interceptor(ctx, in, info, handler) } +func _HandlerService_GetInboundUsers_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetInboundUserRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(HandlerServiceServer).GetInboundUsers(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: HandlerService_GetInboundUsers_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(HandlerServiceServer).GetInboundUsers(ctx, req.(*GetInboundUserRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _HandlerService_GetInboundUsersCount_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetInboundUserRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(HandlerServiceServer).GetInboundUsersCount(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: HandlerService_GetInboundUsersCount_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(HandlerServiceServer).GetInboundUsersCount(ctx, req.(*GetInboundUserRequest)) + } + return interceptor(ctx, in, info, handler) +} + func _HandlerService_AddOutbound_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(AddOutboundRequest) if err := dec(in); err != nil { @@ -293,6 +361,14 @@ var HandlerService_ServiceDesc = grpc.ServiceDesc{ MethodName: "AlterInbound", Handler: _HandlerService_AlterInbound_Handler, }, + { + MethodName: "GetInboundUsers", + Handler: _HandlerService_GetInboundUsers_Handler, + }, + { + MethodName: "GetInboundUsersCount", + Handler: _HandlerService_GetInboundUsersCount_Handler, + }, { MethodName: "AddOutbound", Handler: _HandlerService_AddOutbound_Handler, diff --git a/xray-core/app/stats/command/command.go b/xray-core/app/stats/command/command.go index b2cc196cd4..e4926babe6 100644 --- a/xray-core/app/stats/command/command.go +++ b/xray-core/app/stats/command/command.go @@ -46,6 +46,20 @@ func (s *statsServer) GetStats(ctx context.Context, request *GetStatsRequest) (* }, nil } +func (s *statsServer) GetStatsOnline(ctx context.Context, request *GetStatsRequest) (*GetStatsResponse, error) { + c := s.stats.GetOnlineMap(request.Name) + if c == nil { + return nil, errors.New(request.Name, " not found.") + } + value := int64(c.Count()) + return &GetStatsResponse{ + Stat: &Stat{ + Name: request.Name, + Value: value, + }, + }, nil +} + func (s *statsServer) QueryStats(ctx context.Context, request *QueryStatsRequest) (*QueryStatsResponse, error) { matcher, err := strmatcher.Substr.New(request.Pattern) if err != nil { diff --git a/xray-core/app/stats/command/command.pb.go b/xray-core/app/stats/command/command.pb.go index af8ca34668..3ea15017e9 100644 --- a/xray-core/app/stats/command/command.pb.go +++ b/xray-core/app/stats/command/command.pb.go @@ -1,8 +1,8 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.35.1 -// protoc v5.28.2 -// source: app/stats/command/command.proto +// protoc v5.28.3 +// source: command.proto package command @@ -33,7 +33,7 @@ type GetStatsRequest struct { func (x *GetStatsRequest) Reset() { *x = GetStatsRequest{} - mi := &file_app_stats_command_command_proto_msgTypes[0] + mi := &file_command_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -45,7 +45,7 @@ func (x *GetStatsRequest) String() string { func (*GetStatsRequest) ProtoMessage() {} func (x *GetStatsRequest) ProtoReflect() protoreflect.Message { - mi := &file_app_stats_command_command_proto_msgTypes[0] + mi := &file_command_proto_msgTypes[0] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -58,7 +58,7 @@ func (x *GetStatsRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use GetStatsRequest.ProtoReflect.Descriptor instead. func (*GetStatsRequest) Descriptor() ([]byte, []int) { - return file_app_stats_command_command_proto_rawDescGZIP(), []int{0} + return file_command_proto_rawDescGZIP(), []int{0} } func (x *GetStatsRequest) GetName() string { @@ -86,7 +86,7 @@ type Stat struct { func (x *Stat) Reset() { *x = Stat{} - mi := &file_app_stats_command_command_proto_msgTypes[1] + mi := &file_command_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -98,7 +98,7 @@ func (x *Stat) String() string { func (*Stat) ProtoMessage() {} func (x *Stat) ProtoReflect() protoreflect.Message { - mi := &file_app_stats_command_command_proto_msgTypes[1] + mi := &file_command_proto_msgTypes[1] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -111,7 +111,7 @@ func (x *Stat) ProtoReflect() protoreflect.Message { // Deprecated: Use Stat.ProtoReflect.Descriptor instead. func (*Stat) Descriptor() ([]byte, []int) { - return file_app_stats_command_command_proto_rawDescGZIP(), []int{1} + return file_command_proto_rawDescGZIP(), []int{1} } func (x *Stat) GetName() string { @@ -138,7 +138,7 @@ type GetStatsResponse struct { func (x *GetStatsResponse) Reset() { *x = GetStatsResponse{} - mi := &file_app_stats_command_command_proto_msgTypes[2] + mi := &file_command_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -150,7 +150,7 @@ func (x *GetStatsResponse) String() string { func (*GetStatsResponse) ProtoMessage() {} func (x *GetStatsResponse) ProtoReflect() protoreflect.Message { - mi := &file_app_stats_command_command_proto_msgTypes[2] + mi := &file_command_proto_msgTypes[2] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -163,7 +163,7 @@ func (x *GetStatsResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use GetStatsResponse.ProtoReflect.Descriptor instead. func (*GetStatsResponse) Descriptor() ([]byte, []int) { - return file_app_stats_command_command_proto_rawDescGZIP(), []int{2} + return file_command_proto_rawDescGZIP(), []int{2} } func (x *GetStatsResponse) GetStat() *Stat { @@ -184,7 +184,7 @@ type QueryStatsRequest struct { func (x *QueryStatsRequest) Reset() { *x = QueryStatsRequest{} - mi := &file_app_stats_command_command_proto_msgTypes[3] + mi := &file_command_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -196,7 +196,7 @@ func (x *QueryStatsRequest) String() string { func (*QueryStatsRequest) ProtoMessage() {} func (x *QueryStatsRequest) ProtoReflect() protoreflect.Message { - mi := &file_app_stats_command_command_proto_msgTypes[3] + mi := &file_command_proto_msgTypes[3] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -209,7 +209,7 @@ func (x *QueryStatsRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use QueryStatsRequest.ProtoReflect.Descriptor instead. func (*QueryStatsRequest) Descriptor() ([]byte, []int) { - return file_app_stats_command_command_proto_rawDescGZIP(), []int{3} + return file_command_proto_rawDescGZIP(), []int{3} } func (x *QueryStatsRequest) GetPattern() string { @@ -236,7 +236,7 @@ type QueryStatsResponse struct { func (x *QueryStatsResponse) Reset() { *x = QueryStatsResponse{} - mi := &file_app_stats_command_command_proto_msgTypes[4] + mi := &file_command_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -248,7 +248,7 @@ func (x *QueryStatsResponse) String() string { func (*QueryStatsResponse) ProtoMessage() {} func (x *QueryStatsResponse) ProtoReflect() protoreflect.Message { - mi := &file_app_stats_command_command_proto_msgTypes[4] + mi := &file_command_proto_msgTypes[4] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -261,7 +261,7 @@ func (x *QueryStatsResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use QueryStatsResponse.ProtoReflect.Descriptor instead. func (*QueryStatsResponse) Descriptor() ([]byte, []int) { - return file_app_stats_command_command_proto_rawDescGZIP(), []int{4} + return file_command_proto_rawDescGZIP(), []int{4} } func (x *QueryStatsResponse) GetStat() []*Stat { @@ -279,7 +279,7 @@ type SysStatsRequest struct { func (x *SysStatsRequest) Reset() { *x = SysStatsRequest{} - mi := &file_app_stats_command_command_proto_msgTypes[5] + mi := &file_command_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -291,7 +291,7 @@ func (x *SysStatsRequest) String() string { func (*SysStatsRequest) ProtoMessage() {} func (x *SysStatsRequest) ProtoReflect() protoreflect.Message { - mi := &file_app_stats_command_command_proto_msgTypes[5] + mi := &file_command_proto_msgTypes[5] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -304,7 +304,7 @@ func (x *SysStatsRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use SysStatsRequest.ProtoReflect.Descriptor instead. func (*SysStatsRequest) Descriptor() ([]byte, []int) { - return file_app_stats_command_command_proto_rawDescGZIP(), []int{5} + return file_command_proto_rawDescGZIP(), []int{5} } type SysStatsResponse struct { @@ -326,7 +326,7 @@ type SysStatsResponse struct { func (x *SysStatsResponse) Reset() { *x = SysStatsResponse{} - mi := &file_app_stats_command_command_proto_msgTypes[6] + mi := &file_command_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -338,7 +338,7 @@ func (x *SysStatsResponse) String() string { func (*SysStatsResponse) ProtoMessage() {} func (x *SysStatsResponse) ProtoReflect() protoreflect.Message { - mi := &file_app_stats_command_command_proto_msgTypes[6] + mi := &file_command_proto_msgTypes[6] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -351,7 +351,7 @@ func (x *SysStatsResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use SysStatsResponse.ProtoReflect.Descriptor instead. func (*SysStatsResponse) Descriptor() ([]byte, []int) { - return file_app_stats_command_command_proto_rawDescGZIP(), []int{6} + return file_command_proto_rawDescGZIP(), []int{6} } func (x *SysStatsResponse) GetNumGoroutine() uint32 { @@ -432,7 +432,7 @@ type Config struct { func (x *Config) Reset() { *x = Config{} - mi := &file_app_stats_command_command_proto_msgTypes[7] + mi := &file_command_proto_msgTypes[7] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -444,7 +444,7 @@ func (x *Config) String() string { func (*Config) ProtoMessage() {} func (x *Config) ProtoReflect() protoreflect.Message { - mi := &file_app_stats_command_command_proto_msgTypes[7] + mi := &file_command_proto_msgTypes[7] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -457,99 +457,104 @@ func (x *Config) ProtoReflect() protoreflect.Message { // Deprecated: Use Config.ProtoReflect.Descriptor instead. func (*Config) Descriptor() ([]byte, []int) { - return file_app_stats_command_command_proto_rawDescGZIP(), []int{7} + return file_command_proto_rawDescGZIP(), []int{7} } -var File_app_stats_command_command_proto protoreflect.FileDescriptor +var File_command_proto protoreflect.FileDescriptor -var file_app_stats_command_command_proto_rawDesc = []byte{ - 0x0a, 0x1f, 0x61, 0x70, 0x70, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, - 0x61, 0x6e, 0x64, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x12, 0x16, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x73, 0x74, 0x61, 0x74, - 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x22, 0x3b, 0x0a, 0x0f, 0x47, 0x65, 0x74, - 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, +var file_command_proto_rawDesc = []byte{ + 0x0a, 0x0d, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, + 0x16, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, + 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x22, 0x3b, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x53, 0x74, + 0x61, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, + 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x14, + 0x0a, 0x05, 0x72, 0x65, 0x73, 0x65, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x72, + 0x65, 0x73, 0x65, 0x74, 0x22, 0x30, 0x0a, 0x04, 0x53, 0x74, 0x61, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, - 0x12, 0x14, 0x0a, 0x05, 0x72, 0x65, 0x73, 0x65, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, - 0x05, 0x72, 0x65, 0x73, 0x65, 0x74, 0x22, 0x30, 0x0a, 0x04, 0x53, 0x74, 0x61, 0x74, 0x12, 0x12, - 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, - 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x03, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x44, 0x0a, 0x10, 0x47, 0x65, 0x74, 0x53, - 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x30, 0x0a, 0x04, - 0x73, 0x74, 0x61, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x78, 0x72, 0x61, - 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, - 0x61, 0x6e, 0x64, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x52, 0x04, 0x73, 0x74, 0x61, 0x74, 0x22, 0x43, - 0x0a, 0x11, 0x51, 0x75, 0x65, 0x72, 0x79, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x61, 0x74, 0x74, 0x65, 0x72, 0x6e, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x70, 0x61, 0x74, 0x74, 0x65, 0x72, 0x6e, 0x12, 0x14, 0x0a, - 0x05, 0x72, 0x65, 0x73, 0x65, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x72, 0x65, - 0x73, 0x65, 0x74, 0x22, 0x46, 0x0a, 0x12, 0x51, 0x75, 0x65, 0x72, 0x79, 0x53, 0x74, 0x61, 0x74, - 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x30, 0x0a, 0x04, 0x73, 0x74, 0x61, - 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, - 0x70, 0x70, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, - 0x2e, 0x53, 0x74, 0x61, 0x74, 0x52, 0x04, 0x73, 0x74, 0x61, 0x74, 0x22, 0x11, 0x0a, 0x0f, 0x53, - 0x79, 0x73, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0xa2, - 0x02, 0x0a, 0x10, 0x53, 0x79, 0x73, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x12, 0x22, 0x0a, 0x0c, 0x4e, 0x75, 0x6d, 0x47, 0x6f, 0x72, 0x6f, 0x75, 0x74, - 0x69, 0x6e, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0c, 0x4e, 0x75, 0x6d, 0x47, 0x6f, - 0x72, 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x4e, 0x75, 0x6d, 0x47, 0x43, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x05, 0x4e, 0x75, 0x6d, 0x47, 0x43, 0x12, 0x14, 0x0a, - 0x05, 0x41, 0x6c, 0x6c, 0x6f, 0x63, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x41, 0x6c, - 0x6c, 0x6f, 0x63, 0x12, 0x1e, 0x0a, 0x0a, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x41, 0x6c, 0x6c, 0x6f, - 0x63, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0a, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x41, 0x6c, - 0x6c, 0x6f, 0x63, 0x12, 0x10, 0x0a, 0x03, 0x53, 0x79, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x04, - 0x52, 0x03, 0x53, 0x79, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x4d, 0x61, 0x6c, 0x6c, 0x6f, 0x63, 0x73, - 0x18, 0x06, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x4d, 0x61, 0x6c, 0x6c, 0x6f, 0x63, 0x73, 0x12, - 0x14, 0x0a, 0x05, 0x46, 0x72, 0x65, 0x65, 0x73, 0x18, 0x07, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, - 0x46, 0x72, 0x65, 0x65, 0x73, 0x12, 0x20, 0x0a, 0x0b, 0x4c, 0x69, 0x76, 0x65, 0x4f, 0x62, 0x6a, - 0x65, 0x63, 0x74, 0x73, 0x18, 0x08, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0b, 0x4c, 0x69, 0x76, 0x65, - 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x12, 0x22, 0x0a, 0x0c, 0x50, 0x61, 0x75, 0x73, 0x65, - 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x4e, 0x73, 0x18, 0x09, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0c, 0x50, - 0x61, 0x75, 0x73, 0x65, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x4e, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x55, - 0x70, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x55, 0x70, 0x74, - 0x69, 0x6d, 0x65, 0x22, 0x08, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x32, 0xba, 0x02, - 0x0a, 0x0c, 0x53, 0x74, 0x61, 0x74, 0x73, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x5f, - 0x0a, 0x08, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x73, 0x12, 0x27, 0x2e, 0x78, 0x72, 0x61, - 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, - 0x61, 0x6e, 0x64, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x28, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x73, - 0x74, 0x61, 0x74, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x47, 0x65, 0x74, - 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, - 0x65, 0x0a, 0x0a, 0x51, 0x75, 0x65, 0x72, 0x79, 0x53, 0x74, 0x61, 0x74, 0x73, 0x12, 0x29, 0x2e, + 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, + 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x44, 0x0a, 0x10, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, + 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x30, 0x0a, 0x04, 0x73, 0x74, + 0x61, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, + 0x61, 0x70, 0x70, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, + 0x64, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x52, 0x04, 0x73, 0x74, 0x61, 0x74, 0x22, 0x43, 0x0a, 0x11, + 0x51, 0x75, 0x65, 0x72, 0x79, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x61, 0x74, 0x74, 0x65, 0x72, 0x6e, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x07, 0x70, 0x61, 0x74, 0x74, 0x65, 0x72, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x72, + 0x65, 0x73, 0x65, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x72, 0x65, 0x73, 0x65, + 0x74, 0x22, 0x46, 0x0a, 0x12, 0x51, 0x75, 0x65, 0x72, 0x79, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x30, 0x0a, 0x04, 0x73, 0x74, 0x61, 0x74, 0x18, + 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, + 0x2e, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x53, + 0x74, 0x61, 0x74, 0x52, 0x04, 0x73, 0x74, 0x61, 0x74, 0x22, 0x11, 0x0a, 0x0f, 0x53, 0x79, 0x73, + 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0xa2, 0x02, 0x0a, + 0x10, 0x53, 0x79, 0x73, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x22, 0x0a, 0x0c, 0x4e, 0x75, 0x6d, 0x47, 0x6f, 0x72, 0x6f, 0x75, 0x74, 0x69, 0x6e, + 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0c, 0x4e, 0x75, 0x6d, 0x47, 0x6f, 0x72, 0x6f, + 0x75, 0x74, 0x69, 0x6e, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x4e, 0x75, 0x6d, 0x47, 0x43, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x0d, 0x52, 0x05, 0x4e, 0x75, 0x6d, 0x47, 0x43, 0x12, 0x14, 0x0a, 0x05, 0x41, + 0x6c, 0x6c, 0x6f, 0x63, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x41, 0x6c, 0x6c, 0x6f, + 0x63, 0x12, 0x1e, 0x0a, 0x0a, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x41, 0x6c, 0x6c, 0x6f, 0x63, 0x18, + 0x04, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0a, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x41, 0x6c, 0x6c, 0x6f, + 0x63, 0x12, 0x10, 0x0a, 0x03, 0x53, 0x79, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x04, 0x52, 0x03, + 0x53, 0x79, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x4d, 0x61, 0x6c, 0x6c, 0x6f, 0x63, 0x73, 0x18, 0x06, + 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x4d, 0x61, 0x6c, 0x6c, 0x6f, 0x63, 0x73, 0x12, 0x14, 0x0a, + 0x05, 0x46, 0x72, 0x65, 0x65, 0x73, 0x18, 0x07, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x46, 0x72, + 0x65, 0x65, 0x73, 0x12, 0x20, 0x0a, 0x0b, 0x4c, 0x69, 0x76, 0x65, 0x4f, 0x62, 0x6a, 0x65, 0x63, + 0x74, 0x73, 0x18, 0x08, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0b, 0x4c, 0x69, 0x76, 0x65, 0x4f, 0x62, + 0x6a, 0x65, 0x63, 0x74, 0x73, 0x12, 0x22, 0x0a, 0x0c, 0x50, 0x61, 0x75, 0x73, 0x65, 0x54, 0x6f, + 0x74, 0x61, 0x6c, 0x4e, 0x73, 0x18, 0x09, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0c, 0x50, 0x61, 0x75, + 0x73, 0x65, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x4e, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x55, 0x70, 0x74, + 0x69, 0x6d, 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x55, 0x70, 0x74, 0x69, 0x6d, + 0x65, 0x22, 0x08, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x32, 0xa1, 0x03, 0x0a, 0x0c, + 0x53, 0x74, 0x61, 0x74, 0x73, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x5f, 0x0a, 0x08, + 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x73, 0x12, 0x27, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, + 0x61, 0x70, 0x70, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, + 0x64, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x28, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x73, 0x74, 0x61, + 0x74, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x74, + 0x61, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x65, 0x0a, + 0x0e, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x73, 0x4f, 0x6e, 0x6c, 0x69, 0x6e, 0x65, 0x12, + 0x27, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x73, + 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, + 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x28, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, + 0x61, 0x70, 0x70, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, + 0x64, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x22, 0x00, 0x12, 0x65, 0x0a, 0x0a, 0x51, 0x75, 0x65, 0x72, 0x79, 0x53, 0x74, 0x61, + 0x74, 0x73, 0x12, 0x29, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x73, 0x74, + 0x61, 0x74, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x51, 0x75, 0x65, 0x72, + 0x79, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2a, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x53, 0x74, 0x61, 0x74, - 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2a, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, - 0x61, 0x70, 0x70, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, - 0x64, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x62, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x53, 0x79, 0x73, - 0x53, 0x74, 0x61, 0x74, 0x73, 0x12, 0x27, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, - 0x2e, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x53, - 0x79, 0x73, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x28, - 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, - 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x53, 0x79, 0x73, 0x53, 0x74, 0x61, 0x74, 0x73, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x64, 0x0a, 0x1a, 0x63, 0x6f, - 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x73, - 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x50, 0x01, 0x5a, 0x2b, 0x67, 0x69, 0x74, 0x68, - 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, - 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2f, - 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0xaa, 0x02, 0x16, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x41, - 0x70, 0x70, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, - 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x62, 0x0a, 0x0b, 0x47, + 0x65, 0x74, 0x53, 0x79, 0x73, 0x53, 0x74, 0x61, 0x74, 0x73, 0x12, 0x27, 0x2e, 0x78, 0x72, 0x61, + 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, + 0x61, 0x6e, 0x64, 0x2e, 0x53, 0x79, 0x73, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x28, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x73, + 0x74, 0x61, 0x74, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x53, 0x79, 0x73, + 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, + 0x64, 0x0a, 0x1a, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, + 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x50, 0x01, 0x5a, + 0x2b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, + 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x73, + 0x74, 0x61, 0x74, 0x73, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0xaa, 0x02, 0x16, 0x58, + 0x72, 0x61, 0x79, 0x2e, 0x41, 0x70, 0x70, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x43, 0x6f, + 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( - file_app_stats_command_command_proto_rawDescOnce sync.Once - file_app_stats_command_command_proto_rawDescData = file_app_stats_command_command_proto_rawDesc + file_command_proto_rawDescOnce sync.Once + file_command_proto_rawDescData = file_command_proto_rawDesc ) -func file_app_stats_command_command_proto_rawDescGZIP() []byte { - file_app_stats_command_command_proto_rawDescOnce.Do(func() { - file_app_stats_command_command_proto_rawDescData = protoimpl.X.CompressGZIP(file_app_stats_command_command_proto_rawDescData) +func file_command_proto_rawDescGZIP() []byte { + file_command_proto_rawDescOnce.Do(func() { + file_command_proto_rawDescData = protoimpl.X.CompressGZIP(file_command_proto_rawDescData) }) - return file_app_stats_command_command_proto_rawDescData + return file_command_proto_rawDescData } -var file_app_stats_command_command_proto_msgTypes = make([]protoimpl.MessageInfo, 8) -var file_app_stats_command_command_proto_goTypes = []any{ +var file_command_proto_msgTypes = make([]protoimpl.MessageInfo, 8) +var file_command_proto_goTypes = []any{ (*GetStatsRequest)(nil), // 0: xray.app.stats.command.GetStatsRequest (*Stat)(nil), // 1: xray.app.stats.command.Stat (*GetStatsResponse)(nil), // 2: xray.app.stats.command.GetStatsResponse @@ -559,43 +564,45 @@ var file_app_stats_command_command_proto_goTypes = []any{ (*SysStatsResponse)(nil), // 6: xray.app.stats.command.SysStatsResponse (*Config)(nil), // 7: xray.app.stats.command.Config } -var file_app_stats_command_command_proto_depIdxs = []int32{ +var file_command_proto_depIdxs = []int32{ 1, // 0: xray.app.stats.command.GetStatsResponse.stat:type_name -> xray.app.stats.command.Stat 1, // 1: xray.app.stats.command.QueryStatsResponse.stat:type_name -> xray.app.stats.command.Stat 0, // 2: xray.app.stats.command.StatsService.GetStats:input_type -> xray.app.stats.command.GetStatsRequest - 3, // 3: xray.app.stats.command.StatsService.QueryStats:input_type -> xray.app.stats.command.QueryStatsRequest - 5, // 4: xray.app.stats.command.StatsService.GetSysStats:input_type -> xray.app.stats.command.SysStatsRequest - 2, // 5: xray.app.stats.command.StatsService.GetStats:output_type -> xray.app.stats.command.GetStatsResponse - 4, // 6: xray.app.stats.command.StatsService.QueryStats:output_type -> xray.app.stats.command.QueryStatsResponse - 6, // 7: xray.app.stats.command.StatsService.GetSysStats:output_type -> xray.app.stats.command.SysStatsResponse - 5, // [5:8] is the sub-list for method output_type - 2, // [2:5] is the sub-list for method input_type + 0, // 3: xray.app.stats.command.StatsService.GetStatsOnline:input_type -> xray.app.stats.command.GetStatsRequest + 3, // 4: xray.app.stats.command.StatsService.QueryStats:input_type -> xray.app.stats.command.QueryStatsRequest + 5, // 5: xray.app.stats.command.StatsService.GetSysStats:input_type -> xray.app.stats.command.SysStatsRequest + 2, // 6: xray.app.stats.command.StatsService.GetStats:output_type -> xray.app.stats.command.GetStatsResponse + 2, // 7: xray.app.stats.command.StatsService.GetStatsOnline:output_type -> xray.app.stats.command.GetStatsResponse + 4, // 8: xray.app.stats.command.StatsService.QueryStats:output_type -> xray.app.stats.command.QueryStatsResponse + 6, // 9: xray.app.stats.command.StatsService.GetSysStats:output_type -> xray.app.stats.command.SysStatsResponse + 6, // [6:10] is the sub-list for method output_type + 2, // [2:6] is the sub-list for method input_type 2, // [2:2] is the sub-list for extension type_name 2, // [2:2] is the sub-list for extension extendee 0, // [0:2] is the sub-list for field type_name } -func init() { file_app_stats_command_command_proto_init() } -func file_app_stats_command_command_proto_init() { - if File_app_stats_command_command_proto != nil { +func init() { file_command_proto_init() } +func file_command_proto_init() { + if File_command_proto != nil { return } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_app_stats_command_command_proto_rawDesc, + RawDescriptor: file_command_proto_rawDesc, NumEnums: 0, NumMessages: 8, NumExtensions: 0, NumServices: 1, }, - GoTypes: file_app_stats_command_command_proto_goTypes, - DependencyIndexes: file_app_stats_command_command_proto_depIdxs, - MessageInfos: file_app_stats_command_command_proto_msgTypes, + GoTypes: file_command_proto_goTypes, + DependencyIndexes: file_command_proto_depIdxs, + MessageInfos: file_command_proto_msgTypes, }.Build() - File_app_stats_command_command_proto = out.File - file_app_stats_command_command_proto_rawDesc = nil - file_app_stats_command_command_proto_goTypes = nil - file_app_stats_command_command_proto_depIdxs = nil + File_command_proto = out.File + file_command_proto_rawDesc = nil + file_command_proto_goTypes = nil + file_command_proto_depIdxs = nil } diff --git a/xray-core/app/stats/command/command.proto b/xray-core/app/stats/command/command.proto index bd1f9781d9..1d2ed86754 100644 --- a/xray-core/app/stats/command/command.proto +++ b/xray-core/app/stats/command/command.proto @@ -48,6 +48,7 @@ message SysStatsResponse { service StatsService { rpc GetStats(GetStatsRequest) returns (GetStatsResponse) {} + rpc GetStatsOnline(GetStatsRequest) returns (GetStatsResponse) {} rpc QueryStats(QueryStatsRequest) returns (QueryStatsResponse) {} rpc GetSysStats(SysStatsRequest) returns (SysStatsResponse) {} } diff --git a/xray-core/app/stats/command/command_grpc.pb.go b/xray-core/app/stats/command/command_grpc.pb.go index 40bd638326..e9431453ef 100644 --- a/xray-core/app/stats/command/command_grpc.pb.go +++ b/xray-core/app/stats/command/command_grpc.pb.go @@ -1,8 +1,8 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.5.1 -// - protoc v5.28.2 -// source: app/stats/command/command.proto +// - protoc v5.28.3 +// source: command.proto package command @@ -19,9 +19,10 @@ import ( const _ = grpc.SupportPackageIsVersion9 const ( - StatsService_GetStats_FullMethodName = "/xray.app.stats.command.StatsService/GetStats" - StatsService_QueryStats_FullMethodName = "/xray.app.stats.command.StatsService/QueryStats" - StatsService_GetSysStats_FullMethodName = "/xray.app.stats.command.StatsService/GetSysStats" + StatsService_GetStats_FullMethodName = "/xray.app.stats.command.StatsService/GetStats" + StatsService_GetStatsOnline_FullMethodName = "/xray.app.stats.command.StatsService/GetStatsOnline" + StatsService_QueryStats_FullMethodName = "/xray.app.stats.command.StatsService/QueryStats" + StatsService_GetSysStats_FullMethodName = "/xray.app.stats.command.StatsService/GetSysStats" ) // StatsServiceClient is the client API for StatsService service. @@ -29,6 +30,7 @@ const ( // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. type StatsServiceClient interface { GetStats(ctx context.Context, in *GetStatsRequest, opts ...grpc.CallOption) (*GetStatsResponse, error) + GetStatsOnline(ctx context.Context, in *GetStatsRequest, opts ...grpc.CallOption) (*GetStatsResponse, error) QueryStats(ctx context.Context, in *QueryStatsRequest, opts ...grpc.CallOption) (*QueryStatsResponse, error) GetSysStats(ctx context.Context, in *SysStatsRequest, opts ...grpc.CallOption) (*SysStatsResponse, error) } @@ -51,6 +53,16 @@ func (c *statsServiceClient) GetStats(ctx context.Context, in *GetStatsRequest, return out, nil } +func (c *statsServiceClient) GetStatsOnline(ctx context.Context, in *GetStatsRequest, opts ...grpc.CallOption) (*GetStatsResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(GetStatsResponse) + err := c.cc.Invoke(ctx, StatsService_GetStatsOnline_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *statsServiceClient) QueryStats(ctx context.Context, in *QueryStatsRequest, opts ...grpc.CallOption) (*QueryStatsResponse, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(QueryStatsResponse) @@ -76,6 +88,7 @@ func (c *statsServiceClient) GetSysStats(ctx context.Context, in *SysStatsReques // for forward compatibility. type StatsServiceServer interface { GetStats(context.Context, *GetStatsRequest) (*GetStatsResponse, error) + GetStatsOnline(context.Context, *GetStatsRequest) (*GetStatsResponse, error) QueryStats(context.Context, *QueryStatsRequest) (*QueryStatsResponse, error) GetSysStats(context.Context, *SysStatsRequest) (*SysStatsResponse, error) mustEmbedUnimplementedStatsServiceServer() @@ -91,6 +104,9 @@ type UnimplementedStatsServiceServer struct{} func (UnimplementedStatsServiceServer) GetStats(context.Context, *GetStatsRequest) (*GetStatsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method GetStats not implemented") } +func (UnimplementedStatsServiceServer) GetStatsOnline(context.Context, *GetStatsRequest) (*GetStatsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetStatsOnline not implemented") +} func (UnimplementedStatsServiceServer) QueryStats(context.Context, *QueryStatsRequest) (*QueryStatsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method QueryStats not implemented") } @@ -136,6 +152,24 @@ func _StatsService_GetStats_Handler(srv interface{}, ctx context.Context, dec fu return interceptor(ctx, in, info, handler) } +func _StatsService_GetStatsOnline_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetStatsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(StatsServiceServer).GetStatsOnline(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: StatsService_GetStatsOnline_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(StatsServiceServer).GetStatsOnline(ctx, req.(*GetStatsRequest)) + } + return interceptor(ctx, in, info, handler) +} + func _StatsService_QueryStats_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(QueryStatsRequest) if err := dec(in); err != nil { @@ -183,6 +217,10 @@ var StatsService_ServiceDesc = grpc.ServiceDesc{ MethodName: "GetStats", Handler: _StatsService_GetStats_Handler, }, + { + MethodName: "GetStatsOnline", + Handler: _StatsService_GetStatsOnline_Handler, + }, { MethodName: "QueryStats", Handler: _StatsService_QueryStats_Handler, @@ -193,5 +231,5 @@ var StatsService_ServiceDesc = grpc.ServiceDesc{ }, }, Streams: []grpc.StreamDesc{}, - Metadata: "app/stats/command/command.proto", + Metadata: "command.proto", } diff --git a/xray-core/app/stats/online_map.go b/xray-core/app/stats/online_map.go new file mode 100644 index 0000000000..0ba2b924a0 --- /dev/null +++ b/xray-core/app/stats/online_map.go @@ -0,0 +1,80 @@ +package stats + +import ( + "sync" + "time" +) + +// OnlineMap is an implementation of stats.OnlineMap. +type OnlineMap struct { + value int + ipList map[string]time.Time + access sync.RWMutex + lastCleanup time.Time + cleanupPeriod time.Duration +} + +// NewOnlineMap creates a new instance of OnlineMap. +func NewOnlineMap() *OnlineMap { + return &OnlineMap{ + ipList: make(map[string]time.Time), + lastCleanup: time.Now(), + cleanupPeriod: 10 * time.Second, + } +} + +// Count implements stats.OnlineMap. +func (c *OnlineMap) Count() int { + return c.value +} + +// List implements stats.OnlineMap. +func (c *OnlineMap) List() []string { + return c.GetKeys() +} + +// AddIP implements stats.OnlineMap. +func (c *OnlineMap) AddIP(ip string) { + list := c.ipList + + if ip == "127.0.0.1" { + return + } + if _, ok := list[ip]; !ok { + c.access.Lock() + list[ip] = time.Now() + c.access.Unlock() + } + if time.Since(c.lastCleanup) > c.cleanupPeriod { + list = c.RemoveExpiredIPs(list) + c.lastCleanup = time.Now() + } + + c.value = len(list) + c.ipList = list +} + +func (c *OnlineMap) GetKeys() []string { + c.access.RLock() + defer c.access.RUnlock() + + keys := []string{} + for k := range c.ipList { + keys = append(keys, k) + } + return keys +} + +func (c *OnlineMap) RemoveExpiredIPs(list map[string]time.Time) map[string]time.Time { + c.access.Lock() + defer c.access.Unlock() + + now := time.Now() + for k, t := range list { + diff := now.Sub(t) + if diff.Seconds() > 20 { + delete(list, k) + } + } + return list +} diff --git a/xray-core/app/stats/stats.go b/xray-core/app/stats/stats.go index 5e9d0b5936..5451c5e63b 100644 --- a/xray-core/app/stats/stats.go +++ b/xray-core/app/stats/stats.go @@ -11,17 +11,19 @@ import ( // Manager is an implementation of stats.Manager. type Manager struct { - access sync.RWMutex - counters map[string]*Counter - channels map[string]*Channel - running bool + access sync.RWMutex + counters map[string]*Counter + onlineMap map[string]*OnlineMap + channels map[string]*Channel + running bool } // NewManager creates an instance of Statistics Manager. func NewManager(ctx context.Context, config *Config) (*Manager, error) { m := &Manager{ - counters: make(map[string]*Counter), - channels: make(map[string]*Channel), + counters: make(map[string]*Counter), + onlineMap: make(map[string]*OnlineMap), + channels: make(map[string]*Channel), } return m, nil @@ -81,6 +83,43 @@ func (m *Manager) VisitCounters(visitor func(string, stats.Counter) bool) { } } +// RegisterOnlineMap implements stats.Manager. +func (m *Manager) RegisterOnlineMap(name string) (stats.OnlineMap, error) { + m.access.Lock() + defer m.access.Unlock() + + if _, found := m.onlineMap[name]; found { + return nil, errors.New("onlineMap ", name, " already registered.") + } + errors.LogDebug(context.Background(), "create new onlineMap ", name) + om := NewOnlineMap() + m.onlineMap[name] = om + return om, nil +} + +// UnregisterOnlineMap implements stats.Manager. +func (m *Manager) UnregisterOnlineMap(name string) error { + m.access.Lock() + defer m.access.Unlock() + + if _, found := m.onlineMap[name]; found { + errors.LogDebug(context.Background(), "remove onlineMap ", name) + delete(m.onlineMap, name) + } + return nil +} + +// GetOnlineMap implements stats.Manager. +func (m *Manager) GetOnlineMap(name string) stats.OnlineMap { + m.access.RLock() + defer m.access.RUnlock() + + if om, found := m.onlineMap[name]; found { + return om + } + return nil +} + // RegisterChannel implements stats.Manager. func (m *Manager) RegisterChannel(name string) (stats.Channel, error) { m.access.Lock() diff --git a/xray-core/common/protocol/account.go b/xray-core/common/protocol/account.go index 7793974a7f..755688176c 100644 --- a/xray-core/common/protocol/account.go +++ b/xray-core/common/protocol/account.go @@ -1,8 +1,11 @@ package protocol +import "google.golang.org/protobuf/proto" + // Account is a user identity used for authentication. type Account interface { Equals(Account) bool + ToProto() proto.Message } // AsAccount is an object can be converted into account. diff --git a/xray-core/common/protocol/user.go b/xray-core/common/protocol/user.go index d6e3a1310c..2986eb19a9 100644 --- a/xray-core/common/protocol/user.go +++ b/xray-core/common/protocol/user.go @@ -1,6 +1,9 @@ package protocol -import "github.com/xtls/xray-core/common/errors" +import ( + "github.com/xtls/xray-core/common/errors" + "github.com/xtls/xray-core/common/serial" +) func (u *User) GetTypedAccount() (Account, error) { if u.GetAccount() == nil { @@ -32,6 +35,17 @@ func (u *User) ToMemoryUser() (*MemoryUser, error) { }, nil } +func ToProtoUser(mu *MemoryUser) *User { + if mu == nil { + return nil + } + return &User{ + Account: serial.ToTypedMessage(mu.Account.ToProto()), + Email: mu.Email, + Level: mu.Level, + } +} + // MemoryUser is a parsed form of User, to reduce number of parsing of Account proto. type MemoryUser struct { // Account is the parsed account of the protocol. diff --git a/xray-core/core/proto.go b/xray-core/core/proto.go index b85d99d898..030365cc60 100644 --- a/xray-core/core/proto.go +++ b/xray-core/core/proto.go @@ -1,5 +1,5 @@ package core -//go:generate go install -v google.golang.org/protobuf/cmd/protoc-gen-go@v1.34.2 -//go:generate go install -v google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.5.1 +//go:generate go install -v google.golang.org/protobuf/cmd/protoc-gen-go@latest +//go:generate go install -v google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest //go:generate go run ../infra/vprotogen/main.go -pwd ./.. diff --git a/xray-core/features/policy/policy.go b/xray-core/features/policy/policy.go index 4d3f7ecf32..d6fd20d06b 100644 --- a/xray-core/features/policy/policy.go +++ b/xray-core/features/policy/policy.go @@ -27,6 +27,8 @@ type Stats struct { UserUplink bool // Whether or not to enable stat counter for user downlink traffic. UserDownlink bool + // Whether or not to enable online map for user. + UserOnline bool } // Buffer contains settings for internal buffer. @@ -123,6 +125,7 @@ func SessionDefault() Session { Stats: Stats{ UserUplink: false, UserDownlink: false, + UserOnline: false, }, Buffer: defaultBufferPolicy(), } diff --git a/xray-core/features/stats/stats.go b/xray-core/features/stats/stats.go index 010dd767ed..de343a8205 100644 --- a/xray-core/features/stats/stats.go +++ b/xray-core/features/stats/stats.go @@ -20,6 +20,18 @@ type Counter interface { Add(int64) int64 } +// OnlineMap is the interface for stats. +// +// xray:api:stable +type OnlineMap interface { + // Count is the current value of the OnlineMap. + Count() int + // AddIP adds a ip to the current OnlineMap. + AddIP(string) + // List is the current OnlineMap ip list. + List() []string +} + // Channel is the interface for stats channel. // // xray:api:stable @@ -70,6 +82,13 @@ type Manager interface { // GetCounter returns a counter by its identifier. GetCounter(string) Counter + // RegisterOnlineMap registers a new onlinemap to the manager. The identifier string must not be empty, and unique among other onlinemaps. + RegisterOnlineMap(string) (OnlineMap, error) + // UnregisterOnlineMap unregisters a onlinemap from the manager by its identifier. + UnregisterOnlineMap(string) error + // GetOnlineMap returns a onlinemap by its identifier. + GetOnlineMap(string) OnlineMap + // RegisterChannel registers a new channel to the manager. The identifier string must not be empty, and unique among other channels. RegisterChannel(string) (Channel, error) // UnregisterChannel unregisters a channel from the manager by its identifier. @@ -88,6 +107,16 @@ func GetOrRegisterCounter(m Manager, name string) (Counter, error) { return m.RegisterCounter(name) } +// GetOrRegisterOnlineMap tries to get the OnlineMap first. If not exist, it then tries to create a new onlinemap. +func GetOrRegisterOnlineMap(m Manager, name string) (OnlineMap, error) { + onlineMap := m.GetOnlineMap(name) + if onlineMap != nil { + return onlineMap, nil + } + + return m.RegisterOnlineMap(name) +} + // GetOrRegisterChannel tries to get the StatChannel first. If not exist, it then tries to create a new channel. func GetOrRegisterChannel(m Manager, name string) (Channel, error) { channel := m.GetChannel(name) @@ -128,6 +157,21 @@ func (NoopManager) GetCounter(string) Counter { return nil } +// RegisterOnlineMap implements Manager. +func (NoopManager) RegisterOnlineMap(string) (OnlineMap, error) { + return nil, errors.New("not implemented") +} + +// UnregisterOnlineMap implements Manager. +func (NoopManager) UnregisterOnlineMap(string) error { + return nil +} + +// GetOnlineMap implements Manager. +func (NoopManager) GetOnlineMap(string) OnlineMap { + return nil +} + // RegisterChannel implements Manager. func (NoopManager) RegisterChannel(string) (Channel, error) { return nil, errors.New("not implemented") diff --git a/xray-core/infra/conf/policy.go b/xray-core/infra/conf/policy.go index 5fbf01e672..1182766cc8 100644 --- a/xray-core/infra/conf/policy.go +++ b/xray-core/infra/conf/policy.go @@ -11,6 +11,7 @@ type Policy struct { DownlinkOnly *uint32 `json:"downlinkOnly"` StatsUserUplink bool `json:"statsUserUplink"` StatsUserDownlink bool `json:"statsUserDownlink"` + StatsUserOnline bool `json:"statsUserOnline"` BufferSize *int32 `json:"bufferSize"` } @@ -34,6 +35,7 @@ func (t *Policy) Build() (*policy.Policy, error) { Stats: &policy.Policy_Stats{ UserUplink: t.StatsUserUplink, UserDownlink: t.StatsUserDownlink, + UserOnline: t.StatsUserOnline, }, } diff --git a/xray-core/infra/conf/shadowsocks.go b/xray-core/infra/conf/shadowsocks.go index 1bd6462c80..f12040a6eb 100644 --- a/xray-core/infra/conf/shadowsocks.go +++ b/xray-core/infra/conf/shadowsocks.go @@ -126,9 +126,13 @@ func buildShadowsocks2022(v *ShadowsocksServerConfig) (proto.Message, error) { if user.Cipher != "" { return nil, errors.New("shadowsocks 2022 (multi-user): users must have empty method") } - config.Users = append(config.Users, &shadowsocks_2022.User{ - Key: user.Password, - Email: user.Email, + account := &shadowsocks_2022.Account{ + Key: user.Password, + } + config.Users = append(config.Users, &protocol.User{ + Email: user.Email, + Level: uint32(user.Level), + Account: serial.ToTypedMessage(account), }) } return config, nil diff --git a/xray-core/main/commands/all/api/api.go b/xray-core/main/commands/all/api/api.go index ea43d1070c..329450c955 100644 --- a/xray-core/main/commands/all/api/api.go +++ b/xray-core/main/commands/all/api/api.go @@ -21,8 +21,11 @@ var CmdAPI = &base.Command{ cmdAddOutbounds, cmdRemoveInbounds, cmdRemoveOutbounds, + cmdInboundUser, + cmdInboundUserCount, cmdAddRules, cmdRemoveRules, cmdSourceIpBlock, + cmdOnlineStats, }, } diff --git a/xray-core/main/commands/all/api/inbound_user.go b/xray-core/main/commands/all/api/inbound_user.go new file mode 100644 index 0000000000..6ffa4ebb94 --- /dev/null +++ b/xray-core/main/commands/all/api/inbound_user.go @@ -0,0 +1,50 @@ +package api + +import ( + handlerService "github.com/xtls/xray-core/app/proxyman/command" + "github.com/xtls/xray-core/main/commands/base" +) + +var cmdInboundUser = &base.Command{ + CustomFlags: true, + UsageLine: "{{.Exec}} api inbounduser [--server=127.0.0.1:8080] -tag=tag [-email=email]", + Short: "Get Inbound User", + Long: ` +Get User info from an inbound. +Arguments: + -s, -server + The API server address. Default 127.0.0.1:8080 + -t, -timeout + Timeout seconds to call API. Default 3 + -tag + Inbound tag + -email + User email. If email is not given, will get all users +Example: + {{.Exec}} {{.LongName}} --server=127.0.0.1:8080 -tag="tag name" -email="xray@love.com" +`, + Run: executeInboundUser, +} + +func executeInboundUser(cmd *base.Command, args []string) { + setSharedFlags(cmd) + var tag string + var email string + cmd.Flag.StringVar(&tag, "tag", "", "") + cmd.Flag.StringVar(&email, "email", "", "") + cmd.Flag.Parse(args) + + conn, ctx, close := dialAPIServer() + defer close() + + client := handlerService.NewHandlerServiceClient(conn) + r := &handlerService.GetInboundUserRequest{ + Tag: tag, + Email: email, + } + resp, err := client.GetInboundUsers(ctx, r) + if err != nil { + base.Fatalf("failed to get inbound user: %s", err) + } + showJSONResponse(resp) +} diff --git a/xray-core/main/commands/all/api/inbound_user_count.go b/xray-core/main/commands/all/api/inbound_user_count.go new file mode 100644 index 0000000000..18cab7e80f --- /dev/null +++ b/xray-core/main/commands/all/api/inbound_user_count.go @@ -0,0 +1,45 @@ +package api + +import ( + handlerService "github.com/xtls/xray-core/app/proxyman/command" + "github.com/xtls/xray-core/main/commands/base" +) + +var cmdInboundUserCount = &base.Command{ + CustomFlags: true, + UsageLine: "{{.Exec}} api inboundusercount [--server=127.0.0.1:8080] -tag=tag", + Short: "Get Inbound User Count", + Long: ` +Get User count from an inbound. +Arguments: + -s, -server + The API server address. Default 127.0.0.1:8080 + -t, -timeout + Timeout seconds to call API. Default 3 + -tag + Inbound tag +Example: + {{.Exec}} {{.LongName}} --server=127.0.0.1:8080 -tag="tag name" +`, + Run: executeInboundUserCount, +} + +func executeInboundUserCount(cmd *base.Command, args []string) { + setSharedFlags(cmd) + var tag string + cmd.Flag.StringVar(&tag, "tag", "", "") + cmd.Flag.Parse(args) + + conn, ctx, close := dialAPIServer() + defer close() + + client := handlerService.NewHandlerServiceClient(conn) + r := &handlerService.GetInboundUserRequest{ + Tag: tag, + } + resp, err := client.GetInboundUsersCount(ctx, r) + if err != nil { + base.Fatalf("failed to get inbound user count: %s", err) + } + showJSONResponse(resp) +} diff --git a/xray-core/main/commands/all/api/stats_online.go b/xray-core/main/commands/all/api/stats_online.go new file mode 100644 index 0000000000..9359280753 --- /dev/null +++ b/xray-core/main/commands/all/api/stats_online.go @@ -0,0 +1,47 @@ +package api + +import ( + statsService "github.com/xtls/xray-core/app/stats/command" + "github.com/xtls/xray-core/main/commands/base" +) + +var cmdOnlineStats = &base.Command{ + CustomFlags: true, + UsageLine: "{{.Exec}} api statsonline [--server=127.0.0.1:8080] [-name '']", + Short: "Get online user", + Long: ` +Get statistics from Xray. +Arguments: + -s, -server + The API server address. Default 127.0.0.1:8080 + -t, -timeout + Timeout seconds to call API. Default 3 + -email + email of the user. + -reset + Reset the counter to fetching its value. +Example: + {{.Exec}} {{.LongName}} --server=127.0.0.1:8080 -email "user1@test.com" +`, + Run: executeOnlineStats, +} + +func executeOnlineStats(cmd *base.Command, args []string) { + setSharedFlags(cmd) + email := cmd.Flag.String("email", "", "") + cmd.Flag.Parse(args) + statName := "user>>>" + *email + ">>>online" + conn, ctx, close := dialAPIServer() + defer close() + + client := statsService.NewStatsServiceClient(conn) + r := &statsService.GetStatsRequest{ + Name: statName, + Reset_: false, + } + resp, err := client.GetStatsOnline(ctx, r) + if err != nil { + base.Fatalf("failed to get stats: %s", err) + } + showJSONResponse(resp) +} diff --git a/xray-core/proxy/http/config.go b/xray-core/proxy/http/config.go index 00ce0795b1..a41bb01074 100644 --- a/xray-core/proxy/http/config.go +++ b/xray-core/proxy/http/config.go @@ -1,6 +1,8 @@ package http import ( + "google.golang.org/protobuf/proto" + "github.com/xtls/xray-core/common/protocol" ) @@ -11,6 +13,10 @@ func (a *Account) Equals(another protocol.Account) bool { return false } +func (a *Account) ToProto() proto.Message { + return a +} + func (a *Account) AsAccount() (protocol.Account, error) { return a, nil } diff --git a/xray-core/proxy/proxy.go b/xray-core/proxy/proxy.go index b507cc39bb..868c8dfc42 100644 --- a/xray-core/proxy/proxy.go +++ b/xray-core/proxy/proxy.go @@ -78,6 +78,15 @@ type UserManager interface { // RemoveUser removes a user by email. RemoveUser(context.Context, string) error + + // Get user by email. + GetUser(context.Context, string) *protocol.MemoryUser + + // Get all users. + GetUsers(context.Context) []*protocol.MemoryUser + + // Get users count. + GetUsersCount(context.Context) int64 } type GetInbound interface { diff --git a/xray-core/proxy/shadowsocks/config.go b/xray-core/proxy/shadowsocks/config.go index 396e59be81..e2d812abf8 100644 --- a/xray-core/proxy/shadowsocks/config.go +++ b/xray-core/proxy/shadowsocks/config.go @@ -6,6 +6,7 @@ import ( "crypto/cipher" "crypto/md5" "crypto/sha1" + "google.golang.org/protobuf/proto" "io" "github.com/xtls/xray-core/common" @@ -20,8 +21,10 @@ import ( // MemoryAccount is an account type converted from Account. type MemoryAccount struct { - Cipher Cipher - Key []byte + Cipher Cipher + CipherType CipherType + Key []byte + Password string replayFilter antireplay.GeneralizedReplayFilter } @@ -36,6 +39,14 @@ func (a *MemoryAccount) Equals(another protocol.Account) bool { return false } +func (a *MemoryAccount) ToProto() proto.Message { + return &Account{ + CipherType: a.CipherType, + Password: a.Password, + IvCheck: a.replayFilter != nil, + } +} + func (a *MemoryAccount) CheckIV(iv []byte) error { if a.replayFilter == nil { return nil @@ -107,7 +118,9 @@ func (a *Account) AsAccount() (protocol.Account, error) { } return &MemoryAccount{ Cipher: Cipher, + CipherType: a.CipherType, Key: passwordToCipherKey([]byte(a.Password), Cipher.KeySize()), + Password: a.Password, replayFilter: func() antireplay.GeneralizedReplayFilter { if a.IvCheck { return antireplay.NewBloomRing() diff --git a/xray-core/proxy/shadowsocks/server.go b/xray-core/proxy/shadowsocks/server.go index e6135a456e..356868e4b1 100644 --- a/xray-core/proxy/shadowsocks/server.go +++ b/xray-core/proxy/shadowsocks/server.go @@ -63,6 +63,21 @@ func (s *Server) RemoveUser(ctx context.Context, e string) error { return s.validator.Del(e) } +// GetUser implements proxy.UserManager.GetUser(). +func (s *Server) GetUser(ctx context.Context, email string) *protocol.MemoryUser { + return s.validator.GetByEmail(email) +} + +// GetUsers implements proxy.UserManager.GetUsers(). +func (s *Server) GetUsers(ctx context.Context) []*protocol.MemoryUser { + return s.validator.GetAll() +} + +// GetUsersCount implements proxy.UserManager.GetUsersCount(). +func (s *Server) GetUsersCount(context.Context) int64 { + return s.validator.GetCount() +} + func (s *Server) Network() []net.Network { list := s.config.Network if len(list) == 0 { diff --git a/xray-core/proxy/shadowsocks/validator.go b/xray-core/proxy/shadowsocks/validator.go index ae92a8dc07..84e59dc1cb 100644 --- a/xray-core/proxy/shadowsocks/validator.go +++ b/xray-core/proxy/shadowsocks/validator.go @@ -74,6 +74,40 @@ func (v *Validator) Del(email string) error { return nil } +// GetByEmail Get a Shadowsocks user with a non-empty Email. +func (v *Validator) GetByEmail(email string) *protocol.MemoryUser { + if email == "" { + return nil + } + + v.Lock() + defer v.Unlock() + + email = strings.ToLower(email) + for _, u := range v.users { + if strings.EqualFold(u.Email, email) { + return u + } + } + return nil +} + +// GetAll get all users +func (v *Validator) GetAll() []*protocol.MemoryUser { + v.Lock() + defer v.Unlock() + dst := make([]*protocol.MemoryUser, len(v.users)) + copy(dst, v.users) + return dst +} + +// GetCount get users count +func (v *Validator) GetCount() int64 { + v.Lock() + defer v.Unlock() + return int64(len(v.users)) +} + // Get a Shadowsocks user. func (v *Validator) Get(bs []byte, command protocol.RequestCommand) (u *protocol.MemoryUser, aead cipher.AEAD, ret []byte, ivLen int32, err error) { v.RLock() diff --git a/xray-core/proxy/shadowsocks_2022/config.go b/xray-core/proxy/shadowsocks_2022/config.go index 8a66406c18..3678cd587d 100644 --- a/xray-core/proxy/shadowsocks_2022/config.go +++ b/xray-core/proxy/shadowsocks_2022/config.go @@ -1,22 +1,20 @@ package shadowsocks_2022 import ( + "google.golang.org/protobuf/proto" + "github.com/xtls/xray-core/common/protocol" ) // MemoryAccount is an account type converted from Account. type MemoryAccount struct { Key string - Email string - Level int32 } // AsAccount implements protocol.AsAccount. -func (u *User) AsAccount() (protocol.Account, error) { +func (u *Account) AsAccount() (protocol.Account, error) { return &MemoryAccount{ Key: u.GetKey(), - Email: u.GetEmail(), - Level: u.GetLevel(), }, nil } @@ -27,3 +25,9 @@ func (a *MemoryAccount) Equals(another protocol.Account) bool { } return false } + +func (a *MemoryAccount) ToProto() proto.Message { + return &Account{ + Key: a.Key, + } +} diff --git a/xray-core/proxy/shadowsocks_2022/config.pb.go b/xray-core/proxy/shadowsocks_2022/config.pb.go index b47438eae8..f2f78ad609 100644 --- a/xray-core/proxy/shadowsocks_2022/config.pb.go +++ b/xray-core/proxy/shadowsocks_2022/config.pb.go @@ -8,6 +8,7 @@ package shadowsocks_2022 import ( net "github.com/xtls/xray-core/common/net" + protocol "github.com/xtls/xray-core/common/protocol" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" @@ -103,10 +104,10 @@ type MultiUserServerConfig struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Method string `protobuf:"bytes,1,opt,name=method,proto3" json:"method,omitempty"` - Key string `protobuf:"bytes,2,opt,name=key,proto3" json:"key,omitempty"` - Users []*User `protobuf:"bytes,3,rep,name=users,proto3" json:"users,omitempty"` - Network []net.Network `protobuf:"varint,4,rep,packed,name=network,proto3,enum=xray.common.net.Network" json:"network,omitempty"` + Method string `protobuf:"bytes,1,opt,name=method,proto3" json:"method,omitempty"` + Key string `protobuf:"bytes,2,opt,name=key,proto3" json:"key,omitempty"` + Users []*protocol.User `protobuf:"bytes,3,rep,name=users,proto3" json:"users,omitempty"` + Network []net.Network `protobuf:"varint,4,rep,packed,name=network,proto3,enum=xray.common.net.Network" json:"network,omitempty"` } func (x *MultiUserServerConfig) Reset() { @@ -153,7 +154,7 @@ func (x *MultiUserServerConfig) GetKey() string { return "" } -func (x *MultiUserServerConfig) GetUsers() []*User { +func (x *MultiUserServerConfig) GetUsers() []*protocol.User { if x != nil { return x.Users } @@ -313,30 +314,28 @@ func (x *RelayServerConfig) GetNetwork() []net.Network { return nil } -type User struct { +type Account struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` - Email string `protobuf:"bytes,2,opt,name=email,proto3" json:"email,omitempty"` - Level int32 `protobuf:"varint,3,opt,name=level,proto3" json:"level,omitempty"` + Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` } -func (x *User) Reset() { - *x = User{} +func (x *Account) Reset() { + *x = Account{} mi := &file_proxy_shadowsocks_2022_config_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } -func (x *User) String() string { +func (x *Account) String() string { return protoimpl.X.MessageStringOf(x) } -func (*User) ProtoMessage() {} +func (*Account) ProtoMessage() {} -func (x *User) ProtoReflect() protoreflect.Message { +func (x *Account) ProtoReflect() protoreflect.Message { mi := &file_proxy_shadowsocks_2022_config_proto_msgTypes[4] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -348,32 +347,18 @@ func (x *User) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use User.ProtoReflect.Descriptor instead. -func (*User) Descriptor() ([]byte, []int) { +// Deprecated: Use Account.ProtoReflect.Descriptor instead. +func (*Account) Descriptor() ([]byte, []int) { return file_proxy_shadowsocks_2022_config_proto_rawDescGZIP(), []int{4} } -func (x *User) GetKey() string { +func (x *Account) GetKey() string { if x != nil { return x.Key } return "" } -func (x *User) GetEmail() string { - if x != nil { - return x.Email - } - return "" -} - -func (x *User) GetLevel() int32 { - if x != nil { - return x.Level - } - return 0 -} - type ClientConfig struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -469,76 +454,74 @@ var file_proxy_shadowsocks_2022_config_proto_rawDesc = []byte{ 0x32, 0x32, 0x1a, 0x18, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x6e, 0x65, 0x74, 0x2f, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x18, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x6e, 0x65, 0x74, 0x2f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x98, 0x01, 0x0a, 0x0c, 0x53, 0x65, 0x72, 0x76, 0x65, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1a, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x22, 0x98, 0x01, 0x0a, 0x0c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x43, 0x6f, 0x6e, + 0x66, 0x69, 0x67, 0x12, 0x16, 0x0a, 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x6b, + 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, + 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x6d, + 0x61, 0x69, 0x6c, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x18, 0x04, 0x20, 0x01, + 0x28, 0x05, 0x52, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x12, 0x32, 0x0a, 0x07, 0x6e, 0x65, 0x74, + 0x77, 0x6f, 0x72, 0x6b, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0e, 0x32, 0x18, 0x2e, 0x78, 0x72, 0x61, + 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x4e, 0x65, 0x74, + 0x77, 0x6f, 0x72, 0x6b, 0x52, 0x07, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x22, 0xa7, 0x01, + 0x0a, 0x15, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x16, 0x0a, 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, - 0x79, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, - 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x12, 0x32, 0x0a, - 0x07, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0e, 0x32, 0x18, - 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x6e, 0x65, 0x74, - 0x2e, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x52, 0x07, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, - 0x6b, 0x22, 0xae, 0x01, 0x0a, 0x15, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x55, 0x73, 0x65, 0x72, 0x53, + 0x79, 0x12, 0x30, 0x0a, 0x05, 0x75, 0x73, 0x65, 0x72, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x1a, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x05, 0x75, 0x73, + 0x65, 0x72, 0x73, 0x12, 0x32, 0x0a, 0x07, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x18, 0x04, + 0x20, 0x03, 0x28, 0x0e, 0x32, 0x18, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, + 0x6f, 0x6e, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x52, 0x07, + 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x22, 0x9b, 0x01, 0x0a, 0x10, 0x52, 0x65, 0x6c, 0x61, + 0x79, 0x44, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x10, 0x0a, 0x03, + 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x35, + 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x1b, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x6e, 0x65, + 0x74, 0x2e, 0x49, 0x50, 0x4f, 0x72, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x52, 0x07, 0x61, 0x64, + 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x0d, 0x52, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x6d, 0x61, + 0x69, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x12, + 0x14, 0x0a, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, + 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x22, 0xc4, 0x01, 0x0a, 0x11, 0x52, 0x65, 0x6c, 0x61, 0x79, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x16, 0x0a, 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x37, 0x0a, 0x05, 0x75, 0x73, 0x65, 0x72, 0x73, 0x18, 0x03, - 0x20, 0x03, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x78, - 0x79, 0x2e, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x73, 0x6f, 0x63, 0x6b, 0x73, 0x5f, 0x32, 0x30, - 0x32, 0x32, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x05, 0x75, 0x73, 0x65, 0x72, 0x73, 0x12, 0x32, - 0x0a, 0x07, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0e, 0x32, - 0x18, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x6e, 0x65, - 0x74, 0x2e, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x52, 0x07, 0x6e, 0x65, 0x74, 0x77, 0x6f, - 0x72, 0x6b, 0x22, 0x9b, 0x01, 0x0a, 0x10, 0x52, 0x65, 0x6c, 0x61, 0x79, 0x44, 0x65, 0x73, 0x74, - 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x35, 0x0a, 0x07, 0x61, 0x64, 0x64, - 0x72, 0x65, 0x73, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x78, 0x72, 0x61, - 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x49, 0x50, 0x4f, - 0x72, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, - 0x12, 0x12, 0x0a, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x04, - 0x70, 0x6f, 0x72, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x04, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x65, - 0x76, 0x65, 0x6c, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, - 0x22, 0xc4, 0x01, 0x0a, 0x11, 0x52, 0x65, 0x6c, 0x61, 0x79, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, - 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x16, 0x0a, 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x10, - 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, - 0x12, 0x51, 0x0a, 0x0c, 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, - 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, 0x72, - 0x6f, 0x78, 0x79, 0x2e, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x73, 0x6f, 0x63, 0x6b, 0x73, 0x5f, - 0x32, 0x30, 0x32, 0x32, 0x2e, 0x52, 0x65, 0x6c, 0x61, 0x79, 0x44, 0x65, 0x73, 0x74, 0x69, 0x6e, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0c, 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x73, 0x12, 0x32, 0x0a, 0x07, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x18, 0x04, - 0x20, 0x03, 0x28, 0x0e, 0x32, 0x18, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, - 0x6f, 0x6e, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x52, 0x07, - 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x22, 0x44, 0x0a, 0x04, 0x55, 0x73, 0x65, 0x72, 0x12, - 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, - 0x79, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x22, 0xd6, 0x01, - 0x0a, 0x0c, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x35, - 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x1b, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x6e, 0x65, - 0x74, 0x2e, 0x49, 0x50, 0x4f, 0x72, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x52, 0x07, 0x61, 0x64, - 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x0d, 0x52, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x6d, 0x65, 0x74, - 0x68, 0x6f, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f, - 0x64, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, - 0x6b, 0x65, 0x79, 0x12, 0x20, 0x0a, 0x0c, 0x75, 0x64, 0x70, 0x5f, 0x6f, 0x76, 0x65, 0x72, 0x5f, - 0x74, 0x63, 0x70, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x75, 0x64, 0x70, 0x4f, 0x76, - 0x65, 0x72, 0x54, 0x63, 0x70, 0x12, 0x2f, 0x0a, 0x14, 0x75, 0x64, 0x70, 0x5f, 0x6f, 0x76, 0x65, - 0x72, 0x5f, 0x74, 0x63, 0x70, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x06, 0x20, - 0x01, 0x28, 0x0d, 0x52, 0x11, 0x75, 0x64, 0x70, 0x4f, 0x76, 0x65, 0x72, 0x54, 0x63, 0x70, 0x56, - 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x42, 0x72, 0x0a, 0x1f, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, + 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x51, 0x0a, 0x0c, 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x73, - 0x6f, 0x63, 0x6b, 0x73, 0x5f, 0x32, 0x30, 0x32, 0x32, 0x50, 0x01, 0x5a, 0x30, 0x67, 0x69, 0x74, - 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, - 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x73, 0x68, 0x61, - 0x64, 0x6f, 0x77, 0x73, 0x6f, 0x63, 0x6b, 0x73, 0x5f, 0x32, 0x30, 0x32, 0x32, 0xaa, 0x02, 0x1a, - 0x58, 0x72, 0x61, 0x79, 0x2e, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x53, 0x68, 0x61, 0x64, 0x6f, - 0x77, 0x73, 0x6f, 0x63, 0x6b, 0x73, 0x32, 0x30, 0x32, 0x32, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x33, + 0x6f, 0x63, 0x6b, 0x73, 0x5f, 0x32, 0x30, 0x32, 0x32, 0x2e, 0x52, 0x65, 0x6c, 0x61, 0x79, 0x44, + 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0c, 0x64, 0x65, 0x73, 0x74, + 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x32, 0x0a, 0x07, 0x6e, 0x65, 0x74, 0x77, + 0x6f, 0x72, 0x6b, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0e, 0x32, 0x18, 0x2e, 0x78, 0x72, 0x61, 0x79, + 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x4e, 0x65, 0x74, 0x77, + 0x6f, 0x72, 0x6b, 0x52, 0x07, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x22, 0x1b, 0x0a, 0x07, + 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x22, 0xd6, 0x01, 0x0a, 0x0c, 0x43, 0x6c, + 0x69, 0x65, 0x6e, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x35, 0x0a, 0x07, 0x61, 0x64, + 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x78, 0x72, + 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x49, 0x50, + 0x4f, 0x72, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, + 0x73, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, + 0x04, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x10, 0x0a, + 0x03, 0x6b, 0x65, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, + 0x20, 0x0a, 0x0c, 0x75, 0x64, 0x70, 0x5f, 0x6f, 0x76, 0x65, 0x72, 0x5f, 0x74, 0x63, 0x70, 0x18, + 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x75, 0x64, 0x70, 0x4f, 0x76, 0x65, 0x72, 0x54, 0x63, + 0x70, 0x12, 0x2f, 0x0a, 0x14, 0x75, 0x64, 0x70, 0x5f, 0x6f, 0x76, 0x65, 0x72, 0x5f, 0x74, 0x63, + 0x70, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0d, 0x52, + 0x11, 0x75, 0x64, 0x70, 0x4f, 0x76, 0x65, 0x72, 0x54, 0x63, 0x70, 0x56, 0x65, 0x72, 0x73, 0x69, + 0x6f, 0x6e, 0x42, 0x72, 0x0a, 0x1f, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, + 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x73, 0x6f, 0x63, 0x6b, 0x73, + 0x5f, 0x32, 0x30, 0x32, 0x32, 0x50, 0x01, 0x5a, 0x30, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, + 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, + 0x72, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x73, + 0x6f, 0x63, 0x6b, 0x73, 0x5f, 0x32, 0x30, 0x32, 0x32, 0xaa, 0x02, 0x1a, 0x58, 0x72, 0x61, 0x79, + 0x2e, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x53, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x73, 0x6f, 0x63, + 0x6b, 0x73, 0x32, 0x30, 0x32, 0x32, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -559,19 +542,20 @@ var file_proxy_shadowsocks_2022_config_proto_goTypes = []any{ (*MultiUserServerConfig)(nil), // 1: xray.proxy.shadowsocks_2022.MultiUserServerConfig (*RelayDestination)(nil), // 2: xray.proxy.shadowsocks_2022.RelayDestination (*RelayServerConfig)(nil), // 3: xray.proxy.shadowsocks_2022.RelayServerConfig - (*User)(nil), // 4: xray.proxy.shadowsocks_2022.User + (*Account)(nil), // 4: xray.proxy.shadowsocks_2022.Account (*ClientConfig)(nil), // 5: xray.proxy.shadowsocks_2022.ClientConfig (net.Network)(0), // 6: xray.common.net.Network - (*net.IPOrDomain)(nil), // 7: xray.common.net.IPOrDomain + (*protocol.User)(nil), // 7: xray.common.protocol.User + (*net.IPOrDomain)(nil), // 8: xray.common.net.IPOrDomain } var file_proxy_shadowsocks_2022_config_proto_depIdxs = []int32{ 6, // 0: xray.proxy.shadowsocks_2022.ServerConfig.network:type_name -> xray.common.net.Network - 4, // 1: xray.proxy.shadowsocks_2022.MultiUserServerConfig.users:type_name -> xray.proxy.shadowsocks_2022.User + 7, // 1: xray.proxy.shadowsocks_2022.MultiUserServerConfig.users:type_name -> xray.common.protocol.User 6, // 2: xray.proxy.shadowsocks_2022.MultiUserServerConfig.network:type_name -> xray.common.net.Network - 7, // 3: xray.proxy.shadowsocks_2022.RelayDestination.address:type_name -> xray.common.net.IPOrDomain + 8, // 3: xray.proxy.shadowsocks_2022.RelayDestination.address:type_name -> xray.common.net.IPOrDomain 2, // 4: xray.proxy.shadowsocks_2022.RelayServerConfig.destinations:type_name -> xray.proxy.shadowsocks_2022.RelayDestination 6, // 5: xray.proxy.shadowsocks_2022.RelayServerConfig.network:type_name -> xray.common.net.Network - 7, // 6: xray.proxy.shadowsocks_2022.ClientConfig.address:type_name -> xray.common.net.IPOrDomain + 8, // 6: xray.proxy.shadowsocks_2022.ClientConfig.address:type_name -> xray.common.net.IPOrDomain 7, // [7:7] is the sub-list for method output_type 7, // [7:7] is the sub-list for method input_type 7, // [7:7] is the sub-list for extension type_name diff --git a/xray-core/proxy/shadowsocks_2022/config.proto b/xray-core/proxy/shadowsocks_2022/config.proto index 605409913c..1400664868 100644 --- a/xray-core/proxy/shadowsocks_2022/config.proto +++ b/xray-core/proxy/shadowsocks_2022/config.proto @@ -8,6 +8,7 @@ option java_multiple_files = true; import "common/net/network.proto"; import "common/net/address.proto"; +import "common/protocol/user.proto"; message ServerConfig { string method = 1; @@ -20,7 +21,7 @@ message ServerConfig { message MultiUserServerConfig { string method = 1; string key = 2; - repeated User users = 3; + repeated xray.common.protocol.User users = 3; repeated xray.common.net.Network network = 4; } @@ -39,10 +40,8 @@ message RelayServerConfig { repeated xray.common.net.Network network = 4; } -message User { +message Account { string key = 1; - string email = 2; - int32 level = 3; } message ClientConfig { diff --git a/xray-core/proxy/shadowsocks_2022/inbound_multi.go b/xray-core/proxy/shadowsocks_2022/inbound_multi.go index 8cb2d65ebb..20b851398c 100644 --- a/xray-core/proxy/shadowsocks_2022/inbound_multi.go +++ b/xray-core/proxy/shadowsocks_2022/inbound_multi.go @@ -37,7 +37,7 @@ func init() { type MultiUserInbound struct { sync.Mutex networks []net.Network - users []*User + users []*protocol.MemoryUser service *shadowaead_2022.MultiService[int] } @@ -49,9 +49,22 @@ func NewMultiServer(ctx context.Context, config *MultiUserServerConfig) (*MultiU net.Network_UDP, } } + memUsers := []*protocol.MemoryUser{} + for i, user := range config.Users { + if user.Email == "" { + u := uuid.New() + user.Email = "unnamed-user-" + strconv.Itoa(i) + "-" + u.String() + } + u, err := user.ToMemoryUser() + if err != nil { + return nil, errors.New("failed to get shadowsocks user").Base(err).AtError() + } + memUsers = append(memUsers, u) + } + inbound := &MultiUserInbound{ networks: networks, - users: config.Users, + users: memUsers, } if config.Key == "" { return nil, errors.New("missing key") @@ -64,16 +77,9 @@ func NewMultiServer(ctx context.Context, config *MultiUserServerConfig) (*MultiU if err != nil { return nil, errors.New("create service").Base(err) } - - for i, user := range config.Users { - if user.Email == "" { - u := uuid.New() - user.Email = "unnamed-user-" + strconv.Itoa(i) + "-" + u.String() - } - } err = service.UpdateUsersWithPasswords( - C.MapIndexed(config.Users, func(index int, it *User) int { return index }), - C.Map(config.Users, func(it *User) string { return it.Key }), + C.MapIndexed(memUsers, func(index int, it *protocol.MemoryUser) int { return index }), + C.Map(memUsers, func(it *protocol.MemoryUser) string { return it.Account.(*MemoryAccount).Key }), ) if err != nil { return nil, errors.New("create service").Base(err) @@ -88,25 +94,20 @@ func (i *MultiUserInbound) AddUser(ctx context.Context, u *protocol.MemoryUser) i.Lock() defer i.Unlock() - account := u.Account.(*MemoryAccount) - if account.Email != "" { + if u.Email != "" { for idx := range i.users { - if i.users[idx].Email == account.Email { - return errors.New("User ", account.Email, " already exists.") + if i.users[idx].Email == u.Email { + return errors.New("User ", u.Email, " already exists.") } } } - i.users = append(i.users, &User{ - Key: account.Key, - Email: account.Email, - Level: account.Level, - }) + i.users = append(i.users, u) // sync to multi service // Considering implements shadowsocks2022 in xray-core may have better performance. i.service.UpdateUsersWithPasswords( - C.MapIndexed(i.users, func(index int, it *User) int { return index }), - C.Map(i.users, func(it *User) string { return it.Key }), + C.MapIndexed(i.users, func(index int, it *protocol.MemoryUser) int { return index }), + C.Map(i.users, func(it *protocol.MemoryUser) string { return it.Account.(*MemoryAccount).Key }), ) return nil @@ -142,13 +143,46 @@ func (i *MultiUserInbound) RemoveUser(ctx context.Context, email string) error { // sync to multi service // Considering implements shadowsocks2022 in xray-core may have better performance. i.service.UpdateUsersWithPasswords( - C.MapIndexed(i.users, func(index int, it *User) int { return index }), - C.Map(i.users, func(it *User) string { return it.Key }), + C.MapIndexed(i.users, func(index int, it *protocol.MemoryUser) int { return index }), + C.Map(i.users, func(it *protocol.MemoryUser) string { return it.Account.(*MemoryAccount).Key }), ) return nil } +// GetUser implements proxy.UserManager.GetUser(). +func (i *MultiUserInbound) GetUser(ctx context.Context, email string) *protocol.MemoryUser { + if email == "" { + return nil + } + + i.Lock() + defer i.Unlock() + + for _, u := range i.users { + if strings.EqualFold(u.Email, email) { + return u + } + } + return nil +} + +// GetUsers implements proxy.UserManager.GetUsers(). +func (i *MultiUserInbound) GetUsers(ctx context.Context) []*protocol.MemoryUser { + i.Lock() + defer i.Unlock() + dst := make([]*protocol.MemoryUser, len(i.users)) + copy(dst, i.users) + return dst +} + +// GetUsersCount implements proxy.UserManager.GetUsersCount(). +func (i *MultiUserInbound) GetUsersCount(context.Context) int64 { + i.Lock() + defer i.Unlock() + return int64(len(i.users)) +} + func (i *MultiUserInbound) Network() []net.Network { return i.networks } @@ -194,10 +228,7 @@ func (i *MultiUserInbound) NewConnection(ctx context.Context, conn net.Conn, met inbound := session.InboundFromContext(ctx) userInt, _ := A.UserFromContext[int](ctx) user := i.users[userInt] - inbound.User = &protocol.MemoryUser{ - Email: user.Email, - Level: uint32(user.Level), - } + inbound.User = user ctx = log.ContextWithAccessMessage(ctx, &log.AccessMessage{ From: metadata.Source, To: metadata.Destination, @@ -222,10 +253,7 @@ func (i *MultiUserInbound) NewPacketConnection(ctx context.Context, conn N.Packe inbound := session.InboundFromContext(ctx) userInt, _ := A.UserFromContext[int](ctx) user := i.users[userInt] - inbound.User = &protocol.MemoryUser{ - Email: user.Email, - Level: uint32(user.Level), - } + inbound.User = user ctx = log.ContextWithAccessMessage(ctx, &log.AccessMessage{ From: metadata.Source, To: metadata.Destination, diff --git a/xray-core/proxy/socks/config.go b/xray-core/proxy/socks/config.go index 3b162abe91..e8aa328adf 100644 --- a/xray-core/proxy/socks/config.go +++ b/xray-core/proxy/socks/config.go @@ -1,6 +1,10 @@ package socks -import "github.com/xtls/xray-core/common/protocol" +import ( + "google.golang.org/protobuf/proto" + + "github.com/xtls/xray-core/common/protocol" +) func (a *Account) Equals(another protocol.Account) bool { if account, ok := another.(*Account); ok { @@ -9,6 +13,10 @@ func (a *Account) Equals(another protocol.Account) bool { return false } +func (a *Account) ToProto() proto.Message { + return a +} + func (a *Account) AsAccount() (protocol.Account, error) { return a, nil } diff --git a/xray-core/proxy/trojan/config.go b/xray-core/proxy/trojan/config.go index a02dfe98af..b7591996f4 100644 --- a/xray-core/proxy/trojan/config.go +++ b/xray-core/proxy/trojan/config.go @@ -3,7 +3,8 @@ package trojan import ( "crypto/sha256" "encoding/hex" - fmt "fmt" + "fmt" + "google.golang.org/protobuf/proto" "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/protocol" @@ -33,6 +34,12 @@ func (a *MemoryAccount) Equals(another protocol.Account) bool { return false } +func (a *MemoryAccount) ToProto() proto.Message { + return &Account{ + Password: a.Password, + } +} + func hexSha224(password string) []byte { buf := make([]byte, 56) hash := sha256.New224() diff --git a/xray-core/proxy/trojan/server.go b/xray-core/proxy/trojan/server.go index 6110eec0a4..20ac1fd177 100644 --- a/xray-core/proxy/trojan/server.go +++ b/xray-core/proxy/trojan/server.go @@ -125,6 +125,21 @@ func (s *Server) RemoveUser(ctx context.Context, e string) error { return s.validator.Del(e) } +// GetUser implements proxy.UserManager.GetUser(). +func (s *Server) GetUser(ctx context.Context, email string) *protocol.MemoryUser { + return s.validator.GetByEmail(email) +} + +// GetUsers implements proxy.UserManager.GetUsers(). +func (s *Server) GetUsers(ctx context.Context) []*protocol.MemoryUser { + return s.validator.GetAll() +} + +// GetUsersCount implements proxy.UserManager.GetUsersCount(). +func (s *Server) GetUsersCount(context.Context) int64 { + return s.validator.GetCount() +} + // Network implements proxy.Inbound.Network(). func (s *Server) Network() []net.Network { return []net.Network{net.Network_TCP, net.Network_UNIX} diff --git a/xray-core/proxy/trojan/validator.go b/xray-core/proxy/trojan/validator.go index 4ffe41a1b0..fb3499fac0 100644 --- a/xray-core/proxy/trojan/validator.go +++ b/xray-core/proxy/trojan/validator.go @@ -50,3 +50,33 @@ func (v *Validator) Get(hash string) *protocol.MemoryUser { } return nil } + + +// Get a trojan user with hashed key, nil if user doesn't exist. +func (v *Validator) GetByEmail(email string) *protocol.MemoryUser { + u, _ := v.email.Load(email) + if u != nil { + return u.(*protocol.MemoryUser) + } + return nil +} + +// Get all users +func (v *Validator) GetAll() []*protocol.MemoryUser { + var u = make([]*protocol.MemoryUser, 0, 100) + v.email.Range(func(key, value interface{}) bool { + u = append(u, value.(*protocol.MemoryUser)) + return true + }) + return u +} + +// Get users count +func (v *Validator) GetCount() int64 { + var c int64 = 0 + v.email.Range(func(key, value interface{}) bool { + c++ + return true + }) + return c +} diff --git a/xray-core/proxy/vless/account.go b/xray-core/proxy/vless/account.go index 5349a3bd7b..798b93f4b7 100644 --- a/xray-core/proxy/vless/account.go +++ b/xray-core/proxy/vless/account.go @@ -1,6 +1,8 @@ package vless import ( + "google.golang.org/protobuf/proto" + "github.com/xtls/xray-core/common/errors" "github.com/xtls/xray-core/common/protocol" "github.com/xtls/xray-core/common/uuid" @@ -37,3 +39,11 @@ func (a *MemoryAccount) Equals(account protocol.Account) bool { } return a.ID.Equals(vlessAccount.ID) } + +func (a *MemoryAccount) ToProto() proto.Message { + return &Account{ + Id: a.ID.String(), + Flow: a.Flow, + Encryption: a.Encryption, + } +} diff --git a/xray-core/proxy/vless/inbound/inbound.go b/xray-core/proxy/vless/inbound/inbound.go index f443007dd6..48849eb27a 100644 --- a/xray-core/proxy/vless/inbound/inbound.go +++ b/xray-core/proxy/vless/inbound/inbound.go @@ -172,6 +172,21 @@ func (h *Handler) RemoveUser(ctx context.Context, e string) error { return h.validator.Del(e) } +// GetUser implements proxy.UserManager.GetUser(). +func (h *Handler) GetUser(ctx context.Context, email string) *protocol.MemoryUser { + return h.validator.GetByEmail(email) +} + +// GetUsers implements proxy.UserManager.GetUsers(). +func (h *Handler) GetUsers(ctx context.Context) []*protocol.MemoryUser { + return h.validator.GetAll() +} + +// GetUsersCount implements proxy.UserManager.GetUsersCount(). +func (h *Handler) GetUsersCount(context.Context) int64 { + return h.validator.GetCount() +} + // Network implements proxy.Inbound.Network(). func (*Handler) Network() []net.Network { return []net.Network{net.Network_TCP, net.Network_UNIX} diff --git a/xray-core/proxy/vless/validator.go b/xray-core/proxy/vless/validator.go index 596cb62fd3..ddac6cbbe7 100644 --- a/xray-core/proxy/vless/validator.go +++ b/xray-core/proxy/vless/validator.go @@ -13,6 +13,9 @@ type Validator interface { Get(id uuid.UUID) *protocol.MemoryUser Add(u *protocol.MemoryUser) error Del(email string) error + GetByEmail(email string) *protocol.MemoryUser + GetAll() []*protocol.MemoryUser + GetCount() int64 } // MemoryValidator stores valid VLESS users. @@ -57,3 +60,32 @@ func (v *MemoryValidator) Get(id uuid.UUID) *protocol.MemoryUser { } return nil } + +// Get a VLESS user with email, nil if user doesn't exist. +func (v *MemoryValidator) GetByEmail(email string) *protocol.MemoryUser { + u, _ := v.email.Load(email) + if u != nil { + return u.(*protocol.MemoryUser) + } + return nil +} + +// Get all users +func (v *MemoryValidator) GetAll() []*protocol.MemoryUser { + var u = make([]*protocol.MemoryUser, 0, 100) + v.email.Range(func(key, value interface{}) bool { + u = append(u, value.(*protocol.MemoryUser)) + return true + }) + return u +} + +// Get users count +func (v *MemoryValidator) GetCount() int64 { + var c int64 = 0 + v.email.Range(func(key, value interface{}) bool { + c++ + return true + }) + return c +} diff --git a/xray-core/proxy/vmess/account.go b/xray-core/proxy/vmess/account.go index 5ece7a57c7..d063f9f5d7 100644 --- a/xray-core/proxy/vmess/account.go +++ b/xray-core/proxy/vmess/account.go @@ -1,6 +1,7 @@ package vmess import ( + "google.golang.org/protobuf/proto" "strings" "github.com/xtls/xray-core/common/errors" @@ -28,6 +29,21 @@ func (a *MemoryAccount) Equals(account protocol.Account) bool { return a.ID.Equals(vmessAccount.ID) } +func (a *MemoryAccount) ToProto() proto.Message { + var test = "" + if a.AuthenticatedLengthExperiment { + test = "AuthenticatedLength|" + } + if a.NoTerminationSignal { + test = test + "NoTerminationSignal" + } + return &Account{ + Id: a.ID.String(), + TestsEnabled: test, + SecuritySettings: &protocol.SecurityConfig{Type: a.Security}, + } +} + // AsAccount implements protocol.Account. func (a *Account) AsAccount() (protocol.Account, error) { id, err := uuid.ParseString(a.Id) diff --git a/xray-core/proxy/vmess/inbound/inbound.go b/xray-core/proxy/vmess/inbound/inbound.go index 3102414d15..28b560d834 100644 --- a/xray-core/proxy/vmess/inbound/inbound.go +++ b/xray-core/proxy/vmess/inbound/inbound.go @@ -56,7 +56,7 @@ func (v *userByEmail) Add(u *protocol.MemoryUser) bool { return v.addNoLock(u) } -func (v *userByEmail) Get(email string) (*protocol.MemoryUser, bool) { +func (v *userByEmail) GetOrGenerate(email string) (*protocol.MemoryUser, bool) { email = strings.ToLower(email) v.Lock() @@ -80,6 +80,13 @@ func (v *userByEmail) Get(email string) (*protocol.MemoryUser, bool) { return user, found } +func (v *userByEmail) Get(email string) *protocol.MemoryUser { + email = strings.ToLower(email) + v.Lock() + defer v.Unlock() + return v.cache[email] +} + func (v *userByEmail) Remove(email string) bool { email = strings.ToLower(email) @@ -141,14 +148,26 @@ func (*Handler) Network() []net.Network { return []net.Network{net.Network_TCP, net.Network_UNIX} } -func (h *Handler) GetUser(email string) *protocol.MemoryUser { - user, existing := h.usersByEmail.Get(email) +func (h *Handler) GetOrGenerateUser(email string) *protocol.MemoryUser { + user, existing := h.usersByEmail.GetOrGenerate(email) if !existing { h.clients.Add(user) } return user } +func (h *Handler) GetUser(ctx context.Context, email string) *protocol.MemoryUser { + return h.usersByEmail.Get(email) +} + +func (h *Handler) GetUsers(ctx context.Context) []*protocol.MemoryUser { + return h.clients.GetUsers() +} + +func (h *Handler) GetUsersCount(context.Context) int64 { + return h.clients.GetCount() +} + func (h *Handler) AddUser(ctx context.Context, user *protocol.MemoryUser) error { if len(user.Email) > 0 && !h.usersByEmail.Add(user) { return errors.New("User ", user.Email, " already exists.") @@ -321,7 +340,7 @@ func (h *Handler) generateCommand(ctx context.Context, request *protocol.Request } errors.LogDebug(ctx, "pick detour handler for port ", port, " for ", availableMin, " minutes.") - user := inboundHandler.GetUser(request.User.Email) + user := inboundHandler.GetOrGenerateUser(request.User.Email) if user == nil { return nil } diff --git a/xray-core/proxy/vmess/validator.go b/xray-core/proxy/vmess/validator.go index 43ced00638..b3a82f309b 100644 --- a/xray-core/proxy/vmess/validator.go +++ b/xray-core/proxy/vmess/validator.go @@ -56,6 +56,20 @@ func (v *TimedUserValidator) Add(u *protocol.MemoryUser) error { return nil } +func (v *TimedUserValidator) GetUsers() []*protocol.MemoryUser { + v.Lock() + defer v.Unlock() + dst := make([]*protocol.MemoryUser, len(v.users)) + copy(dst, v.users) + return dst +} + +func (v *TimedUserValidator) GetCount() int64 { + v.Lock() + defer v.Unlock() + return int64(len(v.users)) +} + func (v *TimedUserValidator) GetAEAD(userHash []byte) (*protocol.MemoryUser, bool, error) { v.RLock() defer v.RUnlock() diff --git a/xray-core/proxy/wireguard/config.go b/xray-core/proxy/wireguard/config.go index ac095c194d..cbaa670b74 100644 --- a/xray-core/proxy/wireguard/config.go +++ b/xray-core/proxy/wireguard/config.go @@ -31,13 +31,13 @@ func (c *DeviceConfig) fallbackIP6() bool { } func (c *DeviceConfig) createTun() tunCreator { - // System TUN not support promiscuous mode yet, don't use it when work in inbound mode - // See tun_linux.go createKernelTun() if !c.IsClient { + // See tun_linux.go createKernelTun() + errors.LogWarning(context.Background(), "Using gVisor TUN. WG inbound doesn't support kernel TUN yet.") return createGVisorTun } if c.NoKernelTun { - errors.LogWarning(context.Background(), "Using gVisor TUN.") + errors.LogWarning(context.Background(), "Using gVisor TUN. NoKernelTun is set to true.") return createGVisorTun } kernelTunSupported, err := KernelTunSupported() diff --git a/xray-core/transport/internet/memory_settings.go b/xray-core/transport/internet/memory_settings.go index e1625f37b9..5add530c54 100644 --- a/xray-core/transport/internet/memory_settings.go +++ b/xray-core/transport/internet/memory_settings.go @@ -7,6 +7,7 @@ type MemoryStreamConfig struct { SecurityType string SecuritySettings interface{} SocketSettings *SocketConfig + DownloadSettings *MemoryStreamConfig } // ToMemoryStreamConfig converts a StreamConfig to MemoryStreamConfig. It returns a default non-nil MemoryStreamConfig for nil input. diff --git a/xray-core/transport/internet/splithttp/dialer.go b/xray-core/transport/internet/splithttp/dialer.go index c43783ec0d..43ba0a46a0 100644 --- a/xray-core/transport/internet/splithttp/dialer.go +++ b/xray-core/transport/internet/splithttp/dialer.go @@ -252,18 +252,24 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me requestURL.Path = transportConfiguration.GetNormalizedPath() + sessionIdUuid.String() requestURL.RawQuery = transportConfiguration.GetNormalizedQuery() - httpClient, muxResource := getHTTPClient(ctx, dest, streamSettings) + httpClient, muxRes := getHTTPClient(ctx, dest, streamSettings) var httpClient2 DialerClient + var muxRes2 *muxResource var requestURL2 url.URL if transportConfiguration.DownloadSettings != nil { + globalDialerAccess.Lock() + if streamSettings.DownloadSettings == nil { + streamSettings.DownloadSettings = common.Must2(internet.ToMemoryStreamConfig(transportConfiguration.DownloadSettings)).(*internet.MemoryStreamConfig) + } + globalDialerAccess.Unlock() + memory2 := streamSettings.DownloadSettings dest2 := net.Destination{ Address: transportConfiguration.DownloadSettings.Address.AsAddress(), // just panic Port: net.Port(transportConfiguration.DownloadSettings.Port), Network: net.Network_TCP, } - memory2 := common.Must2(internet.ToMemoryStreamConfig(transportConfiguration.DownloadSettings)).(*internet.MemoryStreamConfig) - httpClient2, _ = getHTTPClient(ctx, dest2, memory2) // no multiplex + httpClient2, muxRes2 = getHTTPClient(ctx, dest2, memory2) if tls.ConfigFromStreamSettings(memory2) != nil || reality.ConfigFromStreamSettings(memory2) != nil { requestURL2.Scheme = "https" } else { @@ -284,13 +290,19 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me // uploadWriter wrapper, exact size limits can be enforced uploadPipeReader, uploadPipeWriter := pipe.New(pipe.WithSizeLimit(maxUploadSize - 1)) - if muxResource != nil { - muxResource.OpenRequests.Add(1) + if muxRes != nil { + muxRes.OpenRequests.Add(1) + } + if muxRes2 != nil { + muxRes2.OpenRequests.Add(1) } go func() { - if muxResource != nil { - defer muxResource.OpenRequests.Add(-1) + if muxRes != nil { + defer muxRes.OpenRequests.Add(-1) + } + if muxRes2 != nil { + defer muxRes2.OpenRequests.Add(-1) } requestsLimiter := semaphore.New(int(scMaxConcurrentPosts.roll())) diff --git a/yt-dlp/test/test_traversal.py b/yt-dlp/test/test_traversal.py index f1d123bd6e..cc0228d270 100644 --- a/yt-dlp/test/test_traversal.py +++ b/yt-dlp/test/test_traversal.py @@ -9,13 +9,17 @@ from yt_dlp.utils import ( determine_ext, dict_get, int_or_none, + join_nonempty, str_or_none, ) from yt_dlp.utils.traversal import ( + find_element, + find_elements, require, subs_list_to_dict, traverse_obj, trim_str, + unpack, ) _TEST_DATA = { @@ -35,6 +39,14 @@ _TEST_DATA = { 'dict': {}, } +_TEST_HTML = ''' +
1
+
2
+
3
+

4

+

5

+''' + class TestTraversal: def test_traversal_base(self): @@ -510,6 +522,59 @@ class TestTraversalHelpers: assert trim_str(start='abc', end='abc')('abc') == '' assert trim_str(start='', end='')('abc') == 'abc' + def test_unpack(self): + assert unpack(lambda *x: ''.join(map(str, x)))([1, 2, 3]) == '123' + assert unpack(join_nonempty)([1, 2, 3]) == '1-2-3' + assert unpack(join_nonempty(delim=' '))([1, 2, 3]) == '1 2 3' + with pytest.raises(TypeError): + unpack(join_nonempty)() + with pytest.raises(TypeError): + unpack() + + def test_find_element(self): + for improper_kwargs in [ + dict(attr='data-id'), + dict(value='y'), + dict(attr='data-id', value='y', cls='a'), + dict(attr='data-id', value='y', id='x'), + dict(cls='a', id='x'), + dict(cls='a', tag='p'), + dict(cls='[ab]', regex=True), + ]: + with pytest.raises(AssertionError): + find_element(**improper_kwargs)(_TEST_HTML) + + assert find_element(cls='a')(_TEST_HTML) == '1' + assert find_element(cls='a', html=True)(_TEST_HTML) == '
1
' + assert find_element(id='x')(_TEST_HTML) == '2' + assert find_element(id='[ex]')(_TEST_HTML) is None + assert find_element(id='[ex]', regex=True)(_TEST_HTML) == '2' + assert find_element(id='x', html=True)(_TEST_HTML) == '
2
' + assert find_element(attr='data-id', value='y')(_TEST_HTML) == '3' + assert find_element(attr='data-id', value='y(?:es)?')(_TEST_HTML) is None + assert find_element(attr='data-id', value='y(?:es)?', regex=True)(_TEST_HTML) == '3' + assert find_element( + attr='data-id', value='y', html=True)(_TEST_HTML) == '
3
' + + def test_find_elements(self): + for improper_kwargs in [ + dict(tag='p'), + dict(attr='data-id'), + dict(value='y'), + dict(attr='data-id', value='y', cls='a'), + dict(cls='a', tag='div'), + dict(cls='[ab]', regex=True), + ]: + with pytest.raises(AssertionError): + find_elements(**improper_kwargs)(_TEST_HTML) + + assert find_elements(cls='a')(_TEST_HTML) == ['1', '2', '4'] + assert find_elements(cls='a', html=True)(_TEST_HTML) == [ + '
1
', '
2
', '

4

'] + assert find_elements(attr='custom', value='z')(_TEST_HTML) == ['2', '3'] + assert find_elements(attr='custom', value='[ez]')(_TEST_HTML) == [] + assert find_elements(attr='custom', value='[ez]', regex=True)(_TEST_HTML) == ['2', '3', '5'] + class TestDictGet: def test_dict_get(self): diff --git a/yt-dlp/yt_dlp/extractor/_extractors.py b/yt-dlp/yt_dlp/extractor/_extractors.py index 13b5633d46..ff5ddb2493 100644 --- a/yt-dlp/yt_dlp/extractor/_extractors.py +++ b/yt-dlp/yt_dlp/extractor/_extractors.py @@ -278,6 +278,7 @@ from .bleacherreport import ( from .blerp import BlerpIE from .blogger import BloggerIE from .bloomberg import BloombergIE +from .bluesky import BlueskyIE from .bokecc import BokeCCIE from .bongacams import BongaCamsIE from .boosty import BoostyIE diff --git a/yt-dlp/yt_dlp/extractor/bluesky.py b/yt-dlp/yt_dlp/extractor/bluesky.py new file mode 100644 index 0000000000..42edd1107a --- /dev/null +++ b/yt-dlp/yt_dlp/extractor/bluesky.py @@ -0,0 +1,388 @@ +from .common import InfoExtractor +from ..utils import ( + ExtractorError, + format_field, + int_or_none, + mimetype2ext, + orderedSet, + parse_iso8601, + truncate_string, + update_url_query, + url_basename, + url_or_none, + variadic, +) +from ..utils.traversal import traverse_obj + + +class BlueskyIE(InfoExtractor): + _VALID_URL = [ + r'https?://(?:www\.)?(?:bsky\.app|main\.bsky\.dev)/profile/(?P[\w.:%-]+)/post/(?P\w+)', + r'at://(?P[\w.:%-]+)/app\.bsky\.feed\.post/(?P\w+)', + ] + _TESTS = [{ + 'url': 'https://bsky.app/profile/blu3blue.bsky.social/post/3l4omssdl632g', + 'md5': '375539c1930ab05d15585ed772ab54fd', + 'info_dict': { + 'id': '3l4omssdl632g', + 'ext': 'mp4', + 'uploader': 'Blu3Blu3Lilith', + 'uploader_id': 'blu3blue.bsky.social', + 'uploader_url': 'https://bsky.app/profile/blu3blue.bsky.social', + 'channel_id': 'did:plc:pzdr5ylumf7vmvwasrpr5bf2', + 'channel_url': 'https://bsky.app/profile/did:plc:pzdr5ylumf7vmvwasrpr5bf2', + 'thumbnail': r're:https://video.bsky.app/watch/.*\.jpg$', + 'title': 'OMG WE HAVE VIDEOS NOW', + 'description': 'OMG WE HAVE VIDEOS NOW', + 'upload_date': '20240921', + 'timestamp': 1726940605, + 'like_count': int, + 'repost_count': int, + 'comment_count': int, + 'tags': [], + }, + }, { + 'url': 'https://bsky.app/profile/bsky.app/post/3l3vgf77uco2g', + 'md5': 'b9e344fdbce9f2852c668a97efefb105', + 'info_dict': { + 'id': '3l3vgf77uco2g', + 'ext': 'mp4', + 'uploader': 'Bluesky', + 'uploader_id': 'bsky.app', + 'uploader_url': 'https://bsky.app/profile/bsky.app', + 'channel_id': 'did:plc:z72i7hdynmk6r22z27h6tvur', + 'channel_url': 'https://bsky.app/profile/did:plc:z72i7hdynmk6r22z27h6tvur', + 'thumbnail': r're:https://video.bsky.app/watch/.*\.jpg$', + 'title': 'Bluesky now has video! Update your app to versi...', + 'alt_title': 'Bluesky video feature announcement', + 'description': r're:(?s)Bluesky now has video! .{239}', + 'upload_date': '20240911', + 'timestamp': 1726074716, + 'like_count': int, + 'repost_count': int, + 'comment_count': int, + 'tags': [], + 'subtitles': { + 'en': 'mincount:1', + }, + }, + }, { + 'url': 'https://main.bsky.dev/profile/souris.moe/post/3l4qhp7bcs52c', + 'md5': '5f2df8c200b5633eb7fb2c984d29772f', + 'info_dict': { + 'id': '3l4qhp7bcs52c', + 'ext': 'mp4', + 'uploader': 'souris', + 'uploader_id': 'souris.moe', + 'uploader_url': 'https://bsky.app/profile/souris.moe', + 'channel_id': 'did:plc:tj7g244gl5v6ai6cm4f4wlqp', + 'channel_url': 'https://bsky.app/profile/did:plc:tj7g244gl5v6ai6cm4f4wlqp', + 'thumbnail': r're:https://video.bsky.app/watch/.*\.jpg$', + 'title': 'Bluesky video #3l4qhp7bcs52c', + 'upload_date': '20240922', + 'timestamp': 1727003838, + 'like_count': int, + 'repost_count': int, + 'comment_count': int, + 'tags': [], + }, + }, { + 'url': 'https://bsky.app/profile/de1.pds.tentacle.expert/post/3l3w4tnezek2e', + 'md5': '1af9c7fda061cf7593bbffca89e43d1c', + 'info_dict': { + 'id': '3l3w4tnezek2e', + 'ext': 'mp4', + 'uploader': 'clean', + 'uploader_id': 'de1.pds.tentacle.expert', + 'uploader_url': 'https://bsky.app/profile/de1.pds.tentacle.expert', + 'channel_id': 'did:web:de1.tentacle.expert', + 'channel_url': 'https://bsky.app/profile/did:web:de1.tentacle.expert', + 'thumbnail': r're:https://video.bsky.app/watch/.*\.jpg$', + 'title': 'Bluesky video #3l3w4tnezek2e', + 'upload_date': '20240911', + 'timestamp': 1726098823, + 'like_count': int, + 'repost_count': int, + 'comment_count': int, + 'tags': [], + }, + }, { + 'url': 'https://bsky.app/profile/yunayuispink.bsky.social/post/3l7gqcfes742o', + 'info_dict': { + 'id': 'XxK3t_5V3ao', + 'ext': 'mp4', + 'uploader': 'yunayu', + 'uploader_id': '@yunayuispink', + 'uploader_url': 'https://www.youtube.com/@yunayuispink', + 'channel': 'yunayu', + 'channel_id': 'UCPLvXnHa7lTyNoR_dGsU14w', + 'channel_url': 'https://www.youtube.com/channel/UCPLvXnHa7lTyNoR_dGsU14w', + 'thumbnail': 'https://i.ytimg.com/vi_webp/XxK3t_5V3ao/maxresdefault.webp', + 'description': r're:Have a good goodx10000day', + 'title': '5min vs 5hours drawing', + 'availability': 'public', + 'live_status': 'not_live', + 'playable_in_embed': True, + 'upload_date': '20241026', + 'timestamp': 1729967784, + 'duration': 321, + 'age_limit': 0, + 'like_count': int, + 'view_count': int, + 'comment_count': int, + 'channel_follower_count': int, + 'categories': ['Entertainment'], + 'tags': [], + }, + 'add_ie': ['Youtube'], + }, { + 'url': 'https://bsky.app/profile/endshark.bsky.social/post/3jzxjkcemae2m', + 'info_dict': { + 'id': '222792849', + 'ext': 'mp3', + 'uploader': 'LASERBAT', + 'uploader_id': 'laserbatx', + 'uploader_url': 'https://laserbatx.bandcamp.com', + 'artists': ['LASERBAT'], + 'album_artists': ['LASERBAT'], + 'album': 'Hari Nezumi [EP]', + 'track': 'Forward to the End', + 'title': 'LASERBAT - Forward to the End', + 'thumbnail': 'https://f4.bcbits.com/img/a2507705510_5.jpg', + 'duration': 228.571, + 'track_id': '222792849', + 'release_date': '20230423', + 'upload_date': '20230423', + 'timestamp': 1682276040.0, + 'release_timestamp': 1682276040.0, + 'track_number': 1, + }, + 'add_ie': ['Bandcamp'], + }, { + 'url': 'https://bsky.app/profile/dannybhoix.bsky.social/post/3l6oe5mtr2c2j', + 'md5': 'b9e344fdbce9f2852c668a97efefb105', + 'info_dict': { + 'id': '3l3vgf77uco2g', + 'ext': 'mp4', + 'uploader': 'Bluesky', + 'uploader_id': 'bsky.app', + 'uploader_url': 'https://bsky.app/profile/bsky.app', + 'channel_id': 'did:plc:z72i7hdynmk6r22z27h6tvur', + 'channel_url': 'https://bsky.app/profile/did:plc:z72i7hdynmk6r22z27h6tvur', + 'thumbnail': r're:https://video.bsky.app/watch/.*\.jpg$', + 'title': 'Bluesky now has video! Update your app to versi...', + 'alt_title': 'Bluesky video feature announcement', + 'description': r're:(?s)Bluesky now has video! .{239}', + 'upload_date': '20240911', + 'timestamp': 1726074716, + 'like_count': int, + 'repost_count': int, + 'comment_count': int, + 'tags': [], + 'subtitles': { + 'en': 'mincount:1', + }, + }, + }, { + 'url': 'https://bsky.app/profile/alt.bun.how/post/3l7rdfxhyds2f', + 'md5': '8775118b235cf9fa6b5ad30f95cda75c', + 'info_dict': { + 'id': '3l7rdfxhyds2f', + 'ext': 'mp4', + 'uploader': 'cinnamon', + 'uploader_id': 'alt.bun.how', + 'uploader_url': 'https://bsky.app/profile/alt.bun.how', + 'channel_id': 'did:plc:7x6rtuenkuvxq3zsvffp2ide', + 'channel_url': 'https://bsky.app/profile/did:plc:7x6rtuenkuvxq3zsvffp2ide', + 'thumbnail': r're:https://video.bsky.app/watch/.*\.jpg$', + 'title': 'crazy that i look like this tbh', + 'description': 'crazy that i look like this tbh', + 'upload_date': '20241030', + 'timestamp': 1730332128, + 'like_count': int, + 'repost_count': int, + 'comment_count': int, + 'tags': ['sexual'], + 'age_limit': 18, + }, + }, { + 'url': 'at://did:plc:ia76kvnndjutgedggx2ibrem/app.bsky.feed.post/3l6zrz6zyl2dr', + 'md5': '71b0eb6d85d03145e6af6642c7fc6d78', + 'info_dict': { + 'id': '3l6zrz6zyl2dr', + 'ext': 'mp4', + 'uploader': 'mary🐇', + 'uploader_id': 'mary.my.id', + 'uploader_url': 'https://bsky.app/profile/mary.my.id', + 'channel_id': 'did:plc:ia76kvnndjutgedggx2ibrem', + 'channel_url': 'https://bsky.app/profile/did:plc:ia76kvnndjutgedggx2ibrem', + 'thumbnail': r're:https://video.bsky.app/watch/.*\.jpg$', + 'title': 'Bluesky video #3l6zrz6zyl2dr', + 'upload_date': '20241021', + 'timestamp': 1729523172, + 'like_count': int, + 'repost_count': int, + 'comment_count': int, + 'tags': [], + }, + }, { + 'url': 'https://bsky.app/profile/purpleicetea.bsky.social/post/3l7gv55dc2o2w', + 'info_dict': { + 'id': '3l7gv55dc2o2w', + }, + 'playlist': [{ + 'info_dict': { + 'id': '3l7gv55dc2o2w', + 'ext': 'mp4', + 'upload_date': '20241026', + 'description': 'One of my favorite videos', + 'comment_count': int, + 'uploader_url': 'https://bsky.app/profile/purpleicetea.bsky.social', + 'uploader': 'Purple.Ice.Tea', + 'thumbnail': r're:https://video.bsky.app/watch/.*\.jpg$', + 'channel_url': 'https://bsky.app/profile/did:plc:bjh5ffwya5f53dfy47dezuwx', + 'like_count': int, + 'channel_id': 'did:plc:bjh5ffwya5f53dfy47dezuwx', + 'repost_count': int, + 'timestamp': 1729973202, + 'tags': [], + 'uploader_id': 'purpleicetea.bsky.social', + 'title': 'One of my favorite videos', + }, + }, { + 'info_dict': { + 'id': '3l77u64l7le2e', + 'ext': 'mp4', + 'title': 'hearing people on twitter say that bluesky isn\'...', + 'like_count': int, + 'uploader_id': 'thafnine.net', + 'uploader_url': 'https://bsky.app/profile/thafnine.net', + 'upload_date': '20241024', + 'channel_url': 'https://bsky.app/profile/did:plc:6ttyq36rhiyed7wu3ws7dmqj', + 'description': r're:(?s)hearing people on twitter say that bluesky .{93}', + 'tags': [], + 'alt_title': 'md5:9b1ee1937fb3d1a81e932f9ec14d560e', + 'uploader': 'T9', + 'channel_id': 'did:plc:6ttyq36rhiyed7wu3ws7dmqj', + 'thumbnail': r're:https://video.bsky.app/watch/.*\.jpg$', + 'timestamp': 1729731642, + 'comment_count': int, + 'repost_count': int, + }, + }], + }] + _BLOB_URL_TMPL = '{}/xrpc/com.atproto.sync.getBlob' + + def _get_service_endpoint(self, did, video_id): + if did.startswith('did:web:'): + url = f'https://{did[8:]}/.well-known/did.json' + else: + url = f'https://plc.directory/{did}' + services = self._download_json( + url, video_id, 'Fetching service endpoint', 'Falling back to bsky.social', fatal=False) + return traverse_obj( + services, ('service', lambda _, x: x['type'] == 'AtprotoPersonalDataServer', + 'serviceEndpoint', {url_or_none}, any)) or 'https://bsky.social' + + def _real_extract(self, url): + handle, video_id = self._match_valid_url(url).group('handle', 'id') + + post = self._download_json( + 'https://public.api.bsky.app/xrpc/app.bsky.feed.getPostThread', + video_id, query={ + 'uri': f'at://{handle}/app.bsky.feed.post/{video_id}', + 'depth': 0, + 'parentHeight': 0, + })['thread']['post'] + + entries = [] + # app.bsky.embed.video.view/app.bsky.embed.external.view + entries.extend(self._extract_videos(post, video_id)) + # app.bsky.embed.recordWithMedia.view + entries.extend(self._extract_videos( + post, video_id, embed_path=('embed', 'media'), record_subpath=('embed', 'media'))) + # app.bsky.embed.record.view + if nested_post := traverse_obj(post, ('embed', 'record', ('record', None), {dict}, any)): + entries.extend(self._extract_videos( + nested_post, video_id, embed_path=('embeds', 0), record_path='value')) + + if not entries: + raise ExtractorError('No video could be found in this post', expected=True) + if len(entries) == 1: + return entries[0] + return self.playlist_result(entries, video_id) + + @staticmethod + def _build_profile_url(path): + return format_field(path, None, 'https://bsky.app/profile/%s', default=None) + + def _extract_videos(self, root, video_id, embed_path='embed', record_path='record', record_subpath='embed'): + embed_path = variadic(embed_path, (str, bytes, dict, set)) + record_path = variadic(record_path, (str, bytes, dict, set)) + record_subpath = variadic(record_subpath, (str, bytes, dict, set)) + + entries = [] + if external_uri := traverse_obj(root, ( + ((*record_path, *record_subpath), embed_path), 'external', 'uri', {url_or_none}, any)): + entries.append(self.url_result(external_uri)) + if playlist := traverse_obj(root, (*embed_path, 'playlist', {url_or_none})): + formats, subtitles = self._extract_m3u8_formats_and_subtitles( + playlist, video_id, 'mp4', m3u8_id='hls', fatal=False) + else: + return entries + + video_cid = traverse_obj( + root, (*embed_path, 'cid', {str}), + (*record_path, *record_subpath, 'video', 'ref', '$link', {str})) + did = traverse_obj(root, ('author', 'did', {str})) + + if did and video_cid: + endpoint = self._get_service_endpoint(did, video_id) + + formats.append({ + 'format_id': 'blob', + 'url': update_url_query( + self._BLOB_URL_TMPL.format(endpoint), {'did': did, 'cid': video_cid}), + **traverse_obj(root, (*embed_path, 'aspectRatio', { + 'width': ('width', {int_or_none}), + 'height': ('height', {int_or_none}), + })), + **traverse_obj(root, (*record_path, *record_subpath, 'video', { + 'filesize': ('size', {int_or_none}), + 'ext': ('mimeType', {mimetype2ext}), + })), + }) + + for sub_data in traverse_obj(root, ( + *record_path, *record_subpath, 'captions', lambda _, v: v['file']['ref']['$link'])): + subtitles.setdefault(sub_data.get('lang') or 'und', []).append({ + 'url': update_url_query( + self._BLOB_URL_TMPL.format(endpoint), {'did': did, 'cid': sub_data['file']['ref']['$link']}), + 'ext': traverse_obj(sub_data, ('file', 'mimeType', {mimetype2ext})), + }) + + entries.append({ + 'id': video_id, + 'formats': formats, + 'subtitles': subtitles, + **traverse_obj(root, { + 'id': ('uri', {url_basename}), + 'thumbnail': (*embed_path, 'thumbnail', {url_or_none}), + 'alt_title': (*embed_path, 'alt', {str}, filter), + 'uploader': ('author', 'displayName', {str}), + 'uploader_id': ('author', 'handle', {str}), + 'uploader_url': ('author', 'handle', {self._build_profile_url}), + 'channel_id': ('author', 'did', {str}), + 'channel_url': ('author', 'did', {self._build_profile_url}), + 'like_count': ('likeCount', {int_or_none}), + 'repost_count': ('repostCount', {int_or_none}), + 'comment_count': ('replyCount', {int_or_none}), + 'timestamp': ('indexedAt', {parse_iso8601}), + 'tags': ('labels', ..., 'val', {str}, all, {orderedSet}), + 'age_limit': ( + 'labels', ..., 'val', {lambda x: 18 if x in ('sexual', 'porn', 'graphic-media') else None}, any), + 'description': (*record_path, 'text', {str}, filter), + 'title': (*record_path, 'text', {lambda x: x.replace('\n', '')}, {truncate_string(left=50)}), + }), + }) + return entries diff --git a/yt-dlp/yt_dlp/utils/_utils.py b/yt-dlp/yt_dlp/utils/_utils.py index e30008e931..2f4c0a00f6 100644 --- a/yt-dlp/yt_dlp/utils/_utils.py +++ b/yt-dlp/yt_dlp/utils/_utils.py @@ -5294,6 +5294,7 @@ def make_archive_id(ie, video_id): return f'{ie_key.lower()} {video_id}' +@partial_application def truncate_string(s, left, right=0): assert left > 3 and right >= 0 if s is None or len(s) <= left + right: diff --git a/yt-dlp/yt_dlp/utils/traversal.py b/yt-dlp/yt_dlp/utils/traversal.py index dd9b4690be..361f239ba6 100644 --- a/yt-dlp/yt_dlp/utils/traversal.py +++ b/yt-dlp/yt_dlp/utils/traversal.py @@ -20,6 +20,7 @@ from ._utils import ( get_elements_html_by_class, get_elements_html_by_attribute, get_elements_by_attribute, + get_element_by_class, get_element_html_by_attribute, get_element_by_attribute, get_element_html_by_id, @@ -373,7 +374,7 @@ def subs_list_to_dict(subs: list[dict] | None = None, /, *, ext=None): @typing.overload -def find_element(*, attr: str, value: str, tag: str | None = None, html=False): ... +def find_element(*, attr: str, value: str, tag: str | None = None, html=False, regex=False): ... @typing.overload @@ -381,14 +382,14 @@ def find_element(*, cls: str, html=False): ... @typing.overload -def find_element(*, id: str, tag: str | None = None, html=False): ... +def find_element(*, id: str, tag: str | None = None, html=False, regex=False): ... @typing.overload -def find_element(*, tag: str, html=False): ... +def find_element(*, tag: str, html=False, regex=False): ... -def find_element(*, tag=None, id=None, cls=None, attr=None, value=None, html=False): +def find_element(*, tag=None, id=None, cls=None, attr=None, value=None, html=False, regex=False): # deliberately using `id=` and `cls=` for ease of readability assert tag or id or cls or (attr and value), 'One of tag, id, cls or (attr AND value) is required' ANY_TAG = r'[\w:.-]+' @@ -397,17 +398,18 @@ def find_element(*, tag=None, id=None, cls=None, attr=None, value=None, html=Fal assert not cls, 'Cannot match both attr and cls' assert not id, 'Cannot match both attr and id' func = get_element_html_by_attribute if html else get_element_by_attribute - return functools.partial(func, attr, value, tag=tag or ANY_TAG) + return functools.partial(func, attr, value, tag=tag or ANY_TAG, escape_value=not regex) elif cls: assert not id, 'Cannot match both cls and id' assert tag is None, 'Cannot match both cls and tag' - func = get_element_html_by_class if html else get_elements_by_class + assert not regex, 'Cannot use regex with cls' + func = get_element_html_by_class if html else get_element_by_class return functools.partial(func, cls) elif id: func = get_element_html_by_id if html else get_element_by_id - return functools.partial(func, id, tag=tag or ANY_TAG) + return functools.partial(func, id, tag=tag or ANY_TAG, escape_value=not regex) index = int(bool(html)) return lambda html: get_element_text_and_html_by_tag(tag, html)[index] @@ -418,19 +420,20 @@ def find_elements(*, cls: str, html=False): ... @typing.overload -def find_elements(*, attr: str, value: str, tag: str | None = None, html=False): ... +def find_elements(*, attr: str, value: str, tag: str | None = None, html=False, regex=False): ... -def find_elements(*, tag=None, cls=None, attr=None, value=None, html=False): +def find_elements(*, tag=None, cls=None, attr=None, value=None, html=False, regex=False): # deliberately using `cls=` for ease of readability assert cls or (attr and value), 'One of cls or (attr AND value) is required' if attr and value: assert not cls, 'Cannot match both attr and cls' func = get_elements_html_by_attribute if html else get_elements_by_attribute - return functools.partial(func, attr, value, tag=tag or r'[\w:.-]+') + return functools.partial(func, attr, value, tag=tag or r'[\w:.-]+', escape_value=not regex) assert not tag, 'Cannot match both cls and tag' + assert not regex, 'Cannot use regex with cls' func = get_elements_html_by_class if html else get_elements_by_class return functools.partial(func, cls) @@ -449,6 +452,14 @@ def trim_str(*, start=None, end=None): return trim +def unpack(func): + @functools.wraps(func) + def inner(items, **kwargs): + return func(*items, **kwargs) + + return inner + + def get_first(obj, *paths, **kwargs): return traverse_obj(obj, *((..., *variadic(keys)) for keys in paths), **kwargs, get_all=False)