XX-net/XX-Net · warning

request address type unknown:%d

Error message

request address type unknown:%d

What it means

SOCKS5 request used an address type (ATYP) other than 1 (IPv4), 3 (domain), or 4 (IPv6). The proxy replies 0x07 (command not supported) and closes.

Source

Thrown at code/default/smart_router/local/proxy_handler.py:282

            return

        command = ord(data[1:2])
        addrtype_pack = data[3:4]
        addrtype = ord(addrtype_pack)
        if addrtype == 1:  # IPv4
            addr_pack = self.read_bytes(4)
            addr = socket.inet_ntoa(addr_pack)
        elif addrtype == 3:  # Domain name
            domain_len_pack = self.read_bytes(1)[0:1]
            domain_len = ord(domain_len_pack)
            domain = self.read_bytes(domain_len)
            addr_pack = domain_len_pack + domain
            addr = domain
        elif addrtype == 4:  # IPv6
            addr_pack = self.read_bytes(16)
            addr = socket.inet_ntop(socket.AF_INET6, addr_pack)
        else:
            xlog.warn("request address type unknown:%d", addrtype)
            sock.send(b"\x05\x07\x00\x01")  # Command not supported
            return
        port = struct.unpack('>H', self.rfile.read(2))[0]

        if command == 3:  # 3. UDP associate
            return self.handle_udp_associate(sock, addr, port, addrtype_pack, addr_pack)

        if command != 1:  # 1. Tcp connect
            xlog.warn("request not supported command mode:%d", command)
            sock.send(b"\x05\x07\x00\x01")  # Command not supported
            return

        # xlog.debug("socks5 %r connect to %s:%d", self.client_address, addr, port)
        reply = b"\x05\x00\x00" + addrtype_pack + addr_pack + struct.pack(">H", port)
        sock.send(reply)

        if addrtype in [1, 4]:
            handle_ip_proxy(sock, addr, port, self.client_address)

View on GitHub (pinned to cfa5bc17b6)

Solutions

  1. Verify the client emits a valid SOCKS5 request: VER CMD RSV ATYP ADDR PORT
  2. Capture the bytes with tcpdump/wireshark to spot protocol corruption
  3. Ensure no TLS/other framing is applied before the SOCKS handshake
  4. Switch to a well-tested SOCKS client library
Defensive patterns

Strategy: validation

Validate before calling

if atyp not in (1,3,4): raise MalformedSocksRequest

Type guard

def valid_atyp(t): return t in (0x01, 0x03, 0x04)

Prevention

When it happens

Trigger: A malformed or non-compliant SOCKS5 client sends an unknown ATYP byte in the request packet.

Common situations: Corrupted handshake bytes, a client speaking a different protocol on the SOCKS port, or buggy SOCKS implementations.

Related errors


AI-assisted analysis of XX-net/XX-Net@cfa5bc17b6 (2026-08-27). Data as JSON: /api/errors/d36aa634603c5c00. Report an issue: GitHub.