fix: skip proxy deep verification for SOCKS5 connections (#579)

SOCKS5 protocol validates connection reachability at protocol level,
deep verification was incorrectly rejecting non-banner services like
SMB(445), RPC(139) and Kerberos(88).
This commit is contained in:
ZacharyZcR
2026-05-12 21:40:47 +08:00
parent 7db89e0bd3
commit 8f72acd17f
3 changed files with 17 additions and 2 deletions
+5
View File
@@ -156,6 +156,11 @@ func IsProxyReliable() bool {
return proxy.IsProxyReliable()
}
// IsSOCKS5Proxy 检查当前代理是否为SOCKS5类型
func IsSOCKS5Proxy() bool {
return proxy.IsSOCKS5Proxy()
}
// SafeHTTPDo 带发包控制的HTTP请求
func SafeHTTPDo(client *http.Client, req *http.Request) (*http.Response, error) {
// 检查发包限制
+9
View File
@@ -19,6 +19,9 @@ var (
// proxyProbed 标记代理是否已经探测过(避免重复探测)
proxyProbed atomic.Bool
// currentProxyType 当前代理类型
currentProxyType atomic.Int32
)
// SetProxyEnabled 设置代理启用状态
@@ -61,6 +64,11 @@ func IsProxyProbed() bool {
return proxyProbed.Load()
}
// IsSOCKS5Proxy 检查当前代理是否为SOCKS5类型
func IsSOCKS5Proxy() bool {
return proxyEnabled.Load() && ProxyType(currentProxyType.Load()) == ProxyTypeSOCKS5
}
// AutoConfigureProxy 自动配置代理相关行为
// 根据代理类型和状态自动调整扫描策略
func AutoConfigureProxy(config *ProxyConfig) {
@@ -74,6 +82,7 @@ func AutoConfigureProxy(config *ProxyConfig) {
// 启用代理标记
SetProxyEnabled(true)
currentProxyType.Store(int32(config.Type))
// SOCKS5代理默认假设非标准(后续由探测函数验证)
if config.Type == ProxyTypeSOCKS5 {
+3 -2
View File
@@ -420,8 +420,9 @@ func isTimeoutError(err error) bool {
// 2. 轻量探测 (发送 \r\n) - 触发某些服务响应,同时不污染协议状态
// 3. 短超时等待 (500ms) - 平衡准确性和性能
func verifyProxyConnectionDeep(conn net.Conn, addr string) (bool, string) {
// 如果没有使用代理,跳过验证
if !common.IsProxyEnabled() {
// 无代理或SOCKS5代理:跳过深度验证
// SOCKS5协议层已验证连接可达性,连接成功即端口开放
if !common.IsProxyEnabled() || common.IsSOCKS5Proxy() {
return true, "direct"
}