Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/xray/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,8 @@ def _resolve_inbounds(self):
try:
from app.xray import core
x25519 = core.get_x25519(pvk)
if not x25519:
raise ValueError(f"Could not parse x25519 output from xray core for {inbound['tag']}")
settings['pbk'] = x25519['public_key']
except ImportError:
pass
Expand Down
18 changes: 13 additions & 5 deletions app/xray/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,20 @@ def get_x25519(self, private_key: str = None):
if private_key:
cmd.extend(['-i', private_key])
output = subprocess.check_output(cmd, stderr=subprocess.STDOUT).decode('utf-8')
m = re.match(r'Private key: (.+)\nPublic key: (.+)', output)
if m:
private, public = m.groups()
data = {}
for line in output.splitlines():
if ":" in line:
key, value = line.split(":", 1)
data[key.strip()] = value.strip()

keys_lower = {k.lower().replace(' ', ''): v for k, v in data.items()}
prv = keys_lower.get("privatekey")
pub = keys_lower.get("publickey") or keys_lower.get("password")

if prv and pub:
return {
"private_key": private,
"public_key": public
"private_key": prv,
"public_key": pub
}

def __capture_process_logs(self):
Expand Down