fix: UDP插件改用 conn.SetDeadline 替代类型断言

This commit is contained in:
ZacharyZcR
2026-06-13 21:52:26 +08:00
parent 1a7770530d
commit 06ba595e32
5 changed files with 5 additions and 15 deletions
+1 -3
View File
@@ -75,9 +75,7 @@ func (p *SNMPPlugin) probe(ctx context.Context, target, community string, timeou
}
defer conn.Close()
if dl, ok := conn.(interface{ SetReadDeadline(time.Time) error }); ok {
_ = dl.SetReadDeadline(time.Now().Add(timeout))
}
_ = conn.SetDeadline(time.Now().Add(timeout))
pkt := buildSNMPGetRequest(community, []int{1, 3, 6, 1, 2, 1, 1, 1, 0})
if _, err := conn.Write(pkt); err != nil {