Files
nix-config/modules/nixos/desktop/networking/mihomo/sources.example.yaml
T
ryan4yin | 二花 63b7183381 feat(mihomo): keep unproxiable ranges out of TUN, fix the startup DNS race (#419)
* feat(mihomo): keep ranges that can never be proxied out of TUN

The list lives in policy.yaml as tun_exclude_address; sources.yaml may override
it. 198.18.0.0/15 stays in TUN: that is the fake-ip range itself.

* feat(mihomo): match Valve's content servers by ASN

The 20 hand-copied prefixes had drifted from what AS32590 announces. The rule
type needs GeoLite2-ASN.mmdb, so geox-url.asn points at the same mirror.

* feat(mihomo): render the gateway config from the same sources

The hand-kept copy had drifted: a manual sync carried the desktop's secret onto
the gateway and dropped external-ui-url. --redact yields a shareable template.

* fix(mihomo): open the link DNS takeover only once the core serves it

The core opens :1053 after parsing rules, and rule parsing is where missing
geodata gets fetched. Flipping at fork time made that fetch SERVFAIL, the config
fatal, and the unit unstartable.

* fix(justfile): keep local endpoints out of the agent proxy

With only HTTP_PROXY set, a request to this host's own llama-swap endpoint went
to mihomo. Node matches exact hosts only, so the literals carry it; the CIDRs
serve curl and Go.

* feat(justfile): seed mihomo geodata into the service state dir

So a cold start never needs the download that the DNS takeover made unstartable.
2026-10-09 12:31:59 +08:00

49 lines
2.0 KiB
YAML

# Copy to ~/.config/mihomo/sources.yaml, fill it in, then run `nu generate.nu`.
# Keep it mode 0600 and never commit it: subscription URLs, the dashboard
# password and private domain names all live here.
#
# The portable routing policy (ads, CN consumer services, local ranges) is not
# here -- it lives in policy.yaml, which is safe to keep in the repository.
# Password for the dashboard at http://127.0.0.1:9090/ui
secret: "replace-me"
# Domains that must never be proxied or fake-IPed: each becomes a DIRECT rule
# plus a fake-ip-filter entry, so it resolves to a real IP. `*.lab.example.com`
# is an alias for the plain form; any other `*` placement is rejected.
private_domains:
# - private.example.com
# - "*.lab.example.com"
# Extra rules, before the ones the sources bring in. Payloads are bare domains,
# never `https://…`. A `MATCH` here is dropped: policy.yaml closes the list.
rules:
# - DOMAIN-SUFFIX,download.example.com,PROXY
# - PROCESS-NAME,some-app,DIRECT
# Keep on unless an app misbehaves under TUN (WeChat and office suites usually).
tun_strict_route: true
# Processes kept off TUN entirely; also re-enables find-process-mode, which
# PROCESS-* rules need.
tun_exclude_process:
# - some-app
# CIDRs kept out of TUN; the default is policy.yaml's list. Setting this replaces
# the whole list, and `[]` puts everything back through TUN.
# tun_exclude_address: [192.168.0.0/16]
providers:
# The core imports a subscription's proxies only; `rules_from` carries its
# rules and groups over from a local snapshot copy. Only worth it when the
# provider ships policy you actually need -- see README.md.
- name: provider-a
url: "https://example.invalid/subscribe/replace-me"
# interval: 86400
# rules_from: "~/.config/mihomo/snapshots/provider-a.yaml"
# A local Clash YAML file: proxies are inlined (the service user cannot read
# /home), and its groups, rules and rule-providers are carried over too.
- name: provider-b
file: "~/work/example/client-proxy.yaml"