Documentation
¶
Index ¶
- Constants
- func IPToReverseDNS(ip net.IP) string
- func PickIPFromSubnet(subnet string) (netip.Addr, error)
- type DNSProxy
- func (p *DNSProxy) AddDNSRecord(domain string, ip net.IP, siteId int) error
- func (p *DNSProxy) ClearDNSRecords()
- func (p *DNSProxy) GetDNSRecords(domain string, recordType RecordType) ([]net.IP, bool)
- func (p *DNSProxy) GetProxyIP() netip.Addr
- func (p *DNSProxy) RemoveDNSRecord(domain string, ip net.IP)
- func (p *DNSProxy) SetJITHandler(handler func(siteId int))
- func (p *DNSProxy) Start() error
- func (p *DNSProxy) Stop()
- type DNSRecordStore
- func (s *DNSRecordStore) AddPTRRecord(ip net.IP, domain string) error
- func (s *DNSRecordStore) AddRecord(domain string, ip net.IP, siteId int) error
- func (s *DNSRecordStore) Clear()
- func (s *DNSRecordStore) GetPTRRecord(domain string) (string, bool)
- func (s *DNSRecordStore) GetRecords(domain string, recordType RecordType) ([]net.IP, bool)
- func (s *DNSRecordStore) GetSiteIdForDomain(domain string) (int, bool)
- func (s *DNSRecordStore) HasPTRRecord(domain string) bool
- func (s *DNSRecordStore) HasRecord(domain string, recordType RecordType) bool
- func (s *DNSRecordStore) RemovePTRRecord(ip net.IP)
- func (s *DNSRecordStore) RemoveRecord(domain string, ip net.IP)
- type RecordType
Constants ¶
const (
DNSPort = 53
)
Variables ¶
This section is empty.
Functions ¶
func IPToReverseDNS ¶ added in v1.4.2
IPToReverseDNS converts an IP address to reverse DNS format Returns the domain name for PTR queries (e.g., "1.0.0.127.in-addr.arpa.")
Types ¶
type DNSProxy ¶
type DNSProxy struct {
// contains filtered or unexported fields
}
DNSProxy implements a DNS proxy using gvisor netstack
func NewDNSProxy ¶
func NewDNSProxy(middleDevice *device.MiddleDevice, mtu int, utilitySubnet string, upstreamDns []string, tunnelDns bool, tunnelIP string) (*DNSProxy, error)
NewDNSProxy creates a new DNS proxy
func (*DNSProxy) AddDNSRecord ¶
AddDNSRecord adds a DNS record to the local store domain should be a domain name (e.g., "example.com" or "example.com.") ip should be a valid IPv4 or IPv6 address
func (*DNSProxy) ClearDNSRecords ¶
func (p *DNSProxy) ClearDNSRecords()
ClearDNSRecords removes all DNS records from the local store
func (*DNSProxy) GetDNSRecords ¶
GetDNSRecords returns all IP addresses for a domain and record type. The second return value indicates whether the domain exists.
func (*DNSProxy) GetProxyIP ¶
func (*DNSProxy) RemoveDNSRecord ¶
RemoveDNSRecord removes a DNS record from the local store If ip is nil, removes all records for the domain
func (*DNSProxy) SetJITHandler ¶ added in v1.4.4
SetJITHandler registers a callback that is invoked whenever a local DNS record is resolved for an A or AAAA query. The siteId identifies which site owns the record. The handler is called in its own goroutine so it must be safe to call concurrently. Pass nil to disable JIT notifications.
type DNSRecordStore ¶
type DNSRecordStore struct {
// contains filtered or unexported fields
}
DNSRecordStore manages local DNS records for A, AAAA, and PTR queries. Exact domains are stored in a map; wildcard patterns are in a separate map.
func NewDNSRecordStore ¶
func NewDNSRecordStore() *DNSRecordStore
NewDNSRecordStore creates a new DNS record store
func (*DNSRecordStore) AddPTRRecord ¶ added in v1.4.2
func (s *DNSRecordStore) AddPTRRecord(ip net.IP, domain string) error
AddPTRRecord adds a PTR record mapping an IP address to a domain name ip should be a valid IPv4 or IPv6 address domain should be in FQDN format (e.g., "example.com.")
func (*DNSRecordStore) AddRecord ¶
AddRecord adds a DNS record mapping (A or AAAA) domain should be in FQDN format (e.g., "example.com.") domain can contain wildcards: * (0+ chars) and ? (exactly 1 char) ip should be a valid IPv4 or IPv6 address siteId is the site that owns this alias/domain Automatically adds a corresponding PTR record for non-wildcard domains
func (*DNSRecordStore) Clear ¶
func (s *DNSRecordStore) Clear()
Clear removes all records from the store
func (*DNSRecordStore) GetPTRRecord ¶ added in v1.4.2
func (s *DNSRecordStore) GetPTRRecord(domain string) (string, bool)
GetPTRRecord returns the domain name for a PTR record query domain should be in reverse DNS format (e.g., "1.0.0.127.in-addr.arpa.")
func (*DNSRecordStore) GetRecords ¶
func (s *DNSRecordStore) GetRecords(domain string, recordType RecordType) ([]net.IP, bool)
GetRecords returns all IP addresses for a domain and record type. The second return value indicates whether the domain exists at all (true = domain exists, use NODATA if no records; false = NXDOMAIN).
func (*DNSRecordStore) GetSiteIdForDomain ¶ added in v1.4.4
func (s *DNSRecordStore) GetSiteIdForDomain(domain string) (int, bool)
GetSiteIdForDomain returns the siteId associated with the given domain. It checks exact matches first, then wildcard patterns. The second return value is false if the domain is not found in local records.
func (*DNSRecordStore) HasPTRRecord ¶ added in v1.4.2
func (s *DNSRecordStore) HasPTRRecord(domain string) bool
HasPTRRecord checks if a PTR record exists for the given reverse DNS domain
func (*DNSRecordStore) HasRecord ¶
func (s *DNSRecordStore) HasRecord(domain string, recordType RecordType) bool
HasRecord checks if a domain has any records of the specified type Checks both exact matches and wildcard patterns
func (*DNSRecordStore) RemovePTRRecord ¶ added in v1.4.2
func (s *DNSRecordStore) RemovePTRRecord(ip net.IP)
RemovePTRRecord removes a PTR record for an IP address
func (*DNSRecordStore) RemoveRecord ¶
func (s *DNSRecordStore) RemoveRecord(domain string, ip net.IP)
RemoveRecord removes a specific DNS record mapping If ip is nil, removes all records for the domain (including wildcards) Automatically removes corresponding PTR records for non-wildcard domains
type RecordType ¶
type RecordType uint16
RecordType represents the type of DNS record
const ( RecordTypeA RecordType = RecordType(dns.TypeA) RecordTypeAAAA RecordType = RecordType(dns.TypeAAAA) RecordTypePTR RecordType = RecordType(dns.TypePTR) )