shadowsocks/shadowsocks-rust · error

`server` shouldn't be an empty string, `server_port` shouldn

Error message

`server` shouldn't be an empty string, `server_port` shouldn't be 0

What it means

When a server's address is a domain name (ServerAddr::DomainName), the hostname must be non-empty and the port non-zero. Config::check rejects domain-form entries violating either condition with ErrorKind::Malformed, covering both problems in one message.

Source

Thrown at crates/shadowsocks-service/src/config.rs:2957

                    }

                    #[cfg(feature = "local-online-config")]
                    if self.config_type.is_online_config() {
                        // Only server could bind to INADDR_ANY
                        let ip = sa.ip();
                        if ip.is_unspecified() {
                            let err = Error::new(
                                ErrorKind::Malformed,
                                "`server` shouldn't be an unspecified address (INADDR_ANY)",
                                None,
                            );
                            return Err(err);
                        }
                    }
                }
                ServerAddr::DomainName(dn, port) => {
                    if dn.is_empty() || *port == 0 {
                        let err = Error::new(
                            ErrorKind::Malformed,
                            "`server` shouldn't be an empty string, `server_port` shouldn't be 0",
                            None,
                        );
                        return Err(err);
                    }
                }
            }

            // Users' key must match key length
            if let Some(user_manager) = server.user_manager() {
                #[cfg(feature = "aead-cipher-2022")]
                if server.method().is_aead_2022() {
                    use shadowsocks::config::method_support_eih;
                    if user_manager.user_count() > 0 && !method_support_eih(server.method()) {
                        let err = Error::new(
                            ErrorKind::Invalid,
                            "server method doesn't support Extended Identity Header (EIH), remove `users`",

View on GitHub (pinned to 8eb0f0a65b)

Solutions

  1. Provide a valid hostname (e.g. server = "example.com") and a port in 1-65535.
  2. Re-copy the ss:// URL ensuring the host:port section is complete.
  3. If you meant to use an IP, write it explicitly (and note port 0 is still rejected).
  4. Validate the subscription/generator output so server fields are never blank.

Example fix

// before
{ "server": "", "server_port": 8388, "password": "pw", "method": "aes-256-gcm" }

// after
{ "server": "example.com", "server_port": 8388, "password": "pw", "method": "aes-256-gcm" }
Defensive patterns

Strategy: validation

Validate before calling

// Rust
assert!(!host.trim().is_empty(), "server hostname must not be empty");
assert!(port != 0, "server_port must be > 0");

Type guard

fn valid_domain_server(host: &str, port: u16) -> bool {
    !host.trim().is_empty() && port != 0
}

Prevention

When it happens

Trigger: A server entry given as hostname:port where the hostname is "" or the port is 0 — e.g. server = "" with server_port = 8388, an ss:// URL like ss://...@:8388 or ss://...@example.com:0, or a SIP008 entry with an empty server string.

Common situations: Template configs where the hostname variable expanded to empty; truncated ss:// links missing the host part; subscription data with blank server names; CLI args where the server host was omitted.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


AI-assisted analysis of shadowsocks/shadowsocks-rust@8eb0f0a65b (2026-09-09). Data as JSON: /api/errors/0db090e459b72b6b. Report an issue: GitHub.