From d2058f05b801c00d5dac88bda38bd90a59cc8b97 Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Fri, 26 Apr 2024 15:16:09 +0200 Subject: [PATCH] Fix XRay/V2Ray user management --- debian/changelog | 6 ++++++ omr-admin.py | 18 +++++++++--------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/debian/changelog b/debian/changelog index 9a492c2..f2043e8 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +omr-vps-admin (0.9+20240426) unstable; urgency=medium + + * Fix V2Ray/XRay json data retrieve + + -- OpenMPTCProuter Fri, 24 Apr 2024 15:03:41 +0200 + omr-vps-admin (0.9+20240324) unstable; urgency=medium * Fix Shadowsocks Rust stats error diff --git a/omr-admin.py b/omr-admin.py index 30aab15..1358481 100755 --- a/omr-admin.py +++ b/omr-admin.py @@ -1712,7 +1712,7 @@ async def config(userid: Optional[int] = Query(None), serial: Optional[str] = Qu if os.path.isfile('/etc/v2ray/v2ray-server.json'): v2ray = True if not 'v2ray' in omr_config_data['users'][0][username]: - v2ray_key = os.popen("jq -r '.inbounds[0].settings.clients[] | select(.email=" + '"' + username + '"' + ") | .id' /etc/v2ray/v2ray-server.json").read().rstrip() + v2ray_key = os.popen("jq -r '.inbounds[0].settings.clients[] | select(.email==" + '"' + username + '"' + ") | .id' /etc/v2ray/v2ray-server.json").read().rstrip() v2ray_port = os.popen('jq -r .inbounds[0].port /etc/v2ray/v2ray-server.json').read().rstrip() v2ray_conf = { 'key': v2ray_key, 'port': v2ray_port} modif_config_user(username, {'v2ray': v2ray_conf}) @@ -1729,9 +1729,9 @@ async def config(userid: Optional[int] = Query(None), serial: Optional[str] = Qu if os.path.isfile('/etc/xray/xray-server.json'): xray = True if not 'xray' in omr_config_data['users'][0][username]: - xray_key = os.popen("jq -r '.inbounds[0].settings.clients[] | select(.email=" + '"' + username + '"' + ") | .id' /etc/xray/xray-server.json").read().rstrip() + xray_key = os.popen("jq -r '.inbounds[0].settings.clients[] | select(.email==" + '"' + username + '"' + ") | .id' /etc/xray/xray-server.json").read().rstrip() xray_ss_skey = os.popen("jq -r '.inbounds[] | select(.tag==" + '"' + 'omrin-shadowsocks-tunnel' + '"' + ") | .settings.password' /etc/xray/xray-server.json").read().rstrip() - xray_ss_ukey = os.popen("jq -r '.inbounds[] | select(.tag==" + '"' + 'omrin-shadowsocks-tunnel' + '"' + ") | .settings.clients[] | select(.email=" + '"' + username + '"' + ") | .password' /etc/xray/xray-server.json").read().rstrip() + xray_ss_ukey = os.popen("jq -r '.inbounds[] | select(.tag==" + '"' + 'omrin-shadowsocks-tunnel' + '"' + ") | .settings.clients[] | select(.email==" + '"' + username + '"' + ") | .password' /etc/xray/xray-server.json").read().rstrip() xray_ss_key = xray_ss_skey + ':' + xray_ss_ukey xray_port = os.popen('jq -r .inbounds[0].port /etc/xray/xray-server.json').read().rstrip() xray_ss_method = os.popen("jq -r '.inbounds[] | select(.tag==" + '"' + 'omrin-shadowsocks-tunnel' + '"' + ") | .settings.method' /etc/xray/xray-server.json").read().rstrip() @@ -1758,9 +1758,9 @@ async def config(userid: Optional[int] = Query(None), serial: Optional[str] = Qu if os.path.isfile('/etc/shadowsocks-go/server.json'): shadowsocks_go = True if not 'shadowsocks-go' in omr_config_data['users'][0][username]: - shadowsocks_go_psk = os.popen("jq -r '.servers[] | select(.name=" + '"ss-2022"' + ") | .psk' /etc/shadowsocks-go/server.json").read().rstrip() - shadowsocks_go_port = os.popen("jq -r '.servers[] | select(.name=" + '"ss-2022"' + ") | .tcpListeners[0].address' /etc/shadowsocks-go/server.json | cut -d ':' -f1").read().rstrip() - shadowsocks_go_protocol = os.popen("jq -r '.servers[] | select(.name=" + '"ss-2022"' + ") | .protocol' /etc/shadowsocks-go/server.json").read().rstrip() + shadowsocks_go_psk = os.popen("jq -r '.servers[] | select(.name==" + '"ss-2022"' + ") | .psk' /etc/shadowsocks-go/server.json").read().rstrip() + shadowsocks_go_port = os.popen("jq -r '.servers[] | select(.name==" + '"ss-2022"' + ") | .tcpListeners[0].address' /etc/shadowsocks-go/server.json | cut -d ':' -f1").read().rstrip() + shadowsocks_go_protocol = os.popen("jq -r '.servers[] | select(.name==" + '"ss-2022"' + ") | .protocol' /etc/shadowsocks-go/server.json").read().rstrip() shadowsocks_go_upsk = os.popen("jq -r --arg user " + '"' + username + '"' + " '.[$user]' /etc/shadowsocks-go/upsks.json").read().rstrip() shadowsocks_go_conf= { 'password': shadowsocks_go_psk + ':' + shadowsocks_go_upsk, 'port': shadowsocks_go_port, 'protocol': shadowsocks_go_protocol } modif_config_user(username, {'shadowsocks-go': shadowsocks_go_conf}) @@ -2343,7 +2343,7 @@ def v2ray(*, params: V2rayconfig, current_user: User = Depends(get_current_user) # json.dump(v2ray_config, outfile, indent=4) username = current_user.username final_md5 = hashlib.md5(file_as_bytes(open('/etc/v2ray/v2ray-server.json', 'rb'))).hexdigest() - v2ray_key = os.popen("jq -r '.inbounds[0].settings.clients[] | select(.email=" + '"' + username + '"' + ") | .id' /etc/v2ray/v2ray-server.json").read().rstrip() + v2ray_key = os.popen("jq -r '.inbounds[0].settings.clients[] | select(.email==" + '"' + username + '"' + ") | .id' /etc/v2ray/v2ray-server.json").read().rstrip() v2ray_port = os.popen('jq -r .inbounds[0].port /etc/v2ray/v2ray-server.json').read().rstrip() v2ray_conf = { 'key': v2ray_key, 'port': v2ray_port} modif_config_user(username, {'v2ray': v2ray_conf}) @@ -2395,9 +2395,9 @@ def xray(*, params: Xrayconfig, current_user: User = Depends(get_current_user)): # json.dump(xray_config, outfile, indent=4) username = current_user.username final_md5 = hashlib.md5(file_as_bytes(open('/etc/xray/xray-server.json', 'rb'))).hexdigest() - xray_key = os.popen("jq -r '.inbounds[0].settings.clients[] | select(.email=" + '"' + username + '"' + ") | .id' /etc/xray/xray-server.json").read().rstrip() + xray_key = os.popen("jq -r '.inbounds[0].settings.clients[] | select(.email==" + '"' + username + '"' + ") | .id' /etc/xray/xray-server.json").read().rstrip() xray_ss_skey = os.popen("jq -r '.inbounds[] | select(.tag==" + '"' + 'omrin-shadowsocks-tunnel' + '"' + ") | .settings.password' /etc/xray/xray-server.json").read().rstrip() - xray_ss_ukey = os.popen("jq -r '.inbounds[] | select(.tag==" + '"' + 'omrin-shadowsocks-tunnel' + '"' + ") | .settings.clients[] | select(.email=" + '"' + username + '"' + ") | .password' /etc/xray/xray-server.json").read().rstrip() + xray_ss_ukey = os.popen("jq -r '.inbounds[] | select(.tag==" + '"' + 'omrin-shadowsocks-tunnel' + '"' + ") | .settings.clients[] | select(.email==" + '"' + username + '"' + ") | .password' /etc/xray/xray-server.json").read().rstrip() xray_ss_key = xray_ss_skey + ':' + xray_ss_ukey xray_port = os.popen('jq -r .inbounds[0].port /etc/xray/xray-server.json').read().rstrip() test_vless_reality = os.popen("jq -r '.inbounds[] | select(.tag==" + '"' + 'omrin-vless-reality' + '"' + ")' /etc/xray/xray-server.json").read().rstrip()