Skip to content

Commit

Permalink
Merge pull request #18 from TrekkieCoder/main
Browse files Browse the repository at this point in the history
PR: udp ep probe fixes
  • Loading branch information
UltraInstinct14 authored Dec 11, 2023
2 parents 122edd7 + dc64148 commit 4ef5bc8
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions serviceprobe.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func L4ServiceProber(sType string, sName string, sHint, req, resp string) bool {
var lc net.ListenConfig
ctx, cancel := context.WithTimeout(context.Background(), time.Duration(3*time.Second))
defer cancel()
rc, err := lc.ListenPacket(ctx, "ip4:1", sHint)
rc, err := lc.ListenPacket(ctx, "ip4:1", "0.0.0.0")
if err != nil {
return sOk
}
Expand All @@ -148,15 +148,20 @@ func L4ServiceProber(sType string, sName string, sHint, req, resp string) bool {
}
pktData := make([]byte, 1500)
rc.SetDeadline(time.Now().Add(1 * time.Second))
_, _, err = rc.ReadFrom(pktData)
_, err = c.Read(pktData)
if err == nil {
return sOk
}

plen, _, err := rc.ReadFrom(pktData)
if err != nil {
return sOk
}
icmpNr, err := icmp.ParseMessage(1, pktData)
if err != nil {
return sOk
}
if icmpNr.Code == 3 && len(pktData) >= 8+20+8 {
if icmpNr.Code == 3 && plen >= 8+20+8 {
iph, err := ipv4.ParseHeader(pktData[8:])
if err != nil {
return sOk
Expand Down

0 comments on commit 4ef5bc8

Please sign in to comment.