shadow1ng/fscan · error
%s: %w [socks5_request_read_failed]
Error message
%s: %w [socks5_request_read_failed]
What it means
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.
Source
Thrown at plugins/local/socks5proxy.go:193
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命令
// 发送不支持的命令响应
response := []byte{0x05, 0x07, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
_, _ = clientConn.Write(response)
return nil, 0, fmt.Errorf(i18n.GetText("socks5_unsupported_command")+": %d", cmd)
}
// 解析目标地址
addrType := header[3]
var targetHost string
var targetPort intView on GitHub (pinned to 95cc12e753)
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
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at plugins/local/socks5proxy.go:193 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of shadow1ng/fscan@95cc12e753 (2026-09-06).
Data as JSON: /api/errors/d4c60c5b10030388.
Report an issue: GitHub.