mihomo: live delivery of nodes and rules via providers#119
Open
Postlog wants to merge 1 commit into
Open
Conversation
Deliver the node list as a proxy-provider and authored rule lists as
rule-providers bound to the subscription token, so the mihomo core refreshes
them on their interval while connected — operator edits reach a connected
client without a profile reload (mobile apps have no background profile timer;
verified against ClashMi source).
- render: drop inline proxies:; emit proxy-providers pointing at
/sub/mihomo/{token}/proxies (per-config proxies_interval); proxy-groups
reference it via use:+filter (QuoteMeta-escaped); authored rule-providers
point at /sub/mihomo/{token}/rules/{name}; new RenderProxiesPayload /
RenderAuthoredProvider.
- mihomo: RuleProvider.Source (external|authored) + authored matcher tree
(RoutingRule, Target nil); Profile.ProxiesInterval; decode/validate +
sentinels.
- migration 0005 (additive): rule_providers.source, mihomo_authored_matchers
(recursive), mihomo_profile.proxies_interval.
- repository: save/read/clone authored matchers; source column.
- ogen: subProxies/subRules endpoints reusing the HMAC token resolution;
MihomoProvider.source+matchers, MihomoConfig.proxiesInterval, schema sources.
- admin UI: provider source toggle + authored-list editor (reused rule-node,
RULE-SET filtered out); nodes-update-interval field.
See the archived OpenSpec change
openspec/changes/archive/2026-06-30-live-providers/.
Co-Authored-By: Claude Opus 4.8 <[email protected]>
a2c1057 to
f554591
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
A mihomo subscription was one YAML doc — nodes (
proxies:), groups and rules all inlined — so whether an operator edit reaches a client depends on the app re-pulling the whole profile. Reading the ClashMi (KaringX/clashmi) source confirmed mobile has no background profile-update timer (the periodic timer is gated onisPC(); noworkmanager/BGTask): the profile refreshes only on app foreground / tunnel (re)connect. SoProfile-Update-Intervalcannot guarantee "edit the config → connected clients apply it within an hour" on phones.mihomo's
proxy-providers/rule-providerscarry anintervalthe core itself re-fetches while the tunnel is up, independent of the app UI. This PR delivers nodes and authored rule lists that way.What
proxies:; emit aproxy-providers:pointing at/sub/mihomo/{token}/proxies(per-configproxies_interval); proxy-groups reference it viause:+filter:(anchored,regexp.QuoteMeta-escaped — labels may contain emoji/regex metachars); authored rule-providers point at/sub/mihomo/{token}/rules/{name}. NewRenderProxiesPayload/RenderAuthoredProvider.RuleProvider.Source(external|authored) + a target-less matcher tree (reusesRoutingRule,Target==nil; leaf + logical AND/OR/NOT, never MATCH/RULE-SET/SUB-RULE — mihomo forbids those in a classical provider);Profile.ProxiesInterval; decode/validate + sentinels.0005(additive, no rebuild):rule_providers.source, recursivemihomo_authored_matchers,mihomo_profile.proxies_interval.sourcecolumn.subProxies/subRulesendpoints reusing the existing HMAC token resolution;MihomoProvider.source+matchers,MihomoConfig.proxiesInterval, schemasources.rule-node, RULE-SET filtered out) + hints; new "nodes update interval" field.subgen stays MIT and never imports mihomo / decodes
mrs: externalmrsis referenced as its own provider; composing "authored + external" toward one target is twoRULE-SETskeleton lines (routing-identical). Design + trade-offs: the archived OpenSpec changeopenspec/changes/archive/2026-06-30-live-providers/(design.md).Scope boundary
The skeleton
rules:and therule-providers:/proxy-providers:declarations stay in the base profile; only the content each provider fetches is live. Structural changes (new groups/targets, reordering, adding a whole provider) still need a profile reload.Documentation
Rebased onto current
main. Following the OpenSpec migration (#121), this PR ships its design as an OpenSpec change (archived underopenspec/changes/archive/2026-06-30-live-providers/, the former ADR-0010) and applies the spec deltas to the living specs (subscription-delivery,mihomo-rendering,mihomo-config).openspec validate --specs --strictis green; theCHANGELOGentry links the archived change.Testing
make allis green (generate + lint + unit-race+ integration + apitest against real 3x-ui panels in docker):use:+filter:groups, classical-text rendering, source validation).GET /sub/{kind}/{token}/proxies(no longer inline in/sub); the config schema advertises the newproxy-providersgenerated key; the black-box save struct carriessource/proxiesInterval.🤖 Generated with Claude Code