feat(route): add optional "name" field to route and DNS rules#4061
Open
Pushkinmazila2 wants to merge 101 commits into
Open
feat(route): add optional "name" field to route and DNS rules#4061Pushkinmazila2 wants to merge 101 commits into
Pushkinmazila2 wants to merge 101 commits into
Conversation
`SecTrustEvaluateWithError` is serial
This reverts commit 62cb06c.
Signed-off-by: Pushkinmazila2 <zavalny199@yandex.com>
Author
|
@nekohasekai ive tested in new build.I tested the new version with your changes, everything works. Whether you have a "name" or not, everything works too. |
Contributor
|
Was I’m wondering because if rules ever become referenceable in the future, having |
Author
|
The trick here is that if there are tags in the future, I'm only in favor, |
1b0e6c5 to
abedea4
Compare
057f540 to
6b07a22
Compare
41d2e8c to
812a8fd
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.
Summary
Adds an optional
namefield toDefaultRuleandLogicalRule(both route and DNS) that allows users to label individual rules with human-readable names. The field is purely cosmetic — it has no effect on matching logic — and is fully backward-compatible.Motivation
Large sing-box configurations can contain dozens of rules. Without labels, log output and debugging rely entirely on auto-generated descriptions like
rule_set(geosite-category-ads) domain_keyword(...), which makes it hard to understand at a glance which rule fired and why.A
namefield solves this with zero risk: old configs without it continue to work unchanged, and new configs with it work fine on old builds (unknown fields are ignored by the JSON parser).Changes
option/rule.goName string \json:"name,omitempty"`toRawDefaultRule`Name string \json:"name,omitempty"`toRawLogicalRule`option/dns_rule.goName string \json:"name,omitempty"`toRawDefaultDNSRule`Name string \json:"name,omitempty"`toLogicalDNSRule`route/rule/rule_abstract.goabstractDefaultRule.String()now prefixes output with[name]whentagis setabstractLogicalRule.String()now prefixes output with[name]whentagis setroute/rule/rule_default.goNewDefaultRule: passesoptions.Name→abstractDefaultRule.tagNewLogicalRule: passesoptions.Name→abstractLogicalRule.tagBehavior
When
nameis set, log lines change from:to:
When
nameis omitted, output is identical to the current behavior.Example
Backward Compatibility
Testing
Built and verified using Docker:
Log output confirms
[name]prefix appears correctly on rule match.