{"record":{"id":"bdace7d13e71ea4c","repo":"XTLS/Xray-core","slug":"tun-is-not-supported-on-your-platform","errorCode":null,"errorMessage":"Tun is not supported on your platform","messagePattern":"Tun is not supported on your platform","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"proxy/tun/tun_default.go","lineNumber":19,"sourceCode":"//go:build !linux && !windows && !android && !darwin && !freebsd\n\npackage tun\n\nimport (\n\t\"net\"\n\n\t\"github.com/xtls/xray-core/common/errors\"\n\t\"gvisor.dev/gvisor/pkg/tcpip/stack\"\n)\n\ntype DefaultTun struct{}\n\n// DefaultTun implements Tun\nvar _ Tun = (*DefaultTun)(nil)\n\n// NewTun builds new tun interface handler\nfunc NewTun(options *Config) (Tun, error) {\n\treturn nil, errors.New(\"Tun is not supported on your platform\")\n}\n\nfunc (t *DefaultTun) Start() error {\n\treturn errors.New(\"Tun is not supported on your platform\")\n}\n\nfunc (t *DefaultTun) Close() error {\n\treturn errors.New(\"Tun is not supported on your platform\")\n}\n\nfunc (t *DefaultTun) Name() (string, error) {\n\treturn \"\", errors.New(\"Tun is not supported on your platform\")\n}\n\nfunc (t *DefaultTun) Index() (int, error) {\n\treturn 0, errors.New(\"Tun is not supported on your platform\")\n}\n","sourceCodeStart":1,"sourceCodeEnd":37,"githubUrl":"https://github.com/XTLS/Xray-core/blob/7d214f8b094f75322fa3990f8aadad1c912f24f5/proxy/tun/tun_default.go#L1-L37","documentation":"Guard error from the stub TUN implementation compiled when none of the supported build tags (linux, windows, android, darwin, freebsd) match the build target. NewTun (and every DefaultTun method) is an unconditional sentinel that always fails, meaning the platform simply has no TUN device support compiled in.","triggerScenarios":"Thrown at proxy/tun/tun_default.go:19 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Build or run xray on a supported platform: linux, windows, android, darwin, or freebsd","Remove or disable the TUN inbound/outbound from the configuration on unsupported platforms","Add a platform-specific implementation of the Tun interface for the target OS and add its build tag to the build constraint"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7d214f8b094f75322fa3990f8aadad1c912f24f5","analyzedAt":"2026-08-15T14:26:24.325Z","contentChangedAt":"2026-08-15T14:26:24.325Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}