diff --git a/config/config.go b/config/config.go index 673883c4..dae686df 100644 --- a/config/config.go +++ b/config/config.go @@ -296,6 +296,10 @@ type RawTun struct { Inet6RouteAddress []netip.Prefix `yaml:"inet6-route-address" json:"inet6-route-address,omitempty"` Inet4RouteExcludeAddress []netip.Prefix `yaml:"inet4-route-exclude-address" json:"inet4-route-exclude-address,omitempty"` Inet6RouteExcludeAddress []netip.Prefix `yaml:"inet6-route-exclude-address" json:"inet6-route-exclude-address,omitempty"` + + // darwin special config + RecvMsgX bool `yaml:"recvmsgx" json:"recvmsgx,omitempty"` + SendMsgX bool `yaml:"sendmsgx" json:"sendmsgx,omitempty"` } type RawTuicServer struct { @@ -513,6 +517,8 @@ func DefaultRawConfig() *RawConfig { AutoRoute: true, AutoDetectInterface: true, Inet6Address: []netip.Prefix{netip.MustParsePrefix("fdfe:dcba:9876::1/126")}, + RecvMsgX: true, + SendMsgX: false, // In the current implementation, if enabled, the kernel may freeze during multi-thread downloads, so it is disabled by default. }, TuicServer: RawTuicServer{ Enable: false, @@ -1554,6 +1560,9 @@ func parseTun(rawTun RawTun, general *General) error { Inet6RouteAddress: rawTun.Inet6RouteAddress, Inet4RouteExcludeAddress: rawTun.Inet4RouteExcludeAddress, Inet6RouteExcludeAddress: rawTun.Inet6RouteExcludeAddress, + + RecvMsgX: rawTun.RecvMsgX, + SendMsgX: rawTun.SendMsgX, } return nil diff --git a/hub/route/configs.go b/hub/route/configs.go index 1ce05a14..92253c3f 100644 --- a/hub/route/configs.go +++ b/hub/route/configs.go @@ -100,6 +100,10 @@ type tunSchema struct { Inet6RouteAddress *[]netip.Prefix `yaml:"inet6-route-address" json:"inet6-route-address,omitempty"` Inet4RouteExcludeAddress *[]netip.Prefix `yaml:"inet4-route-exclude-address" json:"inet4-route-exclude-address,omitempty"` Inet6RouteExcludeAddress *[]netip.Prefix `yaml:"inet6-route-exclude-address" json:"inet6-route-exclude-address,omitempty"` + + // darwin special config + RecvMsgX *bool `yaml:"recvmsgx" json:"recvmsgx,omitempty"` + SendMsgX *bool `yaml:"sendmsgx" json:"sendmsgx,omitempty"` } type tuicServerSchema struct { @@ -243,6 +247,12 @@ func pointerOrDefaultTun(p *tunSchema, def LC.Tun) LC.Tun { if p.FileDescriptor != nil { def.FileDescriptor = *p.FileDescriptor } + if p.RecvMsgX != nil { + def.RecvMsgX = *p.RecvMsgX + } + if p.SendMsgX != nil { + def.SendMsgX = *p.SendMsgX + } } return def } diff --git a/listener/config/tun.go b/listener/config/tun.go index fa20db1e..0efbc827 100644 --- a/listener/config/tun.go +++ b/listener/config/tun.go @@ -54,6 +54,10 @@ type Tun struct { Inet6RouteAddress []netip.Prefix `yaml:"inet6-route-address" json:"inet6-route-address,omitempty"` Inet4RouteExcludeAddress []netip.Prefix `yaml:"inet4-route-exclude-address" json:"inet4-route-exclude-address,omitempty"` Inet6RouteExcludeAddress []netip.Prefix `yaml:"inet6-route-exclude-address" json:"inet6-route-exclude-address,omitempty"` + + // darwin special config + RecvMsgX bool `yaml:"recvmsgx" json:"recvmsgx,omitempty"` + SendMsgX bool `yaml:"sendmsgx" json:"sendmsgx,omitempty"` } func (t *Tun) Sort() { @@ -199,5 +203,12 @@ func (t *Tun) Equal(other Tun) bool { return false } + if t.RecvMsgX != other.RecvMsgX { + return false + } + if t.SendMsgX != other.SendMsgX { + return false + } + return true } diff --git a/listener/inbound/tun.go b/listener/inbound/tun.go index 11cad0c6..e6ebb2a1 100644 --- a/listener/inbound/tun.go +++ b/listener/inbound/tun.go @@ -55,6 +55,10 @@ type TunOption struct { Inet6RouteAddress []netip.Prefix `inbound:"inet6-route-address,omitempty"` Inet4RouteExcludeAddress []netip.Prefix `inbound:"inet4-route-exclude-address,omitempty"` Inet6RouteExcludeAddress []netip.Prefix `inbound:"inet6-route-exclude-address,omitempty"` + + // darwin special config + RecvMsgX bool `inbound:"recvmsgx,omitempty"` + SendMsgX bool `inbound:"sendmsgx,omitempty"` } var _ encoding.TextUnmarshaler = (*netip.Addr)(nil) // ensure netip.Addr can decode direct by structure package @@ -124,6 +128,9 @@ func NewTun(options *TunOption) (*Tun, error) { Inet6RouteAddress: options.Inet6RouteAddress, Inet4RouteExcludeAddress: options.Inet4RouteExcludeAddress, Inet6RouteExcludeAddress: options.Inet6RouteExcludeAddress, + + RecvMsgX: options.RecvMsgX, + SendMsgX: options.SendMsgX, }, }, nil } diff --git a/listener/sing_tun/server.go b/listener/sing_tun/server.go index b0528557..416cf30c 100644 --- a/listener/sing_tun/server.go +++ b/listener/sing_tun/server.go @@ -365,6 +365,8 @@ func New(options LC.Tun, tunnel C.Tunnel, additions ...inbound.Addition) (l *Lis ExcludePackage: options.ExcludePackage, FileDescriptor: options.FileDescriptor, InterfaceMonitor: defaultInterfaceMonitor, + EXP_RecvMsgX: options.RecvMsgX, + EXP_SendMsgX: options.SendMsgX, } if options.AutoRedirect {