From 570ff6fcf2b009262055b65072742386b216a927 Mon Sep 17 00:00:00 2001 From: ReturnFI <151555003+ReturnFI@users.noreply.github.com> Date: Fri, 7 Nov 2025 07:25:26 +0000 Subject: [PATCH] feat(cli): Add clean command for IP limiter --- core/cli.py | 9 +++++++++ core/cli_api.py | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/core/cli.py b/core/cli.py index 244f97d..247e785 100644 --- a/core/cli.py +++ b/core/cli.py @@ -773,6 +773,15 @@ def stop_ip_limit(): except Exception as e: click.echo(f'{e}', err=True) +@cli.command('clean-ip-limit') +def clean_ip_limit(): + """Cleans the IP limiter database and unblocks all IPs.""" + try: + cli_api.clean_ip_limiter() + click.echo('IP Limiter database and block list have been cleaned successfully.') + except Exception as e: + click.echo(f'Error cleaning IP limiter: {e}', err=True) + @cli.command('config-ip-limit') @click.option('--block-duration', '-bd', type=int, help='New block duration in seconds') @click.option('--max-ips', '-mi', type=int, help='New maximum IPs per user') diff --git a/core/cli_api.py b/core/cli_api.py index 2a92182..fc19045 100644 --- a/core/cli_api.py +++ b/core/cli_api.py @@ -768,6 +768,10 @@ def stop_ip_limiter(): '''Stops the IP limiter service.''' run_cmd(['bash', Command.LIMIT_SCRIPT.value, 'stop']) +def clean_ip_limiter(): + """Cleans the IP limiter database and unblocks all IPs.""" + run_cmd(['bash', Command.LIMIT_SCRIPT.value, 'clean']) + def config_ip_limiter(block_duration: Optional[int] = None, max_ips: Optional[int] = None): '''Configures the IP limiter service.''' if block_duration is not None and block_duration <= 0: