From dddb4bcf7e6c1a9c278ce5606c7ac96601ae3207 Mon Sep 17 00:00:00 2001 From: Zoltan Papp Date: Fri, 28 Feb 2025 21:17:17 +0100 Subject: [PATCH] Fix minimum port range --- client/internal/lazyconn/listener/allocator.go | 2 +- client/internal/lazyconn/listener/allocator_test.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/client/internal/lazyconn/listener/allocator.go b/client/internal/lazyconn/listener/allocator.go index 5f9778bd1..832749824 100644 --- a/client/internal/lazyconn/listener/allocator.go +++ b/client/internal/lazyconn/listener/allocator.go @@ -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) diff --git a/client/internal/lazyconn/listener/allocator_test.go b/client/internal/lazyconn/listener/allocator_test.go index 5a8162486..82fee065a 100644 --- a/client/internal/lazyconn/listener/allocator_test.go +++ b/client/internal/lazyconn/listener/allocator_test.go @@ -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) }