shadow1ng/fscan · error
%s: %w [socks5_handshake_write_failed]
Error message
%s: %w [socks5_handshake_write_failed]
What it means
Wrap of a conn.Write failure at the end of the SOCKS5 handshake: the server selected no-auth (response bytes 0x05 0x00) but could not send the method-selection reply to the client (broken/peer-reset connection). The i18n socks5_handshake_write_failed prefix marks the handshake write stage and %w preserves the underlying network error.
Source
Thrown at plugins/local/socks5proxy.go:183
return fmt.Errorf("%s: %w", i18n.GetText("socks5_handshake_read_failed"), err)
}
if header[0] != 0x05 || header[1] == 0 {
return fmt.Errorf("%s", i18n.GetText("socks5_unsupported_version"))
}
methods := make([]byte, int(header[1]))
if _, err := io.ReadFull(conn, methods); err != nil {
return fmt.Errorf("%s: %w", i18n.GetText("socks5_handshake_read_failed"), err)
}
if !containsByte(methods, 0x00) {
_, _ = conn.Write([]byte{0x05, 0xff})
return fmt.Errorf("%s", i18n.GetText("socks5_unsupported_version"))
}
// 发送握手响应(无认证)
response := []byte{0x05, 0x00} // 版本5,无认证
if _, err := conn.Write(response); err != nil {
return fmt.Errorf("%s: %w", i18n.GetText("socks5_handshake_write_failed"), err)
}
return nil
}
// handleSocks5Request 处理SOCKS5连接请求
func (p *Socks5ProxyPlugin) handleSocks5Request(clientConn net.Conn, session *common.ScanSession) (net.Conn, int, error) {
header := make([]byte, 4)
if _, err := io.ReadFull(clientConn, header); err != nil {
return nil, 0, fmt.Errorf("%s: %w", i18n.GetText("socks5_request_read_failed"), err)
}
if header[0] != 0x05 || header[2] != 0x00 {
return nil, 0, fmt.Errorf("%s", i18n.GetText("socks5_invalid_request"))
}
cmd := header[1]
if cmd != 0x01 { // 只支持CONNECT命令View on GitHub (pinned to 95cc12e753)
Solutions
- Drop the client connection; the proxy loop will accept new ones
- Check for network instability or a client-side timeout
- Ensure no firewall is resetting long-lived proxy connections
Defensive patterns
Strategy: retry
When it happens
Trigger: Thrown at plugins/local/socks5proxy.go:183 when the library encounters an invalid state.
Common situations: See trigger scenarios.
Understand the failure class
- SSL/TLS and certificate errors — how TLS handshakes and certificate validation fail.
AI-assisted analysis of shadow1ng/fscan@95cc12e753 (2026-09-06).
Data as JSON: /api/errors/bbe7eea9e91aa413.
Report an issue: GitHub.