|
@@ -154,7 +154,11 @@ func TestUDPServerSubnet(t *testing.T) {
|
|
|
|
|
|
|
|
client := v.GetFeature(feature_dns.ClientType()).(feature_dns.Client)
|
|
client := v.GetFeature(feature_dns.ClientType()).(feature_dns.Client)
|
|
|
|
|
|
|
|
- ips, err := client.LookupIP("google.com")
|
|
|
|
|
|
|
+ ips, err := client.LookupIP("google.com", feature_dns.IPOption{
|
|
|
|
|
+ IPv4Enable: true,
|
|
|
|
|
+ IPv6Enable: true,
|
|
|
|
|
+ FakeEnable: false,
|
|
|
|
|
+ })
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
t.Fatal("unexpected error: ", err)
|
|
t.Fatal("unexpected error: ", err)
|
|
|
}
|
|
}
|
|
@@ -209,7 +213,11 @@ func TestUDPServer(t *testing.T) {
|
|
|
client := v.GetFeature(feature_dns.ClientType()).(feature_dns.Client)
|
|
client := v.GetFeature(feature_dns.ClientType()).(feature_dns.Client)
|
|
|
|
|
|
|
|
{
|
|
{
|
|
|
- ips, err := client.LookupIP("google.com")
|
|
|
|
|
|
|
+ ips, err := client.LookupIP("google.com", feature_dns.IPOption{
|
|
|
|
|
+ IPv4Enable: true,
|
|
|
|
|
+ IPv6Enable: true,
|
|
|
|
|
+ FakeEnable: false,
|
|
|
|
|
+ })
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
t.Fatal("unexpected error: ", err)
|
|
t.Fatal("unexpected error: ", err)
|
|
|
}
|
|
}
|
|
@@ -220,7 +228,11 @@ func TestUDPServer(t *testing.T) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
{
|
|
{
|
|
|
- ips, err := client.LookupIP("facebook.com")
|
|
|
|
|
|
|
+ ips, err := client.LookupIP("facebook.com", feature_dns.IPOption{
|
|
|
|
|
+ IPv4Enable: true,
|
|
|
|
|
+ IPv6Enable: true,
|
|
|
|
|
+ FakeEnable: false,
|
|
|
|
|
+ })
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
t.Fatal("unexpected error: ", err)
|
|
t.Fatal("unexpected error: ", err)
|
|
|
}
|
|
}
|
|
@@ -231,7 +243,11 @@ func TestUDPServer(t *testing.T) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
{
|
|
{
|
|
|
- _, err := client.LookupIP("notexist.google.com")
|
|
|
|
|
|
|
+ _, err := client.LookupIP("notexist.google.com", feature_dns.IPOption{
|
|
|
|
|
+ IPv4Enable: true,
|
|
|
|
|
+ IPv6Enable: true,
|
|
|
|
|
+ FakeEnable: false,
|
|
|
|
|
+ })
|
|
|
if err == nil {
|
|
if err == nil {
|
|
|
t.Fatal("nil error")
|
|
t.Fatal("nil error")
|
|
|
}
|
|
}
|
|
@@ -241,8 +257,11 @@ func TestUDPServer(t *testing.T) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
{
|
|
{
|
|
|
- clientv6 := client.(feature_dns.IPv6Lookup)
|
|
|
|
|
- ips, err := clientv6.LookupIPv6("ipv4only.google.com")
|
|
|
|
|
|
|
+ ips, err := client.LookupIP("ipv4only.google.com", feature_dns.IPOption{
|
|
|
|
|
+ IPv4Enable: false,
|
|
|
|
|
+ IPv6Enable: true,
|
|
|
|
|
+ FakeEnable: false,
|
|
|
|
|
+ })
|
|
|
if err != feature_dns.ErrEmptyResponse {
|
|
if err != feature_dns.ErrEmptyResponse {
|
|
|
t.Fatal("error: ", err)
|
|
t.Fatal("error: ", err)
|
|
|
}
|
|
}
|
|
@@ -254,7 +273,11 @@ func TestUDPServer(t *testing.T) {
|
|
|
dnsServer.Shutdown()
|
|
dnsServer.Shutdown()
|
|
|
|
|
|
|
|
{
|
|
{
|
|
|
- ips, err := client.LookupIP("google.com")
|
|
|
|
|
|
|
+ ips, err := client.LookupIP("google.com", feature_dns.IPOption{
|
|
|
|
|
+ IPv4Enable: true,
|
|
|
|
|
+ IPv6Enable: true,
|
|
|
|
|
+ FakeEnable: false,
|
|
|
|
|
+ })
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
t.Fatal("unexpected error: ", err)
|
|
t.Fatal("unexpected error: ", err)
|
|
|
}
|
|
}
|
|
@@ -331,7 +354,11 @@ func TestPrioritizedDomain(t *testing.T) {
|
|
|
startTime := time.Now()
|
|
startTime := time.Now()
|
|
|
|
|
|
|
|
{
|
|
{
|
|
|
- ips, err := client.LookupIP("google.com")
|
|
|
|
|
|
|
+ ips, err := client.LookupIP("google.com", feature_dns.IPOption{
|
|
|
|
|
+ IPv4Enable: true,
|
|
|
|
|
+ IPv6Enable: true,
|
|
|
|
|
+ FakeEnable: false,
|
|
|
|
|
+ })
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
t.Fatal("unexpected error: ", err)
|
|
t.Fatal("unexpected error: ", err)
|
|
|
}
|
|
}
|
|
@@ -390,10 +417,12 @@ func TestUDPServerIPv6(t *testing.T) {
|
|
|
common.Must(err)
|
|
common.Must(err)
|
|
|
|
|
|
|
|
client := v.GetFeature(feature_dns.ClientType()).(feature_dns.Client)
|
|
client := v.GetFeature(feature_dns.ClientType()).(feature_dns.Client)
|
|
|
- client6 := client.(feature_dns.IPv6Lookup)
|
|
|
|
|
-
|
|
|
|
|
{
|
|
{
|
|
|
- ips, err := client6.LookupIPv6("ipv6.google.com")
|
|
|
|
|
|
|
+ ips, err := client.LookupIP("ipv6.google.com", feature_dns.IPOption{
|
|
|
|
|
+ IPv4Enable: false,
|
|
|
|
|
+ IPv6Enable: true,
|
|
|
|
|
+ FakeEnable: false,
|
|
|
|
|
+ })
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
t.Fatal("unexpected error: ", err)
|
|
t.Fatal("unexpected error: ", err)
|
|
|
}
|
|
}
|
|
@@ -456,7 +485,11 @@ func TestStaticHostDomain(t *testing.T) {
|
|
|
client := v.GetFeature(feature_dns.ClientType()).(feature_dns.Client)
|
|
client := v.GetFeature(feature_dns.ClientType()).(feature_dns.Client)
|
|
|
|
|
|
|
|
{
|
|
{
|
|
|
- ips, err := client.LookupIP("example.com")
|
|
|
|
|
|
|
+ ips, err := client.LookupIP("example.com", feature_dns.IPOption{
|
|
|
|
|
+ IPv4Enable: true,
|
|
|
|
|
+ IPv6Enable: true,
|
|
|
|
|
+ FakeEnable: false,
|
|
|
|
|
+ })
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
t.Fatal("unexpected error: ", err)
|
|
t.Fatal("unexpected error: ", err)
|
|
|
}
|
|
}
|
|
@@ -563,7 +596,11 @@ func TestIPMatch(t *testing.T) {
|
|
|
startTime := time.Now()
|
|
startTime := time.Now()
|
|
|
|
|
|
|
|
{
|
|
{
|
|
|
- ips, err := client.LookupIP("google.com")
|
|
|
|
|
|
|
+ ips, err := client.LookupIP("google.com", feature_dns.IPOption{
|
|
|
|
|
+ IPv4Enable: true,
|
|
|
|
|
+ IPv6Enable: true,
|
|
|
|
|
+ FakeEnable: false,
|
|
|
|
|
+ })
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
t.Fatal("unexpected error: ", err)
|
|
t.Fatal("unexpected error: ", err)
|
|
|
}
|
|
}
|
|
@@ -682,7 +719,11 @@ func TestLocalDomain(t *testing.T) {
|
|
|
startTime := time.Now()
|
|
startTime := time.Now()
|
|
|
|
|
|
|
|
{ // Will match dotless:
|
|
{ // Will match dotless:
|
|
|
- ips, err := client.LookupIP("hostname")
|
|
|
|
|
|
|
+ ips, err := client.LookupIP("hostname", feature_dns.IPOption{
|
|
|
|
|
+ IPv4Enable: true,
|
|
|
|
|
+ IPv6Enable: true,
|
|
|
|
|
+ FakeEnable: false,
|
|
|
|
|
+ })
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
t.Fatal("unexpected error: ", err)
|
|
t.Fatal("unexpected error: ", err)
|
|
|
}
|
|
}
|
|
@@ -693,7 +734,11 @@ func TestLocalDomain(t *testing.T) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
{ // Will match domain:local
|
|
{ // Will match domain:local
|
|
|
- ips, err := client.LookupIP("hostname.local")
|
|
|
|
|
|
|
+ ips, err := client.LookupIP("hostname.local", feature_dns.IPOption{
|
|
|
|
|
+ IPv4Enable: true,
|
|
|
|
|
+ IPv6Enable: true,
|
|
|
|
|
+ FakeEnable: false,
|
|
|
|
|
+ })
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
t.Fatal("unexpected error: ", err)
|
|
t.Fatal("unexpected error: ", err)
|
|
|
}
|
|
}
|
|
@@ -704,7 +749,11 @@ func TestLocalDomain(t *testing.T) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
{ // Will match static ip
|
|
{ // Will match static ip
|
|
|
- ips, err := client.LookupIP("hostnamestatic")
|
|
|
|
|
|
|
+ ips, err := client.LookupIP("hostnamestatic", feature_dns.IPOption{
|
|
|
|
|
+ IPv4Enable: true,
|
|
|
|
|
+ IPv6Enable: true,
|
|
|
|
|
+ FakeEnable: false,
|
|
|
|
|
+ })
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
t.Fatal("unexpected error: ", err)
|
|
t.Fatal("unexpected error: ", err)
|
|
|
}
|
|
}
|
|
@@ -715,7 +764,11 @@ func TestLocalDomain(t *testing.T) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
{ // Will match domain replacing
|
|
{ // Will match domain replacing
|
|
|
- ips, err := client.LookupIP("hostnamealias")
|
|
|
|
|
|
|
+ ips, err := client.LookupIP("hostnamealias", feature_dns.IPOption{
|
|
|
|
|
+ IPv4Enable: true,
|
|
|
|
|
+ IPv6Enable: true,
|
|
|
|
|
+ FakeEnable: false,
|
|
|
|
|
+ })
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
t.Fatal("unexpected error: ", err)
|
|
t.Fatal("unexpected error: ", err)
|
|
|
}
|
|
}
|
|
@@ -726,7 +779,11 @@ func TestLocalDomain(t *testing.T) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
{ // Will match dotless:localhost, but not expectIPs: 127.0.0.2, 127.0.0.3, then matches at dotless:
|
|
{ // Will match dotless:localhost, but not expectIPs: 127.0.0.2, 127.0.0.3, then matches at dotless:
|
|
|
- ips, err := client.LookupIP("localhost")
|
|
|
|
|
|
|
+ ips, err := client.LookupIP("localhost", feature_dns.IPOption{
|
|
|
|
|
+ IPv4Enable: true,
|
|
|
|
|
+ IPv6Enable: true,
|
|
|
|
|
+ FakeEnable: false,
|
|
|
|
|
+ })
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
t.Fatal("unexpected error: ", err)
|
|
t.Fatal("unexpected error: ", err)
|
|
|
}
|
|
}
|
|
@@ -737,7 +794,11 @@ func TestLocalDomain(t *testing.T) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
{ // Will match dotless:localhost, and expectIPs: 127.0.0.2, 127.0.0.3
|
|
{ // Will match dotless:localhost, and expectIPs: 127.0.0.2, 127.0.0.3
|
|
|
- ips, err := client.LookupIP("localhost-a")
|
|
|
|
|
|
|
+ ips, err := client.LookupIP("localhost-a", feature_dns.IPOption{
|
|
|
|
|
+ IPv4Enable: true,
|
|
|
|
|
+ IPv6Enable: true,
|
|
|
|
|
+ FakeEnable: false,
|
|
|
|
|
+ })
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
t.Fatal("unexpected error: ", err)
|
|
t.Fatal("unexpected error: ", err)
|
|
|
}
|
|
}
|
|
@@ -748,7 +809,11 @@ func TestLocalDomain(t *testing.T) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
{ // Will match dotless:localhost, and expectIPs: 127.0.0.2, 127.0.0.3
|
|
{ // Will match dotless:localhost, and expectIPs: 127.0.0.2, 127.0.0.3
|
|
|
- ips, err := client.LookupIP("localhost-b")
|
|
|
|
|
|
|
+ ips, err := client.LookupIP("localhost-b", feature_dns.IPOption{
|
|
|
|
|
+ IPv4Enable: true,
|
|
|
|
|
+ IPv6Enable: true,
|
|
|
|
|
+ FakeEnable: false,
|
|
|
|
|
+ })
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
t.Fatal("unexpected error: ", err)
|
|
t.Fatal("unexpected error: ", err)
|
|
|
}
|
|
}
|
|
@@ -759,7 +824,11 @@ func TestLocalDomain(t *testing.T) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
{ // Will match dotless:
|
|
{ // Will match dotless:
|
|
|
- ips, err := client.LookupIP("Mijia Cloud")
|
|
|
|
|
|
|
+ ips, err := client.LookupIP("Mijia Cloud", feature_dns.IPOption{
|
|
|
|
|
+ IPv4Enable: true,
|
|
|
|
|
+ IPv6Enable: true,
|
|
|
|
|
+ FakeEnable: false,
|
|
|
|
|
+ })
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
t.Fatal("unexpected error: ", err)
|
|
t.Fatal("unexpected error: ", err)
|
|
|
}
|
|
}
|
|
@@ -921,7 +990,11 @@ func TestMultiMatchPrioritizedDomain(t *testing.T) {
|
|
|
startTime := time.Now()
|
|
startTime := time.Now()
|
|
|
|
|
|
|
|
{ // Will match server 1,2 and server 1 returns expected ip
|
|
{ // Will match server 1,2 and server 1 returns expected ip
|
|
|
- ips, err := client.LookupIP("google.com")
|
|
|
|
|
|
|
+ ips, err := client.LookupIP("google.com", feature_dns.IPOption{
|
|
|
|
|
+ IPv4Enable: true,
|
|
|
|
|
+ IPv6Enable: true,
|
|
|
|
|
+ FakeEnable: false,
|
|
|
|
|
+ })
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
t.Fatal("unexpected error: ", err)
|
|
t.Fatal("unexpected error: ", err)
|
|
|
}
|
|
}
|
|
@@ -932,8 +1005,11 @@ func TestMultiMatchPrioritizedDomain(t *testing.T) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
{ // Will match server 1,2 and server 1 returns unexpected ip, then server 2 returns expected one
|
|
{ // Will match server 1,2 and server 1 returns unexpected ip, then server 2 returns expected one
|
|
|
- clientv4 := client.(feature_dns.IPv4Lookup)
|
|
|
|
|
- ips, err := clientv4.LookupIPv4("ipv6.google.com")
|
|
|
|
|
|
|
+ ips, err := client.LookupIP("ipv6.google.com", feature_dns.IPOption{
|
|
|
|
|
+ IPv4Enable: true,
|
|
|
|
|
+ IPv6Enable: false,
|
|
|
|
|
+ FakeEnable: false,
|
|
|
|
|
+ })
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
t.Fatal("unexpected error: ", err)
|
|
t.Fatal("unexpected error: ", err)
|
|
|
}
|
|
}
|
|
@@ -944,7 +1020,11 @@ func TestMultiMatchPrioritizedDomain(t *testing.T) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
{ // Will match server 3,1,2 and server 3 returns expected one
|
|
{ // Will match server 3,1,2 and server 3 returns expected one
|
|
|
- ips, err := client.LookupIP("api.google.com")
|
|
|
|
|
|
|
+ ips, err := client.LookupIP("api.google.com", feature_dns.IPOption{
|
|
|
|
|
+ IPv4Enable: true,
|
|
|
|
|
+ IPv6Enable: true,
|
|
|
|
|
+ FakeEnable: false,
|
|
|
|
|
+ })
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
t.Fatal("unexpected error: ", err)
|
|
t.Fatal("unexpected error: ", err)
|
|
|
}
|
|
}
|
|
@@ -955,7 +1035,11 @@ func TestMultiMatchPrioritizedDomain(t *testing.T) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
{ // Will match server 4,3,1,2 and server 4 returns expected one
|
|
{ // Will match server 4,3,1,2 and server 4 returns expected one
|
|
|
- ips, err := client.LookupIP("v2.api.google.com")
|
|
|
|
|
|
|
+ ips, err := client.LookupIP("v2.api.google.com", feature_dns.IPOption{
|
|
|
|
|
+ IPv4Enable: true,
|
|
|
|
|
+ IPv6Enable: true,
|
|
|
|
|
+ FakeEnable: false,
|
|
|
|
|
+ })
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
t.Fatal("unexpected error: ", err)
|
|
t.Fatal("unexpected error: ", err)
|
|
|
}
|
|
}
|