diff --git a/common/network.go b/common/network.go index 24c2045..1fa304f 100644 --- a/common/network.go +++ b/common/network.go @@ -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) { // 检查发包限制 diff --git a/common/proxy/detector.go b/common/proxy/detector.go index e296f44..544e98c 100644 --- a/common/proxy/detector.go +++ b/common/proxy/detector.go @@ -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 { diff --git a/core/port_scan.go b/core/port_scan.go index bddaeb4..b0d82a9 100644 --- a/core/port_scan.go +++ b/core/port_scan.go @@ -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" }