Files
Blitz-Proxy/core/validator.py
2024-07-22 16:30:37 +03:30

10 lines
324 B
Python

import os
import click
def validate_port(ctx,param,value:int) -> int:
if value < 1 or value > 65535:
raise click.BadParameter('Port must be between 1 and 65535')
# check if port is in use
if os.system(f'lsof -i:{value}') == 0:
raise click.BadParameter(f'Port {value} is in use')
return value