Refactor: A faster DomainMatcher implementation (#348)

Co-authored-by: DarthVader <61409963+darsvador@users.noreply.github.com>
Questo commit è contenuto in:
秋のかえで 2021-04-18 13:21:17 +08:00 committato da GitHub
parent bf94fb53ca
commit 7b7084f825
Non sono state trovate chiavi note per questa firma nel database
ID chiave GPG: 4AEE18F83AFDEB23
15 ha cambiato i file con 912 aggiunte e 52 eliminazioni

Vedi file

@ -98,6 +98,8 @@ type RouterRule struct {
Type string `json:"type"`
OutboundTag string `json:"outboundTag"`
BalancerTag string `json:"balancerTag"`
DomainMatcher string `json:"domainMatcher"`
}
func ParseIP(s string) (*router.CIDR, error) {
@ -491,6 +493,10 @@ func parseFieldRule(msg json.RawMessage) (*router.RoutingRule, error) {
return nil, newError("neither outboundTag nor balancerTag is specified in routing rule")
}
if rawFieldRule.DomainMatcher != "" {
rule.DomainMatcher = rawFieldRule.DomainMatcher
}
if rawFieldRule.Domain != nil {
for _, domain := range *rawFieldRule.Domain {
rules, err := parseDomainRule(domain)