|
@@ -7,6 +7,7 @@ import (
|
|
|
|
|
|
|
|
. "v2ray.com/core/app/dns"
|
|
. "v2ray.com/core/app/dns"
|
|
|
"v2ray.com/core/common"
|
|
"v2ray.com/core/common"
|
|
|
|
|
+ "v2ray.com/core/common/net"
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
func TestStaticHosts(t *testing.T) {
|
|
func TestStaticHosts(t *testing.T) {
|
|
@@ -25,6 +26,13 @@ func TestStaticHosts(t *testing.T) {
|
|
|
{2, 2, 2, 2},
|
|
{2, 2, 2, 2},
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
|
|
+ {
|
|
|
|
|
+ Type: DomainMatchingType_Subdomain,
|
|
|
|
|
+ Domain: "baidu.com",
|
|
|
|
|
+ Ip: [][]byte{
|
|
|
|
|
+ {127, 0, 0, 1},
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
hosts, err := NewStaticHosts(pb, nil)
|
|
hosts, err := NewStaticHosts(pb, nil)
|
|
@@ -55,4 +63,17 @@ func TestStaticHosts(t *testing.T) {
|
|
|
t.Error(diff)
|
|
t.Error(diff)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ {
|
|
|
|
|
+ ips := hosts.LookupIP("baidu.com", IPOption{
|
|
|
|
|
+ IPv4Enable: false,
|
|
|
|
|
+ IPv6Enable: true,
|
|
|
|
|
+ })
|
|
|
|
|
+ if len(ips) != 1 {
|
|
|
|
|
+ t.Error("expect 1 IP, but got ", len(ips))
|
|
|
|
|
+ }
|
|
|
|
|
+ if diff := cmp.Diff([]byte(ips[0].IP()), []byte(net.LocalHostIPv6.IP())); diff != "" {
|
|
|
|
|
+ t.Error(diff)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|