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

This commit is contained in:
ZacharyZcR
2026-06-14 22:23:50 +08:00
parent 63631d6cdf
commit 4169eb6ee0
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 {