import "github.com/v2ray/v2ray-core/app/dns"
Package dns is an implementation of core.DNS feature.
config.pb.go dns.go dnscommon.go dohdns.go errors.generated.go hosts.go nameserver.go server.go udpns.go
var ( DomainMatchingType_name = map[int32]string{ 0: "Full", 1: "Subdomain", 2: "Keyword", 3: "Regex", } DomainMatchingType_value = map[string]int32{ "Full": 0, "Subdomain": 1, "Keyword": 2, "Regex": 3, } )
Enum value maps for DomainMatchingType.
var File_app_dns_config_proto protoreflect.FileDescriptor
Fqdn normalize domain make sure it ends with '.'
func NewLocalNameServer() *localNameServer
func NewClassicNameServer(address net.Destination, dispatcher routing.Dispatcher, clientIP net.IP) *ClassicNameServer
func (s *ClassicNameServer) Cleanup() error
func (s *ClassicNameServer) Name() string
func (s *ClassicNameServer) QueryIP(ctx context.Context, domain string, option IPOption) ([]net.IP, error)
type Client interface { // Name of the Client. Name() string // QueryIP sends IP queries to its configured server. QueryIP(ctx context.Context, domain string, option IPOption) ([]net.IP, error) }
Client is the interface for DNS client.
type Config struct { // Nameservers used by this DNS. Only traditional UDP servers are support at // the moment. A special value 'localhost' as a domain address can be set to // use DNS on local system. // // Deprecated: Do not use. NameServers []*net.Endpoint `protobuf:"bytes,1,rep,name=NameServers,proto3" json:"NameServers,omitempty"` // NameServer list used by this DNS client. NameServer []*NameServer `protobuf:"bytes,5,rep,name=name_server,json=nameServer,proto3" json:"name_server,omitempty"` // Static hosts. Domain to IP. // Deprecated. Use static_hosts. // // Deprecated: Do not use. Hosts map[string]*net.IPOrDomain `protobuf:"bytes,2,rep,name=Hosts,proto3" json:"Hosts,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` // Client IP for EDNS client subnet. Must be 4 bytes (IPv4) or 16 bytes // (IPv6). ClientIp []byte `protobuf:"bytes,3,opt,name=client_ip,json=clientIp,proto3" json:"client_ip,omitempty"` StaticHosts []*Config_HostMapping `protobuf:"bytes,4,rep,name=static_hosts,json=staticHosts,proto3" json:"static_hosts,omitempty"` // Tag is the inbound tag of DNS client. Tag string `protobuf:"bytes,6,opt,name=tag,proto3" json:"tag,omitempty"` // contains filtered or unexported fields }
Deprecated: Use Config.ProtoReflect.Descriptor instead.
func (x *Config) GetHosts() map[string]*net.IPOrDomain
Deprecated: Do not use.
func (x *Config) GetNameServer() []*NameServer
Deprecated: Do not use.
func (x *Config) GetStaticHosts() []*Config_HostMapping
func (x *Config) ProtoReflect() protoreflect.Message
type Config_HostMapping struct { Type DomainMatchingType `protobuf:"varint,1,opt,name=type,proto3,enum=v2ray.core.app.dns.DomainMatchingType" json:"type,omitempty"` Domain string `protobuf:"bytes,2,opt,name=domain,proto3" json:"domain,omitempty"` Ip [][]byte `protobuf:"bytes,3,rep,name=ip,proto3" json:"ip,omitempty"` // ProxiedDomain indicates the mapped domain has the same IP address on this // domain. V2Ray will use this domain for IP queries. This field is only // effective if ip is empty. ProxiedDomain string `protobuf:"bytes,4,opt,name=proxied_domain,json=proxiedDomain,proto3" json:"proxied_domain,omitempty"` // contains filtered or unexported fields }
func (*Config_HostMapping) Descriptor() ([]byte, []int)
Deprecated: Use Config_HostMapping.ProtoReflect.Descriptor instead.
func (x *Config_HostMapping) GetDomain() string
func (x *Config_HostMapping) GetIp() [][]byte
func (x *Config_HostMapping) GetProxiedDomain() string
func (x *Config_HostMapping) GetType() DomainMatchingType
func (*Config_HostMapping) ProtoMessage()
func (x *Config_HostMapping) ProtoReflect() protoreflect.Message
func (x *Config_HostMapping) Reset()
func (x *Config_HostMapping) String() string
DoHNameServer implemented DNS over HTTPS (RFC8484) Wire Format, which is compatible with traditional dns over udp(RFC1035), thus most of the DOH implementation is copied from udpns.go
NewDoHLocalNameServer creates DOH client object for local resolving
func NewDoHNameServer(url *url.URL, dispatcher routing.Dispatcher, clientIP net.IP) (*DoHNameServer, error)
NewDoHNameServer creates DOH client object for remote resolving
func (s *DoHNameServer) Cleanup() error
Cleanup clears expired items from cache
func (s *DoHNameServer) Name() string
Name returns client name
func (s *DoHNameServer) QueryIP(ctx context.Context, domain string, option IPOption) ([]net.IP, error)
QueryIP is called from dns.Server->queryIPTimeout
type DomainMatcherInfo struct {
// contains filtered or unexported fields
}
DomainMatcherInfo contains information attached to index returned by Server.domainMatcher
const ( DomainMatchingType_Full DomainMatchingType = 0 DomainMatchingType_Subdomain DomainMatchingType = 1 DomainMatchingType_Keyword DomainMatchingType = 2 DomainMatchingType_Regex DomainMatchingType = 3 )
func (DomainMatchingType) Descriptor() protoreflect.EnumDescriptor
func (x DomainMatchingType) Enum() *DomainMatchingType
func (DomainMatchingType) EnumDescriptor() ([]byte, []int)
Deprecated: Use DomainMatchingType.Descriptor instead.
func (x DomainMatchingType) Number() protoreflect.EnumNumber
func (x DomainMatchingType) String() string
func (DomainMatchingType) Type() protoreflect.EnumType
IPOption is an object for IP query options.
IPRecord is a cacheable item for a resolved domain
type MultiGeoIPMatcher struct {
// contains filtered or unexported fields
}
MultiGeoIPMatcher for match
func (c *MultiGeoIPMatcher) HasMatcher() bool
HasMatcher check has matcher
func (c *MultiGeoIPMatcher) Match(ip net.IP) bool
Match check ip match
type NameServer struct { Address *net.Endpoint `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` PrioritizedDomain []*NameServer_PriorityDomain `protobuf:"bytes,2,rep,name=prioritized_domain,json=prioritizedDomain,proto3" json:"prioritized_domain,omitempty"` Geoip []*router.GeoIP `protobuf:"bytes,3,rep,name=geoip,proto3" json:"geoip,omitempty"` OriginalRules []*NameServer_OriginalRule `protobuf:"bytes,4,rep,name=original_rules,json=originalRules,proto3" json:"original_rules,omitempty"` // contains filtered or unexported fields }
func (*NameServer) Descriptor() ([]byte, []int)
Deprecated: Use NameServer.ProtoReflect.Descriptor instead.
func (x *NameServer) GetAddress() *net.Endpoint
func (x *NameServer) GetGeoip() []*router.GeoIP
func (x *NameServer) GetOriginalRules() []*NameServer_OriginalRule
func (x *NameServer) GetPrioritizedDomain() []*NameServer_PriorityDomain
func (*NameServer) ProtoMessage()
func (x *NameServer) ProtoReflect() protoreflect.Message
func (x *NameServer) Reset()
func (x *NameServer) String() string
type NameServer_OriginalRule struct { Rule string `protobuf:"bytes,1,opt,name=rule,proto3" json:"rule,omitempty"` Size uint32 `protobuf:"varint,2,opt,name=size,proto3" json:"size,omitempty"` // contains filtered or unexported fields }
func (*NameServer_OriginalRule) Descriptor() ([]byte, []int)
Deprecated: Use NameServer_OriginalRule.ProtoReflect.Descriptor instead.
func (x *NameServer_OriginalRule) GetRule() string
func (x *NameServer_OriginalRule) GetSize() uint32
func (*NameServer_OriginalRule) ProtoMessage()
func (x *NameServer_OriginalRule) ProtoReflect() protoreflect.Message
func (x *NameServer_OriginalRule) Reset()
func (x *NameServer_OriginalRule) String() string
type NameServer_PriorityDomain struct { Type DomainMatchingType `protobuf:"varint,1,opt,name=type,proto3,enum=v2ray.core.app.dns.DomainMatchingType" json:"type,omitempty"` Domain string `protobuf:"bytes,2,opt,name=domain,proto3" json:"domain,omitempty"` // contains filtered or unexported fields }
func (*NameServer_PriorityDomain) Descriptor() ([]byte, []int)
Deprecated: Use NameServer_PriorityDomain.ProtoReflect.Descriptor instead.
func (x *NameServer_PriorityDomain) GetDomain() string
func (x *NameServer_PriorityDomain) GetType() DomainMatchingType
func (*NameServer_PriorityDomain) ProtoMessage()
func (x *NameServer_PriorityDomain) ProtoReflect() protoreflect.Message
func (x *NameServer_PriorityDomain) Reset()
func (x *NameServer_PriorityDomain) String() string
Server is a DNS rely server.
New creates a new DNS server with given configuration.
Close implements common.Closable.
LookupIP implements dns.Client.
LookupIPv4 implements dns.IPv4Lookup.
LookupIPv6 implements dns.IPv6Lookup.
Match check dns ip match geoip
Start implements common.Runnable.
Type implements common.HasType.
type StaticHosts struct {
// contains filtered or unexported fields
}
StaticHosts represents static domain-ip mapping in DNS server.
func NewStaticHosts(hosts []*Config_HostMapping, legacy map[string]*net.IPOrDomain) (*StaticHosts, error)
NewStaticHosts creates a new StaticHosts instance.
LookupIP returns IP address for the given domain, if exists in this StaticHosts.
Package dns imports 36 packages (graph) and is imported by 3 packages. Updated 2020-11-01. Refresh now. Tools for package owners.