Skip to content

Commit

Permalink
Merge pull request #946 from apernet/wip-obsocks5err
Browse files Browse the repository at this point in the history
chore: human-readable outbounds socks5 error msg
  • Loading branch information
tobyxdd authored Feb 21, 2024
2 parents bb99579 + f0d59eb commit a531542
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion extras/outbounds/ob_socks5.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,31 @@ type errSOCKS5RequestFailed struct {
}

func (e errSOCKS5RequestFailed) Error() string {
return fmt.Sprintf("SOCKS5 request failed: %d", e.Rep)
var msg string
// RFC 1928
switch e.Rep {
case 0x00:
msg = "succeeded"
case 0x01:
msg = "general SOCKS server failure"
case 0x02:
msg = "connection not allowed by ruleset"
case 0x03:
msg = "Network unreachable"
case 0x04:
msg = "Host unreachable"
case 0x05:
msg = "Connection refused"
case 0x06:
msg = "TTL expired"
case 0x07:
msg = "Command not supported"
case 0x08:
msg = "Address type not supported"
default:
msg = "undefined"
}
return fmt.Sprintf("SOCKS5 request failed: %s (%d)", msg, e.Rep)
}

// socks5Outbound is a PluggableOutbound that connects to the target using
Expand Down

0 comments on commit a531542

Please sign in to comment.