Fix minimum port range

This commit is contained in:
Zoltan Papp
2025-02-28 21:17:17 +01:00
parent f09d86151b
commit dddb4bcf7e
2 changed files with 4 additions and 4 deletions

View File

@@ -48,7 +48,7 @@ func (p *portAllocator) newConn() (*net.UDPConn, *net.UDPAddr, error) {
func (p *portAllocator) nextPort() int {
port := p.nextFreePort
p.nextFreePort--
if p.nextFreePort == 0 {
if p.nextFreePort == 1024 {
p.nextFreePort = 65535
}
return int(port)

View File

@@ -18,12 +18,12 @@ func Test_portAllocator_newConn(t *testing.T) {
}
}
func Test_portAllocator_port_zero(t *testing.T) {
func Test_portAllocator_port_bottom(t *testing.T) {
pa := newPortAllocator()
pa.nextFreePort = 1
pa.nextFreePort = 1025
port := pa.nextPort()
if port != 1 {
if port != 1025 {
t.Errorf("nextPort() = %v, want %d", port, 1)
}