Skip to content

Commit

Permalink
making icmp non fatal (#1243)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mzack9999 authored Oct 21, 2024
1 parent 5e3d600 commit 1716bbf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 6 additions & 0 deletions v2/pkg/scan/icmp.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,9 @@ func PingIcmpTimestampRequestAsync(ip string) {
if !iputil.IsIPv4(ip) {
return
}
if icmpConn4 == nil {
return
}
destAddr := &net.IPAddr{IP: net.ParseIP(ip)}
m := icmp.Message{
Type: ipv4.ICMPTypeTimestamp,
Expand Down Expand Up @@ -264,6 +267,9 @@ func PingIcmpAddressMaskRequestAsync(ip string) {
if !iputil.IsIPv4(ip) {
return
}
if icmpConn4 == nil {
return
}
destAddr := &net.IPAddr{IP: net.ParseIP(ip)}
m := icmp.Message{
Type: ipv4.ICMPType(17),
Expand Down
5 changes: 4 additions & 1 deletion v2/pkg/scan/scan_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func init() {
var err error
icmpConn4, err = icmp.ListenPacket("ip4:icmp", "0.0.0.0")
if err != nil {
panic(err)
gologger.Error().Msgf("could not setup ip4:icmp: %s", err)
}

icmpConn6, err = icmp.ListenPacket("ip6:icmp", "::")
Expand Down Expand Up @@ -381,6 +381,9 @@ func sendAsyncUDP6(listenHandler *ListenHandler, ip string, p *port.Port, pkgFla
func (l *ListenHandler) ICMPReadWorker4() {
data := make([]byte, 1500)
for {
if icmpConn4 == nil {
return
}
n, addr, err := icmpConn4.ReadFrom(data)
if err != nil {
continue
Expand Down

0 comments on commit 1716bbf

Please sign in to comment.