feat(cli): Add clean command for IP limiter
This commit is contained in:
@ -773,6 +773,15 @@ def stop_ip_limit():
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
click.echo(f'{e}', err=True)
|
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')
|
@cli.command('config-ip-limit')
|
||||||
@click.option('--block-duration', '-bd', type=int, help='New block duration in seconds')
|
@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')
|
@click.option('--max-ips', '-mi', type=int, help='New maximum IPs per user')
|
||||||
|
|||||||
@ -768,6 +768,10 @@ def stop_ip_limiter():
|
|||||||
'''Stops the IP limiter service.'''
|
'''Stops the IP limiter service.'''
|
||||||
run_cmd(['bash', Command.LIMIT_SCRIPT.value, 'stop'])
|
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):
|
def config_ip_limiter(block_duration: Optional[int] = None, max_ips: Optional[int] = None):
|
||||||
'''Configures the IP limiter service.'''
|
'''Configures the IP limiter service.'''
|
||||||
if block_duration is not None and block_duration <= 0:
|
if block_duration is not None and block_duration <= 0:
|
||||||
|
|||||||
Reference in New Issue
Block a user