mirror of
https://github.com/fatedier/frp.git
synced 2026-03-31 22:29:26 +08:00
test/e2e: allocate dynamic ports outside whitelist ranges in server whitelist test (#5268)
This commit is contained in:
@@ -241,6 +241,31 @@ func (f *Framework) AllocPort() int {
|
||||
return port
|
||||
}
|
||||
|
||||
func (f *Framework) AllocPortExcludingRanges(ranges ...[2]int) int {
|
||||
for range 1000 {
|
||||
port := f.portAllocator.Get()
|
||||
ExpectTrue(port > 0, "alloc port failed")
|
||||
|
||||
inExcludedRange := false
|
||||
for _, portRange := range ranges {
|
||||
if port >= portRange[0] && port <= portRange[1] {
|
||||
inExcludedRange = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if inExcludedRange {
|
||||
f.portAllocator.Release(port)
|
||||
continue
|
||||
}
|
||||
|
||||
f.allocatedPorts = append(f.allocatedPorts, port)
|
||||
return port
|
||||
}
|
||||
|
||||
Failf("alloc port outside excluded ranges failed")
|
||||
return 0
|
||||
}
|
||||
|
||||
func (f *Framework) ReleasePort(port int) {
|
||||
f.portAllocator.Release(port)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user