mirror of
https://github.com/XTLS/Xray-core.git
synced 2024-11-22 23:13:01 +00:00
Use 198.18.0.0/16 as default Fake IP Pool (#377)
This commit is contained in:
parent
e0526c27b3
commit
3fe85449a9
@ -41,7 +41,7 @@ func NewFakeDNSHolder() (*Holder, error) {
|
|||||||
if fkdns, err = NewFakeDNSHolderConfigOnly(nil); err != nil {
|
if fkdns, err = NewFakeDNSHolderConfigOnly(nil); err != nil {
|
||||||
return nil, newError("Unable to create Fake Dns Engine").Base(err).AtError()
|
return nil, newError("Unable to create Fake Dns Engine").Base(err).AtError()
|
||||||
}
|
}
|
||||||
err = fkdns.initialize("240.0.0.0/8", 65535)
|
err = fkdns.initialize(dns.FakeIPPool, 65535)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,11 @@ import (
|
|||||||
"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"
|
||||||
|
"github.com/xtls/xray-core/features/dns"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
ipPrefix = "198.18."
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestNewFakeDnsHolder(_ *testing.T) {
|
func TestNewFakeDnsHolder(_ *testing.T) {
|
||||||
@ -20,7 +25,7 @@ func TestFakeDnsHolderCreateMapping(t *testing.T) {
|
|||||||
common.Must(err)
|
common.Must(err)
|
||||||
|
|
||||||
addr := fkdns.GetFakeIPForDomain("fakednstest.example.com")
|
addr := fkdns.GetFakeIPForDomain("fakednstest.example.com")
|
||||||
assert.Equal(t, "240.", addr[0].IP().String()[0:4])
|
assert.Equal(t, ipPrefix, addr[0].IP().String()[0:len(ipPrefix)])
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestFakeDnsHolderCreateMappingMany(t *testing.T) {
|
func TestFakeDnsHolderCreateMappingMany(t *testing.T) {
|
||||||
@ -28,10 +33,10 @@ func TestFakeDnsHolderCreateMappingMany(t *testing.T) {
|
|||||||
common.Must(err)
|
common.Must(err)
|
||||||
|
|
||||||
addr := fkdns.GetFakeIPForDomain("fakednstest.example.com")
|
addr := fkdns.GetFakeIPForDomain("fakednstest.example.com")
|
||||||
assert.Equal(t, "240.", addr[0].IP().String()[0:4])
|
assert.Equal(t, ipPrefix, addr[0].IP().String()[0:len(ipPrefix)])
|
||||||
|
|
||||||
addr2 := fkdns.GetFakeIPForDomain("fakednstest2.example.com")
|
addr2 := fkdns.GetFakeIPForDomain("fakednstest2.example.com")
|
||||||
assert.Equal(t, "240.", addr2[0].IP().String()[0:4])
|
assert.Equal(t, ipPrefix, addr2[0].IP().String()[0:len(ipPrefix)])
|
||||||
assert.NotEqual(t, addr[0].IP().String(), addr2[0].IP().String())
|
assert.NotEqual(t, addr[0].IP().String(), addr2[0].IP().String())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,7 +69,7 @@ func TestFakeDnsHolderCreateMappingManySingleDomain(t *testing.T) {
|
|||||||
|
|
||||||
func TestFakeDnsHolderCreateMappingAndRollOver(t *testing.T) {
|
func TestFakeDnsHolderCreateMappingAndRollOver(t *testing.T) {
|
||||||
fkdns, err := NewFakeDNSHolderConfigOnly(&FakeDnsPool{
|
fkdns, err := NewFakeDNSHolderConfigOnly(&FakeDnsPool{
|
||||||
IpPool: "240.0.0.0/12",
|
IpPool: dns.FakeIPPool,
|
||||||
LruSize: 256,
|
LruSize: 256,
|
||||||
})
|
})
|
||||||
common.Must(err)
|
common.Must(err)
|
||||||
|
@ -13,3 +13,5 @@ type FakeDNSEngine interface {
|
|||||||
GetDomainFromFakeDNS(ip net.Address) string
|
GetDomainFromFakeDNS(ip net.Address) string
|
||||||
GetFakeIPRange() *gonet.IPNet
|
GetFakeIPRange() *gonet.IPNet
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var FakeIPPool = "198.18.0.0/16"
|
||||||
|
@ -3,6 +3,7 @@ package conf
|
|||||||
import (
|
import (
|
||||||
"github.com/golang/protobuf/proto"
|
"github.com/golang/protobuf/proto"
|
||||||
"github.com/xtls/xray-core/app/dns/fakedns"
|
"github.com/xtls/xray-core/app/dns/fakedns"
|
||||||
|
"github.com/xtls/xray-core/features/dns"
|
||||||
)
|
)
|
||||||
|
|
||||||
type FakeDNSConfig struct {
|
type FakeDNSConfig struct {
|
||||||
@ -36,7 +37,7 @@ func (FakeDNSPostProcessingStage) Process(conf *Config) error {
|
|||||||
if conf.FakeDNS == nil {
|
if conf.FakeDNS == nil {
|
||||||
// Add a Fake DNS Config if there is none
|
// Add a Fake DNS Config if there is none
|
||||||
conf.FakeDNS = &FakeDNSConfig{
|
conf.FakeDNS = &FakeDNSConfig{
|
||||||
IPPool: "240.0.0.0/8",
|
IPPool: dns.FakeIPPool,
|
||||||
LruSize: 65535,
|
LruSize: 65535,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user