Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

making icmp non fatal #1243

Merged
merged 1 commit into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading