From ab200801d96207eca9dbf9dce9b4aef4b0565b65 Mon Sep 17 00:00:00 2001 From: moradpoor Date: Fri, 29 Sep 2023 18:37:13 +0330 Subject: [PATCH 1/3] fix key error client['id'] in line 43 --- pyxui/methods/clients.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pyxui/methods/clients.py b/pyxui/methods/clients.py index 472b35c..464ce98 100644 --- a/pyxui/methods/clients.py +++ b/pyxui/methods/clients.py @@ -37,9 +37,10 @@ def get_client( continue settings = json.loads(inbound['settings']) - + protocol = inbound['protocol'] for client in settings['clients']: - if client['email'] != email and client['id'] != uuid: + clientid = client['id'] if protocol in ['vless','vmess'] else client['password'] + if client['email'] != email and clientid != uuid: continue return client From cf42e9ec48b899234d917fdc69055e550dd70228 Mon Sep 17 00:00:00 2001 From: moradpoor Date: Fri, 29 Sep 2023 18:55:55 +0330 Subject: [PATCH 2/3] some changes for find_client --- pyxui/methods/clients.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pyxui/methods/clients.py b/pyxui/methods/clients.py index 464ce98..5fd1627 100644 --- a/pyxui/methods/clients.py +++ b/pyxui/methods/clients.py @@ -43,7 +43,7 @@ def get_client( if client['email'] != email and clientid != uuid: continue - return client + return client , protocol raise errors.NotFound() @@ -187,14 +187,14 @@ def delete_client( `~Dict`: On success, a dict is returned else 404 error will be raised """ - find_client = self.get_client( + find_client , protocol = self.get_client( inbound_id=inbound_id, email=email, uuid=uuid ) - + clientid = find_client['id'] if protocol in ['vless','vmess'] else find_client['password'] response = self.request( - path=f"{inbound_id}/delClient/{find_client['id']}", + path=f"{inbound_id}/delClient/{clientid}", method="POST" ) @@ -250,7 +250,7 @@ def update_client( `~Dict`: On success, a dict is returned else 404 error will be raised """ - find_client = self.get_client( + find_client , protocol = self.get_client( inbound_id=inbound_id, email=email, uuid=uuid @@ -278,9 +278,9 @@ def update_client( "id": inbound_id, "settings": json.dumps(settings) } - + clientid = find_client['id'] if protocol in ['vless','vmess'] else find_client['password'] response = self.request( - path=f"updateClient/{find_client['id']}", + path=f"updateClient/{clientid}", method="POST", params=params ) From 127515405b42cbcfa27083542f4860a5297fba56 Mon Sep 17 00:00:00 2001 From: moradpoor Date: Mon, 2 Oct 2023 14:06:39 +0330 Subject: [PATCH 3/3] add uuid_key variable line 258 --- pyxui/methods/clients.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pyxui/methods/clients.py b/pyxui/methods/clients.py index 5fd1627..8078544 100644 --- a/pyxui/methods/clients.py +++ b/pyxui/methods/clients.py @@ -255,11 +255,11 @@ def update_client( email=email, uuid=uuid ) - + uuid_key = "password" if protocol == 'trojan' else "id" settings = { "clients": [ { - "id": uuid, + uuid_key: uuid, "email": email, "enable": enable, "flow": flow, @@ -273,7 +273,7 @@ def update_client( "decryption": "none", "fallbacks": [] } - + params = { "id": inbound_id, "settings": json.dumps(settings)