diff --git a/ansible/roles/core-net/remnawave/files/profile-cascade-ru.json b/ansible/roles/core-net/remnawave/files/profile-cascade-ru.json index 9f40077..1e30a0c 100644 --- a/ansible/roles/core-net/remnawave/files/profile-cascade-ru.json +++ b/ansible/roles/core-net/remnawave/files/profile-cascade-ru.json @@ -53,7 +53,7 @@ "vnext": [ { "address": "2a12:bec4:1bb0:2e80::2", - "port": 1443, + "port": 443, "users": [ { "id": "__CASCADE_UUID__", diff --git a/ansible/roles/core-net/remnawave/files/sync_remnawave.py b/ansible/roles/core-net/remnawave/files/sync_remnawave.py index 81158f5..cdd02d2 100644 --- a/ansible/roles/core-net/remnawave/files/sync_remnawave.py +++ b/ansible/roles/core-net/remnawave/files/sync_remnawave.py @@ -207,9 +207,22 @@ def ensure_cascade_credentials( de_obj = de_full.get("response") or de_full de_cfg = de_obj.get("config") or {} inbounds = de_cfg.get("inbounds") or [] - has_cascade_inb = any(i.get("tag") == "Cascade-RU-DE" for i in inbounds) + has_cascade_inb = any( + i.get("tag") == "Cascade-RU-DE" and i.get("port") == 443 + for i in inbounds + ) - if has_cascade_inb and ru_prof: + ru_has_443 = False + if ru_prof: + _, ru_full = api.request("GET", f"/config-profiles/{ru_prof['uuid']}") + ru_cfg = (ru_full.get("response") or ru_full).get("config") or {} + for ob in ru_cfg.get("outbounds") or []: + if ob.get("tag") == "CASCADE-DE": + vnext = (ob.get("settings") or {}).get("vnext") or [] + if vnext and vnext[0].get("port") == 443: + ru_has_443 = True + + if has_cascade_inb and ru_has_443: return {} _, users_resp = api.request("GET", "/users/") @@ -227,7 +240,7 @@ def ensure_cascade_credentials( cascade_inbound = { "tag": "Cascade-RU-DE", "listen": "2a12:bec4:1bb0:2e80::2", - "port": 1443, + "port": 443, "protocol": "vless", "settings": { "clients": [{"id": creds["uuid"], "flow": "xtls-rprx-vision"}], @@ -249,11 +262,32 @@ def ensure_cascade_credentials( }, }, } - new_inbounds = [i for i in inbounds if i.get("tag") != "Cascade-RU-DE"] + new_inbounds = [] + for i in inbounds: + if i.get("tag") == "Cascade-RU-DE": + continue + if i.get("tag") == "Steal-Yali": + i = dict(i) + i["listen"] = "150.241.64.209" + new_inbounds.append(i) new_inbounds.append(cascade_inbound) de_cfg["inbounds"] = new_inbounds api.request("PATCH", "/config-profiles/", {"uuid": de_uuid, "config": de_cfg}) - changes.append("updated profile DE-Yali with Cascade-RU-DE inbound") + changes.append("updated profile DE-Yali with Cascade-RU-DE inbound on :443") + if ru_prof and not ru_has_443: + _, ru_full = api.request("GET", f"/config-profiles/{ru_prof['uuid']}") + ru_cfg = (ru_full.get("response") or ru_full).get("config") or {} + for ob in ru_cfg.get("outbounds") or []: + if ob.get("tag") == "CASCADE-DE": + vnext = (ob.get("settings") or {}).get("vnext") or [] + if vnext: + vnext[0]["port"] = 443 + vnext[0]["users"][0]["id"] = creds["uuid"] + rs = (ob.get("streamSettings") or {}).get("realitySettings") or {} + rs["publicKey"] = creds["pub"] + rs["shortId"] = creds["short_id"] + api.request("PATCH", "/config-profiles/", {"uuid": ru_prof["uuid"], "config": ru_cfg}) + changes.append("updated profile RU-Cascade to port 443") return creds