{"record":{"id":"6837ca4eb0a6043e","repo":"shadowsocks/shadowsocks-rust","slug":"missing-addr-in-configuration","errorCode":null,"errorMessage":"missing `addr` in configuration","messagePattern":"missing `addr` in configuration","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/shadowsocks-service/src/config.rs","lineNumber":1333,"sourceCode":"            fake_dns_database_path: None,\n        }\n    }\n\n    /// Create a new `LocalConfig` with listen address\n    pub fn new_with_addr(addr: ServerAddr, protocol: ProtocolType) -> Self {\n        let mut config = Self::new(protocol);\n        config.addr = Some(addr);\n        config\n    }\n\n    fn check_integrity(&self) -> Result<(), Error> {\n        match self.protocol {\n            #[cfg(feature = \"local-tun\")]\n            ProtocolType::Tun => {}\n\n            _ => {\n                if self.addr.is_none() {\n                    let err = Error::new(ErrorKind::MissingField, \"missing `addr` in configuration\", None);\n                    return Err(err);\n                }\n            }\n        }\n\n        match self.protocol {\n            #[cfg(feature = \"local-dns\")]\n            ProtocolType::Dns => {\n                if self.local_dns_addr.is_none() || self.remote_dns_addr.is_none() {\n                    let err = Error::new(\n                        ErrorKind::MissingField,\n                        \"missing `local_dns_addr` or `remote_dns_addr` in configuration\",\n                        None,\n                    );\n                    return Err(err);\n                }\n            }\n            #[cfg(feature = \"local-tunnel\")]","sourceCodeStart":1315,"sourceCodeEnd":1351,"githubUrl":"https://github.com/shadowsocks/shadowsocks-rust/blob/8eb0f0a65b1d976ab6bed5787327ef86529b0435/crates/shadowsocks-service/src/config.rs#L1315-L1351","documentation":"shadowsocks-service's Config checker validates LocalConfig before running the local service: every ProtocolType except Tun must have `addr` (the local listening address) set, since TUN operates on a virtual interface instead of a socket. Missing it yields ErrorKind::MissingField with this message, propagated from check() / from_url. (The compile_regex/from_url references in the metadata point at the shared Error type, not this specific message.)","triggerScenarios":"Building LocalConfig programmatically (or via Config::from_url) without setting `local.addr`, then calling Config::check()/ConfigType::Local validation; a config JSON missing the `local_addr` field for a socks/http/dns/tunnel/redir protocol; a sslocal:// URL without the address component.","commonSituations":"Hand-written config.json with `\"local_port\"` but no address fields in the expected shape; API users of shadowsocks-service crate constructing LocalConfig::new(ProtocolType::Dns) and forgetting `config.addr = Some(...)`; tooling generating configs dropping empty fields.","solutions":["Set the local listening address: `config.local.addr = Some(\"127.0.0.1:1080\".parse()?)` before check()","Add `local_addr` (and/or `local_address`+`local_port` as required by your version) to the config JSON","If you intentionally don't need a listening address, use ProtocolType::Tun (requires the local-tun feature)","For from_url usage, ensure the sslocal:// URL includes the bind address/port"],"exampleFix":"// before\nlet mut local = LocalConfig::new(ProtocolType::Socks);\n// after\nlet mut local = LocalConfig::new(ProtocolType::Socks);\nlocal.addr = Some(\"127.0.0.1:1080\".parse().unwrap());","handlingStrategy":"validation","validationCode":"// before calling config.check()\nfor local in &config.local {\n    if local.protocol != ProtocolType::Tun && local.addr.is_none() {\n        return Err(\"local.addr must be set for non-TUN protocols\");\n    }\n}","typeGuard":null,"tryCatchPattern":"// this one is a returned error, so handle it normally:\nif let Err(err) = config.check() {\n    eprintln!(\"invalid config: {err}\");\n    std::process::exit(1);\n}","preventionTips":["Always set local.addr for socks/http/tunnel/redir/dns protocols before check()","Validate generated config JSON against the shadowsocks schema in CI","When using from_url, assert the sslocal:// URL contains a bind address","Only omit addr when protocol is Tun with the local-tun feature enabled"],"tags":["configuration","validation","shadowsocks-service"],"backgroundTag":"missing-required-config-field","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"}