0
mirror of https://github.com/XTLS/Xray-core.git synced 2025-06-20 06:58:38 +03:00

Merge branch 'dns' into dns-geo

This commit is contained in:
秋のかえで
2021-04-14 13:04:07 +08:00
7 changed files with 110 additions and 35 deletions

View File

@ -21,6 +21,20 @@ func TestStaticHosts(t *testing.T) {
{1, 1, 1, 1},
},
},
{
Type: domain.MatchingType_Full,
Domain: "proxy.example.com",
Ip: [][]byte{
{1, 2, 3, 4},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
},
ProxiedDomain: "another-proxy.example.com",
},
{
Type: domain.MatchingType_Full,
Domain: "proxy2.example.com",
ProxiedDomain: "proxy.example.com",
},
{
Type: domain.MatchingType_Subdomain,
Domain: "example.cn",
@ -33,6 +47,7 @@ func TestStaticHosts(t *testing.T) {
Domain: "baidu.com",
Ip: [][]byte{
{127, 0, 0, 1},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
},
},
}
@ -53,6 +68,32 @@ func TestStaticHosts(t *testing.T) {
}
}
{
domain := hosts.Lookup("proxy.example.com", &dns.IPOption{
IPv4Enable: true,
IPv6Enable: false,
})
if len(domain) != 1 {
t.Error("expect 1 domain, but got ", len(domain))
}
if diff := cmp.Diff(domain[0].Domain(), "another-proxy.example.com"); diff != "" {
t.Error(diff)
}
}
{
domain := hosts.Lookup("proxy2.example.com", &dns.IPOption{
IPv4Enable: true,
IPv6Enable: false,
})
if len(domain) != 1 {
t.Error("expect 1 domain, but got ", len(domain))
}
if diff := cmp.Diff(domain[0].Domain(), "another-proxy.example.com"); diff != "" {
t.Error(diff)
}
}
{
ips := hosts.Lookup("www.example.cn", &dns.IPOption{
IPv4Enable: true,