|
@@ -1,6 +1,7 @@
|
|
|
package dns_test
|
|
package dns_test
|
|
|
|
|
|
|
|
import (
|
|
import (
|
|
|
|
|
+ "github.com/v2fly/v2ray-core/v4/app/router/routercommon"
|
|
|
"google.golang.org/protobuf/types/known/anypb"
|
|
"google.golang.org/protobuf/types/known/anypb"
|
|
|
"testing"
|
|
"testing"
|
|
|
"time"
|
|
"time"
|
|
@@ -14,7 +15,6 @@ import (
|
|
|
"github.com/v2fly/v2ray-core/v4/app/policy"
|
|
"github.com/v2fly/v2ray-core/v4/app/policy"
|
|
|
"github.com/v2fly/v2ray-core/v4/app/proxyman"
|
|
"github.com/v2fly/v2ray-core/v4/app/proxyman"
|
|
|
_ "github.com/v2fly/v2ray-core/v4/app/proxyman/outbound"
|
|
_ "github.com/v2fly/v2ray-core/v4/app/proxyman/outbound"
|
|
|
- "github.com/v2fly/v2ray-core/v4/app/router"
|
|
|
|
|
"github.com/v2fly/v2ray-core/v4/common"
|
|
"github.com/v2fly/v2ray-core/v4/common"
|
|
|
"github.com/v2fly/v2ray-core/v4/common/net"
|
|
"github.com/v2fly/v2ray-core/v4/common/net"
|
|
|
"github.com/v2fly/v2ray-core/v4/common/serial"
|
|
"github.com/v2fly/v2ray-core/v4/common/serial"
|
|
@@ -430,7 +430,7 @@ func TestStaticHostDomain(t *testing.T) {
|
|
|
Port: uint32(port),
|
|
Port: uint32(port),
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
- StaticHosts: []*Config_HostMapping{
|
|
|
|
|
|
|
+ StaticHosts: []*HostMapping{
|
|
|
{
|
|
{
|
|
|
Type: DomainMatchingType_Full,
|
|
Type: DomainMatchingType_Full,
|
|
|
Domain: "example.com",
|
|
Domain: "example.com",
|
|
@@ -496,10 +496,10 @@ func TestIPMatch(t *testing.T) {
|
|
|
},
|
|
},
|
|
|
Port: uint32(port),
|
|
Port: uint32(port),
|
|
|
},
|
|
},
|
|
|
- Geoip: []*router.GeoIP{
|
|
|
|
|
|
|
+ Geoip: []*routercommon.GeoIP{
|
|
|
{
|
|
{
|
|
|
CountryCode: "local",
|
|
CountryCode: "local",
|
|
|
- Cidr: []*router.CIDR{
|
|
|
|
|
|
|
+ Cidr: []*routercommon.CIDR{
|
|
|
{
|
|
{
|
|
|
// inner ip, will not match
|
|
// inner ip, will not match
|
|
|
Ip: []byte{192, 168, 11, 1},
|
|
Ip: []byte{192, 168, 11, 1},
|
|
@@ -520,10 +520,10 @@ func TestIPMatch(t *testing.T) {
|
|
|
},
|
|
},
|
|
|
Port: uint32(port),
|
|
Port: uint32(port),
|
|
|
},
|
|
},
|
|
|
- Geoip: []*router.GeoIP{
|
|
|
|
|
|
|
+ Geoip: []*routercommon.GeoIP{
|
|
|
{
|
|
{
|
|
|
CountryCode: "test",
|
|
CountryCode: "test",
|
|
|
- Cidr: []*router.CIDR{
|
|
|
|
|
|
|
+ Cidr: []*routercommon.CIDR{
|
|
|
{
|
|
{
|
|
|
Ip: []byte{8, 8, 8, 8},
|
|
Ip: []byte{8, 8, 8, 8},
|
|
|
Prefix: 32,
|
|
Prefix: 32,
|
|
@@ -532,7 +532,7 @@ func TestIPMatch(t *testing.T) {
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
CountryCode: "test",
|
|
CountryCode: "test",
|
|
|
- Cidr: []*router.CIDR{
|
|
|
|
|
|
|
+ Cidr: []*routercommon.CIDR{
|
|
|
{
|
|
{
|
|
|
Ip: []byte{8, 8, 8, 4},
|
|
Ip: []byte{8, 8, 8, 4},
|
|
|
Prefix: 32,
|
|
Prefix: 32,
|
|
@@ -620,10 +620,10 @@ func TestLocalDomain(t *testing.T) {
|
|
|
// Equivalent of dotless:localhost
|
|
// Equivalent of dotless:localhost
|
|
|
{Type: DomainMatchingType_Regex, Domain: "^[^.]*localhost[^.]*$"},
|
|
{Type: DomainMatchingType_Regex, Domain: "^[^.]*localhost[^.]*$"},
|
|
|
},
|
|
},
|
|
|
- Geoip: []*router.GeoIP{
|
|
|
|
|
|
|
+ Geoip: []*routercommon.GeoIP{
|
|
|
{ // Will match localhost, localhost-a and localhost-b,
|
|
{ // Will match localhost, localhost-a and localhost-b,
|
|
|
CountryCode: "local",
|
|
CountryCode: "local",
|
|
|
- Cidr: []*router.CIDR{
|
|
|
|
|
|
|
+ Cidr: []*routercommon.CIDR{
|
|
|
{Ip: []byte{127, 0, 0, 2}, Prefix: 32},
|
|
{Ip: []byte{127, 0, 0, 2}, Prefix: 32},
|
|
|
{Ip: []byte{127, 0, 0, 3}, Prefix: 32},
|
|
{Ip: []byte{127, 0, 0, 3}, Prefix: 32},
|
|
|
{Ip: []byte{127, 0, 0, 4}, Prefix: 32},
|
|
{Ip: []byte{127, 0, 0, 4}, Prefix: 32},
|
|
@@ -649,7 +649,7 @@ func TestLocalDomain(t *testing.T) {
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
- StaticHosts: []*Config_HostMapping{
|
|
|
|
|
|
|
+ StaticHosts: []*HostMapping{
|
|
|
{
|
|
{
|
|
|
Type: DomainMatchingType_Full,
|
|
Type: DomainMatchingType_Full,
|
|
|
Domain: "hostnamestatic",
|
|
Domain: "hostnamestatic",
|
|
@@ -818,9 +818,9 @@ func TestMultiMatchPrioritizedDomain(t *testing.T) {
|
|
|
Domain: "google.com",
|
|
Domain: "google.com",
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
- Geoip: []*router.GeoIP{
|
|
|
|
|
|
|
+ Geoip: []*routercommon.GeoIP{
|
|
|
{ // Will only match 8.8.8.8 and 8.8.4.4
|
|
{ // Will only match 8.8.8.8 and 8.8.4.4
|
|
|
- Cidr: []*router.CIDR{
|
|
|
|
|
|
|
+ Cidr: []*routercommon.CIDR{
|
|
|
{Ip: []byte{8, 8, 8, 8}, Prefix: 32},
|
|
{Ip: []byte{8, 8, 8, 8}, Prefix: 32},
|
|
|
{Ip: []byte{8, 8, 4, 4}, Prefix: 32},
|
|
{Ip: []byte{8, 8, 4, 4}, Prefix: 32},
|
|
|
},
|
|
},
|
|
@@ -843,9 +843,9 @@ func TestMultiMatchPrioritizedDomain(t *testing.T) {
|
|
|
Domain: "google.com",
|
|
Domain: "google.com",
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
- Geoip: []*router.GeoIP{
|
|
|
|
|
|
|
+ Geoip: []*routercommon.GeoIP{
|
|
|
{ // Will match 8.8.8.8 and 8.8.8.7, etc
|
|
{ // Will match 8.8.8.8 and 8.8.8.7, etc
|
|
|
- Cidr: []*router.CIDR{
|
|
|
|
|
|
|
+ Cidr: []*routercommon.CIDR{
|
|
|
{Ip: []byte{8, 8, 8, 7}, Prefix: 24},
|
|
{Ip: []byte{8, 8, 8, 7}, Prefix: 24},
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
@@ -867,9 +867,9 @@ func TestMultiMatchPrioritizedDomain(t *testing.T) {
|
|
|
Domain: "api.google.com",
|
|
Domain: "api.google.com",
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
- Geoip: []*router.GeoIP{
|
|
|
|
|
|
|
+ Geoip: []*routercommon.GeoIP{
|
|
|
{ // Will only match 8.8.7.7 (api.google.com)
|
|
{ // Will only match 8.8.7.7 (api.google.com)
|
|
|
- Cidr: []*router.CIDR{
|
|
|
|
|
|
|
+ Cidr: []*routercommon.CIDR{
|
|
|
{Ip: []byte{8, 8, 7, 7}, Prefix: 32},
|
|
{Ip: []byte{8, 8, 7, 7}, Prefix: 32},
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
@@ -891,9 +891,9 @@ func TestMultiMatchPrioritizedDomain(t *testing.T) {
|
|
|
Domain: "v2.api.google.com",
|
|
Domain: "v2.api.google.com",
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
- Geoip: []*router.GeoIP{
|
|
|
|
|
|
|
+ Geoip: []*routercommon.GeoIP{
|
|
|
{ // Will only match 8.8.7.8 (v2.api.google.com)
|
|
{ // Will only match 8.8.7.8 (v2.api.google.com)
|
|
|
- Cidr: []*router.CIDR{
|
|
|
|
|
|
|
+ Cidr: []*routercommon.CIDR{
|
|
|
{Ip: []byte{8, 8, 7, 8}, Prefix: 32},
|
|
{Ip: []byte{8, 8, 7, 8}, Prefix: 32},
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|