mirror of
https://github.com/XTLS/Xray-core.git
synced 2024-11-22 12:49:20 +02:00
Update fakedns_test.go
This commit is contained in:
parent
924fe16077
commit
439c91d509
|
@ -4,6 +4,7 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
|
||||||
"github.com/xtls/xray-core/common"
|
"github.com/xtls/xray-core/common"
|
||||||
"github.com/xtls/xray-core/common/net"
|
"github.com/xtls/xray-core/common/net"
|
||||||
"github.com/xtls/xray-core/common/uuid"
|
"github.com/xtls/xray-core/common/uuid"
|
||||||
|
@ -18,7 +19,7 @@ func TestFakeDnsHolderCreateMapping(t *testing.T) {
|
||||||
fkdns, err := NewFakeDNSHolder()
|
fkdns, err := NewFakeDNSHolder()
|
||||||
common.Must(err)
|
common.Must(err)
|
||||||
|
|
||||||
addr := fkdns.GetFakeIPForDomain("fakednstest.v2fly.org")
|
addr := fkdns.GetFakeIPForDomain("fakednstest.example.com")
|
||||||
assert.Equal(t, "240.", addr[0].IP().String()[0:4])
|
assert.Equal(t, "240.", addr[0].IP().String()[0:4])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,10 +27,10 @@ func TestFakeDnsHolderCreateMappingMany(t *testing.T) {
|
||||||
fkdns, err := NewFakeDNSHolder()
|
fkdns, err := NewFakeDNSHolder()
|
||||||
common.Must(err)
|
common.Must(err)
|
||||||
|
|
||||||
addr := fkdns.GetFakeIPForDomain("fakednstest.v2fly.org")
|
addr := fkdns.GetFakeIPForDomain("fakednstest.example.com")
|
||||||
assert.Equal(t, "240.", addr[0].IP().String()[0:4])
|
assert.Equal(t, "240.", addr[0].IP().String()[0:4])
|
||||||
|
|
||||||
addr2 := fkdns.GetFakeIPForDomain("fakednstest2.v2fly.org")
|
addr2 := fkdns.GetFakeIPForDomain("fakednstest2.example.com")
|
||||||
assert.Equal(t, "240.", addr2[0].IP().String()[0:4])
|
assert.Equal(t, "240.", addr2[0].IP().String()[0:4])
|
||||||
assert.NotEqual(t, addr[0].IP().String(), addr2[0].IP().String())
|
assert.NotEqual(t, addr[0].IP().String(), addr2[0].IP().String())
|
||||||
}
|
}
|
||||||
|
@ -38,17 +39,17 @@ func TestFakeDnsHolderCreateMappingManyAndResolve(t *testing.T) {
|
||||||
fkdns, err := NewFakeDNSHolder()
|
fkdns, err := NewFakeDNSHolder()
|
||||||
common.Must(err)
|
common.Must(err)
|
||||||
|
|
||||||
addr := fkdns.GetFakeIPForDomain("fakednstest.v2fly.org")
|
addr := fkdns.GetFakeIPForDomain("fakednstest.example.com")
|
||||||
addr2 := fkdns.GetFakeIPForDomain("fakednstest2.v2fly.org")
|
addr2 := fkdns.GetFakeIPForDomain("fakednstest2.example.com")
|
||||||
|
|
||||||
{
|
{
|
||||||
result := fkdns.GetDomainFromFakeDNS(addr[0])
|
result := fkdns.GetDomainFromFakeDNS(addr[0])
|
||||||
assert.Equal(t, "fakednstest.v2fly.org", result)
|
assert.Equal(t, "fakednstest.example.com", result)
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
result := fkdns.GetDomainFromFakeDNS(addr2[0])
|
result := fkdns.GetDomainFromFakeDNS(addr2[0])
|
||||||
assert.Equal(t, "fakednstest2.v2fly.org", result)
|
assert.Equal(t, "fakednstest2.example.com", result)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,8 +57,8 @@ func TestFakeDnsHolderCreateMappingManySingleDomain(t *testing.T) {
|
||||||
fkdns, err := NewFakeDNSHolder()
|
fkdns, err := NewFakeDNSHolder()
|
||||||
common.Must(err)
|
common.Must(err)
|
||||||
|
|
||||||
addr := fkdns.GetFakeIPForDomain("fakednstest.v2fly.org")
|
addr := fkdns.GetFakeIPForDomain("fakednstest.example.com")
|
||||||
addr2 := fkdns.GetFakeIPForDomain("fakednstest.v2fly.org")
|
addr2 := fkdns.GetFakeIPForDomain("fakednstest.example.com")
|
||||||
assert.Equal(t, addr[0].IP().String(), addr2[0].IP().String())
|
assert.Equal(t, addr[0].IP().String(), addr2[0].IP().String())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,23 +73,23 @@ func TestFakeDnsHolderCreateMappingAndRollOver(t *testing.T) {
|
||||||
|
|
||||||
common.Must(err)
|
common.Must(err)
|
||||||
|
|
||||||
addr := fkdns.GetFakeIPForDomain("fakednstest.v2fly.org")
|
addr := fkdns.GetFakeIPForDomain("fakednstest.example.com")
|
||||||
addr2 := fkdns.GetFakeIPForDomain("fakednstest2.v2fly.org")
|
addr2 := fkdns.GetFakeIPForDomain("fakednstest2.example.com")
|
||||||
|
|
||||||
for i := 0; i <= 8192; i++ {
|
for i := 0; i <= 8192; i++ {
|
||||||
{
|
{
|
||||||
result := fkdns.GetDomainFromFakeDNS(addr[0])
|
result := fkdns.GetDomainFromFakeDNS(addr[0])
|
||||||
assert.Equal(t, "fakednstest.v2fly.org", result)
|
assert.Equal(t, "fakednstest.example.com", result)
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
result := fkdns.GetDomainFromFakeDNS(addr2[0])
|
result := fkdns.GetDomainFromFakeDNS(addr2[0])
|
||||||
assert.Equal(t, "fakednstest2.v2fly.org", result)
|
assert.Equal(t, "fakednstest2.example.com", result)
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
uuid := uuid.New()
|
uuid := uuid.New()
|
||||||
domain := uuid.String() + ".fakednstest.v2fly.org"
|
domain := uuid.String() + ".fakednstest.example.com"
|
||||||
tempAddr := fkdns.GetFakeIPForDomain(domain)
|
tempAddr := fkdns.GetFakeIPForDomain(domain)
|
||||||
rsaddr := tempAddr[0].IP().String()
|
rsaddr := tempAddr[0].IP().String()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue