dns

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2023 License: AGPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BadUpstreamFormatError = fmt.Errorf("bad upstream format")
View Source
var (
	FormatError = fmt.Errorf("format error")
)

Functions

func TypeParserFactory

func TypeParserFactory(callback func(f *config_parser.Function, types []uint16, overrideOutbound *routing.Outbound) (err error)) routing.FunctionParser

Types

type Dns

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

func New

func New(dns *config.Dns, opt *NewOption) (s *Dns, err error)

func (*Dns) CheckUpstreamsFormat added in v0.1.2

func (s *Dns) CheckUpstreamsFormat() error

func (*Dns) InitUpstreams

func (s *Dns) InitUpstreams()

func (*Dns) RequestSelect

func (s *Dns) RequestSelect(qname string, qtype uint16) (upstreamIndex consts.DnsRequestOutboundIndex, upstream *Upstream, err error)

func (*Dns) ResponseSelect

func (s *Dns) ResponseSelect(msg *dnsmessage.Msg, fromUpstream *Upstream) (upstreamIndex consts.DnsResponseOutboundIndex, upstream *Upstream, err error)

type NewOption

type NewOption struct {
	Logger                  *logrus.Logger
	LocationFinder          *assets.LocationFinder
	UpstreamReadyCallback   func(dnsUpstream *Upstream) (err error)
	UpstreamResolverNetwork string
}

type RequestMatcher

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

func (*RequestMatcher) Match

func (m *RequestMatcher) Match(
	qName string,
	qType uint16,
) (upstreamIndex consts.DnsRequestOutboundIndex, err error)

type RequestMatcherBuilder

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

func NewRequestMatcherBuilder

func NewRequestMatcherBuilder(log *logrus.Logger, rules []*config_parser.RoutingRule, upstreamName2Id map[string]uint8, fallback config.FunctionOrString) (b *RequestMatcherBuilder, err error)

func (*RequestMatcherBuilder) Build

func (b *RequestMatcherBuilder) Build() (matcher *RequestMatcher, err error)

type ResponseMatcher

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

func (*ResponseMatcher) Match

func (m *ResponseMatcher) Match(
	qName string,
	qType uint16,
	ips []netip.Addr,
	upstream consts.DnsRequestOutboundIndex,
) (upstreamIndex consts.DnsResponseOutboundIndex, err error)

type ResponseMatcherBuilder

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

func NewResponseMatcherBuilder

func NewResponseMatcherBuilder(log *logrus.Logger, rules []*config_parser.RoutingRule, upstreamName2Id map[string]uint8, fallback config.FunctionOrString) (b *ResponseMatcherBuilder, err error)

func (*ResponseMatcherBuilder) Build

func (b *ResponseMatcherBuilder) Build() (matcher *ResponseMatcher, err error)

type Upstream

type Upstream struct {
	Scheme   UpstreamScheme
	Hostname string
	Port     uint16
	*netutils.Ip46
}

func NewUpstream

func NewUpstream(ctx context.Context, upstream *url.URL, resolverNetwork string) (up *Upstream, err error)

func (*Upstream) String

func (u *Upstream) String() string

func (*Upstream) SupportedNetworks

func (u *Upstream) SupportedNetworks() (ipversions []consts.IpVersionStr, l4protos []consts.L4ProtoStr)

type UpstreamResolver

type UpstreamResolver struct {
	Raw     *url.URL
	Network string
	// FinishInitCallback may be invoked again if err is not nil
	FinishInitCallback func(raw *url.URL, upstream *Upstream) (err error)
	// contains filtered or unexported fields
}

func (*UpstreamResolver) GetUpstream

func (u *UpstreamResolver) GetUpstream() (_ *Upstream, err error)

type UpstreamScheme

type UpstreamScheme string
const (
	UpstreamScheme_TCP     UpstreamScheme = "tcp"
	UpstreamScheme_UDP     UpstreamScheme = "udp"
	UpstreamScheme_TCP_UDP UpstreamScheme = "tcp+udp"
)

func ParseRawUpstream

func ParseRawUpstream(raw *url.URL) (scheme UpstreamScheme, hostname string, port uint16, err error)

func (UpstreamScheme) ContainsTcp

func (s UpstreamScheme) ContainsTcp() bool

Jump to

Keyboard shortcuts

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