feat(remnawave,rus-central): add IPv6 Xray cascade lulu.gunihome.ru -> ger-nod-02
ansible-deploy / plan (push) Successful in 2s
ansible-lint / lint (push) Successful in 3s
ansible-deploy / deploy (core-net, ) (push) Failing after 16s
ansible-deploy / deploy (ger-nod-02, ) (push) Successful in 47s
ansible-deploy / deploy (rus-central, ) (push) Successful in 6m20s
ansible-deploy / plan (push) Successful in 2s
ansible-lint / lint (push) Successful in 3s
ansible-deploy / deploy (core-net, ) (push) Failing after 16s
ansible-deploy / deploy (ger-nod-02, ) (push) Successful in 47s
ansible-deploy / deploy (rus-central, ) (push) Successful in 6m20s
This commit is contained in:
1 parent
71f1a009bf
commit
202290fa98
11 files changed
+244
-27
No files matched your search
@@ -96,6 +96,9 @@ case "$machine" in
|
||||
rus-central)
|
||||
input_email="${INPUT_LETSENCRYPT_EMAIL:-}"
|
||||
eval "$(infisical export --domain="${INFISICAL_DOMAIN}" --token="${TOKEN}" --env=prod --projectId="${INFISICAL_PROJECT_ID}" --path="/services/netbird" --format=dotenv-export --silent)"
|
||||
eval "$(infisical export --domain="${INFISICAL_DOMAIN}" --token="${TOKEN}" --env=prod --projectId="${INFISICAL_PROJECT_ID}" --path="/services/remnawave" --format=dotenv-export --silent 2>/dev/null || true)"
|
||||
export REMNANODE_SECRET_KEY="${REMNANODE_SECRET_KEY:-}"
|
||||
export CLOUDFLARE_API="${CLOUDFLARE_API:-}"
|
||||
export NETBIRD_AUTH_SECRET="${NETBIRD_AUTH_SECRET:-}"
|
||||
export NETBIRD_DATASTORE_KEY="${NETBIRD_DATASTORE_KEY:-}"
|
||||
export NETBIRD_SESSION_KEY="${NETBIRD_SESSION_KEY:-}"
|
||||
|
||||
@@ -1,2 +1,11 @@
|
||||
---
|
||||
netbird_domain: central.gunihome.ru
|
||||
remnanode_public_ip: "31.177.108.210"
|
||||
remnanode_wait_host: "31.177.108.210"
|
||||
remnanode_allow_panel_wan: true
|
||||
remnanode_selfsteal_domain: "lulu.gunihome.ru"
|
||||
remnanode_cloudflare_zone: "gunihome.ru"
|
||||
remnanode_xhttp_path: "/xhttp-lulu"
|
||||
remnanode_panel_egress_ips:
|
||||
- "213.128.28.107" # провайдер 1 (МТС)
|
||||
- "185.160.137.140" # провайдер 2 (NorCom)
|
||||
@@ -5,5 +5,7 @@
|
||||
roles:
|
||||
- role: rus-central/netbird
|
||||
tags: [netbird]
|
||||
- role: remnanode
|
||||
tags: [remnanode]
|
||||
- role: rus-central/cadvisor
|
||||
tags: [cadvisor]
|
||||
@@ -16,7 +16,20 @@ nodes:
|
||||
profile_name: "DE-Yali"
|
||||
profile_template: "profile-selfsteal-xhttp.json"
|
||||
inbound_tag: "Steal-Yali"
|
||||
extra_inbound_tags:
|
||||
- "Cascade-RU-DE"
|
||||
selfsteal_domain: "yali.gunis.top"
|
||||
xhttp_path: "/xhttp-yali"
|
||||
host_remark: "🇩🇪 ger-nod-02"
|
||||
|
||||
- name: Rus-central
|
||||
address: "31.177.108.210"
|
||||
port: 2222
|
||||
country_code: "RU"
|
||||
profile_name: "RU-Cascade"
|
||||
profile_template: "profile-cascade-ru.json"
|
||||
inbound_tag: "Steal-Lulu"
|
||||
selfsteal_domain: "lulu.gunihome.ru"
|
||||
xhttp_path: "/xhttp-lulu"
|
||||
host_remark: "🇷🇺→🇩🇪 lulu"
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
{
|
||||
"log": {
|
||||
"loglevel": "warning"
|
||||
},
|
||||
"inbounds": [
|
||||
{
|
||||
"tag": "__INBOUND_TAG__",
|
||||
"listen": "31.177.108.210",
|
||||
"port": 443,
|
||||
"protocol": "vless",
|
||||
"settings": {
|
||||
"clients": [],
|
||||
"decryption": "none"
|
||||
},
|
||||
"sniffing": {
|
||||
"enabled": true,
|
||||
"destOverride": ["http", "tls", "quic"]
|
||||
},
|
||||
"streamSettings": {
|
||||
"network": "xhttp",
|
||||
"security": "reality",
|
||||
"xhttpSettings": {
|
||||
"host": "__SELFSTEAL_DOMAIN__",
|
||||
"mode": "stream-one",
|
||||
"path": "__XHTTP_PATH__"
|
||||
},
|
||||
"realitySettings": {
|
||||
"dest": "/dev/shm/nginx.sock",
|
||||
"show": false,
|
||||
"xver": 1,
|
||||
"spiderX": "",
|
||||
"shortIds": ["__REALITY_SHORT_ID__"],
|
||||
"privateKey": "__REALITY_PRIVATE_KEY__",
|
||||
"serverNames": ["__SELFSTEAL_DOMAIN__"]
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"outbounds": [
|
||||
{
|
||||
"tag": "CASCADE-DE",
|
||||
"protocol": "vless",
|
||||
"settings": {
|
||||
"vnext": [
|
||||
{
|
||||
"address": "2a12:bec4:1bb0:2e80::2",
|
||||
"port": 1443,
|
||||
"users": [
|
||||
{
|
||||
"id": "__CASCADE_UUID__",
|
||||
"encryption": "none",
|
||||
"flow": "xtls-rprx-vision"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"streamSettings": {
|
||||
"network": "tcp",
|
||||
"security": "reality",
|
||||
"realitySettings": {
|
||||
"serverName": "www.cloudflare.com",
|
||||
"fingerprint": "chrome",
|
||||
"publicKey": "__CASCADE_PUBLIC_KEY__",
|
||||
"shortId": "__CASCADE_SHORT_ID__"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"tag": "BLOCK",
|
||||
"protocol": "blackhole"
|
||||
}
|
||||
],
|
||||
"routing": {
|
||||
"domainStrategy": "AsIs",
|
||||
"rules": [
|
||||
{
|
||||
"type": "field",
|
||||
"ip": ["geoip:private"],
|
||||
"outboundTag": "BLOCK"
|
||||
},
|
||||
{
|
||||
"type": "field",
|
||||
"protocol": ["bittorrent"],
|
||||
"outboundTag": "BLOCK"
|
||||
},
|
||||
{
|
||||
"type": "field",
|
||||
"network": "tcp,udp",
|
||||
"outboundTag": "CASCADE-DE"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import re
|
||||
import secrets
|
||||
import subprocess
|
||||
import sys
|
||||
import uuid
|
||||
from typing import Any
|
||||
|
||||
|
||||
@@ -177,12 +178,87 @@ def sync_xray_template(
|
||||
return tpl_uuid
|
||||
|
||||
|
||||
def generate_x25519(api: RemnawaveAPI) -> tuple[str, str]:
|
||||
_, key_resp = api.request("GET", "/system/tools/x25519/generate")
|
||||
resp_obj = key_resp.get("response") or key_resp
|
||||
keypairs = resp_obj.get("keypairs") or []
|
||||
first = keypairs[0] if keypairs else resp_obj
|
||||
priv = first.get("privateKey") or first.get("privKey") or ""
|
||||
pub = first.get("publicKey") or first.get("pubKey") or ""
|
||||
if not priv or not pub:
|
||||
raise RuntimeError("Не удалось сгенерировать X25519 ключ Reality")
|
||||
return priv, pub
|
||||
|
||||
|
||||
def ensure_cascade_credentials(
|
||||
api: RemnawaveAPI,
|
||||
changes: list[str],
|
||||
) -> dict[str, str]:
|
||||
"""Ensure DE-Yali has Cascade-RU-DE inbound and return credentials if RU-Cascade needs creation."""
|
||||
_, profiles_resp = api.request("GET", "/config-profiles/")
|
||||
profiles = _extract_list(profiles_resp, "configProfiles")
|
||||
de_prof = next((p for p in profiles if p.get("name") == "DE-Yali"), None)
|
||||
ru_prof = next((p for p in profiles if p.get("name") == "RU-Cascade"), None)
|
||||
if not de_prof:
|
||||
return {}
|
||||
|
||||
de_uuid = de_prof["uuid"]
|
||||
_, de_full = api.request("GET", f"/config-profiles/{de_uuid}")
|
||||
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)
|
||||
|
||||
if has_cascade_inb and ru_prof:
|
||||
return {}
|
||||
|
||||
priv, pub = generate_x25519(api)
|
||||
creds = {
|
||||
"uuid": str(uuid.uuid4()),
|
||||
"priv": priv,
|
||||
"pub": pub,
|
||||
"short_id": secrets.token_hex(8),
|
||||
}
|
||||
cascade_inbound = {
|
||||
"tag": "Cascade-RU-DE",
|
||||
"listen": "2a12:bec4:1bb0:2e80::2",
|
||||
"port": 1443,
|
||||
"protocol": "vless",
|
||||
"settings": {
|
||||
"clients": [{"id": creds["uuid"], "flow": "xtls-rprx-vision"}],
|
||||
"decryption": "none",
|
||||
},
|
||||
"sniffing": {
|
||||
"enabled": True,
|
||||
"destOverride": ["http", "tls", "quic"],
|
||||
},
|
||||
"streamSettings": {
|
||||
"network": "tcp",
|
||||
"security": "reality",
|
||||
"realitySettings": {
|
||||
"dest": "www.cloudflare.com:443",
|
||||
"show": False,
|
||||
"shortIds": [creds["short_id"]],
|
||||
"privateKey": creds["priv"],
|
||||
"serverNames": ["www.cloudflare.com"],
|
||||
},
|
||||
},
|
||||
}
|
||||
new_inbounds = [i for i in inbounds if i.get("tag") != "Cascade-RU-DE"]
|
||||
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")
|
||||
return creds
|
||||
|
||||
|
||||
def ensure_profile_and_inbound(
|
||||
api: RemnawaveAPI,
|
||||
node_cfg: dict[str, Any],
|
||||
profile_templates: dict[str, str],
|
||||
cascade_creds: dict[str, str],
|
||||
changes: list[str],
|
||||
) -> tuple[str, str]:
|
||||
) -> tuple[str, str, list[str]]:
|
||||
profile_name = node_cfg["profile_name"]
|
||||
inbound_tag = node_cfg["inbound_tag"]
|
||||
|
||||
@@ -196,18 +272,7 @@ def ensure_profile_and_inbound(
|
||||
if not raw_tpl:
|
||||
raise RuntimeError(f"Не найден шаблон профиля {tpl_key}")
|
||||
|
||||
_, key_resp = api.request("GET", "/system/tools/x25519/generate")
|
||||
resp_obj = key_resp.get("response") or key_resp
|
||||
keypairs = resp_obj.get("keypairs") or []
|
||||
priv = (
|
||||
(keypairs[0].get("privateKey") if keypairs else None)
|
||||
or resp_obj.get("privateKey")
|
||||
or resp_obj.get("privKey")
|
||||
or ""
|
||||
)
|
||||
if not priv:
|
||||
raise RuntimeError("Не удалось сгенерировать X25519 ключ Reality")
|
||||
|
||||
priv, _ = generate_x25519(api)
|
||||
short_id = secrets.token_hex(8)
|
||||
rendered = (
|
||||
raw_tpl.replace("__REALITY_PRIVATE_KEY__", priv)
|
||||
@@ -215,6 +280,9 @@ def ensure_profile_and_inbound(
|
||||
.replace("__INBOUND_TAG__", inbound_tag)
|
||||
.replace("__SELFSTEAL_DOMAIN__", node_cfg["selfsteal_domain"])
|
||||
.replace("__XHTTP_PATH__", node_cfg["xhttp_path"])
|
||||
.replace("__CASCADE_UUID__", cascade_creds.get("uuid", ""))
|
||||
.replace("__CASCADE_PUBLIC_KEY__", cascade_creds.get("pub", ""))
|
||||
.replace("__CASCADE_SHORT_ID__", cascade_creds.get("short_id", ""))
|
||||
)
|
||||
_, created = api.request(
|
||||
"POST",
|
||||
@@ -235,7 +303,13 @@ def ensure_profile_and_inbound(
|
||||
inbound_uuid = next((i["uuid"] for i in inbounds if i.get("tag") == inbound_tag), "")
|
||||
if not inbound_uuid:
|
||||
raise RuntimeError(f"Не найден inbound {inbound_tag} в профиле {profile_uuid}")
|
||||
return profile_uuid, inbound_uuid
|
||||
extra_uuids = [
|
||||
i["uuid"]
|
||||
for tag in node_cfg.get("extra_inbound_tags", [])
|
||||
for i in inbounds
|
||||
if i.get("tag") == tag
|
||||
]
|
||||
return profile_uuid, inbound_uuid, extra_uuids
|
||||
|
||||
|
||||
def sync_node_and_host(
|
||||
@@ -243,6 +317,7 @@ def sync_node_and_host(
|
||||
node_cfg: dict[str, Any],
|
||||
profile_uuid: str,
|
||||
inbound_uuid: str,
|
||||
extra_inbound_uuids: list[str],
|
||||
tpl_uuid: str,
|
||||
nb_peers: dict[str, str],
|
||||
netbird_connected: bool,
|
||||
@@ -263,9 +338,10 @@ def sync_node_and_host(
|
||||
nodes = _extract_list(nodes_resp)
|
||||
existing_node = next((n for n in nodes if n.get("name") == node_name), None)
|
||||
|
||||
active_inbounds = [inbound_uuid] + extra_inbound_uuids
|
||||
desired_cp = {
|
||||
"activeConfigProfileUuid": profile_uuid,
|
||||
"activeInbounds": [inbound_uuid],
|
||||
"activeInbounds": active_inbounds,
|
||||
}
|
||||
|
||||
if not existing_node:
|
||||
@@ -295,7 +371,7 @@ def sync_node_and_host(
|
||||
existing_node.get("address") != target_addr
|
||||
or int(existing_node.get("port") or 0) != int(node_cfg["port"])
|
||||
or cur_cp.get("activeConfigProfileUuid") != profile_uuid
|
||||
or cur_inbounds != [inbound_uuid]
|
||||
or set(cur_inbounds) != set(active_inbounds)
|
||||
)
|
||||
if needs_update:
|
||||
payload = {
|
||||
@@ -585,10 +661,12 @@ def main() -> int:
|
||||
changes,
|
||||
)
|
||||
|
||||
cascade_creds = ensure_cascade_credentials(api, changes)
|
||||
|
||||
inbound_uuids: list[str] = []
|
||||
for node_cfg in cfg.get("nodes", []):
|
||||
profile_uuid, inbound_uuid = ensure_profile_and_inbound(
|
||||
api, node_cfg, cfg.get("profile_templates", {}), changes
|
||||
profile_uuid, inbound_uuid, extra_inbound_uuids = ensure_profile_and_inbound(
|
||||
api, node_cfg, cfg.get("profile_templates", {}), cascade_creds, changes
|
||||
)
|
||||
inbound_uuids.append(inbound_uuid)
|
||||
sync_node_and_host(
|
||||
@@ -596,6 +674,7 @@ def main() -> int:
|
||||
node_cfg,
|
||||
profile_uuid,
|
||||
inbound_uuid,
|
||||
extra_inbound_uuids,
|
||||
tpl_uuid,
|
||||
nb_peers,
|
||||
bool(cfg.get("netbird_connected")),
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
users: "{{ remnawave_users_cfg.users | default([]) }}"
|
||||
profile_templates:
|
||||
profile-selfsteal-xhttp.json: "{{ lookup('file', role_path ~ '/files/profile-selfsteal-xhttp.json') }}"
|
||||
profile-cascade-ru.json: "{{ lookup('file', role_path ~ '/files/profile-cascade-ru.json') }}"
|
||||
|
||||
- name: Положить скрипт синхронизации Remnawave
|
||||
ansible.builtin.copy:
|
||||
|
||||
@@ -32,6 +32,11 @@
|
||||
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:
|
||||
|
||||
@@ -3,6 +3,9 @@ remnanode_dir: /opt/remnanode
|
||||
remnanode_image: "remnawave/node:latest"
|
||||
remnanode_nginx_image: "nginx:1.28"
|
||||
remnanode_node_port: 2222
|
||||
remnanode_public_ip: "{{ ansible_host }}"
|
||||
remnanode_wait_host: "127.0.0.1"
|
||||
remnanode_allow_panel_wan: false
|
||||
|
||||
remnanode_selfsteal_domain: "yali.gunis.top"
|
||||
remnanode_xhttp_path: "/xhttp-yali"
|
||||
|
||||
@@ -74,7 +74,7 @@
|
||||
body:
|
||||
type: A
|
||||
name: "{{ remnanode_selfsteal_domain }}"
|
||||
content: "{{ ansible_host }}"
|
||||
content: "{{ remnanode_public_ip }}"
|
||||
ttl: 120
|
||||
proxied: false
|
||||
status_code: [200, 201]
|
||||
@@ -92,14 +92,14 @@
|
||||
body:
|
||||
type: A
|
||||
name: "{{ remnanode_selfsteal_domain }}"
|
||||
content: "{{ ansible_host }}"
|
||||
content: "{{ remnanode_public_ip }}"
|
||||
ttl: 120
|
||||
proxied: false
|
||||
status_code: 200
|
||||
when: >-
|
||||
(cf_dns_lookup.json.result | length) > 0 and
|
||||
(
|
||||
(cf_dns_lookup.json.result | first).content != ansible_host or
|
||||
(cf_dns_lookup.json.result | first).content != remnanode_public_ip or
|
||||
(cf_dns_lookup.json.result | first).proxied
|
||||
)
|
||||
no_log: true
|
||||
@@ -142,6 +142,7 @@
|
||||
ansible.builtin.command: >
|
||||
certbot certonly
|
||||
--standalone
|
||||
--http-01-address {{ remnanode_public_ip }}
|
||||
--non-interactive
|
||||
--agree-tos
|
||||
--email {{ remnanode_letsencrypt_email }}
|
||||
@@ -203,7 +204,9 @@
|
||||
ufw allow from {{ remnanode_panel_nb.stdout | trim }} to any port {{ remnanode_node_port }} proto tcp
|
||||
register: ufw_node_nb
|
||||
changed_when: "'added' in (ufw_node_nb.stdout | lower)"
|
||||
when: remnanode_panel_nb.stdout | default('') | trim is match('^[0-9.]+$')
|
||||
when:
|
||||
- not (remnanode_allow_panel_wan | bool)
|
||||
- remnanode_panel_nb.stdout | default('') | trim is match('^[0-9.]+$')
|
||||
|
||||
- name: Убрать WAN-доступ к NODE_PORT
|
||||
ansible.builtin.command: >
|
||||
@@ -212,7 +215,9 @@
|
||||
register: ufw_node_wan_del
|
||||
changed_when: "'deleted' in (stdout | default('') | lower)"
|
||||
failed_when: false
|
||||
when: remnanode_panel_nb.stdout | default('') | trim is match('^[0-9.]+$')
|
||||
when:
|
||||
- not (remnanode_allow_panel_wan | bool)
|
||||
- remnanode_panel_nb.stdout | default('') | trim is match('^[0-9.]+$')
|
||||
|
||||
- name: Разрешить NODE_PORT только с egress панели (оба провайдера)
|
||||
ansible.builtin.command: >
|
||||
@@ -220,7 +225,7 @@
|
||||
loop: "{{ remnanode_panel_egress_ips }}"
|
||||
register: ufw_node
|
||||
changed_when: "'added' in (stdout | default('') | lower)"
|
||||
when: remnanode_panel_nb.stdout | default('') | trim is not match('^[0-9.]+$')
|
||||
when: (remnanode_allow_panel_wan | bool) or (remnanode_panel_nb.stdout | default('') | trim is not match('^[0-9.]+$'))
|
||||
|
||||
- name: Включить firewall
|
||||
ansible.builtin.command: ufw --force enable
|
||||
@@ -244,7 +249,7 @@
|
||||
- name: Дождаться 443 после конфига с панели
|
||||
ansible.builtin.wait_for:
|
||||
port: 443
|
||||
host: 127.0.0.1
|
||||
host: "{{ remnanode_wait_host }}"
|
||||
timeout: 180
|
||||
register: remnanode_wait_443
|
||||
failed_when: false
|
||||
|
||||
@@ -33,8 +33,10 @@ services:
|
||||
- "--ping.entrypoint=ping"
|
||||
- "--entrypoints.ping.address=:8082"
|
||||
ports:
|
||||
- "443:443"
|
||||
- "80:80"
|
||||
- "45.154.185.208:443:443"
|
||||
- "127.0.0.1:443:443"
|
||||
- "45.154.185.208:80:80"
|
||||
- "127.0.0.1:80:80"
|
||||
volumes:
|
||||
- /var/run/docker.sock:/var/run/docker.sock:ro
|
||||
- netbird_traefik_letsencrypt:/letsencrypt
|
||||
|
||||
Reference in new issue
Block a user