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 (CONNECT). Any other command code (e.g. 2=BIND, 3=UDP ASSOCIATE) triggers this warning and the connection is closed.

Source

Thrown at code/default/x_tunnel/local/proxy_handler.py:187

                        raise e

                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.connection
        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] != 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 TCP CONNECT only
  2. Use SOCKS5 with a client that falls back to TCP
  3. UDP proxying is not supported by this handler
Defensive patterns

Strategy: validation

Validate before calling

if cmd != 1: reject_client_side()  # only CONNECT supported

Prevention

When it happens

Trigger: A SOCKS4 client issuing BIND or UDP ASSOCIATE to the local proxy.

Common situations: Torrent clients, DNS-over-SOCKS, or games trying UDP via SOCKS4. Rare; most clients use CONNECT.

Related errors


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