mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2025-12-19 16:30:07 +08:00
chore: add recvmsgx and sendmsgx config to tun
Some checks are pending
Test / test (1.20, macos-13) (push) Waiting to run
Test / test (1.20, macos-latest) (push) Waiting to run
Test / test (1.20, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.20, ubuntu-latest) (push) Waiting to run
Test / test (1.20, windows-latest) (push) Waiting to run
Test / test (1.21, macos-13) (push) Waiting to run
Test / test (1.21, macos-latest) (push) Waiting to run
Test / test (1.21, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.21, ubuntu-latest) (push) Waiting to run
Test / test (1.21, windows-latest) (push) Waiting to run
Test / test (1.22, macos-13) (push) Waiting to run
Test / test (1.22, macos-latest) (push) Waiting to run
Test / test (1.22, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.22, ubuntu-latest) (push) Waiting to run
Test / test (1.22, windows-latest) (push) Waiting to run
Test / test (1.23, macos-13) (push) Waiting to run
Test / test (1.23, macos-latest) (push) Waiting to run
Test / test (1.23, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.23, ubuntu-latest) (push) Waiting to run
Test / test (1.23, windows-latest) (push) Waiting to run
Test / test (1.24, macos-13) (push) Waiting to run
Test / test (1.24, macos-latest) (push) Waiting to run
Test / test (1.24, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.24, ubuntu-latest) (push) Waiting to run
Test / test (1.24, windows-latest) (push) Waiting to run
Trigger CMFA Update / trigger-CMFA-update (push) Waiting to run
Some checks are pending
Test / test (1.20, macos-13) (push) Waiting to run
Test / test (1.20, macos-latest) (push) Waiting to run
Test / test (1.20, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.20, ubuntu-latest) (push) Waiting to run
Test / test (1.20, windows-latest) (push) Waiting to run
Test / test (1.21, macos-13) (push) Waiting to run
Test / test (1.21, macos-latest) (push) Waiting to run
Test / test (1.21, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.21, ubuntu-latest) (push) Waiting to run
Test / test (1.21, windows-latest) (push) Waiting to run
Test / test (1.22, macos-13) (push) Waiting to run
Test / test (1.22, macos-latest) (push) Waiting to run
Test / test (1.22, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.22, ubuntu-latest) (push) Waiting to run
Test / test (1.22, windows-latest) (push) Waiting to run
Test / test (1.23, macos-13) (push) Waiting to run
Test / test (1.23, macos-latest) (push) Waiting to run
Test / test (1.23, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.23, ubuntu-latest) (push) Waiting to run
Test / test (1.23, windows-latest) (push) Waiting to run
Test / test (1.24, macos-13) (push) Waiting to run
Test / test (1.24, macos-latest) (push) Waiting to run
Test / test (1.24, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.24, ubuntu-latest) (push) Waiting to run
Test / test (1.24, windows-latest) (push) Waiting to run
Trigger CMFA Update / trigger-CMFA-update (push) Waiting to run
Only for advanced users, enabling `recvmsgx` under darwin can improve performance, but enabling `sendmsgx` may cause unknown problems, please use with caution.
This commit is contained in:
parent
b9260e06b8
commit
8f18d3f6db
@ -296,6 +296,10 @@ type RawTun struct {
|
|||||||
Inet6RouteAddress []netip.Prefix `yaml:"inet6-route-address" json:"inet6-route-address,omitempty"`
|
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"`
|
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"`
|
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 {
|
type RawTuicServer struct {
|
||||||
@ -513,6 +517,8 @@ func DefaultRawConfig() *RawConfig {
|
|||||||
AutoRoute: true,
|
AutoRoute: true,
|
||||||
AutoDetectInterface: true,
|
AutoDetectInterface: true,
|
||||||
Inet6Address: []netip.Prefix{netip.MustParsePrefix("fdfe:dcba:9876::1/126")},
|
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{
|
TuicServer: RawTuicServer{
|
||||||
Enable: false,
|
Enable: false,
|
||||||
@ -1554,6 +1560,9 @@ func parseTun(rawTun RawTun, general *General) error {
|
|||||||
Inet6RouteAddress: rawTun.Inet6RouteAddress,
|
Inet6RouteAddress: rawTun.Inet6RouteAddress,
|
||||||
Inet4RouteExcludeAddress: rawTun.Inet4RouteExcludeAddress,
|
Inet4RouteExcludeAddress: rawTun.Inet4RouteExcludeAddress,
|
||||||
Inet6RouteExcludeAddress: rawTun.Inet6RouteExcludeAddress,
|
Inet6RouteExcludeAddress: rawTun.Inet6RouteExcludeAddress,
|
||||||
|
|
||||||
|
RecvMsgX: rawTun.RecvMsgX,
|
||||||
|
SendMsgX: rawTun.SendMsgX,
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@ -100,6 +100,10 @@ type tunSchema struct {
|
|||||||
Inet6RouteAddress *[]netip.Prefix `yaml:"inet6-route-address" json:"inet6-route-address,omitempty"`
|
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"`
|
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"`
|
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 {
|
type tuicServerSchema struct {
|
||||||
@ -243,6 +247,12 @@ func pointerOrDefaultTun(p *tunSchema, def LC.Tun) LC.Tun {
|
|||||||
if p.FileDescriptor != nil {
|
if p.FileDescriptor != nil {
|
||||||
def.FileDescriptor = *p.FileDescriptor
|
def.FileDescriptor = *p.FileDescriptor
|
||||||
}
|
}
|
||||||
|
if p.RecvMsgX != nil {
|
||||||
|
def.RecvMsgX = *p.RecvMsgX
|
||||||
|
}
|
||||||
|
if p.SendMsgX != nil {
|
||||||
|
def.SendMsgX = *p.SendMsgX
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return def
|
return def
|
||||||
}
|
}
|
||||||
|
|||||||
@ -54,6 +54,10 @@ type Tun struct {
|
|||||||
Inet6RouteAddress []netip.Prefix `yaml:"inet6-route-address" json:"inet6-route-address,omitempty"`
|
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"`
|
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"`
|
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() {
|
func (t *Tun) Sort() {
|
||||||
@ -199,5 +203,12 @@ func (t *Tun) Equal(other Tun) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if t.RecvMsgX != other.RecvMsgX {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if t.SendMsgX != other.SendMsgX {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|||||||
@ -55,6 +55,10 @@ type TunOption struct {
|
|||||||
Inet6RouteAddress []netip.Prefix `inbound:"inet6-route-address,omitempty"`
|
Inet6RouteAddress []netip.Prefix `inbound:"inet6-route-address,omitempty"`
|
||||||
Inet4RouteExcludeAddress []netip.Prefix `inbound:"inet4-route-exclude-address,omitempty"`
|
Inet4RouteExcludeAddress []netip.Prefix `inbound:"inet4-route-exclude-address,omitempty"`
|
||||||
Inet6RouteExcludeAddress []netip.Prefix `inbound:"inet6-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
|
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,
|
Inet6RouteAddress: options.Inet6RouteAddress,
|
||||||
Inet4RouteExcludeAddress: options.Inet4RouteExcludeAddress,
|
Inet4RouteExcludeAddress: options.Inet4RouteExcludeAddress,
|
||||||
Inet6RouteExcludeAddress: options.Inet6RouteExcludeAddress,
|
Inet6RouteExcludeAddress: options.Inet6RouteExcludeAddress,
|
||||||
|
|
||||||
|
RecvMsgX: options.RecvMsgX,
|
||||||
|
SendMsgX: options.SendMsgX,
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@ -365,6 +365,8 @@ func New(options LC.Tun, tunnel C.Tunnel, additions ...inbound.Addition) (l *Lis
|
|||||||
ExcludePackage: options.ExcludePackage,
|
ExcludePackage: options.ExcludePackage,
|
||||||
FileDescriptor: options.FileDescriptor,
|
FileDescriptor: options.FileDescriptor,
|
||||||
InterfaceMonitor: defaultInterfaceMonitor,
|
InterfaceMonitor: defaultInterfaceMonitor,
|
||||||
|
EXP_RecvMsgX: options.RecvMsgX,
|
||||||
|
EXP_SendMsgX: options.SendMsgX,
|
||||||
}
|
}
|
||||||
|
|
||||||
if options.AutoRedirect {
|
if options.AutoRedirect {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user