dispatcher

package
v1.4.4 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2020 License: GPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MaxUDPSize max udp packet size in edns0
	MaxUDPSize = 1480
)

Variables

View Source
var (
	// ErrUpstreamsFailed all upstreams are failed or not respond in time.
	ErrUpstreamsFailed = errors.New("all upstreams failed or not respond in time")
)

Functions

func GenConfig

func GenConfig(p string) error

GenConfig generates a template config to path p.

func NewUpstream

func NewUpstream(name string, sc *BasicUpstreamConfig, rootCAs *x509.CertPool) (*enhancedUpstream, error)

NewUpstream inits a upstream instance base on the config. rootCAs will be used in dot/doh upstream in tls server verification.

Types

type BasicUpstreamConfig added in v1.4.4

type BasicUpstreamConfig struct {
	Addr     string `yaml:"addr"`
	Protocol string `yaml:"protocol"`
	Socks5   string `yaml:"socks5"`

	TCP struct {
		IdleTimeout uint `yaml:"idle_timeout"`
	} `yaml:"tcp"`

	DoT struct {
		ServerName  string `yaml:"server_name"`
		IdleTimeout uint   `yaml:"idle_timeout"`
	} `yaml:"dot"`

	DoH struct {
		URL string `yaml:"url"`
	} `yaml:"doh"`

	// for test and experts only, we add `omitempty`
	InsecureSkipVerify bool `yaml:"insecure_skip_verify,omitempty"`

	Deduplicate          bool `yaml:"deduplicate"`
	MaxConcurrentQueries int  `yaml:"max_concurrent_queries"`

	EDNS0 struct {
		ClientSubnet string `yaml:"client_subnet"`
		OverwriteECS bool   `yaml:"overwrite_ecs"`
	} `yaml:"edns0"`
	Policies struct {
		DenyUnhandlableTypes bool   `yaml:"deny_unhandlable_types"`
		Domain               string `yaml:"domain"`
		DenyErrorRcode       bool   `yaml:"deny_error_rcode"`
		CheckCNAME           bool   `yaml:"check_cname"`
		DenyEmptyIPReply     bool   `yaml:"deny_empty_ip_reply"`
		IP                   string `yaml:"ip"`
	}
}

BasicUpstreamConfig is a basic config for a dns upstream.

type Config

type Config struct {
	Dispatcher struct {
		Bind []string `yaml:"bind"`
	} `yaml:"dispatcher"`

	Upstream map[string]*BasicUpstreamConfig `yaml:"upstream"`

	CA struct {
		Path []string `yaml:"path"`
	} `yaml:"ca"`
}

Config is config

func LoadConfig

func LoadConfig(p string) (*Config, error)

LoadConfig loads a yaml config from path p.

type Dispatcher

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

Dispatcher represents a dns query dispatcher

func InitDispatcher

func InitDispatcher(conf *Config) (*Dispatcher, error)

InitDispatcher inits a dispatcher from configuration

func (*Dispatcher) ServeDNS

func (d *Dispatcher) ServeDNS(ctx context.Context, q *dns.Msg) (r *dns.Msg, err error)

ServeDNS sends q to upstreams and return first valid result.

func (*Dispatcher) StartServer added in v1.3.1

func (d *Dispatcher) StartServer() error

StartServer starts mos-chinadns. Will always return a non-nil err.

Directories

Path Synopsis
logger for the whole dispatcher package
logger for the whole dispatcher package

Jump to

Keyboard shortcuts

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