{"record":{"id":"f517587827d9ded6","repo":"shadow1ng/fscan","slug":"socks5-success-response-failed-w","errorCode":null,"errorMessage":"socks5_success_response_failed: %w","messagePattern":"socks5_success_response_failed: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"plugins/local/socks5proxy.go","lineNumber":285,"sourceCode":"\t\treturn nil, 0, fmt.Errorf(\"%s\", i18n.GetText(\"local_address_unavailable\"))\n\t}\n\tlocalPort := localAddr.Port\n\n\t// 发送成功响应\n\tresponse := make([]byte, 10)\n\tresponse[0] = 0x05 // SOCKS版本\n\tresponse[1] = 0x00 // 成功\n\tresponse[2] = 0x00 // 保留\n\tresponse[3] = 0x01 // IPv4地址类型\n\t// 绑定地址和端口（使用127.0.0.1:localPort）\n\tcopy(response[4:8], []byte{127, 0, 0, 1})\n\tresponse[8] = byte(localPort >> 8)\n\tresponse[9] = byte(localPort & 0xff)\n\n\t_, err = clientConn.Write(response)\n\tif err != nil {\n\t\t_ = targetConn.Close()\n\t\treturn nil, 0, fmt.Errorf(\"%s: %w\", i18n.GetText(\"socks5_success_response_failed\"), err)\n\t}\n\n\tsession.LogDebug(i18n.Tr(\"socks5_proxy_connection_established\", targetAddr))\n\treturn targetConn, localPort, nil\n}\n\nfunc containsByte(values []byte, target byte) bool {\n\tfor _, value := range values {\n\t\tif value == target {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}\n\n// relayData 双向数据转发\nfunc (p *Socks5ProxyPlugin) relayData(clientConn, targetConn net.Conn) {\n\tdone := make(chan struct{}, 2)","sourceCodeStart":267,"sourceCodeEnd":303,"githubUrl":"https://github.com/shadow1ng/fscan/blob/95cc12e753bf43de7004e5aef42a9ffba3934303/plugins/local/socks5proxy.go#L267-L303","documentation":"The proxy built the SOCKS5 success reply (0x00) but the write to the client connection failed. The proxy closes the established target connection and aborts with socks5_success_response_failed wrapping the underlying write error.","triggerScenarios":"clientConn.Write(response) returns an error right after the target connection succeeded: client closed the connection, network reset, or client socket buffer issues.","commonSituations":"Impatient SOCKS5 client gives up and closes its socket while the proxy is dialing the target; NAT/firewall resets the client connection mid-handshake.","solutions":["Check the wrapped %w error: ECONNRESET/EOF means the client vanished — normal operational noise, log at debug","Ensure the client waits for the SOCKS5 reply before sending payload data","If frequent, reduce client handshake timeouts or verify intermediate proxies/firewalls between client and proxy"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// caller\nif _, _, err := handleSocks5Request(...); err != nil {\n    if errors.Is(err, io.ErrClosedPipe) || errors.Is(err, syscall.ECONNRESET) || errors.Is(err, io.EOF) {\n        log.Println(\"client disconnected during handshake\") // benign\n    } else {\n        log.Printf(\"handshake write failed: %v\", err)\n    }\n}","preventionTips":["Client must wait for the SOCKS5 reply before sending data","Keep client-side read timeouts longer than the proxy's dial timeout","Log client disconnects at debug level to reduce noise"],"tags":["socks5","network","write","broken-pipe"],"backgroundTag":"broken-pipe","analyzedSha":"95cc12e753bf43de7004e5aef42a9ffba3934303","analyzedAt":"2026-09-06T17:07:30.094Z","contentChangedAt":"2026-09-06T17:07:30.094Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}