{"record":{"id":"7d59dfa56902e31c","repo":"shadowsocks/shadowsocks-rust","slug":"not-supported-udp-transparent-proxy-type","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/freebsd.rs","lineNumber":45,"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 {\n            if 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                }","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/shadowsocks/shadowsocks-rust/blob/8eb0f0a65b1d976ab6bed5787327ef86529b0435/crates/shadowsocks-service/src/local/redir/udprelay/sys/unix/freebsd.rs#L27-L63","documentation":"UdpRedirSocket::bind on the BSD freebsd path rejects RedirType::NotSupported with InvalidInput. NotSupported is the placeholder used when the platform/config has no UDP transparent proxy capability, so binding a UDP redir socket with it is always a programming or configuration error.","triggerScenarios":"Calling UdpRedirSocket::bind/bind_nonlocal with ty == RedirType::NotSupported — e.g. UDP transparent proxy disabled at build time (cfg-gated) or the config omitted a udp redir type so the resolved type defaulted to NotSupported.","commonSituations":"Configs enabling a UDP redir inbound on platforms/versions where UDP redir isn't supported, or code paths that propagate a NotSupported default instead of erroring earlier at config parsing.","solutions":["Set an explicit supported UDP redir type in the config (e.g. packet-filter on FreeBSD).","Check RedirType::udp_support()/feature flags before constructing a UDP redir listener.","Disable the UDP portion of the redir inbound if the platform lacks UDP transparent proxying.","Upgrade the library/platform if you expect UDP redir support here."],"exampleFix":"// before\nlet sock = UdpRedirSocket::bind_nonlocal(redir_type, addr, &opts)?; // redir_type == NotSupported\n// after\nif RedirType::udp_default() == RedirType::NotSupported {\n    eprintln!(\"UDP transparent proxy not supported on this platform; skipping UDP redir\");\n} else {\n    let sock = UdpRedirSocket::bind_nonlocal(RedirType::udp_default(), addr, &opts)?;\n}","handlingStrategy":"validation","validationCode":"// check platform UDP support before binding\nif RedirType::udp_default() == RedirType::NotSupported {\n    return Err(io::Error::new(io::ErrorKind::Unsupported, \"udp redir unavailable\"));\n}","typeGuard":"fn udp_redir_available(ty: &RedirType) -> bool { *ty != RedirType::NotSupported }","tryCatchPattern":"match UdpRedirSocket::bind_nonlocal(ty, addr, &opts) {\n    Err(e) if e.kind() == std::io::ErrorKind::InvalidInput => {\n        tracing::warn!(\"UDP transparent proxy unsupported; running TCP-only\");\n        None\n    }\n    r => Some(r?),\n}","preventionTips":["Derive the redir type from RedirType::udp_default() instead of hardcoding","Check build-time feature flags enabling UDP redir on the target platform","Fail fast at config load if a UDP redir inbound is requested on an unsupported platform"],"tags":["configuration","freebsd","udp","transparent-proxy","unsupported-platform"],"backgroundTag":"unsupported-enum-value","analyzedSha":"8eb0f0a65b1d976ab6bed5787327ef86529b0435","analyzedAt":"2026-09-09T12:20:43.168Z","contentChangedAt":"2026-09-09T12:20:43.168Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}