From 640fcbc550f5b12a5ee835211b380a97dd90180b Mon Sep 17 00:00:00 2001 From: "Marcelo E. Magallon" Date: Fri, 21 Oct 2022 16:42:25 -0600 Subject: [PATCH] Compare ICMPType values, not their strings Signed-off-by: Marcelo E. Magallon --- pkg/icmp/icmp.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/icmp/icmp.go b/pkg/icmp/icmp.go index 3e61b76..3164831 100644 --- a/pkg/icmp/icmp.go +++ b/pkg/icmp/icmp.go @@ -206,7 +206,7 @@ func listenForSpecific4(conn *icmp.PacketConn, deadline time.Time, neededPeer st continue } - if typ, ok := x.Type.(ipv4.ICMPType); ok && typ.String() == "time exceeded" { + if typ, ok := x.Type.(ipv4.ICMPType); ok && typ == ipv4.ICMPTypeTimeExceeded { body := x.Body.(*icmp.TimeExceeded).Data index := bytes.Index(body, sent[:4]) @@ -225,7 +225,7 @@ func listenForSpecific4(conn *icmp.PacketConn, deadline time.Time, neededPeer st } } - if typ, ok := x.Type.(ipv4.ICMPType); ok && typ.String() == "echo reply" { + if typ, ok := x.Type.(ipv4.ICMPType); ok && typ == ipv4.ICMPTypeEchoReply { b, _ := x.Body.Marshal(1) if string(b[4:]) != string(neededBody) { continue