mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-12-17 04:34:35 +03:00
Some checks are pending
Build docker image / build-image (push) Waiting to run
Build and Release / prepare (push) Waiting to run
Build and Release / build (386, freebsd, , ) (push) Blocked by required conditions
Build and Release / build (386, linux, , ) (push) Blocked by required conditions
Build and Release / build (386, openbsd, , ) (push) Blocked by required conditions
Build and Release / build (386, windows, , ) (push) Blocked by required conditions
Build and Release / build (386, windows, 1.21.4, win7-32) (push) Blocked by required conditions
Build and Release / build (amd64, darwin, , ) (push) Blocked by required conditions
Build and Release / build (amd64, freebsd, , ) (push) Blocked by required conditions
Build and Release / build (amd64, linux, , ) (push) Blocked by required conditions
Build and Release / build (amd64, openbsd, , ) (push) Blocked by required conditions
Build and Release / build (amd64, windows, , ) (push) Blocked by required conditions
Build and Release / build (amd64, windows, 1.21.4, win7-64) (push) Blocked by required conditions
Build and Release / build (arm, 5, linux) (push) Blocked by required conditions
Build and Release / build (arm, 6, linux) (push) Blocked by required conditions
Build and Release / build (arm, 7, freebsd) (push) Blocked by required conditions
Build and Release / build (arm, 7, linux) (push) Blocked by required conditions
Build and Release / build (arm, 7, openbsd) (push) Blocked by required conditions
Build and Release / build (arm, 7, windows) (push) Blocked by required conditions
Build and Release / build (arm64, android) (push) Blocked by required conditions
Build and Release / build (arm64, darwin) (push) Blocked by required conditions
Build and Release / build (arm64, freebsd) (push) Blocked by required conditions
Build and Release / build (arm64, linux) (push) Blocked by required conditions
Build and Release / build (arm64, openbsd) (push) Blocked by required conditions
Build and Release / build (arm64, windows) (push) Blocked by required conditions
Build and Release / build (loong64, linux) (push) Blocked by required conditions
Build and Release / build (mips, linux) (push) Blocked by required conditions
Build and Release / build (mips64, linux) (push) Blocked by required conditions
Build and Release / build (mips64le, linux) (push) Blocked by required conditions
Build and Release / build (mipsle, linux) (push) Blocked by required conditions
Build and Release / build (ppc64, linux) (push) Blocked by required conditions
Build and Release / build (ppc64le, linux) (push) Blocked by required conditions
Build and Release / build (riscv64, linux) (push) Blocked by required conditions
Build and Release / build (s390x, linux) (push) Blocked by required conditions
Test / test (macos-latest) (push) Waiting to run
Test / test (ubuntu-latest) (push) Waiting to run
Test / test (windows-latest) (push) Waiting to run
Co-authored-by: RPRX <63339210+RPRX@users.noreply.github.com>
55 lines
1.6 KiB
Go
55 lines
1.6 KiB
Go
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 ||
|
|
c.DomainStrategy == DeviceConfig_FORCE_IP46
|
|
}
|
|
|
|
func (c *DeviceConfig) preferIP6() bool {
|
|
return c.DomainStrategy == DeviceConfig_FORCE_IP ||
|
|
c.DomainStrategy == DeviceConfig_FORCE_IP6 ||
|
|
c.DomainStrategy == DeviceConfig_FORCE_IP64
|
|
}
|
|
|
|
func (c *DeviceConfig) hasFallback() bool {
|
|
return c.DomainStrategy == DeviceConfig_FORCE_IP46 || c.DomainStrategy == DeviceConfig_FORCE_IP64
|
|
}
|
|
|
|
func (c *DeviceConfig) fallbackIP4() bool {
|
|
return c.DomainStrategy == DeviceConfig_FORCE_IP64
|
|
}
|
|
|
|
func (c *DeviceConfig) fallbackIP6() bool {
|
|
return c.DomainStrategy == DeviceConfig_FORCE_IP46
|
|
}
|
|
|
|
func (c *DeviceConfig) createTun() tunCreator {
|
|
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. NoKernelTun is set to true.")
|
|
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
|
|
}
|
|
errors.LogWarning(context.Background(), "Using kernel TUN.")
|
|
return createKernelTun
|
|
}
|