diff --git a/NotchBuddy/Sources/App/NetPanel.swift b/NotchBuddy/Sources/App/NetPanel.swift index 00f532d..f43523b 100644 --- a/NotchBuddy/Sources/App/NetPanel.swift +++ b/NotchBuddy/Sources/App/NetPanel.swift @@ -276,6 +276,24 @@ final class NetCore: ObservableObject { 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. static func needsReload(_ name: String) -> Bool { !name.hasPrefix("AWG ") } @@ -458,6 +476,18 @@ struct NetPanel: View { } } 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) diff --git a/scripts/netcore/gen.py b/scripts/netcore/gen.py index 1959e98..ababdd1 100755 --- a/scripts/netcore/gen.py +++ b/scripts/netcore/gen.py @@ -190,8 +190,9 @@ def main(): rules += ["DOMAIN-SUFFIX,ru,DIRECT", "DOMAIN-SUFFIX,su,DIRECT", "DOMAIN-SUFFIX,xn--p1ai,DIRECT", "MATCH,exit"] vless = { - # Fetch the list directly: the nodes themselves are dialled directly anyway. - "type": "http", "url": sub, "interval": 43200, "path": "./providers/vless.yaml", "proxy": "DIRECT", + # Fetch through the exit: the subscription host is unreachable directly from home + # (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}} if hid["vless"]: # Hidden nodes stay in the subscription, the core just skips them. diff --git a/scripts/netcore/netctl.py b/scripts/netcore/netctl.py index 2a1b057..f7a262c 100644 --- a/scripts/netcore/netctl.py +++ b/scripts/netcore/netctl.py @@ -11,6 +11,7 @@ allows exactly these operations: 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 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 out of "auto" (the key / subscription stay, nothing is deleted) unhide {name} put it back @@ -386,6 +387,14 @@ def change_hidden(name, hide): 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): 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, - "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