{"record":{"id":"5744c273bdaade1a","repo":"shadowsocks/shadowsocks-rust","slug":"udp-redir-invalid","errorCode":null,"errorMessage":"`udp_redir` invalid","messagePattern":"`udp_redir` invalid","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/shadowsocks-service/src/config.rs","lineNumber":1963,"sourceCode":"                        }\n\n                        #[cfg(feature = \"local-redir\")]\n                        if let Some(tcp_redir) = local.tcp_redir {\n                            match tcp_redir.parse::<RedirType>() {\n                                Ok(r) => local_config.tcp_redir = r,\n                                Err(..) => {\n                                    let err = Error::new(ErrorKind::Malformed, \"`tcp_redir` invalid\", None);\n                                    return Err(err);\n                                }\n                            }\n                        }\n\n                        #[cfg(feature = \"local-redir\")]\n                        if let Some(udp_redir) = local.udp_redir {\n                            match udp_redir.parse::<RedirType>() {\n                                Ok(r) => local_config.udp_redir = r,\n                                Err(..) => {\n                                    let err = Error::new(ErrorKind::Malformed, \"`udp_redir` invalid\", None);\n                                    return Err(err);\n                                }\n                            }\n                        }\n\n                        #[cfg(feature = \"local-dns\")]\n                        if let Some(local_dns_address) = local.local_dns_address {\n                            match local_dns_address.parse::<IpAddr>() {\n                                Ok(ip) => {\n                                    local_config.local_dns_addr = Some(NameServerAddr::SocketAddr(SocketAddr::new(\n                                        ip,\n                                        local.local_dns_port.unwrap_or(53),\n                                    )));\n                                }\n                                #[cfg(unix)]\n                                Err(..) => {\n                                    local_config.local_dns_addr =\n                                        Some(NameServerAddr::UnixSocketAddr(PathBuf::from(local_dns_address)));","sourceCodeStart":1945,"sourceCodeEnd":1981,"githubUrl":"https://github.com/shadowsocks/shadowsocks-rust/blob/8eb0f0a65b1d976ab6bed5787327ef86529b0435/crates/shadowsocks-service/src/config.rs#L1945-L1981","documentation":"Raised under the `local-redir` feature when the `udp_redir` string cannot be parsed into a `RedirType`. This is the UDP counterpart of the tcp_redir validation: the value must name a UDP redirect mechanism supported by the current platform and build.","triggerScenarios":"A config entry contains `udp_redir` set to an unrecognized string, e.g. `\"redirect\"` where UDP only supports \"tproxy\" on Linux, or any typo/wrong-case value.","commonSituations":"Users copying the TCP redir value into udp_redir (redirect is TCP-only on Linux; UDP needs tproxy); platform-mismatched configs; typos.","solutions":["Set `udp_redir` to a UDP-capable RedirType for your platform, e.g. \"tproxy\" on Linux.","Remove `udp_redir` if UDP redirect is not needed.","Confirm the local-redir feature and the required backend features (e.g. local-redir with tproxy support) are compiled in."],"exampleFix":"// before\n{ \"udp_redir\": \"redirect\" }\n// after\n{ \"udp_redir\": \"tproxy\" }","handlingStrategy":"validation","validationCode":"fn validate_udp_redir(entry: &serde_json::Value, platform: &str) -> Result<(), String> {\n    if let Some(r) = entry.get(\"udp_redir\").and_then(|v| v.as_str()) {\n        let ok = match platform {\n            \"linux\" => r == \"tproxy\", // UDP redirect on Linux requires tproxy\n            \"macos\" | \"freebsd\" | \"openbsd\" => r == \"pf\",\n            _ => false,\n        };\n        if !ok {\n            return Err(format!(\"udp_redir '{r}' not valid for {platform}\"));\n        }\n    }\n    Ok(())\n}","typeGuard":null,"tryCatchPattern":"#[cfg(feature = \"local-redir\")]\nmatch LocalConfig::load_from(config_path) {\n    Ok(cfg) => start(cfg),\n    Err(e) if e.to_string().contains(\"udp_redir\") => {\n        eprintln!(\"Bad udp_redir (UDP usually needs tproxy on Linux): {e}\");\n        std::process::exit(1);\n    }\n    Err(e) => return Err(e.into()),\n}","preventionTips":["Don't copy the TCP redir value into udp_redir — on Linux UDP requires tproxy.","Omit udp_redir when UDP redirect isn't used.","Confirm tproxy/kernel support before choosing it in configs."],"tags":["config","redir","udp","validation"],"backgroundTag":"invalid-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"}