dns

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2024 License: MIT Imports: 40 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

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) (netapi.Resolver, 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, do func(context.Context, []byte) ([]byte, error)) *client

func NewDnsServer

func NewDnsServer(server string, process netapi.Resolver) netapi.DNSHandler

func NewDoH

func NewDoH(config Config) (netapi.Resolver, error)

func NewDoH3

func NewDoH3(config Config) (netapi.Resolver, error)

func NewDoQ

func NewDoQ(config Config) (netapi.Resolver, error)

func NewDoT

func NewDoT(config Config) (netapi.Resolver, error)

func NewDoU

func NewDoU(config Config) (netapi.Resolver, error)

func NewTCP

func NewTCP(config Config) (netapi.Resolver, error)

func ParseAddr

func ParseAddr(netType statistic.Type, host, defaultPort string) (netapi.Address, error)

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

func Register

func Register(tYPE pd.Type, f func(Config) (netapi.Resolver, 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       pd.Type
	IPv6       bool
	Subnet     netip.Prefix
	Name       string
	Host       string
	Servername string
	Dialer     netapi.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 DOQWrapConn

type DOQWrapConn struct {
	net.PacketConn
	// contains filtered or unexported fields
}

func (*DOQWrapConn) LocalAddr

func (d *DOQWrapConn) LocalAddr() net.Addr

type FakeDNS

type FakeDNS struct {
	netapi.Resolver
	*FakeIPPool
}

func NewFakeDNS

func NewFakeDNS(upStreamDo netapi.Resolver, ipRange netip.Prefix, bbolt *cache.Cache) *FakeDNS

func (*FakeDNS) Close

func (f *FakeDNS) Close() error

func (*FakeDNS) LookupIP

func (f *FakeDNS) LookupIP(_ context.Context, domain string, opts ...func(*netapi.LookupIPOption)) ([]net.IP, error)

func (*FakeDNS) LookupPtr

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

func (*FakeDNS) Raw

type FakeIPPool

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

func NewFakeIPPool

func NewFakeIPPool(prefix netip.Prefix, bbolt *cache.Cache) *FakeIPPool

func (*FakeIPPool) GetDomainFromIP

func (n *FakeIPPool) GetDomainFromIP(ip netip.Addr) (string, bool)

func (*FakeIPPool) GetFakeIPForDomain

func (n *FakeIPPool) GetFakeIPForDomain(s string) netip.Addr

func (*FakeIPPool) LRU

func (n *FakeIPPool) LRU() *lru.LRU[string, netip.Addr]

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