@@ -32,25 +32,16 @@ func (r *Rule) Apply(ctx routing.Context) bool {
3232func (rr * RoutingRule ) BuildCondition () (Condition , error ) {
3333 conds := NewConditionChan ()
3434
35- if len (rr .Domain ) > 0 {
36- matcher , err := NewMphMatcherGroup (rr .Domain )
37- if err != nil {
38- return nil , errors .New ("failed to build domain condition with MphDomainMatcher" ).Base (err )
39- }
40- errors .LogDebug (context .Background (), "MphDomainMatcher is enabled for " , len (rr .Domain ), " domain rule(s)" )
41- conds .Add (matcher )
42- }
43-
44- if len (rr .UserEmail ) > 0 {
45- conds .Add (NewUserMatcher (rr .UserEmail ))
35+ if len (rr .InboundTag ) > 0 {
36+ conds .Add (NewInboundTagMatcher (rr .InboundTag ))
4637 }
4738
48- if rr .VlessRouteList != nil {
49- conds .Add (NewPortMatcher (rr .VlessRouteList , MatcherAsType_VlessRoute ))
39+ if len ( rr .Networks ) > 0 {
40+ conds .Add (NewNetworkMatcher (rr .Networks ))
5041 }
5142
52- if len (rr .InboundTag ) > 0 {
53- conds .Add (NewInboundTagMatcher (rr .InboundTag ))
43+ if len (rr .Protocol ) > 0 {
44+ conds .Add (NewProtocolMatcher (rr .Protocol ))
5445 }
5546
5647 if rr .PortList != nil {
@@ -65,8 +56,20 @@ func (rr *RoutingRule) BuildCondition() (Condition, error) {
6556 conds .Add (NewPortMatcher (rr .LocalPortList , MatcherAsType_Local ))
6657 }
6758
68- if len (rr .Networks ) > 0 {
69- conds .Add (NewNetworkMatcher (rr .Networks ))
59+ if rr .VlessRouteList != nil {
60+ conds .Add (NewPortMatcher (rr .VlessRouteList , MatcherAsType_VlessRoute ))
61+ }
62+
63+ if len (rr .UserEmail ) > 0 {
64+ conds .Add (NewUserMatcher (rr .UserEmail ))
65+ }
66+
67+ if len (rr .Attributes ) > 0 {
68+ configuredKeys := make (map [string ]* regexp.Regexp )
69+ for key , value := range rr .Attributes {
70+ configuredKeys [strings .ToLower (key )] = regexp .MustCompile (value )
71+ }
72+ conds .Add (& AttributeMatcher {configuredKeys })
7073 }
7174
7275 if len (rr .Geoip ) > 0 {
@@ -94,16 +97,13 @@ func (rr *RoutingRule) BuildCondition() (Condition, error) {
9497 errors .LogWarning (context .Background (), "Due to some limitations, in UDP connections, localIP is always equal to listen interface IP, so \" localIP\" rule condition does not work properly on UDP inbound connections that listen on all interfaces" )
9598 }
9699
97- if len (rr .Protocol ) > 0 {
98- conds .Add (NewProtocolMatcher (rr .Protocol ))
99- }
100-
101- if len (rr .Attributes ) > 0 {
102- configuredKeys := make (map [string ]* regexp.Regexp )
103- for key , value := range rr .Attributes {
104- configuredKeys [strings .ToLower (key )] = regexp .MustCompile (value )
100+ if len (rr .Domain ) > 0 {
101+ matcher , err := NewMphMatcherGroup (rr .Domain )
102+ if err != nil {
103+ return nil , errors .New ("failed to build domain condition with MphDomainMatcher" ).Base (err )
105104 }
106- conds .Add (& AttributeMatcher {configuredKeys })
105+ errors .LogDebug (context .Background (), "MphDomainMatcher is enabled for " , len (rr .Domain ), " domain rule(s)" )
106+ conds .Add (matcher )
107107 }
108108
109109 if conds .Len () == 0 {
0 commit comments