{"record":{"id":"c1816c95d81f4698","repo":"shadowsocks/shadowsocks-rust","slug":"udp-redir","errorCode":null,"errorMessage":"udp-redir","messagePattern":"udp-redir","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/service/local.rs","lineNumber":767,"sourceCode":"            }\n\n            #[cfg(feature = \"local-tunnel\")]\n            if let Some(addr) = matches.get_one::<Address>(\"FORWARD_ADDR\").cloned() {\n                local_config.forward_addr = Some(addr);\n            }\n\n            #[cfg(feature = \"local-redir\")]\n            {\n                if RedirType::tcp_default() != RedirType::NotSupported\n                    && let Some(tcp_redir) = matches.get_one::<String>(\"TCP_REDIR\")\n                {\n                    local_config.tcp_redir = tcp_redir.parse::<RedirType>().expect(\"tcp-redir\");\n                }\n\n                if RedirType::udp_default() != RedirType::NotSupported\n                    && let Some(udp_redir) = matches.get_one::<String>(\"UDP_REDIR\")\n                {\n                    local_config.udp_redir = udp_redir.parse::<RedirType>().expect(\"udp-redir\");\n                }\n            }\n\n            #[cfg(feature = \"local-dns\")]\n            {\n                use shadowsocks_service::local::dns::NameServerAddr;\n\n                use self::local_value_parser::RemoteDnsAddress;\n\n                if let Some(addr) = matches.get_one::<NameServerAddr>(\"LOCAL_DNS_ADDR\").cloned() {\n                    local_config.local_dns_addr = Some(addr);\n                }\n\n                if let Some(addr) = matches.get_one::<RemoteDnsAddress>(\"REMOTE_DNS_ADDR\").cloned() {\n                    local_config.remote_dns_addr = Some(addr.0);\n                }\n            }\n","sourceCodeStart":749,"sourceCodeEnd":785,"githubUrl":"https://github.com/shadowsocks/shadowsocks-rust/blob/8eb0f0a65b1d976ab6bed5787327ef86529b0435/src/service/local.rs#L749-L785","documentation":"Analogous to the tcp case: under the local-redir feature, UDP_REDIR is parsed into RedirType and .expect(\"udp-redir\") panics on an unknown value. It only evaluates when the platform has a UDP-capable redirect default (tproxy on Linux; many platforms have no UDP redirect).","triggerScenarios":"Passing --udp-redir with a name not valid for the platform/build, such as \"redirect\" (TCP-only mechanism) where only \"tproxy\" supports UDP, or a typo like \"udtproxy\".","commonSituations":"Assuming redirect supports UDP (it does not); enabling --udp-redir on macOS/BSD where UDP redirect is unsupported; typos and case mistakes.","solutions":["Use \"tproxy\" for --udp-redir on Linux; on platforms without UDP redirect, omit the flag entirely.","Check RedirType::udp_default() != NotSupported for your build before using the flag.","Correct typos so the string matches the RedirType FromStr implementation exactly."],"exampleFix":"// before\nsslocal --udp-redir redirect ...\n\n// after\nsslocal --udp-redir tproxy ...","handlingStrategy":"validation","validationCode":"if let Some(s) = matches.get_one::<String>(\"UDP_REDIR\") {\n    match s.parse::<shadowsocks::local::net::RedirType>() {\n        Ok(t) if t != shadowsocks::local::net::RedirType::NotSupported => {}\n        _ => return Err(format!(\"udp-redir '{}' unsupported on this platform (use tproxy on Linux)\", s)),\n    }\n}","typeGuard":null,"tryCatchPattern":"let t = s.parse::<RedirType>().unwrap_or_else(|_| {\n    eprintln!(\"invalid udp-redir: {}\", s);\n    std::process::exit(2);\n});","preventionTips":["Remember only tproxy supports UDP redirect; \"redirect\" is TCP-only.","Skip --udp-redir entirely on platforms where RedirType::udp_default() is NotSupported.","Validate redir flags in CI across the target OS matrix."],"tags":["cli","rust","redirect","udp","panic"],"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"}