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 Config
- type ExecutablePlugin
- type MatcherPlugin
- type Mosdns
- 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) GetPluginMetricsReg() *metrics.Registry
- func (m *Mosdns) GetSafeClose() *safe_close.SafeClose
- func (m *Mosdns) GetServerMetricsReg() *metrics.Registry
- type NewPersetPluginFunc
- type NewPluginArgsFunc
- type NewPluginFunc
- type Plugin
- type PluginConfig
- type PluginTypeInfo
- 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 ¶
BP represents a basic plugin, which implements Plugin. It also has an internal logger, for convenience.
func (*BP) GetMetricsReg ¶
func (*BP) S ¶
func (p *BP) S() *zap.SugaredLogger
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"` }
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) 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) GetPluginMetricsReg ¶
func (*Mosdns) GetSafeClose ¶
func (m *Mosdns) GetSafeClose() *safe_close.SafeClose
func (*Mosdns) GetServerMetricsReg ¶
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 Args map[string]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 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. IdleTimeout uint `yaml:"idle_timeout"` // (sec) used by tcp, dot, doh as connection idle timeout. }