Skip to content

Commit

Permalink
Pass UDPAddr.Zone to net.ListenUDP
Browse files Browse the repository at this point in the history
listenUDPInPortRange wasn't passing the Zone and would always fail to
bind. This would cause high CPU usage as every port in the range would
be attempted and fail.

Fixes #742
  • Loading branch information
N1cOs authored and Sean-Der committed Nov 26, 2024
1 parent 2c699d8 commit 1c850ea
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions net.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,13 @@ func listenUDPInPortRange(n transport.Net, log logging.LeveledLogger, portMax, p
portStart := globalMathRandomGenerator.Intn(j-i+1) + i
portCurrent := portStart
for {
lAddr = &net.UDPAddr{IP: lAddr.IP, Port: portCurrent}
c, e := n.ListenUDP(network, lAddr)
addr := &net.UDPAddr{
IP: lAddr.IP,
Zone: lAddr.Zone,
Port: portCurrent,
}

c, e := n.ListenUDP(network, addr)
if e == nil {
return c, e //nolint:nilerr
}
Expand Down

0 comments on commit 1c850ea

Please sign in to comment.