mirror of
https://github.com/shadow1ng/fscan.git
synced 2026-09-22 03:10:42 +08:00
fix: 所有UDP插件添加ReadDeadline防止无限阻塞
SNMP/BACnet/DNS/IPMI/TFTP 的 conn.Read() 在目标不响应时 无限阻塞(goroutine 泄漏),导致整个扫描无法结束。 在 Write 前设置 ReadDeadline 确保超时后返回。
This commit is contained in:
@@ -34,6 +34,10 @@ func (p *DNSPlugin) Scan(ctx context.Context, info *common.HostInfo, session *co
|
||||
}
|
||||
defer conn.Close()
|
||||
|
||||
if dl, ok := conn.(interface{ SetReadDeadline(time.Time) error }); ok {
|
||||
_ = dl.SetReadDeadline(time.Now().Add(timeout))
|
||||
}
|
||||
|
||||
if _, err := conn.Write(query); err != nil {
|
||||
return &ScanResult{Success: false, Service: "dns"}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user