From a1ae24ecedc867053a3722f3025733da0938902b Mon Sep 17 00:00:00 2001 From: BiMaghz <9ineamir@gmail.com> Date: Tue, 18 Nov 2025 14:39:58 +0330 Subject: [PATCH] Fix: Compatibility for Xray v25.8.3+ key generation output --- marznode/backends/xray/_utils.py | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/marznode/backends/xray/_utils.py b/marznode/backends/xray/_utils.py index ae57610..9101d10 100644 --- a/marznode/backends/xray/_utils.py +++ b/marznode/backends/xray/_utils.py @@ -21,17 +21,27 @@ def get_version(xray_path: str) -> str | None: def get_x25519(xray_path: str, private_key: str = None) -> Dict[str, str] | None: """ - get x25519 public key using the private key - :param xray_path: - :param private_key: - :return: x25519 publickey + Calculates the public key from the provided private key. + + - Old output format ("Public key:") + - New output format ("Password:") """ + cmd = [xray_path, "x25519"] if private_key: cmd.extend(["-i", private_key]) output = subprocess.check_output(cmd, stderr=subprocess.STDOUT).decode("utf-8") - match = re.match(r"Private key: (.+)\nPublic key: (.+)", output) - if match: - private, public = match.groups() + + # Try New Format (v25.8.3+): Looks for "Password:" instead of Public Key + match_new = re.match(r"PrivateKey:\s*(.+)\nPassword:\s*(.+)", output) + if match_new: + private, public = match_new.groups() return {"private_key": private, "public_key": public} + + # Try Old Format (< v25.8.3): Looks for standard "Public key:" + match_old = re.match(r"Private key:\s*(.+)\nPublic key:\s*(.+)", output) + if match_old: + private, public = match_old.groups() + return {"private_key": private, "public_key": public} + return None