This commit is contained in:
Arthur Morgan 2021-10-20 00:52:49 +08:00
parent a229a7f85e
commit 500c6de359
2 changed files with 10 additions and 10 deletions

View file

@ -21,17 +21,17 @@ func TestStaticHosts(t *testing.T) {
},
{
Type: DomainMatchingType_Full,
Domain: "proxy.v2fly.org",
Domain: "proxy.xray.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.v2fly.org",
ProxiedDomain: "another-proxy.xray.com",
},
{
Type: DomainMatchingType_Full,
Domain: "proxy2.v2fly.org",
ProxiedDomain: "proxy.v2fly.org",
Domain: "proxy2.xray.com",
ProxiedDomain: "proxy.xray.com",
},
{
Type: DomainMatchingType_Subdomain,
@ -67,27 +67,27 @@ func TestStaticHosts(t *testing.T) {
}
{
domain := hosts.Lookup("proxy.v2fly.org", dns.IPOption{
domain := hosts.Lookup("proxy.xray.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.v2fly.org"); diff != "" {
if diff := cmp.Diff(domain[0].Domain(), "another-proxy.xray.com"); diff != "" {
t.Error(diff)
}
}
{
domain := hosts.Lookup("proxy2.v2fly.org", dns.IPOption{
domain := hosts.Lookup("proxy2.xray.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.v2fly.org"); diff != "" {
if diff := cmp.Diff(domain[0].Domain(), "another-proxy.xray.com"); diff != "" {
t.Error(diff)
}
}

View file

@ -11,13 +11,13 @@ import (
func BenchmarkACAutomaton(b *testing.B) {
ac := NewACAutomaton()
for i := 1; i <= 1024; i++ {
ac.Add(strconv.Itoa(i)+".v2ray.com", Domain)
ac.Add(strconv.Itoa(i)+".xray.com", Domain)
}
ac.Build()
b.ResetTimer()
for i := 0; i < b.N; i++ {
_ = ac.Match("0.v2ray.com")
_ = ac.Match("0.xray.com")
}
}