1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-22 01:57:12 -05:00

reorder condition list to short circuit IP resolution if possible.

Fix #1021
This commit is contained in:
Darien Raymond 2018-04-06 15:56:53 +02:00
parent 84a05e7cd9
commit 758723516e
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169

View File

@ -59,12 +59,12 @@ func (rr *RoutingRule) BuildCondition() (Condition, error) {
conds.Add(matcher)
}
if len(rr.Cidr) > 0 {
cond, err := cidrToCondition(rr.Cidr, false)
if err != nil {
return nil, err
if len(rr.UserEmail) > 0 {
conds.Add(NewUserMatcher(rr.UserEmail))
}
conds.Add(cond)
if len(rr.InboundTag) > 0 {
conds.Add(NewInboundTagMatcher(rr.InboundTag))
}
if rr.PortRange != nil {
@ -75,6 +75,14 @@ func (rr *RoutingRule) BuildCondition() (Condition, error) {
conds.Add(NewNetworkMatcher(rr.NetworkList))
}
if len(rr.Cidr) > 0 {
cond, err := cidrToCondition(rr.Cidr, false)
if err != nil {
return nil, err
}
conds.Add(cond)
}
if len(rr.SourceCidr) > 0 {
cond, err := cidrToCondition(rr.SourceCidr, true)
if err != nil {
@ -83,14 +91,6 @@ func (rr *RoutingRule) BuildCondition() (Condition, error) {
conds.Add(cond)
}
if len(rr.UserEmail) > 0 {
conds.Add(NewUserMatcher(rr.UserEmail))
}
if len(rr.InboundTag) > 0 {
conds.Add(NewInboundTagMatcher(rr.InboundTag))
}
if conds.Len() == 0 {
return nil, newError("this rule has no effective fields").AtWarning()
}