dns

package
v0.3.8 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2025 License: MIT Imports: 43 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

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",
	Subnet:     subnet,
})
Output:

func NewClient

func NewClient(config Config, dialer Dialer) *client

func NewServer added in v0.3.5

func NewServer(server string, process netapi.Resolver) netapi.DNSServer

func ParseAddr

func ParseAddr(netType string, 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) (Dialer, error))

func RetrieveIPFromPtr

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

Types

type Answer

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

type BytesResponse added in v0.3.7

type BytesResponse []byte

func (BytesResponse) Msg added in v0.3.7

func (b BytesResponse) Msg() (msg dnsmessage.Message, err error)

func (BytesResponse) Release added in v0.3.7

func (b BytesResponse) Release()

type CacheKey added in v0.3.7

type CacheKey struct {
	Name unique.Handle[string]
	Type dnsmessage.Type
}

func (CacheKey) FromQuestion added in v0.3.7

func (c CacheKey) FromQuestion(q dnsmessage.Question) CacheKey

type Config

type Config struct {
	Dialer     netapi.Proxy
	Subnet     netip.Prefix
	Name       string
	Host       string
	Servername string
	Type       pd.Type
}

type DOHJson

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

func DOHJsonAPI

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

type DOQBufferWrapConn added in v0.3.7

type DOQBufferWrapConn struct {
	direct.BufferPacketConn
	// contains filtered or unexported fields
}

func (*DOQBufferWrapConn) LocalAddr added in v0.3.7

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

type Dialer added in v0.3.7

type Dialer interface {
	Do(ctx context.Context, req *Request) (Response, error)
	Close() error
}

func NewDoH

func NewDoH(config Config) (Dialer, error)

func NewDoH3

func NewDoH3(config Config) (Dialer, error)

func NewDoQ

func NewDoQ(config Config) (Dialer, error)

func NewDoT

func NewDoT(config Config) (Dialer, error)

func NewDoU

func NewDoU(config Config) (Dialer, error)

func NewTCP

func NewTCP(config Config) (Dialer, error)

type DialerFunc added in v0.3.7

type DialerFunc func(context.Context, *Request) (Response, error)

func (DialerFunc) Close added in v0.3.7

func (f DialerFunc) Close() error

func (DialerFunc) Do added in v0.3.7

func (f DialerFunc) Do(ctx context.Context, req *Request) (Response, error)

type FakeDNS

type FakeDNS struct {
	netapi.Resolver
	// contains filtered or unexported fields
}

func NewFakeDNS

func NewFakeDNS(upStreamDo netapi.Resolver, ipRange netip.Prefix, ipv6Range netip.Prefix, db *bolt.DB) *FakeDNS

func (*FakeDNS) Close

func (f *FakeDNS) Close() error

func (*FakeDNS) Contains added in v0.3.6

func (f *FakeDNS) Contains(addr netip.Addr) bool

func (*FakeDNS) Equal added in v0.3.6

func (f *FakeDNS) Equal(ipRange, ipv6Range netip.Prefix) bool

func (*FakeDNS) Flush added in v0.3.6

func (f *FakeDNS) Flush()

func (*FakeDNS) GetDomainFromIP added in v0.3.5

func (f *FakeDNS) GetDomainFromIP(ip netip.Addr) (string, bool)

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, db *bolt.DB) *FakeIPPool

func (*FakeIPPool) Flush added in v0.3.6

func (n *FakeIPPool) Flush()

func (*FakeIPPool) GetDomainFromIP

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

func (*FakeIPPool) GetFakeIPForDomain

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

type Group added in v0.3.7

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

func NewGroup added in v0.3.7

func NewGroup(dialers ...Dialer) (*Group, error)

func (*Group) Close added in v0.3.7

func (g *Group) Close() error

func (*Group) Do added in v0.3.7

func (g *Group) Do(ctx context.Context, req *Request) (Response, error)

type HTTPSResource added in v0.3.7

type HTTPSResource struct {
	Priority uint16
	Target   dnsmessage.Name
	Params   []Param
}

func (*HTTPSResource) GoString added in v0.3.7

func (r *HTTPSResource) GoString() string

GoString implements fmt.GoStringer.GoString.

type MsgResponse added in v0.3.7

type MsgResponse dnsmessage.Message

func (MsgResponse) Msg added in v0.3.7

func (m MsgResponse) Msg() (msg dnsmessage.Message, err error)

func (MsgResponse) Release added in v0.3.7

func (m MsgResponse) Release()

type Param added in v0.3.7

type Param struct {
	Key   ParamKey
	Value []byte
}

func (Param) GoString added in v0.3.7

func (p Param) GoString() string

type ParamKey added in v0.3.7

type ParamKey uint16
const (
	ParamMandatory     ParamKey = 0
	ParamALPN          ParamKey = 1
	ParamNoDefaultALPN ParamKey = 2
	ParamPort          ParamKey = 3
	ParamIPv4Hint      ParamKey = 4
	ParamECHConfig     ParamKey = 5
	ParamIPv6Hint      ParamKey = 6
)

func (ParamKey) GoString added in v0.3.7

func (t ParamKey) GoString() string

GoString implements fmt.GoStringer.GoString.

type Question

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

type Request added in v0.3.7

type Request struct {
	QuestionBytes []byte
	Question      dnsmessage.Question
	ID            uint16
	Truncated     bool
}

type Response added in v0.3.7

type Response interface {
	Msg() (dnsmessage.Message, error)
	Release()
}

type SVCBResource added in v0.3.7

type SVCBResource struct {
	Priority uint16
	Target   dnsmessage.Name
	Params   []Param
}

An SVCBResource is an SVCB Resource record.

func (*SVCBResource) GoString added in v0.3.7

func (r *SVCBResource) GoString() string

GoString implements fmt.GoStringer.GoString.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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