mirror of
https://github.com/netbirdio/netbird.git
synced 2026-09-07 07:21:27 +02:00
Fix minimum port range
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user