Fix bug
This commit is contained in:
@ -59,7 +59,7 @@ def cli():
|
|||||||
|
|
||||||
# region hysteria2 menu options
|
# region hysteria2 menu options
|
||||||
@cli.command('install-hysteria2')
|
@cli.command('install-hysteria2')
|
||||||
@click.option('--port','-p', required=True, help='New port for Hysteria2',type=int,validate=validator.validate_port)
|
@click.option('--port','-p', required=True, help='New port for Hysteria2',type=int,callback=validator.validate_port)
|
||||||
def install_hysteria2(port:int):
|
def install_hysteria2(port:int):
|
||||||
run_cmd(['bash', Command.INSTALL_HYSTERIA2.value, str(port)])
|
run_cmd(['bash', Command.INSTALL_HYSTERIA2.value, str(port)])
|
||||||
|
|
||||||
@ -78,7 +78,7 @@ def restart_hysteria2():
|
|||||||
|
|
||||||
|
|
||||||
@cli.command('change-hysteria2-port')
|
@cli.command('change-hysteria2-port')
|
||||||
@click.option('--port','-p', required=True, help='New port for Hysteria2',type=int,validate=validator.validate_port)
|
@click.option('--port','-p', required=True, help='New port for Hysteria2',type=int,callback=validator.validate_port)
|
||||||
def change_hysteria2_port(port:int):
|
def change_hysteria2_port(port:int):
|
||||||
run_cmd(['bash', Command.CHANGE_PORT_HYSTERIA2.value, str(port)])
|
run_cmd(['bash', Command.CHANGE_PORT_HYSTERIA2.value, str(port)])
|
||||||
|
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
|
|
||||||
def validate_port(p:int)-> bool:
|
def validate_port(ctx,param,value)-> bool:
|
||||||
if p < 1 or p > 65535:
|
if value < 1 or value > 65535:
|
||||||
return False
|
return False
|
||||||
# check if port is in use
|
# check if port is in use
|
||||||
if os.system(f'lsof -i:{p}') == 0:
|
if os.system(f'lsof -i:{value}') == 0:
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
Reference in New Issue
Block a user