mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-12-22 10:08:15 -05:00
reorder condition list to short circuit IP resolution if possible.
Fix #1021
This commit is contained in:
parent
84a05e7cd9
commit
758723516e
@ -59,12 +59,12 @@ func (rr *RoutingRule) BuildCondition() (Condition, error) {
|
|||||||
conds.Add(matcher)
|
conds.Add(matcher)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(rr.Cidr) > 0 {
|
if len(rr.UserEmail) > 0 {
|
||||||
cond, err := cidrToCondition(rr.Cidr, false)
|
conds.Add(NewUserMatcher(rr.UserEmail))
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
}
|
||||||
conds.Add(cond)
|
|
||||||
|
if len(rr.InboundTag) > 0 {
|
||||||
|
conds.Add(NewInboundTagMatcher(rr.InboundTag))
|
||||||
}
|
}
|
||||||
|
|
||||||
if rr.PortRange != nil {
|
if rr.PortRange != nil {
|
||||||
@ -75,6 +75,14 @@ func (rr *RoutingRule) BuildCondition() (Condition, error) {
|
|||||||
conds.Add(NewNetworkMatcher(rr.NetworkList))
|
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 {
|
if len(rr.SourceCidr) > 0 {
|
||||||
cond, err := cidrToCondition(rr.SourceCidr, true)
|
cond, err := cidrToCondition(rr.SourceCidr, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -83,14 +91,6 @@ func (rr *RoutingRule) BuildCondition() (Condition, error) {
|
|||||||
conds.Add(cond)
|
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 {
|
if conds.Len() == 0 {
|
||||||
return nil, newError("this rule has no effective fields").AtWarning()
|
return nil, newError("this rule has no effective fields").AtWarning()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user