dns

package module
v0.0.0-...-109c5d9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 13, 2021 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DNSDialer

func DNSDialer(port int) func(ctx context.Context, network, address string) (net.Conn, error)

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 communicating with the gateway - should be capable of H2, and have
	// all authetication set up.
	H2 *http.Client

	// Address and port for the DNS-over-https gateway. If empty, direct calls
	// using dnsUDPClient.
	BaseUrl string

	Port int
	// contains filtered or unexported fields
}

func NewDmDns

func NewDmDns(port int) (*DmDns, error)

New DNS server, listening on port.

func (*DmDns) AddRecord

func (s *DmDns) AddRecord(domain string, rtype uint16, rr dns.RR)

func (*DmDns) DNSOverTCP

func (s *DmDns) DNSOverTCP(in io.ReadCloser, out io.Writer) error

DNSOverTCP implements DNS over TCP protocol. Used in TCP capture, for port 53. TODO: also as a standalone server.

func (*DmDns) ForwardRealDNS

func (s *DmDns) ForwardRealDNS(req *dns.Msg) (*dns.Msg, error)

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. Will use the DNS VPN or direct calls.

func (*DmDns) HostByAddr

func (s *DmDns) HostByAddr(addr string) (string, bool)

HostByAddr returns the last lookup address for an IP, or the original address. The IP is expressed as a string ( ip.String() ).

func (*DmDns) HttpDebugDNS

func (s *DmDns) HttpDebugDNS(w http.ResponseWriter, r *http.Request)

HttpDebugDNS dumps DNS cache (dnsByName)

func (*DmDns) IPResolve

func (s *DmDns) IPResolve(ip string) string

func (*DmDns) NameByAddr

func (s *DmDns) NameByAddr(addr string) (*DnsEntry, bool)

Given an IPv4 or IPv6 address, return the name if DNS was used.

func (*DmDns) Process

func (s *DmDns) Process(req *dns.Msg) *dns.Msg

Process 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) Serve

func (s *DmDns) Serve()

Blocking

func (*DmDns) Start

func (s *DmDns) Start(mux *http.ServeMux)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL