diff --git a/app/services/xui.py b/app/services/xui.py index f6174f8..9484922 100644 --- a/app/services/xui.py +++ b/app/services/xui.py @@ -320,13 +320,15 @@ class XuiClient: raise XuiApiError(f"Inbound #{inbound_id} — не WireGuard (protocol={proto})") keys = await self.get_new_x25519() + # Leave allowedIPs empty — 3x-ui allocates a unique peer address + # (e.g. 10.0.0.3/32). Sending 0.0.0.0/0 collides with other clients. client = { "email": email, "enable": True, "privateKey": keys["privateKey"], "publicKey": keys["publicKey"], "preSharedKey": "", - "allowedIPs": ["0.0.0.0/0", "::/0"], + "allowedIPs": [], "keepAlive": 0, "totalGB": total_gb, "expiryTime": int(expiry_time), @@ -337,12 +339,23 @@ class XuiClient: } await self.add_client_raw(client, [inbound_id]) details = await self.get_client(email) + allowed_ips = [] + if isinstance(details, dict): + allowed_ips = details.get("allowedIPs") or details.get("allowed_ips") or [] + if not allowed_ips: + # Client may be nested under inbounds / clients list + for key in ("client", "obj"): + nested = details.get(key) + if isinstance(nested, dict) and nested.get("allowedIPs"): + allowed_ips = nested["allowedIPs"] + break return { "protocol": "wireguard", "email": email, "inbound_id": inbound_id, "privateKey": keys["privateKey"], "publicKey": keys["publicKey"], + "allowedIPs": allowed_ips, "expiryTime": int(expiry_time), "details": details, "inbound": { diff --git a/app/templates/admin/xui_detail.html b/app/templates/admin/xui_detail.html index bdf82ae..636c844 100644 --- a/app/templates/admin/xui_detail.html +++ b/app/templates/admin/xui_detail.html @@ -63,7 +63,8 @@

Ключи клиента (конфиг соберите в 3x-ui или ниже):

PrivateKey = {{ created.privateKey }}
 PublicKey = {{ created.publicKey }}
-{% if created.inbound %}Endpoint port = {{ created.inbound.port }}{% endif %}
+{% if created.allowedIPs %}AllowedIPs = {{ created.allowedIPs | join(', ') }} +{% endif %}{% if created.inbound %}Endpoint port = {{ created.inbound.port }}{% endif %} {% endif %}