dns

package
v0.3.1-rc.5 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2023 License: MIT Imports: 33 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

View Source
var ErrNoIPFound = errors.New("no ip fond")
View Source
var TlsProtos = []string{"doq-i02"}
View Source
var TlsProtosCompat = []string{"doq-i02", "doq-i01", "doq-i00", "doq", "dq"}

TlsProtosCompat stores alternative TLS protocols for experimental interoperability

Functions

func DOHJsonAPI

func DOHJsonAPI(DNSServer, domain string, proxy func(ctx context.Context, network, addr string) (net.Conn, error)) (DNS []net.IP, err error)

func New

func New(config Config) (dns.DNS, error)
Example
subnet, err := netip.ParsePrefix("1.1.1.1/24")
if err != nil {
	panic(err)
}

New(Config{
	Type:       dns.Type_doh,
	Name:       "cloudflare",
	Host:       "cloudflare-dns.com",
	Servername: "cloudflare-dns.com",
	IPv6:       true,
	Subnet:     subnet,
})
Output:

func NewClient

func NewClient(config Config, send func([]byte) ([]byte, error)) *client

func NewDnsServer

func NewDnsServer(server string, process proxy.ResolverProxy) server.DNSServer

func NewDoH

func NewDoH(config Config) (dns.DNS, error)

func NewDoH3

func NewDoH3(config Config) (dns.DNS, error)

func NewDoQ

func NewDoQ(config Config) (dns.DNS, error)

func NewDoT

func NewDoT(config Config) (dns.DNS, error)

func NewDoU

func NewDoU(config Config) (dns.DNS, error)

func NewTCP

func NewTCP(config Config) (dns.DNS, error)

func ParseAddr

func ParseAddr(host, defaultPort string) (proxy.Address, error)

ParseAddr host eg: cloudflare-dns.com, https://cloudflare-dns.com, 1.1.1.1:853

func Register

func Register(tYPE pdns.Type, f func(Config) (dns.DNS, error))

func RetrieveIPFromPtr

func RetrieveIPFromPtr(name string) (net.IP, error)

Types

type Answer

type Answer struct {
	Name    string `json:"name"`
	Type    int    `json:"type"`
	TTL     int    `json:"TTL"`
	Expires string `json:"Expires"`
	Data    string `json:"data"`
}

type Config

type Config struct {
	Type       pdns.Type
	IPv6       bool
	Subnet     netip.Prefix
	Name       string
	Host       string
	Servername string
	Dialer     proxy.Proxy
}

type DOHJson

type DOHJson struct {
	Status           int        `json:"status"`
	TC               bool       `json:"TC"`
	RD               bool       `json:"RD"`
	RA               bool       `json:"RA"`
	AD               bool       `json:"AD"`
	CD               bool       `json:"CD"`
	Question         []Question `json:"Question"`
	Answer           []Answer   `json:"Answer"`
	EdnsClientSubnet string     `json:"edns_client_subnet"`
}

type FakeDNS

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

func WrapFakeDNS

func WrapFakeDNS(upStreamDo func(b []byte) ([]byte, error), pool *NFakeDNS) *FakeDNS

func (*FakeDNS) Close

func (f *FakeDNS) Close() error

func (*FakeDNS) Do

func (f *FakeDNS) Do(b []byte) ([]byte, error)

func (*FakeDNS) LookupIP

func (f *FakeDNS) LookupIP(domain string) ([]net.IP, error)

func (*FakeDNS) LookupPtr

func (f *FakeDNS) LookupPtr(name string) (string, error)

func (*FakeDNS) Record

func (f *FakeDNS) Record(domain string, t dnsmessage.Type) (dns.IPResponse, error)

type NFakeDNS

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

func NewNFakeDNS

func NewNFakeDNS(prefix netip.Prefix) *NFakeDNS

func (*NFakeDNS) GetDomainFromIP

func (n *NFakeDNS) GetDomainFromIP(ip string) (string, bool)

func (*NFakeDNS) GetFakeIPForDomain

func (n *NFakeDNS) GetFakeIPForDomain(s string) string

type Question

type Question struct {
	Name string `json:"name"`
	Type int    `json:"type"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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