mirror of
https://github.com/shadow1ng/fscan.git
synced 2026-09-23 03:31:53 +08:00
fix: 补全 HTTP/TLS proxy stats 加锁,修复 RPC/SMB 解析越界和 POC 加载逻辑
- httpdialer.go/tlsdialer.go: LastError/LastConnectTime/AverageConnectTime 加 mutex - findnet.go: RPC 响应结束标记位置 < 4 时跳过截断,防止负数切片 panic - ms17010.go: SMB 会话响应最小长度改为 45,sessionSetupResponse 加长度校验 - web_scan.go: POC 加载失败时不标记 pocLoaded,允许后续重试 - Eval.go: DNSLog 配置去掉 sync.Once,允许多次扫描更新配置
This commit is contained in:
@@ -30,7 +30,9 @@ func (h *httpDialer) DialContext(ctx context.Context, network, address string) (
|
||||
proxyConn, err := h.baseDial.DialContext(ctx, NetworkTCP, h.config.Address)
|
||||
if err != nil {
|
||||
atomic.AddInt64(&h.stats.FailedConnections, 1)
|
||||
h.stats.mu.Lock()
|
||||
h.stats.LastError = err.Error()
|
||||
h.stats.mu.Unlock()
|
||||
return nil, NewProxyError(ErrTypeConnection, ErrMsgHTTPConnFailed, ErrCodeHTTPConnFailed, err)
|
||||
}
|
||||
|
||||
@@ -38,12 +40,16 @@ func (h *httpDialer) DialContext(ctx context.Context, network, address string) (
|
||||
if err := h.sendConnectRequest(proxyConn, address); err != nil {
|
||||
_ = proxyConn.Close() // 错误处理路径,Close错误可忽略
|
||||
atomic.AddInt64(&h.stats.FailedConnections, 1)
|
||||
h.stats.mu.Lock()
|
||||
h.stats.LastError = err.Error()
|
||||
h.stats.mu.Unlock()
|
||||
return nil, err
|
||||
}
|
||||
|
||||
duration := time.Since(start)
|
||||
h.stats.mu.Lock()
|
||||
h.stats.LastConnectTime = start
|
||||
h.stats.mu.Unlock()
|
||||
atomic.AddInt64(&h.stats.ActiveConnections, 1)
|
||||
h.updateAverageConnectTime(duration)
|
||||
|
||||
@@ -108,7 +114,8 @@ func (h *httpDialer) sendConnectRequest(conn net.Conn, address string) error {
|
||||
|
||||
// updateAverageConnectTime 更新平均连接时间
|
||||
func (h *httpDialer) updateAverageConnectTime(duration time.Duration) {
|
||||
// 简单的移动平均
|
||||
h.stats.mu.Lock()
|
||||
defer h.stats.mu.Unlock()
|
||||
if h.stats.AverageConnectTime == 0 {
|
||||
h.stats.AverageConnectTime = duration
|
||||
} else {
|
||||
|
||||
@@ -50,7 +50,9 @@ func (t *tlsDialerWrapper) DialTLSContext(ctx context.Context, network, address
|
||||
if err := tlsConn.Handshake(); err != nil {
|
||||
_ = tcpConn.Close() // TLS握手失败,Close错误可忽略
|
||||
atomic.AddInt64(&t.stats.FailedConnections, 1)
|
||||
t.stats.mu.Lock()
|
||||
t.stats.LastError = err.Error()
|
||||
t.stats.mu.Unlock()
|
||||
return nil, NewProxyError(ErrTypeConnection, ErrMsgTLSHandshakeFailed, ErrCodeTLSHandshakeFailed, err)
|
||||
}
|
||||
|
||||
@@ -71,7 +73,8 @@ func (t *tlsDialerWrapper) DialTLSContext(ctx context.Context, network, address
|
||||
|
||||
// updateAverageConnectTime 更新平均连接时间
|
||||
func (t *tlsDialerWrapper) updateAverageConnectTime(duration time.Duration) {
|
||||
// 简单的移动平均
|
||||
t.stats.mu.Lock()
|
||||
defer t.stats.mu.Unlock()
|
||||
if t.stats.AverageConnectTime == 0 {
|
||||
t.stats.AverageConnectTime = duration
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user