Net core: subscription fetched through the exit, hourly, and on demand

The cluster subscription host is unreachable directly from home: the provider pull had
failed with EOF since day one and the node list went stale (a new node, Aurora, never
showed up). The provider now downloads through «exit», every hour instead of 12, and
netctl refresh (BroV: «Обновить список узлов») pulls it now and reports added/removed
nodes, without a reload.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
maksarsanjeev
2026-10-12 20:36:05 +03:00
parent b11d778b04
commit 0586b3c7e9
3 changed files with 44 additions and 3 deletions
+30
View File
@@ -276,6 +276,24 @@ final class NetCore: ObservableObject {
await refresh() await refresh()
} }
/// Re-downloads the cluster subscription now (new nodes appear without a reload).
func refreshNodes() async {
busy = true
let r = await call(["cmd": "refresh"], timeout: 40)
busy = false
if r?["ok"] as? Bool == true {
let added = r?["added"] as? [String] ?? [], removed = r?["removed"] as? [String] ?? []
lastError = added.isEmpty && removed.isEmpty ? "Список узлов актуален."
: ([added.isEmpty ? nil : "Новые узлы: " + added.joined(separator: ", "),
removed.isEmpty ? nil : "Пропали: " + removed.joined(separator: ", ")].compactMap { $0 }.joined(separator: ". ") + ".")
SoundEngine.shared.play("pop")
} else {
lastError = "Не удалось обновить подписку: \(r?["error"] as? String ?? "помощник не ответил")."
}
await refresh()
await measure()
}
/// VLESS nodes come from the subscription: hiding one rebuilds the core config. /// VLESS nodes come from the subscription: hiding one rebuilds the core config.
static func needsReload(_ name: String) -> Bool { !name.hasPrefix("AWG ") } static func needsReload(_ name: String) -> Bool { !name.hasPrefix("AWG ") }
@@ -458,6 +476,18 @@ struct NetPanel: View {
} }
} }
if !net.hidden.isEmpty { HiddenSection(net: net) } if !net.hidden.isEmpty { HiddenSection(net: net) }
Button { Task { await net.refreshNodes() } } label: {
HStack(spacing: 5) {
Image(systemName: "arrow.triangle.2.circlepath").font(.system(size: 11))
Text("Обновить список узлов").font(.system(size: 11.5, weight: .medium))
}
.foregroundColor(Color(hex: "#8E939C"))
.padding(.horizontal, 8).padding(.vertical, 6)
.contentShape(Rectangle())
}
.buttonStyle(.plain)
.disabled(net.busy)
.help("Скачать подписку кластера сейчас — новые узлы появятся сразу")
} }
.frame(width: 230) .frame(width: 230)
+3 -2
View File
@@ -190,8 +190,9 @@ def main():
rules += ["DOMAIN-SUFFIX,ru,DIRECT", "DOMAIN-SUFFIX,su,DIRECT", "DOMAIN-SUFFIX,xn--p1ai,DIRECT", rules += ["DOMAIN-SUFFIX,ru,DIRECT", "DOMAIN-SUFFIX,su,DIRECT", "DOMAIN-SUFFIX,xn--p1ai,DIRECT",
"MATCH,exit"] "MATCH,exit"]
vless = { vless = {
# Fetch the list directly: the nodes themselves are dialled directly anyway. # Fetch through the exit: the subscription host is unreachable directly from home
"type": "http", "url": sub, "interval": 43200, "path": "./providers/vless.yaml", "proxy": "DIRECT", # (the pull failed with EOF and the node list went stale).
"type": "http", "url": sub, "interval": 3600, "path": "./providers/vless.yaml", "proxy": "exit",
"health-check": {"enable": True, "url": TEST_URL, "interval": 300}} "health-check": {"enable": True, "url": TEST_URL, "interval": 300}}
if hid["vless"]: if hid["vless"]:
# Hidden nodes stay in the subscription, the core just skips them. # Hidden nodes stay in the subscription, the core just skips them.
+11 -1
View File
@@ -11,6 +11,7 @@ allows exactly these operations:
delay {group}|{proxy} speed test of exit / ai-out / amnezia, or of a client tunnel delay {group}|{proxy} speed test of exit / ai-out / amnezia, or of a client tunnel
tun {on} traffic capture on (fresh core start) / off; remembered tun {on} traffic capture on (fresh core start) / off; remembered
add_key {text} vpn:// Amnezia key (checked by gen.py) or a vless:// link: stored, core updated add_key {text} vpn:// Amnezia key (checked by gen.py) or a vless:// link: stored, core updated
refresh {} re-download the VLESS subscription now (new cluster nodes), no reload
hide {name} take an Amnezia connection or a VLESS node out of the list and hide {name} take an Amnezia connection or a VLESS node out of the list and
out of "auto" (the key / subscription stay, nothing is deleted) out of "auto" (the key / subscription stay, nothing is deleted)
unhide {name} put it back unhide {name} put it back
@@ -386,6 +387,14 @@ def change_hidden(name, hide):
return {"ok": True, "reloaded": kind == "vless"} return {"ok": True, "reloaded": kind == "vless"}
def cmd_refresh(_):
before = set(provider_names("vless-cluster"))
api("PUT", "/providers/proxies/vless-cluster", timeout=30)
after = provider_names("vless-cluster")
return {"ok": True, "nodes": after, "added": [n for n in after if n not in before],
"removed": sorted(before - set(after))}
def cmd_hide(r): def cmd_hide(r):
return change_hidden(r.get("name"), True) return change_hidden(r.get("name"), True)
@@ -395,7 +404,8 @@ def cmd_unhide(r):
COMMANDS = {"state": cmd_state, "select": cmd_select, "delay": cmd_delay, "tun": cmd_tun, COMMANDS = {"state": cmd_state, "select": cmd_select, "delay": cmd_delay, "tun": cmd_tun,
"add_key": cmd_add_key, "hide": cmd_hide, "unhide": cmd_unhide} "add_key": cmd_add_key, "hide": cmd_hide, "unhide": cmd_unhide,
"refresh": cmd_refresh}
# MARK: - Socket server # MARK: - Socket server