feat(ger-nod-02,remnawave): move ger-nod-02 SelfSteal & Xray strictly to IPv6 (AAAA)
ansible-deploy / plan (push) Successful in 2s
ansible-lint / lint (push) Successful in 3s
ansible-deploy / deploy (core-net, ) (push) Successful in 18s
ansible-deploy / deploy (ger-nod-02, ) (push) Successful in 1m19s
ansible-deploy / deploy (rus-central, ) (push) Successful in 40s
ansible-deploy / plan (push) Successful in 2s
ansible-lint / lint (push) Successful in 3s
ansible-deploy / deploy (core-net, ) (push) Successful in 18s
ansible-deploy / deploy (ger-nod-02, ) (push) Successful in 1m19s
ansible-deploy / deploy (rus-central, ) (push) Successful in 40s
This commit is contained in:
1 parent
e03bd49077
commit
028deea531
7 files changed
+96
-35
No files matched your search
@@ -2,6 +2,12 @@
|
||||
ansible_host: 150.241.64.209
|
||||
ansible_user: root
|
||||
remnanode_selfsteal_domain: "yali.gunis.top"
|
||||
remnanode_public_ip: "2a12:bec4:1bb0:2e80::2"
|
||||
remnanode_wait_host: "2a12:bec4:1bb0:2e80::2"
|
||||
remnanode_dns_record_type: "AAAA"
|
||||
remnanode_ipv6_only: true
|
||||
remnanode_cascade_allowed_ips:
|
||||
- "2a06:dd00:1:4::6bd1"
|
||||
# WAN egress панели (core-net): оба провайдера → NODE_PORT
|
||||
remnanode_panel_egress_ips:
|
||||
- "213.128.28.107" # провайдер 1 (МТС)
|
||||
|
||||
@@ -15,9 +15,8 @@ nodes:
|
||||
country_code: "DE"
|
||||
profile_name: "DE-Yali"
|
||||
profile_template: "profile-selfsteal-xhttp.json"
|
||||
inbound_tag: "Steal-Yali"
|
||||
extra_inbound_tags:
|
||||
- "Cascade-RU-DE"
|
||||
inbound_tag: "Cascade-RU-DE"
|
||||
create_host: false
|
||||
selfsteal_domain: "yali.gunis.top"
|
||||
xhttp_path: "/xhttp-yali"
|
||||
host_remark: "🇩🇪 ger-nod-02"
|
||||
|
||||
@@ -68,7 +68,7 @@
|
||||
"network": "tcp",
|
||||
"security": "reality",
|
||||
"realitySettings": {
|
||||
"serverName": "www.cloudflare.com",
|
||||
"serverName": "yali.gunis.top",
|
||||
"fingerprint": "chrome",
|
||||
"publicKey": "__CASCADE_PUBLIC_KEY__",
|
||||
"shortId": "__CASCADE_SHORT_ID__"
|
||||
|
||||
@@ -208,21 +208,25 @@ def ensure_cascade_credentials(
|
||||
de_cfg = de_obj.get("config") or {}
|
||||
inbounds = de_cfg.get("inbounds") or []
|
||||
has_cascade_inb = any(
|
||||
i.get("tag") == "Cascade-RU-DE" and i.get("port") == 443
|
||||
i.get("tag") == "Cascade-RU-DE"
|
||||
and i.get("port") == 443
|
||||
and ((i.get("streamSettings") or {}).get("realitySettings") or {}).get("dest") == "/dev/shm/nginx.sock"
|
||||
for i in inbounds
|
||||
)
|
||||
has_steal_yali = any(i.get("tag") == "Steal-Yali" for i in inbounds)
|
||||
|
||||
ru_has_443 = False
|
||||
ru_ok = 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
|
||||
rs = (ob.get("streamSettings") or {}).get("realitySettings") or {}
|
||||
if vnext and vnext[0].get("port") == 443 and rs.get("serverName") == "yali.gunis.top":
|
||||
ru_ok = True
|
||||
|
||||
if has_cascade_inb and ru_has_443:
|
||||
if has_cascade_inb and not has_steal_yali and ru_ok:
|
||||
return {}
|
||||
|
||||
_, users_resp = api.request("GET", "/users/")
|
||||
@@ -254,27 +258,25 @@ def ensure_cascade_credentials(
|
||||
"network": "tcp",
|
||||
"security": "reality",
|
||||
"realitySettings": {
|
||||
"dest": "www.cloudflare.com:443",
|
||||
"dest": "/dev/shm/nginx.sock",
|
||||
"show": False,
|
||||
"xver": 1,
|
||||
"spiderX": "",
|
||||
"shortIds": [creds["short_id"]],
|
||||
"privateKey": creds["priv"],
|
||||
"serverNames": ["www.cloudflare.com"],
|
||||
"serverNames": ["yali.gunis.top"],
|
||||
},
|
||||
},
|
||||
}
|
||||
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 = [
|
||||
i for i in inbounds
|
||||
if i.get("tag") not in ("Cascade-RU-DE", "Steal-Yali")
|
||||
]
|
||||
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 on :443")
|
||||
if ru_prof and not ru_has_443:
|
||||
changes.append("updated profile DE-Yali to IPv6-only SelfSteal Cascade-RU-DE")
|
||||
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 []:
|
||||
@@ -284,10 +286,11 @@ def ensure_cascade_credentials(
|
||||
vnext[0]["port"] = 443
|
||||
vnext[0]["users"][0]["id"] = creds["uuid"]
|
||||
rs = (ob.get("streamSettings") or {}).get("realitySettings") or {}
|
||||
rs["serverName"] = "yali.gunis.top"
|
||||
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")
|
||||
changes.append("updated profile RU-Cascade to SelfSteal yali.gunis.top")
|
||||
return creds
|
||||
|
||||
|
||||
@@ -426,6 +429,9 @@ def sync_node_and_host(
|
||||
api.request("PUT", "/nodes/", payload)
|
||||
changes.append(f"updated node {node_name} ({target_addr})")
|
||||
|
||||
if not node_cfg.get("create_host", True):
|
||||
return
|
||||
|
||||
selfsteal = node_cfg["selfsteal_domain"]
|
||||
_, hosts_resp = api.request("GET", "/hosts/")
|
||||
hosts = _extract_list(hosts_resp)
|
||||
@@ -506,7 +512,7 @@ def cleanup_removed_nodes_and_hosts(
|
||||
desired_nodes: list[dict[str, Any]],
|
||||
changes: list[str],
|
||||
) -> None:
|
||||
desired_domains = {n["selfsteal_domain"] for n in desired_nodes}
|
||||
desired_domains = {n["selfsteal_domain"] for n in desired_nodes if n.get("create_host", True)}
|
||||
desired_node_names = {n["name"] for n in desired_nodes}
|
||||
desired_profile_names = {n["profile_name"] for n in desired_nodes}
|
||||
|
||||
|
||||
@@ -32,11 +32,6 @@
|
||||
changed_when: "'added' in (ufw_netbird_wg.stdout | lower) or 'deleted' in (ufw_netbird_wg.stdout | lower)"
|
||||
failed_when: false
|
||||
|
||||
- name: Разрешить каскад Xray по IPv6 только с rus-central (1443/tcp)
|
||||
ansible.builtin.command: ufw allow from 2a06:dd00:1:4::6bd1 to any port 1443 proto tcp
|
||||
register: ufw_cascade_v6
|
||||
changed_when: "'added' in (ufw_cascade_v6.stdout | lower)"
|
||||
|
||||
- name: Запретить любой исходящий доступ с exit node в домашнюю LAN (defense-in-depth)
|
||||
ansible.builtin.command: "{{ item }}"
|
||||
loop:
|
||||
|
||||
@@ -6,6 +6,9 @@ remnanode_node_port: 2222
|
||||
remnanode_public_ip: "{{ ansible_host }}"
|
||||
remnanode_wait_host: "127.0.0.1"
|
||||
remnanode_allow_panel_wan: false
|
||||
remnanode_dns_record_type: "A"
|
||||
remnanode_ipv6_only: false
|
||||
remnanode_cascade_allowed_ips: []
|
||||
|
||||
remnanode_selfsteal_domain: "yali.gunis.top"
|
||||
remnanode_xhttp_path: "/xhttp-yali"
|
||||
|
||||
@@ -52,9 +52,9 @@
|
||||
ansible.builtin.set_fact:
|
||||
remnanode_cf_zone_id: "{{ (cf_zones.json.result | first).id }}"
|
||||
|
||||
- name: Найти существующую A-запись SelfSteal
|
||||
- name: Найти существующую DNS-запись SelfSteal ({{ remnanode_dns_record_type }})
|
||||
ansible.builtin.uri:
|
||||
url: "https://api.cloudflare.com/client/v4/zones/{{ remnanode_cf_zone_id }}/dns_records?type=A&name={{ remnanode_selfsteal_domain }}"
|
||||
url: "https://api.cloudflare.com/client/v4/zones/{{ remnanode_cf_zone_id }}/dns_records?type={{ remnanode_dns_record_type }}&name={{ remnanode_selfsteal_domain }}"
|
||||
headers:
|
||||
Authorization: "Bearer {{ remnanode_cloudflare_api }}"
|
||||
Content-Type: application/json
|
||||
@@ -63,7 +63,33 @@
|
||||
register: cf_dns_lookup
|
||||
no_log: true
|
||||
|
||||
- name: Создать A-запись SelfSteal
|
||||
- name: Найти старую A-запись SelfSteal (если AAAA)
|
||||
ansible.builtin.uri:
|
||||
url: "https://api.cloudflare.com/client/v4/zones/{{ remnanode_cf_zone_id }}/dns_records?type=A&name={{ remnanode_selfsteal_domain }}"
|
||||
headers:
|
||||
Authorization: "Bearer {{ remnanode_cloudflare_api }}"
|
||||
Content-Type: application/json
|
||||
return_content: true
|
||||
status_code: 200
|
||||
register: cf_old_a_lookup
|
||||
when: remnanode_dns_record_type == "AAAA"
|
||||
no_log: true
|
||||
|
||||
- name: Удалить старую A-запись SelfSteal при переходе на IPv6-only
|
||||
ansible.builtin.uri:
|
||||
url: "https://api.cloudflare.com/client/v4/zones/{{ remnanode_cf_zone_id }}/dns_records/{{ item.id }}"
|
||||
method: DELETE
|
||||
headers:
|
||||
Authorization: "Bearer {{ remnanode_cloudflare_api }}"
|
||||
Content-Type: application/json
|
||||
status_code: 200
|
||||
loop: "{{ (cf_old_a_lookup.json.result | default([])) }}"
|
||||
when:
|
||||
- remnanode_dns_record_type == "AAAA"
|
||||
- cf_old_a_lookup is defined
|
||||
no_log: true
|
||||
|
||||
- name: Создать DNS-запись SelfSteal ({{ remnanode_dns_record_type }})
|
||||
ansible.builtin.uri:
|
||||
url: "https://api.cloudflare.com/client/v4/zones/{{ remnanode_cf_zone_id }}/dns_records"
|
||||
method: POST
|
||||
@@ -72,7 +98,7 @@
|
||||
Content-Type: application/json
|
||||
body_format: json
|
||||
body:
|
||||
type: A
|
||||
type: "{{ remnanode_dns_record_type }}"
|
||||
name: "{{ remnanode_selfsteal_domain }}"
|
||||
content: "{{ remnanode_public_ip }}"
|
||||
ttl: 120
|
||||
@@ -81,7 +107,7 @@
|
||||
when: (cf_dns_lookup.json.result | length) == 0
|
||||
no_log: true
|
||||
|
||||
- name: Обновить A-запись SelfSteal
|
||||
- name: Обновить DNS-запись SelfSteal ({{ remnanode_dns_record_type }})
|
||||
ansible.builtin.uri:
|
||||
url: "https://api.cloudflare.com/client/v4/zones/{{ remnanode_cf_zone_id }}/dns_records/{{ (cf_dns_lookup.json.result | first).id }}"
|
||||
method: PUT
|
||||
@@ -90,7 +116,7 @@
|
||||
Content-Type: application/json
|
||||
body_format: json
|
||||
body:
|
||||
type: A
|
||||
type: "{{ remnanode_dns_record_type }}"
|
||||
name: "{{ remnanode_selfsteal_domain }}"
|
||||
content: "{{ remnanode_public_ip }}"
|
||||
ttl: 120
|
||||
@@ -133,10 +159,21 @@
|
||||
path: /root/.secrets/cloudflare.ini
|
||||
state: absent
|
||||
|
||||
- name: Разрешить HTTP для Let's Encrypt HTTP-01
|
||||
- name: Разрешить HTTP для Let's Encrypt HTTP-01 (dual-stack)
|
||||
ansible.builtin.command: ufw allow 80/tcp
|
||||
register: ufw_http
|
||||
changed_when: "'added' in (ufw_http.stdout | lower)"
|
||||
when: not (remnanode_ipv6_only | bool)
|
||||
|
||||
- name: Закрыть общий 80/tcp и открыть 80/tcp только для IPv6 (HTTP-01)
|
||||
ansible.builtin.command: "{{ item }}"
|
||||
loop:
|
||||
- ufw --force delete allow 80/tcp
|
||||
- "ufw allow from ::/0 to {{ remnanode_public_ip }} port 80 proto tcp"
|
||||
register: ufw_http_v6
|
||||
changed_when: "'added' in (ufw_http_v6.stdout | lower)"
|
||||
failed_when: false
|
||||
when: remnanode_ipv6_only | bool
|
||||
|
||||
- name: Выпустить/обновить сертификат через HTTP-01 (без TXT в Cloudflare)
|
||||
ansible.builtin.command: >
|
||||
@@ -178,6 +215,21 @@
|
||||
ansible.builtin.command: ufw allow 443/tcp
|
||||
register: ufw_https
|
||||
changed_when: "'added' in (ufw_https.stdout | lower)"
|
||||
when: not (remnanode_ipv6_only | bool)
|
||||
|
||||
- name: Закрыть общий 443/tcp и открыть 443/tcp только для разрешённых IPv6-каскадов
|
||||
ansible.builtin.command: ufw --force delete allow 443/tcp
|
||||
register: ufw_https_del
|
||||
changed_when: "'deleted' in (ufw_https_del.stdout | lower)"
|
||||
failed_when: false
|
||||
when: remnanode_ipv6_only | bool
|
||||
|
||||
- name: Разрешить 443/tcp только с входных IPv6 каскада
|
||||
ansible.builtin.command: "ufw allow from {{ item }} to {{ remnanode_public_ip }} port 443 proto tcp"
|
||||
loop: "{{ remnanode_cascade_allowed_ips }}"
|
||||
register: ufw_https_v6
|
||||
changed_when: "'added' in (ufw_https_v6.stdout | lower)"
|
||||
when: remnanode_ipv6_only | bool
|
||||
|
||||
- name: Узнать NetBird IP панели
|
||||
ansible.builtin.shell: |
|
||||
|
||||
Reference in new issue
Block a user