Repository navigation
Conversation
PUT /rules takes the same body as PUT /configs (payload, or path, or neither for the current config file) but applies only the rules, sub-rules and rule providers, through the new executor.ApplyRules. Proxies, DNS, listeners and TUN keep running and are not suspended. Rule providers are loaded before the new rules take effect; parsing creates them empty, so swapping them in unloaded would leave every RULE-SET rule matching nothing. A rule that targets a proxy or group which is not running is rejected with 400 and nothing changes, because the tunnel would otherwise skip it silently. Like the other write endpoints, PUT /rules is not available in embed mode. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
What
Adds
PUT /rules, which replaces the rules, sub-rules and rule providers of a running core without reloading anything else.It takes the same body as
PUT /configs:Only
rules,sub-rulesandrule-providersfrom that config are applied, through a newexecutor.ApplyRules. Proxies, groups and their selections, DNS, listeners and TUN keep running, and the tunnel is not suspended.Why
Clients that edit routing at runtime, for example "send this domain to that group", currently have to
PUT /configs. That rebuilds every proxy, DNS and listener, and suspends the tunnel to change a few rule lines.PATCH /rules/disablecan only turn existing rules on and off; it cannot add, reorder or retarget them.Details
RULE-SETrule matching nothing until the next full reload.ApplyRulescalls the existingloadProviderfirst, with the same semantics asApplyConfig: a provider that fails to load is logged, and the update still goes ahead.400, and nothing changes. Adding proxies still needsPUT /configs.ApplyRulesholds the same lock asApplyConfig.updateConfigsmoves intoparseConfigRequest, so both endpoints share the samepayload/path/ safe-path handling.PUT /configsbehaves as before.PUT /configsandPATCH /rules/disable,PUT /rulesis not registered in embed mode.Testing
hub/executor/apply_rules_test.go:RULE-SETrules keep matching afterApplyRules. This test fails if the provider loading is removed.go test ./hub/... ./config/... ./rules/...,go vetwith Go 1.20 and 1.27, and cross-builds for linux, windows and android.PUT /rulesswitched a domain between DIRECT and the node by aRULE-SET, by the node's own name (emoji and|included), and back.400 … proxy [Netflix] is not running …, with traffic unaffected.400, and{}reloaded the rules from the config file.PUT /configsstill worked.PUT /rulescalls that alternated the route: no request failed, and both routes were used.The API docs live in MetaCubeX/Meta-Docs. I can open a matching docs PR there if this is accepted.
🤖 Generated with Claude Code