{"record":{"id":"d4c60c5b10030388","repo":"shadow1ng/fscan","slug":"s-w-socks5-request-read-failed","errorCode":null,"errorMessage":"%s: %w [socks5_request_read_failed]","messagePattern":"(.+?): %w \\[socks5_request_read_failed\\]","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugins/local/socks5proxy.go","lineNumber":193,"sourceCode":"\tif !containsByte(methods, 0x00) {\n\t\t_, _ = conn.Write([]byte{0x05, 0xff})\n\t\treturn fmt.Errorf(\"%s\", i18n.GetText(\"socks5_unsupported_version\"))\n\t}\n\n\t// 发送握手响应（无认证）\n\tresponse := []byte{0x05, 0x00} // 版本5，无认证\n\tif _, err := conn.Write(response); err != nil {\n\t\treturn fmt.Errorf(\"%s: %w\", i18n.GetText(\"socks5_handshake_write_failed\"), err)\n\t}\n\n\treturn nil\n}\n\n// handleSocks5Request 处理SOCKS5连接请求\nfunc (p *Socks5ProxyPlugin) handleSocks5Request(clientConn net.Conn, session *common.ScanSession) (net.Conn, int, error) {\n\theader := make([]byte, 4)\n\tif _, err := io.ReadFull(clientConn, header); err != nil {\n\t\treturn nil, 0, fmt.Errorf(\"%s: %w\", i18n.GetText(\"socks5_request_read_failed\"), err)\n\t}\n\n\tif header[0] != 0x05 || header[2] != 0x00 {\n\t\treturn nil, 0, fmt.Errorf(\"%s\", i18n.GetText(\"socks5_invalid_request\"))\n\t}\n\n\tcmd := header[1]\n\tif cmd != 0x01 { // 只支持CONNECT命令\n\t\t// 发送不支持的命令响应\n\t\tresponse := []byte{0x05, 0x07, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}\n\t\t_, _ = clientConn.Write(response)\n\t\treturn nil, 0, fmt.Errorf(i18n.GetText(\"socks5_unsupported_command\")+\": %d\", cmd)\n\t}\n\n\t// 解析目标地址\n\taddrType := header[3]\n\tvar targetHost string\n\tvar targetPort int","sourceCodeStart":175,"sourceCodeEnd":211,"githubUrl":"https://github.com/shadow1ng/fscan/blob/95cc12e753bf43de7004e5aef42a9ffba3934303/plugins/local/socks5proxy.go#L175-L211","documentation":"Wrap of an io.ReadFull failure at the start of handleSocks5Request: the 4-byte SOCKS5 request header (VER, CMD, RSV, ATYP) could not be read from the client connection, typically a mid-session disconnect or timeout after a successful handshake. The i18n socks5_request_read_failed prefix identifies the request-read stage and %w preserves the I/O cause.","triggerScenarios":"Thrown at plugins/local/socks5proxy.go:193 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the client actually speaks SOCKS5 and stays connected for the full request phase (header read happens right after the handshake reply)","Check for network intermediaries (LB idle timeouts, NAT, firewalls) dropping long-lived proxied connections and tighten keepalives","If reading times out repeatedly, inspect the client's read deadlines set around the proxy connection and raise forward.Timeout","Capture the returned error with errors.Unwrap to distinguish EOF/timeout from a protocol-level refusal and handle client disconnects as non-fatal"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"95cc12e753bf43de7004e5aef42a9ffba3934303","analyzedAt":"2026-09-06T17:07:30.094Z","contentChangedAt":"2026-09-06T17:07:30.094Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}