2021-02-08 05:18:52 -05:00
|
|
|
package dns
|
|
|
|
|
|
|
|
import (
|
2022-01-02 10:16:23 -05:00
|
|
|
"github.com/v2fly/v2ray-core/v5/common/net"
|
|
|
|
"github.com/v2fly/v2ray-core/v5/features"
|
2021-02-08 05:18:52 -05:00
|
|
|
)
|
|
|
|
|
2022-12-14 21:38:28 -05:00
|
|
|
// FakeDNSEngine is a V2Ray feature for converting between domain and fake IPs.
|
|
|
|
//
|
|
|
|
// v2ray:api:beta
|
2021-02-08 05:18:52 -05:00
|
|
|
type FakeDNSEngine interface {
|
|
|
|
features.Feature
|
2022-12-14 21:38:28 -05:00
|
|
|
|
|
|
|
// GetFakeIPForDomain returns fake IP addresses for the given domain, and registers the domain with the returned IPs.
|
2021-02-08 05:18:52 -05:00
|
|
|
GetFakeIPForDomain(domain string) []net.Address
|
2022-12-14 21:38:28 -05:00
|
|
|
|
|
|
|
// GetDomainFromFakeDNS returns the bound domain name for the given fake IP.
|
2021-02-08 05:18:52 -05:00
|
|
|
GetDomainFromFakeDNS(ip net.Address) string
|
|
|
|
}
|
2021-04-09 19:01:14 -04:00
|
|
|
|
2022-12-14 21:38:28 -05:00
|
|
|
// FakeDNSEngineRev0 adds additional APIs for FakeDNSEngine.
|
|
|
|
//
|
|
|
|
// v2ray:api:beta
|
2021-04-09 19:01:14 -04:00
|
|
|
type FakeDNSEngineRev0 interface {
|
2021-04-13 10:23:30 -04:00
|
|
|
FakeDNSEngine
|
2022-12-14 21:38:28 -05:00
|
|
|
|
|
|
|
// IsIPInIPPool tests whether the given IP address resides in managed fake IP pools.
|
2021-04-09 19:01:14 -04:00
|
|
|
IsIPInIPPool(ip net.Address) bool
|
2022-12-14 21:38:28 -05:00
|
|
|
|
|
|
|
// GetFakeIPForDomain3 registers and returns fake IP addresses for the given domain in IPv4 and/or IPv6.
|
|
|
|
GetFakeIPForDomain3(domain string, IPv4 bool, IPv6 bool) []net.Address
|
|
|
|
}
|
|
|
|
|
|
|
|
// ClientWithFakeDNS is an optional feature for utilizing FakeDNS feature of DNS client.
|
|
|
|
//
|
|
|
|
// v2ray:api:beta
|
|
|
|
type ClientWithFakeDNS interface {
|
|
|
|
// AsFakeDNSClient converts the client to dns.Client that enables FakeDNS querying option.
|
|
|
|
AsFakeDNSClient() Client
|
|
|
|
|
|
|
|
// AsFakeDNSEngine converts the client to dns.FakeDNSEngine that could serve FakeDNSEngine feature.
|
|
|
|
AsFakeDNSEngine() FakeDNSEngine
|
|
|
|
}
|
|
|
|
|
|
|
|
// FakeDNSEngineType returns the type of FakeDNSEngine interface. Can be used for implementing common.HasType.
|
|
|
|
//
|
|
|
|
// v2ray:api:beta
|
|
|
|
func FakeDNSEngineType() interface{} {
|
|
|
|
return (*FakeDNSEngine)(nil)
|
2021-04-09 19:01:14 -04:00
|
|
|
}
|