shadowsocks/shadowsocks-rust · error

target address must not be unnamed

Error message

target address must not be unnamed

What it means

send_to on a unix-datagram manager socket received a unix socket address that has no pathname (an unnamed/unbound address). Unix datagram sends require a concrete filesystem path, so the call fails with ErrorKind::InvalidInput.

Solutions

  1. Ensure the unix socket address is bound to a filesystem path and pass that path
  2. Read the manager socket path from config and build the address from it explicitly
  3. Check saddr.as_pathname() yourself before calling send_to and report a clearer error

Example fix

// before
let addr = unsafe { UnixSocketAddr::from_unnamed() }; // as_pathname() == None
unix_conn.send_to(buf, &addr).await?;
// after
let addr = UnixSocketAddr::from_pathname("/var/run/ss-manager.sock")?;
unix_conn.send_to(buf, &addr).await?;
Defensive patterns

Strategy: validation

Validate before calling

if target.as_pathname().is_none() {
    return Err(anyhow!("unix target has no pathname"));
}

Prevention

When it happens

Trigger: Calling send_to with ManagerSocketAddr::UnixSocketAddr whose SocketAddr (unix) was created without a path or whose as_pathname() returns None (e.g. from an abstract/unbound peer address), while the transport is ManagerDatagram::UnixDatagram.

Common situations: Using an address obtained from recv_from on an unnamed peer; constructing a unix SocketAddr from a default/uninitialized value; forgetting to set the manager socket path in config.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


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

Appendix: source

Thrown at crates/shadowsocks/src/manager/datagram.rs:157

    }

    /// Sends data to the socket to the specified address.
    pub async fn send_to(&mut self, buf: &[u8], target: &ManagerSocketAddr) -> io::Result<usize> {
        match *self {
            Self::UdpDatagram(ref mut udp) => match *target {
                ManagerSocketAddr::SocketAddr(ref saddr) => udp.send_to(buf, saddr).await,
                #[cfg(unix)]
                ManagerSocketAddr::UnixSocketAddr(..) => {
                    let err = io::Error::new(ErrorKind::InvalidInput, "udp datagram requires IP address target");
                    Err(err)
                }
            },
            #[cfg(unix)]
            Self::UnixDatagram(ref mut unix) => match *target {
                ManagerSocketAddr::UnixSocketAddr(ref saddr) => match saddr.as_pathname() {
                    Some(paddr) => unix.send_to(buf, paddr).await,
                    None => {
                        let err = io::Error::new(ErrorKind::InvalidInput, "target address must not be unnamed");
                        Err(err)
                    }
                },
                ManagerSocketAddr::SocketAddr(..) => {
                    let err = io::Error::new(ErrorKind::InvalidInput, "unix datagram requires path address target");
                    Err(err)
                }
            },
        }
    }

    /// Sends data on the socket to the specified manager address
    pub async fn send_to_manager(&mut self, buf: &[u8], context: &Context, target: &ManagerAddr) -> io::Result<usize> {
        match *self {
            Self::UdpDatagram(ref mut udp) => match *target {
                ManagerAddr::SocketAddr(ref saddr) => udp.send_to(buf, saddr).await,
                ManagerAddr::DomainName(ref dname, port) => {
                    let (_, n) = lookup_then!(context, dname, port, |saddr| { udp.send_to(buf, saddr).await })?;

View on GitHub (pinned to 8eb0f0a65b)