Skip to content

Commit

Permalink
fix infinity loop
Browse files Browse the repository at this point in the history
  • Loading branch information
EAShakhov authored and EAShakhov committed Aug 31, 2021
1 parent 147aa3c commit dc8a624
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/utils/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,12 @@ func ListenUDPInPortRange(portMin, portMax int, laddr *net.UDPAddr) (*net.UDPCon
}
portStart := rand.Intn(j-i+1) + i
portCurrent := portStart
tryCount := 10
for {
tryCount -= 1
if tryCount < 0 {
return nil, ErrPort
}
*laddr = net.UDPAddr{IP: laddr.IP, Port: portCurrent}
c, e := net.ListenUDP("udp", laddr)
if e == nil {
Expand Down

0 comments on commit dc8a624

Please sign in to comment.