Documentation ¶
Index ¶
Constants ¶
View Source
const (
// MaxUDPSize max udp packet size
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 SetLoggerLevel ¶ added in v1.4.0
Types ¶
type BasicServerConfig ¶
type BasicServerConfig 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"` } }
BasicServerConfig is a basic config for a upstream dns server.
type Config ¶
type Config struct { Dispatcher struct { Bind []string `yaml:"bind"` Cache struct { Size int `yaml:"size"` } `yaml:"cache"` MinTTL uint32 `yaml:"min_ttl"` } `yaml:"dispatcher"` Upstream map[string]*BasicServerConfig `yaml:"upstream"` CA struct { Path []string `yaml:"path"` } `yaml:"ca"` }
Config is config
func LoadConfig ¶
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 ¶
ServeDNS sends q to upstreams and return first valid result. Note: q will be unsafe to modify even after ServeDNS is returned. (Some goroutine may still be running even after ServeDNS is returned)
func (*Dispatcher) StartServer ¶ added in v1.3.1
func (d *Dispatcher) StartServer() error
StartServer starts mos-chinadns. Will always return a non-nil err.
type Upstream ¶
Upstream represents a dns upstream
func NewUpstream ¶
func NewUpstream(sc *BasicServerConfig, rootCAs *x509.CertPool) (Upstream, error)
NewUpstream inits a upstream instance base on the config. rootCAs will be used in dot/doh upstream in tls server verification.
Source Files ¶
Click to show internal directories.
Click to hide internal directories.