feat(cli): add bulk user creation command

This commit is contained in:
Whispering Wind
2025-08-20 23:22:29 +03:30
committed by GitHub
parent c1a60cbf32
commit 8341f23611
2 changed files with 33 additions and 0 deletions

View File

@ -27,6 +27,7 @@ class Command(Enum):
CHANGE_SNI_HYSTERIA2 = os.path.join(SCRIPT_DIR, 'hysteria2', 'change_sni.py')
GET_USER = os.path.join(SCRIPT_DIR, 'hysteria2', 'get_user.py')
ADD_USER = os.path.join(SCRIPT_DIR, 'hysteria2', 'add_user.py')
BULK_USER = os.path.join(SCRIPT_DIR, 'hysteria2', 'bulk_users.py')
EDIT_USER = os.path.join(SCRIPT_DIR, 'hysteria2', 'edit_user.sh')
RESET_USER = os.path.join(SCRIPT_DIR, 'hysteria2', 'reset_user.py')
REMOVE_USER = os.path.join(SCRIPT_DIR, 'hysteria2', 'remove_user.py')
@ -285,6 +286,24 @@ def add_user(username: str, traffic_limit: int, expiration_days: int, password:
run_cmd(command)
def bulk_user_add(traffic_gb: float, expiration_days: int, count: int, prefix: str, start_number: int, unlimited: bool):
"""
Executes the bulk user creation script with specified parameters.
"""
command = [
'python3',
Command.BULK_USER.value,
'--traffic-gb', str(traffic_gb),
'--expiration-days', str(expiration_days),
'--count', str(count),
'--prefix', prefix,
'--start-number', str(start_number)
]
if unlimited:
command.append('--unlimited')
run_cmd(command)
def edit_user(username: str, new_username: str | None, new_traffic_limit: int | None, new_expiration_days: int | None, renew_password: bool, renew_creation_date: bool, blocked: bool | None, unlimited_ip: bool | None):
'''