File size: 417 Bytes
079c32c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
import random
from typing import Iterable
def random_port(excludes: Iterable[int] = None) -> int:
return random.choice(list(set(range(10000, 20000)) - set(excludes or [])))
def random_channel(excludes: Iterable[int] = None) -> int:
excludes = set(list(excludes or []))
while True:
_channel = random.randint(1000, (1 << 31) - 1)
if _channel not in excludes:
return _channel
|