core: v2ray.com/core/app/dns Index | Files

package dns

import "v2ray.com/core/app/dns"

Package dns is an implementation of core.DNS feature.

Index

Package Files

config.pb.go dns.go errors.generated.go hosts.go nameserver.go server.go udpns.go

Variables

var DomainMatchingType_name = map[int32]string{
    0:  "Full",
    1:  "Subdomain",
    2:  "Keyword",
    3:  "Regex",
}
var DomainMatchingType_value = map[string]int32{
    "Full":      0,
    "Subdomain": 1,
    "Keyword":   2,
    "Regex":     3,
}

func Fqdn Uses

func Fqdn(domain string) string

func NewLocalNameServer Uses

func NewLocalNameServer() *localNameServer

type ClassicNameServer Uses

type ClassicNameServer struct {
    sync.RWMutex
    // contains filtered or unexported fields
}

func NewClassicNameServer Uses

func NewClassicNameServer(address net.Destination, dispatcher routing.Dispatcher, clientIP net.IP) *ClassicNameServer

func (*ClassicNameServer) Cleanup Uses

func (s *ClassicNameServer) Cleanup() error

func (*ClassicNameServer) HandleResponse Uses

func (s *ClassicNameServer) HandleResponse(ctx context.Context, packet *udp_proto.Packet)

func (*ClassicNameServer) Name Uses

func (s *ClassicNameServer) Name() string

func (*ClassicNameServer) QueryIP Uses

func (s *ClassicNameServer) QueryIP(ctx context.Context, domain string, option IPOption) ([]net.IP, error)

type Client Uses

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 Uses

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.
    NameServers []*net.Endpoint `protobuf:"bytes,1,rep,name=NameServers,proto3" json:"NameServers,omitempty"` // Deprecated: Do not use.
    // 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.
    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"` // Deprecated: Do not use.
    // 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"`
    XXX_NoUnkeyedLiteral struct{} `json:"-"`
    XXX_unrecognized     []byte   `json:"-"`
    XXX_sizecache        int32    `json:"-"`
}

func (*Config) Descriptor Uses

func (*Config) Descriptor() ([]byte, []int)

func (*Config) GetClientIp Uses

func (m *Config) GetClientIp() []byte

func (*Config) GetHosts Uses

func (m *Config) GetHosts() map[string]*net.IPOrDomain

Deprecated: Do not use.

func (*Config) GetNameServer Uses

func (m *Config) GetNameServer() []*NameServer

func (*Config) GetNameServers Uses

func (m *Config) GetNameServers() []*net.Endpoint

Deprecated: Do not use.

func (*Config) GetStaticHosts Uses

func (m *Config) GetStaticHosts() []*Config_HostMapping

func (*Config) GetTag Uses

func (m *Config) GetTag() string

func (*Config) ProtoMessage Uses

func (*Config) ProtoMessage()

func (*Config) Reset Uses

func (m *Config) Reset()

func (*Config) String Uses

func (m *Config) String() string

func (*Config) XXX_DiscardUnknown Uses

func (m *Config) XXX_DiscardUnknown()

func (*Config) XXX_Marshal Uses

func (m *Config) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Config) XXX_Merge Uses

func (m *Config) XXX_Merge(src proto.Message)

func (*Config) XXX_Size Uses

func (m *Config) XXX_Size() int

func (*Config) XXX_Unmarshal Uses

func (m *Config) XXX_Unmarshal(b []byte) error

type Config_HostMapping Uses

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"`
    XXX_NoUnkeyedLiteral struct{} `json:"-"`
    XXX_unrecognized     []byte   `json:"-"`
    XXX_sizecache        int32    `json:"-"`
}

func (*Config_HostMapping) Descriptor Uses

func (*Config_HostMapping) Descriptor() ([]byte, []int)

func (*Config_HostMapping) GetDomain Uses

func (m *Config_HostMapping) GetDomain() string

func (*Config_HostMapping) GetIp Uses

func (m *Config_HostMapping) GetIp() [][]byte

func (*Config_HostMapping) GetProxiedDomain Uses

func (m *Config_HostMapping) GetProxiedDomain() string

func (*Config_HostMapping) GetType Uses

func (m *Config_HostMapping) GetType() DomainMatchingType

func (*Config_HostMapping) ProtoMessage Uses

func (*Config_HostMapping) ProtoMessage()

func (*Config_HostMapping) Reset Uses

func (m *Config_HostMapping) Reset()

func (*Config_HostMapping) String Uses

func (m *Config_HostMapping) String() string

func (*Config_HostMapping) XXX_DiscardUnknown Uses

func (m *Config_HostMapping) XXX_DiscardUnknown()

func (*Config_HostMapping) XXX_Marshal Uses

func (m *Config_HostMapping) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Config_HostMapping) XXX_Merge Uses

func (m *Config_HostMapping) XXX_Merge(src proto.Message)

func (*Config_HostMapping) XXX_Size Uses

func (m *Config_HostMapping) XXX_Size() int

func (*Config_HostMapping) XXX_Unmarshal Uses

func (m *Config_HostMapping) XXX_Unmarshal(b []byte) error

type DomainMatchingType Uses

type DomainMatchingType int32
const (
    DomainMatchingType_Full      DomainMatchingType = 0
    DomainMatchingType_Subdomain DomainMatchingType = 1
    DomainMatchingType_Keyword   DomainMatchingType = 2
    DomainMatchingType_Regex     DomainMatchingType = 3
)

func (DomainMatchingType) EnumDescriptor Uses

func (DomainMatchingType) EnumDescriptor() ([]byte, []int)

func (DomainMatchingType) String Uses

func (x DomainMatchingType) String() string

type IPOption Uses

type IPOption struct {
    IPv4Enable bool
    IPv6Enable bool
}

IPOption is an object for IP query options.

type IPRecord Uses

type IPRecord struct {
    IP     []net.Address
    Expire time.Time
    RCode  dnsmessage.RCode
}

type NameServer Uses

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"`
    XXX_NoUnkeyedLiteral struct{}                     `json:"-"`
    XXX_unrecognized     []byte                       `json:"-"`
    XXX_sizecache        int32                        `json:"-"`
}

func (*NameServer) Descriptor Uses

func (*NameServer) Descriptor() ([]byte, []int)

func (*NameServer) GetAddress Uses

func (m *NameServer) GetAddress() *net.Endpoint

func (*NameServer) GetPrioritizedDomain Uses

func (m *NameServer) GetPrioritizedDomain() []*NameServer_PriorityDomain

func (*NameServer) ProtoMessage Uses

func (*NameServer) ProtoMessage()

func (*NameServer) Reset Uses

func (m *NameServer) Reset()

func (*NameServer) String Uses

func (m *NameServer) String() string

func (*NameServer) XXX_DiscardUnknown Uses

func (m *NameServer) XXX_DiscardUnknown()

func (*NameServer) XXX_Marshal Uses

func (m *NameServer) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*NameServer) XXX_Merge Uses

func (m *NameServer) XXX_Merge(src proto.Message)

func (*NameServer) XXX_Size Uses

func (m *NameServer) XXX_Size() int

func (*NameServer) XXX_Unmarshal Uses

func (m *NameServer) XXX_Unmarshal(b []byte) error

type NameServer_PriorityDomain Uses

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"`
    XXX_NoUnkeyedLiteral struct{}           `json:"-"`
    XXX_unrecognized     []byte             `json:"-"`
    XXX_sizecache        int32              `json:"-"`
}

func (*NameServer_PriorityDomain) Descriptor Uses

func (*NameServer_PriorityDomain) Descriptor() ([]byte, []int)

func (*NameServer_PriorityDomain) GetDomain Uses

func (m *NameServer_PriorityDomain) GetDomain() string

func (*NameServer_PriorityDomain) GetType Uses

func (m *NameServer_PriorityDomain) GetType() DomainMatchingType

func (*NameServer_PriorityDomain) ProtoMessage Uses

func (*NameServer_PriorityDomain) ProtoMessage()

func (*NameServer_PriorityDomain) Reset Uses

func (m *NameServer_PriorityDomain) Reset()

func (*NameServer_PriorityDomain) String Uses

func (m *NameServer_PriorityDomain) String() string

func (*NameServer_PriorityDomain) XXX_DiscardUnknown Uses

func (m *NameServer_PriorityDomain) XXX_DiscardUnknown()

func (*NameServer_PriorityDomain) XXX_Marshal Uses

func (m *NameServer_PriorityDomain) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*NameServer_PriorityDomain) XXX_Merge Uses

func (m *NameServer_PriorityDomain) XXX_Merge(src proto.Message)

func (*NameServer_PriorityDomain) XXX_Size Uses

func (m *NameServer_PriorityDomain) XXX_Size() int

func (*NameServer_PriorityDomain) XXX_Unmarshal Uses

func (m *NameServer_PriorityDomain) XXX_Unmarshal(b []byte) error

type Server Uses

type Server struct {
    sync.Mutex
    // contains filtered or unexported fields
}

Server is a DNS rely server.

func New Uses

func New(ctx context.Context, config *Config) (*Server, error)

New creates a new DNS server with given configuration.

func (*Server) Close Uses

func (s *Server) Close() error

Close implements common.Closable.

func (s *Server) IsOwnLink(ctx context.Context) bool

func (*Server) LookupIP Uses

func (s *Server) LookupIP(domain string) ([]net.IP, error)

LookupIP implements dns.Client.

func (*Server) LookupIPv4 Uses

func (s *Server) LookupIPv4(domain string) ([]net.IP, error)

LookupIPv4 implements dns.IPv4Lookup.

func (*Server) LookupIPv6 Uses

func (s *Server) LookupIPv6(domain string) ([]net.IP, error)

LookupIPv6 implements dns.IPv6Lookup.

func (*Server) Start Uses

func (s *Server) Start() error

Start implements common.Runnable.

func (*Server) Type Uses

func (*Server) Type() interface{}

Type implements common.HasType.

type StaticHosts Uses

type StaticHosts struct {
    // contains filtered or unexported fields
}

StaticHosts represents static domain-ip mapping in DNS server.

func NewStaticHosts Uses

func NewStaticHosts(hosts []*Config_HostMapping, legacy map[string]*net.IPOrDomain) (*StaticHosts, error)

NewStaticHosts creates a new StaticHosts instance.

func (*StaticHosts) LookupIP Uses

func (h *StaticHosts) LookupIP(domain string, option IPOption) []net.Address

LookupIP returns IP address for the given domain, if exists in this StaticHosts.

Package dns imports 25 packages (graph) and is imported by 18 packages. Updated 2019-07-06. Refresh now. Tools for package owners.