Network core: home WireGuard as a client network (off = direct at home, on = via home tunnel when away); drop Saga's overlapping 10.0.0.0/24 tunnel subnet

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
maksarsanjeev
2026-10-08 01:31:14 +03:00
parent 0d5c68f83b
commit a7a0195d34
4 changed files with 39 additions and 17 deletions
+13 -6
View File
@@ -23,6 +23,8 @@ struct NetClient: Identifiable, Equatable {
var subnet: String
var on: Bool
var delay: Int?
/// What "off" means: REJECT (network unreachable) or DIRECT (home: you're there).
var offName: String = "REJECT"
}
@MainActor
@@ -49,7 +51,10 @@ final class NetCore: ObservableObject {
static let clientInfo: [String: (title: String, subnet: String)] = [
"saga": ("Сага", "192.168.8.0/24"),
"planet9": ("Planet9", "192.168.68.0/24"),
"home": ("Дом", "192.168.10.0/24 · вне дома"),
]
/// Order in the panel.
static let clientOrder = ["home", "saga", "planet9"]
// MARK: Root helper (netctl.py)
//
@@ -153,11 +158,12 @@ final class NetCore: ObservableObject {
delay: delay)
}
}
clients = Self.clientInfo.keys.sorted().compactMap { id in
guard let g = proxies["\(id)-sw"] else { return nil }
let info = Self.clientInfo[id]!
clients = Self.clientOrder.compactMap { id in
guard let g = proxies["\(id)-sw"], let info = Self.clientInfo[id] else { return nil }
let all = g["all"] as? [String] ?? []
return NetClient(id: id, title: info.title, subnet: info.subnet,
on: (g["now"] as? String) == id, delay: lastDelay(id))
on: (g["now"] as? String) == id, delay: lastDelay(id),
offName: all.first ?? "REJECT")
}
}
@@ -191,7 +197,8 @@ final class NetCore: ObservableObject {
func set(client id: String, on: Bool) async {
if let i = clients.firstIndex(where: { $0.id == id }) { clients[i].on = on }
_ = await call(["cmd": "select", "group": "\(id)-sw", "name": on ? id : "REJECT"])
let off = clients.first(where: { $0.id == id })?.offName ?? "REJECT"
_ = await call(["cmd": "select", "group": "\(id)-sw", "name": on ? id : off])
SoundEngine.shared.play(on ? "pop" : "close")
if on, let m = (await call(["cmd": "delay", "proxy": id], timeout: 15))?["delays"] as? [String: Int] {
for (k, v) in m { measured[k] = v }
@@ -374,7 +381,7 @@ struct NetPanel: View {
Task { await net.set(client: c.id, on: !c.on) }
}
}
Text("Выключенная сеть недоступна. Claude и интернет это не трогает.")
Text("Выключенная сеть клиента недоступна; «Дом» выключен — значит напрямую (ты дома). Claude и интернет это не трогает.")
.font(.system(size: 10.5)).foregroundColor(Color(hex: "#6B7079"))
.fixedSize(horizontal: false, vertical: true)
.padding(.top, 4)