shadow1ng/fscan · warning
socks5_success_response_failed: %w
Error message
socks5_success_response_failed: %w
What it means
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.
Source
Thrown at plugins/local/socks5proxy.go:285
return nil, 0, fmt.Errorf("%s", i18n.GetText("local_address_unavailable"))
}
localPort := localAddr.Port
// 发送成功响应
response := make([]byte, 10)
response[0] = 0x05 // SOCKS版本
response[1] = 0x00 // 成功
response[2] = 0x00 // 保留
response[3] = 0x01 // IPv4地址类型
// 绑定地址和端口(使用127.0.0.1:localPort)
copy(response[4:8], []byte{127, 0, 0, 1})
response[8] = byte(localPort >> 8)
response[9] = byte(localPort & 0xff)
_, err = clientConn.Write(response)
if err != nil {
_ = targetConn.Close()
return nil, 0, fmt.Errorf("%s: %w", i18n.GetText("socks5_success_response_failed"), err)
}
session.LogDebug(i18n.Tr("socks5_proxy_connection_established", targetAddr))
return targetConn, localPort, nil
}
func containsByte(values []byte, target byte) bool {
for _, value := range values {
if value == target {
return true
}
}
return false
}
// relayData 双向数据转发
func (p *Socks5ProxyPlugin) relayData(clientConn, targetConn net.Conn) {
done := make(chan struct{}, 2)View on GitHub (pinned to 95cc12e753)
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
Defensive patterns
Strategy: try-catch
Try / catch
// caller
if _, _, err := handleSocks5Request(...); err != nil {
if errors.Is(err, io.ErrClosedPipe) || errors.Is(err, syscall.ECONNRESET) || errors.Is(err, io.EOF) {
log.Println("client disconnected during handshake") // benign
} else {
log.Printf("handshake write failed: %v", err)
}
} Prevention
- 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
When it happens
Trigger: clientConn.Write(response) returns an error right after the target connection succeeded: client closed the connection, network reset, or client socket buffer issues.
Common situations: Impatient SOCKS5 client gives up and closes its socket while the proxy is dialing the target; NAT/firewall resets the client connection mid-handshake.
Related errors
- %s: %w [listen_port_failed]
- %s: %w [socks5_handshake_read_failed]
- %s [socks5_unsupported_version]
- socks5_target_connect_failed: %w
- ms17010_send_protocol_error: %w
AI-assisted analysis of shadow1ng/fscan@95cc12e753 (2026-09-06).
Data as JSON: /api/errors/f517587827d9ded6.
Report an issue: GitHub.