{"record":{"id":"e6877305b923a462","repo":"XX-net/XX-Net","slug":"socks4-cmd-d-not-supported","errorCode":null,"errorMessage":"Socks4 cmd:%d not supported","messagePattern":"Socks4 cmd:(.+?) not supported","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"code/default/smart_router/local/proxy_handler.py","lineNumber":208,"sourceCode":"\n                if len(data):\n                    self.read_buffer += data\n                else:\n                    raise socket.error(\"recv fail\")\n        finally:\n            sock.setblocking(1)\n\n        data = self.read_buffer[self.buffer_start:self.buffer_start + size]\n        self.buffer_start += size\n        return data\n\n    def socks4_handler(self):\n        # Socks4 or Socks4a\n        sock = self.conn\n        socks_version = ord(self.read_bytes(1))\n        cmd = ord(self.read_bytes(1))\n        if cmd != 1:\n            xlog.warn(\"Socks4 cmd:%d not supported\", cmd)\n            return\n\n        data = self.read_bytes(6)\n        port = struct.unpack(\">H\", data[0:2])[0]\n        addr_pack = data[2:6]\n        if addr_pack[0:3] == b'\\x00\\x00\\x00' and addr_pack[3:4] != b'\\x00':\n            domain_mode = True\n        else:\n            ip = socket.inet_ntoa(addr_pack)\n            domain_mode = False\n\n        user_id = self.read_null_end_line()\n        if len(user_id):\n            xlog.debug(\"Socks4 user_id:%s\", user_id)\n\n        if domain_mode:\n            addr = self.read_null_end_line()\n        else:","sourceCodeStart":190,"sourceCodeEnd":226,"githubUrl":"https://github.com/XX-net/XX-Net/blob/cfa5bc17b67676e467f37ec50766127e0ab5f0aa/code/default/smart_router/local/proxy_handler.py#L190-L226","documentation":"SOCKS4 handler only supports cmd=1 (TCP CONNECT). The client requested bind (2) or udp associate (3), which is rejected and the session terminated.","triggerScenarios":"A SOCKS4 client issuing CMD 0x02 (BIND) or any value other than 0x01.","commonSituations":"FTP active mode via SOCKS4, or SOCKS clients configured for BIND; most commonly an old/misbehaving client.","solutions":["Configure the client to use SOCKS5 with TCP CONNECT","Use passive mode in the client app (e.g. FTP passive) to avoid BIND","Upgrade the client library to one that only issues CONNECT","If BIND is required, use a proxy that supports it"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if cmd != 1: reject early with socks4 error reply","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Configure SOCKS clients to use CONNECT only","Use passive-mode apps to avoid BIND"],"tags":["socks4","protocol","unsupported-command"],"backgroundTag":"socks-command-not-supported","analyzedSha":"cfa5bc17b67676e467f37ec50766127e0ab5f0aa","analyzedAt":"2026-08-27T19:28:28.225Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}