From 526fe293fc3fe4d415ac0cd68062052009e3eb80 Mon Sep 17 00:00:00 2001 From: Whispering Wind <151555003+ReturnFI@users.noreply.github.com> Date: Sat, 7 Dec 2024 23:10:11 +0330 Subject: [PATCH] Update ip-address Add 2 options * Add * Edit --- core/cli.py | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/core/cli.py b/core/cli.py index 51b790d..9eb3220 100644 --- a/core/cli.py +++ b/core/cli.py @@ -268,11 +268,24 @@ def manage_obfs(remove, generate): click.echo("Error: Please specify either --remove or --generate.") @cli.command('ip-address') -def run_ip_script(): - try: - run_cmd(['bash', Command.IP_ADD.value]) - except subprocess.CalledProcessError as e: - click.echo(f"Error while running IP script: {e.output.decode()}", err=True) +@click.option('--edit', is_flag=True, help="Edit IP addresses manually.") +@click.option('-4', '--ipv4', type=str, help="Specify the new IPv4 address.") +@click.option('-6', '--ipv6', type=str, help="Specify the new IPv6 address.") +def ip_address(edit, ipv4, ipv6): + """ + Manage IP addresses in .configs.env. + - Use without options to add auto-detected IPs. + - Use --edit with -4 or -6 to manually update IPs. + """ + if edit: + if ipv4: + run_cmd(['bash', Command.IP_ADD.value, 'edit', '-4', ipv4]) + if ipv6: + run_cmd(['bash', Command.IP_ADD.value, 'edit', '-6', ipv6]) + if not ipv4 and not ipv6: + click.echo("Error: --edit requires at least one of --ipv4 or --ipv6.") + else: + run_cmd(['bash', Command.IP_ADD.value, 'add']) # endregion