WireGuard config: Replace kernelMode with noKernelTun

https://github.com/XTLS/Xray-core/pull/3871#issuecomment-2420770309
This commit is contained in:
RPRX 2024-10-18 00:10:09 +00:00 committed by GitHub
parent b0272c172a
commit 9bdf72d658
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 58 additions and 65 deletions

View file

@ -1,5 +1,11 @@
package wireguard
import (
"context"
"github.com/xtls/xray-core/common/errors"
)
func (c *DeviceConfig) preferIP4() bool {
return c.DomainStrategy == DeviceConfig_FORCE_IP ||
c.DomainStrategy == DeviceConfig_FORCE_IP4 ||
@ -25,8 +31,17 @@ func (c *DeviceConfig) fallbackIP6() bool {
}
func (c *DeviceConfig) createTun() tunCreator {
if c.KernelMode {
return createKernelTun
if c.NoKernelTun {
return createGVisorTun
}
return createGVisorTun
kernelTunSupported, err := KernelTunSupported()
if err != nil {
errors.LogWarning(context.Background(), "Using gVisor TUN. Failed to check kernel TUN support:", err)
return createGVisorTun
}
if !kernelTunSupported {
errors.LogWarning(context.Background(), "Using gVisor TUN. Kernel TUN is not supported on your OS, or your permission is insufficient.)")
return createGVisorTun
}
return createKernelTun
}