{"record":{"id":"33dbcf5d8bdfcbad","repo":"shadowsocks/shadowsocks-rust","slug":"not-supported-udp-transparent-proxy-type-33dbcf","errorCode":null,"errorMessage":"not supported udp transparent proxy type","messagePattern":"not supported udp transparent proxy type","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/shadowsocks-service/src/local/redir/udprelay/sys/unix/macos.rs","lineNumber":44,"sourceCode":"\nimpl UdpRedirSocket {\n    /// Create a new UDP socket binded to `addr`\n    ///\n    /// This will allow listening to `addr` that is not in local host\n    pub fn listen(ty: RedirType, addr: SocketAddr) -> io::Result<UdpRedirSocket> {\n        UdpRedirSocket::bind(ty, addr, false)\n    }\n\n    /// Create a new UDP socket binded to `addr`\n    ///\n    /// This will allow binding to `addr` that is not in local host\n    pub fn bind_nonlocal(ty: RedirType, addr: SocketAddr, _: &RedirSocketOpts) -> io::Result<UdpRedirSocket> {\n        UdpRedirSocket::bind(ty, addr, true)\n    }\n\n    fn bind(ty: RedirType, addr: SocketAddr, reuse_port: bool) -> io::Result<UdpRedirSocket> {\n        if ty == RedirType::NotSupported {\n            return Err(Error::new(\n                ErrorKind::InvalidInput,\n                \"not supported udp transparent proxy type\",\n            ));\n        }\n\n        let socket = Socket::new(Domain::for_address(addr), Type::DGRAM, Some(Protocol::UDP))?;\n        set_socket_before_bind(&addr, &socket)?;\n\n        socket.set_nonblocking(true)?;\n        socket.set_reuse_address(true)?;\n        if reuse_port && let Err(err) = socket.set_reuse_port(true) {\n            if let Some(libc::ENOPROTOOPT) = err.raw_os_error() {\n                trace!(\"failed to set SO_REUSEPORT, error: {}\", err);\n            } else {\n                error!(\"failed to set SO_REUSEPORT, error: {}\", err);\n                return Err(err);\n            }\n        }","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/shadowsocks/shadowsocks-rust/blob/8eb0f0a65b1d976ab6bed5787327ef86529b0435/crates/shadowsocks-service/src/local/redir/udprelay/sys/unix/macos.rs#L26-L62","documentation":"On macOS, UDP transparent proxy support is absent, so UdpRedirSocket::bind rejects only RedirType::NotSupported with InvalidInput; effectively every meaningful tproxy type yields this error unless a supported value exists on that platform.","triggerScenarios":"Calling UdpRedirSocket::bind/bind_nonlocal with ty == RedirType::NotSupported on macOS — typically when the configured redir type was resolved to NotSupported because macOS does not support UDP transparent proxying.","commonSituations":"Running the redir/tun local server on macOS with a UDP relay enabled; config copied from a Linux tproxy setup; code paths that unconditionally build a UDP redir socket.","solutions":["Disable the UDP transparent proxy relay on macOS (TCP redir is supported, UDP tproxy is not)","Use the tun-based local server instead of redir if UDP proxying is needed on macOS","Guard platform-specific code so UDP redir sockets are only created on platforms with a supported RedirType","Check the resolved RedirType at startup and fail fast with a clear config error rather than at bind time"],"exampleFix":"// before\nUdpRedirSocket::bind_nonlocal(ty, addr, &opts)?; // ty == NotSupported on macOS\n// after\nif cfg!(target_os = \"macos\") { skip_udp_redir(); } else { UdpRedirSocket::bind_nonlocal(ty, addr, &opts)?; }","handlingStrategy":"validation","validationCode":"#[cfg(target_os = \"macos\")]\nif ty == RedirType::NotSupported { skip_udp_relay(); }","typeGuard":"fn udp_redir_available(ty: RedirType) -> bool { ty != RedirType::NotSupported }","tryCatchPattern":"match UdpRedirSocket::bind_nonlocal(ty, addr, &opts) { Err(e) if e.kind()==InvalidInput => eprintln!(\"UDP redir unsupported here\"), r => r? }","preventionTips":["Check platform support before enabling UDP relay in config","Prefer tun mode for UDP on macOS","Fail at config load time, not bind time","Keep per-platform config files"],"tags":["network","udp","transparent-proxy","macos","unsupported-platform"],"backgroundTag":"unsupported-platform","analyzedSha":"8eb0f0a65b1d976ab6bed5787327ef86529b0435","analyzedAt":"2026-09-09T12:20:43.168Z","contentChangedAt":"2026-09-09T12:20:43.168Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}