{"record":{"id":"9005aea96d8b9000","repo":"shadowsocks/shadowsocks-rust","slug":"dns-9005ae","errorCode":null,"errorMessage":"dns","messagePattern":"dns","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/service/server.rs","lineNumber":467,"sourceCode":"\n        #[cfg(all(unix, not(target_os = \"android\")))]\n        match matches.get_one::<u64>(\"NOFILE\") {\n            Some(nofile) => config.nofile = Some(*nofile),\n            None => {\n                if config.nofile.is_none() {\n                    crate::sys::adjust_nofile();\n                }\n            }\n        }\n\n        if let Some(acl_file) = matches.get_one::<String>(\"ACL\") {\n            let acl = AccessControl::load_from_file(acl_file)\n                .map_err(|err| ShadowsocksError::LoadAclFailure(format!(\"loading ACL \\\"{acl_file}\\\", {err}\")))?;\n            config.acl = Some(acl);\n        }\n\n        if let Some(dns) = matches.get_one::<String>(\"DNS\") {\n            config.set_dns_formatted(dns).expect(\"dns\");\n        }\n\n        if let Some(dns_cache_size) = matches.get_one::<usize>(\"DNS_CACHE_SIZE\") {\n            config.dns_cache_size = Some(*dns_cache_size);\n        }\n\n        if matches.get_flag(\"IPV6_FIRST\") {\n            config.ipv6_first = true;\n        }\n\n        if let Some(udp_timeout) = matches.get_one::<u64>(\"UDP_TIMEOUT\") {\n            config.udp_timeout = Some(Duration::from_secs(*udp_timeout));\n        }\n\n        if let Some(udp_max_assoc) = matches.get_one::<usize>(\"UDP_MAX_ASSOCIATIONS\") {\n            config.udp_max_associations = Some(*udp_max_assoc);\n        }\n","sourceCodeStart":449,"sourceCodeEnd":485,"githubUrl":"https://github.com/shadowsocks/shadowsocks-rust/blob/8eb0f0a65b1d976ab6bed5787327ef86529b0435/src/service/server.rs#L449-L485","documentation":"This panic fires from `.expect(\"dns\")` on `config.set_dns_formatted(dns)` when the value of the `--dns` CLI flag cannot be parsed as a DNS server specification. The library expects a formatted string like `\"1.1.1.1\",\"8.8.8.8:53,udp\"` (address with optional port and protocol) and panics rather than returning an error for malformed input.","triggerScenarios":"Running the server with `--dns` set to a malformed value, e.g. a bare hostname (`--dns dns.google`), an empty string, a value with wrong quoting/comma syntax, or an unsupported protocol suffix (`--dns \"1.1.1.1,xxx\"`).","commonSituations":"Copy-pasted DNS configs losing their quotes in shell escaping, using a hostname instead of an IP, missing the `,udp`/`,tcp` suffix rules, or shell stripping quotes so the parser sees a single malformed token.","solutions":["Use a valid formatted DNS string, e.g. `--dns '\"1.1.1.1\"'` or `--dns '\"8.8.8.8:53,udp\"'` with proper shell quoting.","Prefer IP addresses over hostnames in the --dns value.","Verify shell quoting so commas and embedded double-quotes survive to the process.","Remove --dns to use the system DNS resolution defaults.","When modifying code, replace `.expect(\"dns\")` with proper error propagation into ShadowsocksError."],"exampleFix":"// before (shell eats the quotes -> malformed)\nssserver --dns \"1.1.1.1\"\n// after\nssserver --dns '\"1.1.1.1\"'\n# or with protocol\nssserver --dns '\"8.8.8.8:53,udp\"'","handlingStrategy":"validation","validationCode":"// Validate --dns before launching: quoted address, optional :port, optional ,udp|,tcp suffix\nlet dns = std::env::args().nth(/* position of --dns value */ 0).unwrap_or_default();\nassert!(dns.starts_with('\"') && dns.ends_with('\"'), \"--dns must be a quoted spec like \\\"8.8.8.8:53,udp\\\"\");","typeGuard":"fn looks_like_dns_spec(s: &str) -> bool {\n    let inner = s.trim().trim_matches('\"');\n    inner.parse::<std::net::IpAddr>().is_ok()\n        || inner.split_once(':').map(|(ip, _)| ip.parse::<std::net::IpAddr>().is_ok()).unwrap_or(false)\n}","tryCatchPattern":null,"preventionTips":["Always single-quote --dns values in shell so embedded double quotes survive.","Use IP addresses, not hostnames, in DNS specs.","Follow the documented format: \"addr\" or \"addr:port,proto\" entries."],"tags":["dns","configuration","panic","cli"],"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"}