1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2026-01-06 01:05:35 -05:00

refactor common router structure into separate package

This commit is contained in:
Shelikhoo
2021-09-07 09:13:58 +01:00
parent fd63ad7160
commit 68f28b1913
17 changed files with 1323 additions and 1192 deletions

View File

@@ -1,6 +1,7 @@
package router
import (
"github.com/v2fly/v2ray-core/v4/app/router/routercommon"
"github.com/v2fly/v2ray-core/v4/common/net"
"github.com/v2fly/v2ray-core/v4/common/serial"
"github.com/v2fly/v2ray-core/v4/features/outbound"
@@ -8,7 +9,7 @@ import (
)
// CIDRList is an alias of []*CIDR to provide sort.Interface.
type CIDRList []*CIDR
type CIDRList []*routercommon.CIDR
// Len implements sort.Interface.
func (l *CIDRList) Len() int {
@@ -118,7 +119,7 @@ func (rr *RoutingRule) BuildCondition() (Condition, error) {
}
conds.Add(cond)
} else if len(rr.Cidr) > 0 {
cond, err := NewMultiGeoIPMatcher([]*GeoIP{{Cidr: rr.Cidr}}, false)
cond, err := NewMultiGeoIPMatcher([]*routercommon.GeoIP{{Cidr: rr.Cidr}}, false)
if err != nil {
return nil, err
}
@@ -132,7 +133,7 @@ func (rr *RoutingRule) BuildCondition() (Condition, error) {
}
conds.Add(cond)
} else if len(rr.SourceCidr) > 0 {
cond, err := NewMultiGeoIPMatcher([]*GeoIP{{Cidr: rr.SourceCidr}}, true)
cond, err := NewMultiGeoIPMatcher([]*routercommon.GeoIP{{Cidr: rr.SourceCidr}}, true)
if err != nil {
return nil, err
}