Documentation
¶
Index ¶
- type DNSDispatcher
- type DoHResolver
- type HostsAwareResolver
- type HostsResolver
- func (r *HostsResolver) AddHost(domain string, ip net.IP)
- func (r *HostsResolver) Count() int
- func (r *HostsResolver) GetAllHosts() map[string][]net.IP
- func (r *HostsResolver) LoadFile(path string) error
- func (r *HostsResolver) LoadString(content string) error
- func (r *HostsResolver) Reload() error
- func (r *HostsResolver) RemoveHost(domain string)
- func (r *HostsResolver) Resolve(domain string) ([]net.IP, bool)
- func (r *HostsResolver) ResolveIPv4(domain string) ([]net.IP, bool)
- func (r *HostsResolver) ResolveIPv6(domain string) ([]net.IP, bool)
- func (r *HostsResolver) SetHost(domain string, ips ...net.IP)
- type RouteMatcher
- type Server
- func (s *Server) AddRule(domain string, upstream string)
- func (s *Server) SetHostsFile(path string) error
- func (s *Server) SetHostsResolver(hosts *HostsResolver)
- func (s *Server) SetRouter(router RouteMatcher)
- func (s *Server) Start(ctx context.Context) error
- func (s *Server) Stop(ctx context.Context) error
- type UDPResolver
- type UpstreamResolver
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DNSDispatcher ¶
type DNSDispatcher struct {
// contains filtered or unexported fields
}
DNSDispatcher handles Split-DNS routing
func NewDNSDispatcher ¶
func NewDNSDispatcher(defaultResolver UpstreamResolver) *DNSDispatcher
func (*DNSDispatcher) AddRule ¶
func (d *DNSDispatcher) AddRule(domain string, resolver UpstreamResolver)
func (*DNSDispatcher) Dispatch ¶
func (d *DNSDispatcher) Dispatch(domain string) UpstreamResolver
type DoHResolver ¶
DoHResolver implements DNS over HTTPS
type HostsAwareResolver ¶
type HostsAwareResolver struct {
// contains filtered or unexported fields
}
HostsAwareResolver wraps an upstream resolver with hosts file support
func NewHostsAwareResolver ¶
func NewHostsAwareResolver(hosts *HostsResolver, upstream UpstreamResolver) *HostsAwareResolver
NewHostsAwareResolver creates a new hosts-aware resolver
type HostsResolver ¶
type HostsResolver struct {
// contains filtered or unexported fields
}
HostsResolver resolves domains using a hosts file
func NewHostsResolver ¶
func NewHostsResolver() *HostsResolver
NewHostsResolver creates a new hosts resolver
func (*HostsResolver) AddHost ¶
func (r *HostsResolver) AddHost(domain string, ip net.IP)
AddHost adds a host entry
func (*HostsResolver) Count ¶
func (r *HostsResolver) Count() int
Count returns the number of host entries
func (*HostsResolver) GetAllHosts ¶
func (r *HostsResolver) GetAllHosts() map[string][]net.IP
GetAllHosts returns all host entries
func (*HostsResolver) LoadFile ¶
func (r *HostsResolver) LoadFile(path string) error
LoadFile loads hosts from a file (e.g., /etc/hosts)
func (*HostsResolver) LoadString ¶
func (r *HostsResolver) LoadString(content string) error
LoadString loads hosts from a string
func (*HostsResolver) RemoveHost ¶
func (r *HostsResolver) RemoveHost(domain string)
RemoveHost removes a host entry
func (*HostsResolver) Resolve ¶
func (r *HostsResolver) Resolve(domain string) ([]net.IP, bool)
Resolve looks up a domain in the hosts file
func (*HostsResolver) ResolveIPv4 ¶
func (r *HostsResolver) ResolveIPv4(domain string) ([]net.IP, bool)
ResolveIPv4 returns only IPv4 addresses
func (*HostsResolver) ResolveIPv6 ¶
func (r *HostsResolver) ResolveIPv6(domain string) ([]net.IP, bool)
ResolveIPv6 returns only IPv6 addresses
type RouteMatcher ¶
type RouteMatcher interface {
MatchDomain(domain string) (string, bool) // returns upstream, found
}
RouteMatcher matches domains to upstreams
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server represents a DNS proxy server
func (*Server) SetHostsFile ¶
SetHostsFile sets the hosts file for the DNS server
func (*Server) SetHostsResolver ¶
func (s *Server) SetHostsResolver(hosts *HostsResolver)
SetHostsResolver sets a custom hosts resolver for the DNS server
func (*Server) SetRouter ¶
func (s *Server) SetRouter(router RouteMatcher)
SetRouter injects the router for policy-based resolution