mirror of
https://github.com/ryan4yin/nix-config.git
synced 2026-11-29 17:52:32 +01:00
fix(desktop): tie ai's link DNS takeover to mihomo's lifecycle (#380)
* fix(desktop): tie ai's link DNS takeover to mihomo's lifecycle sing-tun normally points systemd-resolved at the TUN DNS by running resolvectl (dns/domain/default-route). Under nixpkgs' hardened DynamicUser mihomo unit that hand-off fails silently: the unit's RestrictAddressFamilies blocks resolvectl's D-Bus socket and resolve1 requires privileged authorization, so resolved keeps querying the physical-link DNS, fake-ip is bypassed, and domain rules degrade to MATCH. Do the hand-off as '+' ExecStartPost/ExecStopPost hooks instead: '+' commands run outside the sandbox (systemd.exec: address-family restrictions do not apply to them) and ExecStopPost reverts even on crashes, so a dead mihomo leaves DNS usable. Signed-off-by: Ryan Yin <xiaoyin_c@qq.com> * docs(mihomo): record sing-tun's resolvectl hand-off as the leak cause Signed-off-by: Ryan Yin <xiaoyin_c@qq.com> * refactor(desktop): keep mihomo only on ai and shoukei ruby/kana never ran the core (service inactive live), and their resolved + TUN combo would reintroduce the resolver leak once enabled. Drop the enable and the explicit module import from computer-use; the eval test now pins mihomo=false for both guests. --------- Signed-off-by: Ryan Yin <xiaoyin_c@qq.com>
This commit is contained in:
1 parent
bbd230e6fd
commit
8f0961d9c2
7 files changed
+42
-22
No files matched your search
@@ -14,8 +14,6 @@ let
|
||||
timeZone = if cfg.proxyRegion == "jp" then "Asia/Tokyo" else "America/Los_Angeles";
|
||||
in
|
||||
{
|
||||
imports = [ ./networking/mihomo ]; # also pulled in by the desktop scanPaths; explicit for clarity
|
||||
|
||||
options.modules.desktop.computerUse = {
|
||||
enable = lib.mkEnableOption "headless computer-use environment (X11 + desktop automation)";
|
||||
proxyRegion = lib.mkOption {
|
||||
@@ -46,10 +44,5 @@ in
|
||||
|
||||
# Browsers keep their profile/preferences in dconf.
|
||||
programs.dconf.enable = true;
|
||||
|
||||
# Native mihomo runs the proxy as a system service (TUN), so the headless
|
||||
# session does not depend on a GUI starting the core. Its config lives at
|
||||
# ~/.config/mihomo/config.yaml (out of the Nix store).
|
||||
modules.networking.mihomo.enable = true;
|
||||
};
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
# Mihomo
|
||||
|
||||
Native mihomo core + metacubexd dashboard, replacing the Clash Verge GUI. Enable per host with
|
||||
`modules.networking.mihomo.enable = true` (`ai`, `shoukei`, `ruby`, `kana`).
|
||||
`modules.networking.mihomo.enable = true` (`ai`, `shoukei`).
|
||||
|
||||
## Usage
|
||||
|
||||
@@ -46,6 +46,13 @@ targets instead of writing a config the core rejects.
|
||||
won clash-verge-rev#1762).
|
||||
- `find-process-mode: off` unless `PROCESS-*` rules or `tun_exclude_process` need it.
|
||||
- Rule payloads are bare domains: `DOMAIN-SUFFIX,https://qlogo.cn` is invalid.
|
||||
- On a systemd-resolved host, sing-tun normally points resolved at the TUN DNS with `resolvectl`.
|
||||
The nixpkgs `DynamicUser` sandbox cannot make those privileged D-Bus changes, so resolved's own
|
||||
upstream queries bypass `dns-hijack any:53` and leave via the NIC. Tie a resolver takeover to the
|
||||
service lifetime (`resolvectl dns`/`revert` in `ExecStartPost`/`ExecStopPost`, see
|
||||
`hosts/idols-ai/default.nix`), prefixed with `+` to run outside the unit sandbox. Never set link
|
||||
DNS statically to mihomo: a dead mihomo would take DNS down with it, and resolved does not fall
|
||||
back.
|
||||
|
||||
## References
|
||||
|
||||
|
||||
@@ -518,7 +518,9 @@ def main [
|
||||
enable: true
|
||||
# port 53 is unreachable here: the unit runs DynamicUser with only
|
||||
# CAP_NET_ADMIN, so a privileged bind fails. TUN's dns-hijack covers
|
||||
# resolution; this listener is a loopback convenience only.
|
||||
# queries that leave through an interface; hosts whose system resolver
|
||||
# answers over loopback (systemd-resolved) need their resolver taken over
|
||||
# while mihomo runs, or fake-ip is bypassed entirely.
|
||||
listen: "127.0.0.1:1053"
|
||||
ipv6: false
|
||||
"enhanced-mode": "fake-ip"
|
||||
|
||||
Reference in new issue
Block a user