package xray import ( "errors" "io/fs" "os" "sync" "golang.org/x/sys/unix" ) // The files the core's WireGuard kernel TUN opens before it creates the device // (proxy/wireguard/tun_linux.go); a missing one is skipped there too. var kernelTunSysctls = []string{ "/proc/sys/net/ipv4/conf/all/rp_filter", "/proc/sys/net/ipv6/conf/all/disable_ipv6", "/proc/sys/net/ipv6/conf/all/rp_filter", } // KernelTunBlocked reports that the core would put a WireGuard outbound on a kernel TUN // (it holds CAP_NET_ADMIN) where a read-only /proc/sys or a missing /dev/net/tun aborts its start. var KernelTunBlocked = sync.OnceValue(func() bool { return hasEffectiveNetAdmin() && !kernelTunReachable() }) func hasEffectiveNetAdmin() bool { hdr := unix.CapUserHeader{Version: unix.LINUX_CAPABILITY_VERSION_3} var data [2]unix.CapUserData if err := unix.Capget(&hdr, &data[0]); err != nil { return false } return data[0].Effective&(1<