Documentation ¶
Index ¶
- func AddSubCmd(c *cobra.Command)
- func DelPluginType(typ string)
- func GetAllPluginTypes() []string
- func LoadNewPersetPluginFuncs() map[string]NewPersetPluginFunc
- func RegNewPersetPluginFunc(tag string, f NewPersetPluginFunc)
- func RegNewPluginFunc(typ string, initFunc NewPluginFunc, argsType NewPluginArgsFunc)
- func Run() error
- func RunMosdns(cfg *Config) error
- func StartServer(sf *serverFlags) error
- type APIConfig
- type BP
- type BadIPObserverConfig
- type Config
- type ExecutablePlugin
- type MatcherPlugin
- type Mosdns
- func (m *Mosdns) GetBadIPObserver() ip_observer.IPObserver
- func (m *Mosdns) GetDataManager() *data_provider.DataManager
- func (m *Mosdns) GetExecutables() map[string]executable_seq.Executable
- func (m *Mosdns) GetHTTPAPIMux() *http.ServeMux
- func (m *Mosdns) GetMatchers() map[string]executable_seq.Matcher
- func (m *Mosdns) GetMetricsReg() prometheus.Registerer
- func (m *Mosdns) GetSafeClose() *safe_close.SafeClose
- type NewPersetPluginFunc
- type NewPluginArgsFunc
- type NewPluginFunc
- type Plugin
- type PluginConfig
- type PluginTypeInfo
- type SecurityConfig
- type ServerConfig
- type ServerListenerConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DelPluginType ¶
func DelPluginType(typ string)
DelPluginType deletes the init func for this plugin type. It is a noop if pluginType is not registered.
func GetAllPluginTypes ¶
func GetAllPluginTypes() []string
GetAllPluginTypes returns all plugin types which are configurable.
func LoadNewPersetPluginFuncs ¶
func LoadNewPersetPluginFuncs() map[string]NewPersetPluginFunc
func RegNewPersetPluginFunc ¶
func RegNewPersetPluginFunc(tag string, f NewPersetPluginFunc)
func RegNewPluginFunc ¶
func RegNewPluginFunc(typ string, initFunc NewPluginFunc, argsType NewPluginArgsFunc)
RegNewPluginFunc registers the type. If the type has been registered. RegNewPluginFunc will panic.
func StartServer ¶
func StartServer(sf *serverFlags) error
Types ¶
type BP ¶
type BP struct {
// contains filtered or unexported fields
}
BP represents a basic plugin, which implements Plugin. It also has an internal logger, for convenience.
func (*BP) GetMetricsReg ¶
func (p *BP) GetMetricsReg() prometheus.Registerer
GetMetricsReg return a prometheus.Registerer with a prefix of "plugin_${plugin_tag}_]"
func (*BP) S ¶
func (p *BP) S() *zap.SugaredLogger
type BadIPObserverConfig ¶ added in v4.3.0
type BadIPObserverConfig struct { Threshold int `yaml:"threshold"` // Zero Threshold will disable the bad ip observer. Interval int `yaml:"interval"` // (sec) Default is 10. TTL int `yaml:"ttl"` // (sec) Default is 600 (10min). OnUpdateCallBack string `yaml:"on_update_callback"` // IP masks to aggregate an IP range. IPv4Mask int `yaml:"ipv4_mask"` // Default is 32. IPv6Mask int `yaml:"ipv6_mask"` // Default is 48. }
BadIPObserverConfig is a copy of ip_observer.BadIPObserverOpts.
func (*BadIPObserverConfig) Init ¶ added in v4.3.0
func (c *BadIPObserverConfig) Init()
type Config ¶
type Config struct { Log mlog.LogConfig `yaml:"log"` Include []string `yaml:"include"` DataProviders []data_provider.DataProviderConfig `yaml:"data_providers"` Plugins []PluginConfig `yaml:"plugins"` Servers []ServerConfig `yaml:"servers"` API APIConfig `yaml:"api"` // Experimental Security SecurityConfig `yaml:"security"` }
type ExecutablePlugin ¶
type ExecutablePlugin interface { Plugin executable_seq.Executable }
ExecutablePlugin represents a Plugin that is Executable.
type MatcherPlugin ¶
type MatcherPlugin interface { Plugin executable_seq.Matcher }
MatcherPlugin represents a Plugin that is a Matcher.
type Mosdns ¶
type Mosdns struct {
// contains filtered or unexported fields
}
func (*Mosdns) GetBadIPObserver ¶ added in v4.3.0
func (m *Mosdns) GetBadIPObserver() ip_observer.IPObserver
GetBadIPObserver returns the ip_observer.BadIPObserver. It returns nil if is not enabled.
func (*Mosdns) GetDataManager ¶
func (m *Mosdns) GetDataManager() *data_provider.DataManager
func (*Mosdns) GetExecutables ¶
func (m *Mosdns) GetExecutables() map[string]executable_seq.Executable
func (*Mosdns) GetHTTPAPIMux ¶
GetHTTPAPIMux returns the api http.ServeMux. The pattern "/plugins/plugin_tag/" has been registered if Plugin implements http.Handler interface. Plugin caller should register path that has "/plugins/plugin_tag/" prefix only.
func (*Mosdns) GetMatchers ¶
func (m *Mosdns) GetMatchers() map[string]executable_seq.Matcher
func (*Mosdns) GetMetricsReg ¶ added in v4.2.0
func (m *Mosdns) GetMetricsReg() prometheus.Registerer
GetMetricsReg returns a prometheus.Registerer with a prefix of "mosdns_"
func (*Mosdns) GetSafeClose ¶
func (m *Mosdns) GetSafeClose() *safe_close.SafeClose
type NewPersetPluginFunc ¶
type NewPluginArgsFunc ¶
type NewPluginArgsFunc func() interface{}
NewPluginArgsFunc represents a func that creates a new args object.
type NewPluginFunc ¶
NewPluginFunc represents a func that can init a Plugin. args is the object created by NewPluginArgsFunc.
type PluginConfig ¶
type PluginConfig struct { // Tag, required Tag string `yaml:"tag"` // Type, required Type string `yaml:"type"` // Args, might be required by some plugins. // The type of Args is depended on RegNewPluginFunc. // If it's a map[string]interface{}, it will be converted by mapstruct. Args interface{} `yaml:"args"` }
PluginConfig represents a plugin config
type PluginTypeInfo ¶
type PluginTypeInfo struct { NewPlugin NewPluginFunc NewArgs NewPluginArgsFunc }
func GetPluginType ¶
func GetPluginType(typ string) (PluginTypeInfo, bool)
GetPluginType gets the registered type init func.
type SecurityConfig ¶ added in v4.3.0
type SecurityConfig struct {
BadIPObserver BadIPObserverConfig `yaml:"bad_ip_observer"`
}
type ServerConfig ¶
type ServerConfig struct { Exec string `yaml:"exec"` Timeout uint `yaml:"timeout"` // (sec) query timeout. Listeners []*ServerListenerConfig `yaml:"listeners"` }
type ServerListenerConfig ¶
type ServerListenerConfig struct { // Protocol: server protocol, can be: // "", "udp" -> udp // "tcp" -> tcp // "dot", "tls" -> dns over tls // "doh", "https" -> dns over https (rfc 8844) // "http" -> dns over https (rfc 8844) but without tls Protocol string `yaml:"protocol"` // Addr: server "host:port" addr. // Addr cannot be empty. Addr string `yaml:"addr"` Cert string `yaml:"cert"` // certificate path, used by dot, doh Key string `yaml:"key"` // certificate key path, used by dot, doh URLPath string `yaml:"url_path"` // used by doh, http. If it's empty, any path will be handled. GetUserIPFromHeader string `yaml:"get_user_ip_from_header"` // used by doh, http. ProxyProtocol bool `yaml:"proxy_protocol"` // accepting the PROXYProtocol IdleTimeout uint `yaml:"idle_timeout"` // (sec) used by tcp, dot, doh as connection idle timeout. }