Manage obfs (cli.py)
This commit is contained in:
18
core/cli.py
18
core/cli.py
@ -29,6 +29,7 @@ class Command(Enum):
|
|||||||
RESET_USER = os.path.join(SCRIPT_DIR, 'hysteria2', 'reset_user.sh')
|
RESET_USER = os.path.join(SCRIPT_DIR, 'hysteria2', 'reset_user.sh')
|
||||||
REMOVE_USER = os.path.join(SCRIPT_DIR, 'hysteria2', 'remove_user.sh')
|
REMOVE_USER = os.path.join(SCRIPT_DIR, 'hysteria2', 'remove_user.sh')
|
||||||
SHOW_USER_URI = os.path.join(SCRIPT_DIR, 'hysteria2', 'show_user_uri.sh')
|
SHOW_USER_URI = os.path.join(SCRIPT_DIR, 'hysteria2', 'show_user_uri.sh')
|
||||||
|
REMOVE_OBFS = os.path.join(SCRIPT_DIR, 'hysteria2', 'remove_obfs.sh')
|
||||||
TRAFFIC_STATUS = 'traffic.py' # won't be call directly (it's a python module)
|
TRAFFIC_STATUS = 'traffic.py' # won't be call directly (it's a python module)
|
||||||
LIST_USERS = os.path.join(SCRIPT_DIR, 'hysteria2', 'list_users.sh')
|
LIST_USERS = os.path.join(SCRIPT_DIR, 'hysteria2', 'list_users.sh')
|
||||||
SERVER_INFO = os.path.join(SCRIPT_DIR, 'hysteria2', 'server_info.sh')
|
SERVER_INFO = os.path.join(SCRIPT_DIR, 'hysteria2', 'server_info.sh')
|
||||||
@ -247,6 +248,23 @@ def backup_hysteria():
|
|||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
click.echo(f"Backup failed: {e.output.decode()}", err=True)
|
click.echo(f"Backup failed: {e.output.decode()}", err=True)
|
||||||
|
|
||||||
|
@cli.command('manage_obfs')
|
||||||
|
@click.option('--remove', '-r', is_flag=True, help="Remove 'obfs' from config.json.")
|
||||||
|
@click.option('--generate', '-g', is_flag=True, help="Generate new 'obfs' in config.json.")
|
||||||
|
def manage_obfs(remove, generate):
|
||||||
|
"""Manage 'obfs' in Hysteria2 configuration."""
|
||||||
|
if remove and generate:
|
||||||
|
click.echo("Error: You cannot use both --remove and --generate at the same time.")
|
||||||
|
return
|
||||||
|
elif remove:
|
||||||
|
click.echo("Removing 'obfs' from config.json...")
|
||||||
|
run_cmd(['bash', Command.REMOVE_OBFS.value, '--remove'])
|
||||||
|
elif generate:
|
||||||
|
click.echo("Generating 'obfs' in config.json...")
|
||||||
|
run_cmd(['bash', Command.REMOVE_OBFS.value, '--generate'])
|
||||||
|
else:
|
||||||
|
click.echo("Error: Please specify either --remove or --generate.")
|
||||||
|
|
||||||
# endregion
|
# endregion
|
||||||
|
|
||||||
# region advanced menu
|
# region advanced menu
|
||||||
|
|||||||
Reference in New Issue
Block a user