{"record":{"id":"5ccc9935d4b995c8","repo":"shadowsocks/shadowsocks-rust","slug":"tun-interface-address-invalid","errorCode":null,"errorMessage":"`tun_interface_address` invalid","messagePattern":"`tun_interface_address` invalid","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/shadowsocks-service/src/config.rs","lineNumber":2010,"sourceCode":"                        if let Some(client_cache_size) = local.client_cache_size {\n                            local_config.client_cache_size = Some(client_cache_size);\n                        }\n\n                        #[cfg(feature = \"local-dns\")]\n                        if let Some(remote_dns_address) = local.remote_dns_address {\n                            let remote_dns_port = local.remote_dns_port.unwrap_or(53);\n                            local_config.remote_dns_addr = Some(match remote_dns_address.parse::<IpAddr>() {\n                                Ok(ip) => Address::from(SocketAddr::new(ip, remote_dns_port)),\n                                Err(..) => Address::from((remote_dns_address, remote_dns_port)),\n                            });\n                        }\n\n                        #[cfg(feature = \"local-tun\")]\n                        if let Some(tun_interface_address) = local.tun_interface_address {\n                            match tun_interface_address.parse::<IpNet>() {\n                                Ok(addr) => local_config.tun_interface_address = Some(addr),\n                                Err(..) => {\n                                    let err = Error::new(ErrorKind::Malformed, \"`tun_interface_address` invalid\", None);\n                                    return Err(err);\n                                }\n                            }\n                        }\n\n                        #[cfg(feature = \"local-tun\")]\n                        if let Some(tun_interface_destination) = local.tun_interface_destination {\n                            match tun_interface_destination.parse::<IpNet>() {\n                                Ok(addr) => local_config.tun_interface_destination = Some(addr),\n                                Err(..) => {\n                                    let err =\n                                        Error::new(ErrorKind::Malformed, \"`tun_interface_destination` invalid\", None);\n                                    return Err(err);\n                                }\n                            }\n                        }\n\n                        #[cfg(feature = \"local-tun\")]","sourceCodeStart":1992,"sourceCodeEnd":2028,"githubUrl":"https://github.com/shadowsocks/shadowsocks-rust/blob/8eb0f0a65b1d976ab6bed5787327ef86529b0435/crates/shadowsocks-service/src/config.rs#L1992-L2028","documentation":"Thrown while parsing a SIP008/JSON local config: the `tun_interface_address` field failed to parse as an IpNet (CIDR network). The library requires a valid IPv4/IPv6 network like `10.0.0.1/24`; anything else is rejected with ErrorKind::Malformed during Config::load_from_json / from (SIP008) processing.","triggerScenarios":"Calling config parsing with a local entry whose `tun_interface_address` is set to a bare IP without a prefix length, a hostname, an empty string, or any string not parseable by `IpNet::from_str`.","commonSituations":"Copying a TUN address from another tool that uses plain IPs instead of CIDR notation; typos like `10.0.0.1/33`; forgetting the `/prefix` suffix; IPv6 addresses with invalid prefix.","solutions":["Use CIDR notation with a valid prefix, e.g. `\"tun_interface_address\": \"10.0.0.1/24\"`","Verify the prefix length is valid for the address family (0-32 for IPv4, 0-128 for IPv6)","If only a plain address is needed, append `/32` (IPv4) or `/128` (IPv6)"],"exampleFix":"// before\n{\"tun_interface_address\": \"10.0.0.1\"}\n// after\n{\"tun_interface_address\": \"10.0.0.1/24\"}","handlingStrategy":"validation","validationCode":"fn valid_ipnet(s: &str) -> bool { s.parse::<ipnet::IpNet>().is_ok() }\n// before load: assert config[\"tun_interface_address\"].as_str().map(valid_ipnet).unwrap_or(true)","typeGuard":"fn is_ipnet(s: &str) -> bool { s.parse::<ipnet::IpNet>().is_ok() }","tryCatchPattern":"match Config::load_from_json(...) { Err(e) if format!(\"{e}\").contains(\"tun_interface_address\") => fix_and_retry(), ... }","preventionTips":["Always write TUN addresses in CIDR notation","Validate the JSON with a schema before loading","Append /32 or /128 when only a host address is intended"],"tags":["config","tun","cidr"],"backgroundTag":"invalid-config-value","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"}