Repository navigation
Add app-store endpoints so clash-cli can read and edit profile config - #13
Open
zifengjiang wants to merge 1 commit into
Open
zifengjiang wants to merge 1 commit into
zifengjiang wants to merge 1 commit into
Conversation
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
clash-clican already read and drive the runtime (proxies, rules in force, DNS lookups, connections), but it cannot touch the app's configuration store: a profile's override rules and its per-domain DNS never leave the App Group, so the only way to edit them is the macOS/iOS UI. That blocks scripted setup and lets an AI assistant drive everything except the part that actually persists.What
Four endpoints on the existing private API surface, registered with the same
privateRoutePrefixeshelper as the rest of/clash/v1, and guarded by the same check as other app-state routes (overAppGroupSocketorRequestFromManagedListener), so a LAN controller client with the right secret and certificate fingerprint can use them too:GET /clash/v1/app/profilesGET|PUT /clash/v1/app/profiles/{id}/rulesoverride.prependRules,override.appendRules)GET|PUT /clash/v1/app/profiles/{id}/dns-policydns.nameserver-policyanddns.fake-ip-filterin the profile's runtime patchDesign notes:
published-rules.yaml, the resolved runtime config, revisions) stay owned by the app.PUTof DNS policy replaces only the keys it is given; other keys and unknown fields are preserved.app-store-v1from/clash/v1/capabilities, so clients can detect it.Tests
cd bind/clash && go build ./... && go test ./ -run AppStore -count=1Covers reading a real-shaped store, unknown-field preservation, replace-vs-preserve semantics for both rule lists and per-domain DNS, unknown profile ids, malformed payloads, and that a write leaves unrelated profiles byte-identical.