mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-04-30 01:08:33 +00:00
Support regex matching with attr (#2258)
* Support regex matching with attr * Add test case * Optimizing regex parsing at core start * simpliy
This commit is contained in:
parent
07389eca96
commit
a6c5c57930
3 changed files with 22 additions and 7 deletions
|
@ -1,6 +1,7 @@
|
|||
package router
|
||||
|
||||
import (
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/xtls/xray-core/common/net"
|
||||
|
@ -145,9 +146,9 @@ func (rr *RoutingRule) BuildCondition() (Condition, error) {
|
|||
}
|
||||
|
||||
if len(rr.Attributes) > 0 {
|
||||
configuredKeys := make(map[string]string)
|
||||
configuredKeys := make(map[string]*regexp.Regexp)
|
||||
for key, value := range rr.Attributes {
|
||||
configuredKeys[strings.ToLower(key)] = strings.ToLower(value)
|
||||
configuredKeys[strings.ToLower(key)] = regexp.MustCompile(value)
|
||||
}
|
||||
conds.Add(&AttributeMatcher{configuredKeys})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue