Skip to content
Open
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
25 changes: 13 additions & 12 deletions pyxui/methods/clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,13 @@ 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
return client , protocol

raise errors.NotFound()

Expand Down Expand Up @@ -186,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"
)

Expand Down Expand Up @@ -249,16 +250,16 @@ 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
)

uuid_key = "password" if protocol == 'trojan' else "id"
settings = {
"clients": [
{
"id": uuid,
uuid_key: uuid,
"email": email,
"enable": enable,
"flow": flow,
Expand All @@ -272,14 +273,14 @@ def update_client(
"decryption": "none",
"fallbacks": []
}

params = {
"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
)
Expand Down