XX-net/XX-Net · warning

Socks4 cmd:%d not supported

Error message

Socks4 cmd:%d not supported

What it means

SOCKS4 handler only supports cmd=1 (TCP CONNECT). The client requested bind (2) or udp associate (3), which is rejected and the session terminated.

Source

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

                if len(data):
                    self.read_buffer += data
                else:
                    raise socket.error("recv fail")
        finally:
            sock.setblocking(1)

        data = self.read_buffer[self.buffer_start:self.buffer_start + size]
        self.buffer_start += size
        return data

    def socks4_handler(self):
        # Socks4 or Socks4a
        sock = self.conn
        socks_version = ord(self.read_bytes(1))
        cmd = ord(self.read_bytes(1))
        if cmd != 1:
            xlog.warn("Socks4 cmd:%d not supported", cmd)
            return

        data = self.read_bytes(6)
        port = struct.unpack(">H", data[0:2])[0]
        addr_pack = data[2:6]
        if addr_pack[0:3] == b'\x00\x00\x00' and addr_pack[3:4] != b'\x00':
            domain_mode = True
        else:
            ip = socket.inet_ntoa(addr_pack)
            domain_mode = False

        user_id = self.read_null_end_line()
        if len(user_id):
            xlog.debug("Socks4 user_id:%s", user_id)

        if domain_mode:
            addr = self.read_null_end_line()
        else:

View on GitHub (pinned to cfa5bc17b6)

Solutions

  1. Configure the client to use SOCKS5 with TCP CONNECT
  2. Use passive mode in the client app (e.g. FTP passive) to avoid BIND
  3. Upgrade the client library to one that only issues CONNECT
  4. If BIND is required, use a proxy that supports it
Defensive patterns

Strategy: validation

Validate before calling

if cmd != 1: reject early with socks4 error reply

Prevention

When it happens

Trigger: A SOCKS4 client issuing CMD 0x02 (BIND) or any value other than 0x01.

Common situations: FTP active mode via SOCKS4, or SOCKS clients configured for BIND; most commonly an old/misbehaving client.

Related errors


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