Documentation
¶
Index ¶
- func DNSDialer(port int) func(ctx context.Context, network, address string) (net.Conn, error)
- type DmDns
- func (s *DmDns) AddRecord(domain string, rtype uint16, rr dns.RR)
- func (s *DmDns) DNSOverTCP(in io.ReadCloser, out io.Writer) error
- func (s *DmDns) Do(req *dns.Msg) *dns.Msg
- func (s *DmDns) ForwardHttp(req *dns.Msg) (*dns.Msg, error)
- func (s *DmDns) ForwardRealDNS(req *dns.Msg) (*dns.Msg, error)
- func (gw *DmDns) HandleUdp(dstAddr net.IP, dstPort uint16, localAddr net.IP, localPort uint16, ...)
- func (s *DmDns) HostByAddr(addr string) (string, bool)
- func (s *DmDns) IPResolve(ip string) string
- func (s *DmDns) NameByAddr(addr string) (*DnsEntry, bool)
- func (d *DmDns) Provision(ctx context.Context) error
- func (s *DmDns) ServeDNS(req *dns.Msg, w dns.ResponseWriter) (int, error)
- func (s *DmDns) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (s *DmDns) Start(ctx context.Context) error
- type DnsEntry
- type Record
- type UdpWriter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DmDns ¶
type DmDns struct {
UDPConn *net.UDPConn
// UDP
// Capture return - sends packets back to client app.
// This is typically a netstack or TProxy
UDPWriter UdpWriter
// Client used for DNS-over-HTTPS requests.
H2 *http.Client
// Address and port for the DNS-over-https gateway. If empty, direct calls
// using dnsUDPClient.
BaseUrl string `json:"dohURL,omitempty"`
Records map[string]*Record
// Nameservers to use for direct calls, without a VPN.
// Overriden from "DNS" env variable.
Nameservers []string
Port int
Mux *http.ServeMux
Capture bool
// contains filtered or unexported fields
}
func (*DmDns) DNSOverTCP ¶
DNSOverTCP implements DNS over TCP protocol. Used in TCP capture, for port 53. TODO: also as a standalone server.
func (*DmDns) Do ¶
Do resolves a query by forwarding to a recursive nameserver or handling it locally. This is the main function - can be called from: - the real local UDP DNS (mike's) - DNS-over-TCP or TLS server - captured UDP:53 from TUN
Wrapps the real process method with stats gathering and builds a reverse map of IP to names
func (*DmDns) ForwardHttp ¶
ForwardHttp forwards the req to a http server, using dmesh-specific DNS-over-HTTP Using GET method - see https://developers.cloudflare.com/1.1.1.1/dns-over-https/wireformat/ and https://cloudflare-dns.com/dns-query Appears to be supported on 1.1.1.1 ( also supports DNS-TLS)
Using DNS over http has hight overhead and doesn't make so much sense in a mesh where DOT can be used instead, with secure L4, or UDP with DNSSEC.
func (*DmDns) ForwardRealDNS ¶
ForwardRealDNS sends the query to real nameservers.
func (*DmDns) HandleUdp ¶
func (gw *DmDns) HandleUdp(dstAddr net.IP, dstPort uint16, localAddr net.IP, localPort uint16, data []byte)
Special capture for DNS with TUN or TPROXY. Will use the DNS VPN or direct calls.
func (*DmDns) HostByAddr ¶
HostByAddr returns the last lookup address for an IP, or the original address. The IP is expressed as a string ( ip.String() ).
func (*DmDns) NameByAddr ¶
Given an IPv4 or IPv6 address, return the name if DNS was used.
type DnsEntry ¶
type DnsEntry struct {
// DNS name, with trailing .
Name string
IP net.IP
// Number of times it was called.
Count int
RCount int
// Latency on getting the entry
Lat time.Duration
// contains filtered or unexported fields
}
Info and stats about a DNS entry.
type UdpWriter ¶
type UdpWriter interface {
WriteTo(data []byte, dstAddr *net.UDPAddr, srcAddr *net.UDPAddr) (int, error)
}
UdpWriter is the interface implemented by the TunTransport, to send packets back to the virtual interface Set by TProxy and TUN capture. If missing, a regular UDP will be used, first with WriteMsgUdp and if it fails without preserving srcAddr.