mirror of https://github.com/v2ray/v2ray-core
sort cidr list before use
parent
de384a4ee4
commit
5400153827
|
@ -1,6 +1,8 @@
|
|||
package router
|
||||
|
||||
import (
|
||||
"sort"
|
||||
|
||||
"v2ray.com/core/common/net"
|
||||
"v2ray.com/core/common/serial"
|
||||
)
|
||||
|
@ -52,6 +54,9 @@ func (m *GeoIPMatcher) Init(cidrs []*CIDR) error {
|
|||
}
|
||||
}
|
||||
|
||||
cidrList := CIDRList(cidrs)
|
||||
sort.Sort(&cidrList)
|
||||
|
||||
m.ip4 = make([]uint32, 0, ip4Count)
|
||||
m.prefix4 = make([]uint8, 0, ip4Count)
|
||||
m.ip6 = make([]ipv6, 0, ip6Count)
|
||||
|
|
|
@ -3,7 +3,6 @@ package router_test
|
|||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"testing"
|
||||
|
||||
proto "github.com/golang/protobuf/proto"
|
||||
|
@ -32,8 +31,6 @@ func TestGeoIPMatcher(t *testing.T) {
|
|||
{Ip: []byte{91, 108, 4, 0}, Prefix: 16},
|
||||
}
|
||||
|
||||
sort.Sort(&cidrList)
|
||||
|
||||
matcher := &router.GeoIPMatcher{}
|
||||
common.Must(matcher.Init(cidrList))
|
||||
|
||||
|
|
|
@ -71,18 +71,15 @@ message RoutingRule {
|
|||
// List of GeoIPs for target IP address matching. If this entry exists, the cidr above will have no effect.
|
||||
// GeoIP fields with the same country code are supposed to contain exactly same content. They will be merged during runtime.
|
||||
// For customized GeoIPs, please leave country code empty.
|
||||
// The CIDR list in the GeoIP must be sorted beforehand.
|
||||
repeated GeoIP geoip = 10;
|
||||
|
||||
v2ray.core.common.net.PortRange port_range = 4;
|
||||
v2ray.core.common.net.NetworkList network_list = 5;
|
||||
|
||||
// List of CIDRs for source IP address matching.
|
||||
// The list must be sorted beforehand.
|
||||
repeated CIDR source_cidr = 6 [deprecated = true];
|
||||
|
||||
// List of GeoIPs for source IP address matching. If this entry exists, the source_cidr above will have no effect.
|
||||
// The CIDR list in the GeoIP must be sorted beforehand.
|
||||
repeated GeoIP source_geoip = 11;
|
||||
|
||||
repeated string user_email = 7;
|
||||
|
|
Loading…
Reference in New Issue