From af3ad880c6f229d3e48529ca9ff258bfefc1b834 Mon Sep 17 00:00:00 2001 From: Whispering Wind <151555003+ReturnFI@users.noreply.github.com> Date: Mon, 25 Aug 2025 22:59:04 +0330 Subject: [PATCH] Set user creation_date to None by default --- core/scripts/hysteria2/add_user.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/scripts/hysteria2/add_user.py b/core/scripts/hysteria2/add_user.py index ec23b0a..d9853e7 100644 --- a/core/scripts/hysteria2/add_user.py +++ b/core/scripts/hysteria2/add_user.py @@ -18,7 +18,7 @@ def add_user(username, traffic_gb, expiration_days, password=None, creation_date traffic_gb (str): The traffic limit in GB. expiration_days (str): The number of days until the account expires. password (str, optional): The user's password. If None, a random one is generated. - creation_date (str, optional): The account creation date in YYYY-MM-DD format. If None, the current date is used. + creation_date (str, optional): The account creation date in YYYY-MM-DD format. Defaults to None. unlimited_user (bool, optional): If True, user is exempt from IP limits. Defaults to False. Returns: @@ -48,9 +48,7 @@ def add_user(username, traffic_gb, expiration_days, password=None, creation_date print("Error: Failed to generate password. Please install 'pwgen' or ensure /proc access.") return 1 - if not creation_date: - creation_date = datetime.now().strftime("%Y-%m-%d") - else: + if creation_date: if not re.match(r"^[0-9]{4}-[0-9]{2}-[0-9]{2}$", creation_date): print("Invalid date format. Expected YYYY-MM-DD.") return 1 @@ -59,6 +57,8 @@ def add_user(username, traffic_gb, expiration_days, password=None, creation_date except ValueError: print("Invalid date. Please provide a valid date in YYYY-MM-DD format.") return 1 + else: + creation_date = None if not re.match(r"^[a-zA-Z0-9_]+$", username): print("Error: Username can only contain letters, numbers, and underscores.")