{"record":{"id":"3dd5badb6adaba9d","repo":"shadowsocks/shadowsocks-rust","slug":"not-supported-udp-transparent-proxy-type-3dd5ba","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/openbsd.rs","lineNumber":47,"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":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/shadowsocks/shadowsocks-rust/blob/8eb0f0a65b1d976ab6bed5787327ef86529b0435/crates/shadowsocks-service/src/local/redir/udprelay/sys/unix/openbsd.rs#L29-L65","documentation":"OpenBSD's UDP transparent proxy bind rejects RedirType::NotSupported with InvalidInput. Like macOS, this fires when the caller passes a type the platform cannot actually serve, guarding against silently creating a useless socket.","triggerScenarios":"Calling UdpRedirSocket::bind/bind_nonlocal with ty == RedirType::NotSupported on OpenBSD — usually because config resolution produced NotSupported for this platform.","commonSituations":"Deploying the same shadowsocks local config across BSD/Linux hosts; OpenBSD lacks the UDP tproxy mode used on Linux.","solutions":["Remove or disable the UDP relay in the redir local server config on OpenBSD","Ensure the RedirType parsed from config is valid for OpenBSD before binding","Gate UDP redir socket creation behind platform capability checks","Use divert-to/pf-based forwarding only for the types the platform supports"],"exampleFix":"// before\nUdpRedirSocket::bind(RedirType::NotSupported, addr, false)?;\n// after\nmatch ty { RedirType::NotSupported => return Ok(()), _ => UdpRedirSocket::bind(ty, addr, false)? }","handlingStrategy":"validation","validationCode":"if ty == RedirType::NotSupported { return; } // skip UDP relay on OpenBSD","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 => log::info!(\"udp redir not supported; disabled\"), r => r? }","preventionTips":["Gate UDP relay on RedirType::NotSupported checks","Use platform-specific configuration","Verify pf divert-to rules for supported types","Test bind at startup with graceful skip"],"tags":["network","udp","transparent-proxy","openbsd","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-14T16:17:12.679Z"}