Documentation ¶
Index ¶
- Constants
- func GetAllPluginTag() []string
- func GetConfigurablePluginTypes() []string
- func InitAndRegPlugin(c *Config) (err error)
- func MustRegPlugin(p Plugin)
- func NewErrFromTemplate(t ErrTemplate, args ...interface{}) error
- func PluginFatalErr(tag string, msg string)
- func PurgePluginRegister()
- func RegInitFunc(pluginType string, initFunc NewPluginFunc)
- func RegPlugin(p Plugin) error
- func WeakDecode(in map[string]interface{}, output interface{}) error
- type Config
- type Context
- type ContextPlugin
- type ContextStatus
- type DefaultServerHandler
- type DefaultServerHandlerConfig
- type DummyExecutable
- type DummyMatcher
- type DummyServerHandler
- type ErrTemplate
- type Error
- type Executable
- type ExecutableCmd
- type ExecutableCmdSequence
- type ExecutablePlugin
- type ExecutablePluginWrapper
- type IfBlockConfig
- type Matcher
- type MatcherPlugin
- type MatcherPluginWrapper
- type NewPluginFunc
- type PipeContext
- type Plugin
- type ResponseWriter
- type ServerHandler
Constants ¶
const ( ETInvalidArgs = "invalid args: %w" ETTypeNotDefined = "plugin type %s not defined" ETTagNotDefined = "plugin tag %s not defined" )
Variables ¶
This section is empty.
Functions ¶
func GetAllPluginTag ¶ added in v0.15.0
func GetAllPluginTag() []string
func GetConfigurablePluginTypes ¶ added in v0.15.0
func GetConfigurablePluginTypes() []string
GetConfigurablePluginTypes returns all plugin types which are configurable.
func InitAndRegPlugin ¶ added in v0.10.0
InitAndRegPlugin inits and registers this plugin globally. Duplicate plugin tags are not allowed.
func MustRegPlugin ¶ added in v0.14.0
func MustRegPlugin(p Plugin)
MustRegPlugin: see RegPlugin. MustRegPlugin will panic if err.
func NewErrFromTemplate ¶ added in v0.12.0
func NewErrFromTemplate(t ErrTemplate, args ...interface{}) error
func PluginFatalErr ¶ added in v0.16.0
PluginFatalErr: If a plugin has a fatal err, call this.
func PurgePluginRegister ¶ added in v0.12.0
func PurgePluginRegister()
PurgePluginRegister should only be used in test.
func RegInitFunc ¶
func RegInitFunc(pluginType string, initFunc NewPluginFunc)
RegInitFunc registers this plugin type. This should only be called in init() of the plugin package. Duplicate plugin types are not allowed.
func RegPlugin ¶
RegPlugin registers this Plugin globally. Duplicate Plugin tag will cause an error.
func WeakDecode ¶ added in v0.13.0
WeakDecode decodes args from config to output.
Types ¶
type Context ¶
type Context struct { Q *dns.Msg From net.Addr Status ContextStatus R *dns.Msg // contains filtered or unexported fields }
Context is a query context that pass through plugins A Context will always have a non-nil Q. Context MUST be created by NewContext.
func NewContext ¶ added in v0.17.1
func (*Context) SetResponse ¶ added in v0.21.0
func (ctx *Context) SetResponse(r *dns.Msg, status ContextStatus)
type ContextPlugin ¶ added in v0.19.1
type ContextPlugin interface { Plugin // Connect connects this ContextPlugin to its predecessor. Connect(ctx context.Context, qCtx *Context, pipeCtx *PipeContext) (err error) }
ContextPlugin
func GetContextPlugin ¶ added in v0.19.1
func GetContextPlugin(tag string) (p ContextPlugin, err error)
type ContextStatus ¶ added in v0.21.0
type ContextStatus uint8
const ( ContextStatusWaitingResponse ContextStatus = iota ContextStatusResponded ContextStatusServerFailed ContextStatusDropped ContextStatusRejected )
func (ContextStatus) String ¶ added in v0.21.0
func (status ContextStatus) String() string
type DefaultServerHandler ¶ added in v0.15.0
type DefaultServerHandler struct {
// contains filtered or unexported fields
}
func NewDefaultServerHandler ¶ added in v0.21.0
func NewDefaultServerHandler(config *DefaultServerHandlerConfig) *DefaultServerHandler
NewDefaultServerHandler: concurrentLimit <= 0 means no concurrent limit. Also see DefaultServerHandler.ServeDNS.
func (*DefaultServerHandler) ServeDNS ¶ added in v0.15.0
func (h *DefaultServerHandler) ServeDNS(ctx context.Context, qCtx *Context, w ResponseWriter)
ServeDNS: If entry returns an err, a SERVFAIL response will be sent back to client. If concurrentLimit is reached, the query will block and wait available token until ctx is done.
type DefaultServerHandlerConfig ¶ added in v0.21.0
type DefaultServerHandlerConfig struct { // Logger is used for logging, it cannot be nil. Logger *logrus.Entry // Entry is the entry ExecutablePlugin's tag. This shouldn't be empty. Entry string // ConcurrentLimit controls the max concurrent queries. // If ConcurrentLimit <= 0, means no limit. ConcurrentLimit int }
type DummyExecutable ¶ added in v0.19.1
type DummyExecutable struct {
WantErr error
}
type DummyMatcher ¶ added in v0.10.0
type DummyServerHandler ¶ added in v0.16.0
func (*DummyServerHandler) ServeDNS ¶ added in v0.16.0
func (d *DummyServerHandler) ServeDNS(_ context.Context, qCtx *Context, w ResponseWriter)
type ErrTemplate ¶ added in v0.12.0
type ErrTemplate string
type Error ¶ added in v0.12.0
type Error struct {
// contains filtered or unexported fields
}
func NewPluginError ¶ added in v0.19.1
type Executable ¶ added in v0.19.1
type ExecutableCmd ¶ added in v0.20.0
type ExecutableCmdSequence ¶ added in v0.20.0
type ExecutableCmdSequence []ExecutableCmd
func NewExecutableCmdSequence ¶ added in v0.20.0
func NewExecutableCmdSequence() *ExecutableCmdSequence
func (*ExecutableCmdSequence) Exec ¶ added in v0.20.0
func (es *ExecutableCmdSequence) Exec(ctx context.Context, qCtx *Context, logger *logrus.Entry) (err error)
Exec executes the sequence, include its `goto`.
func (*ExecutableCmdSequence) ExecCmd ¶ added in v0.20.0
func (es *ExecutableCmdSequence) ExecCmd(ctx context.Context, qCtx *Context, logger *logrus.Entry) (goTwo string, err error)
ExecCmd executes the sequence.
func (*ExecutableCmdSequence) Parse ¶ added in v0.20.0
func (es *ExecutableCmdSequence) Parse(in []interface{}) error
type ExecutablePlugin ¶ added in v0.19.1
type ExecutablePlugin interface { Plugin Executable }
func GetExecutablePlugin ¶ added in v0.19.1
func GetExecutablePlugin(tag string) (p ExecutablePlugin, err error)
type ExecutablePluginWrapper ¶ added in v0.19.1
type ExecutablePluginWrapper struct { Executable // contains filtered or unexported fields }
func WrapExecutablePlugin ¶ added in v0.19.1
func WrapExecutablePlugin(tag, typ string, executable Executable) *ExecutablePluginWrapper
WrapExecutablePlugin returns a *ExecutablePluginWrapper which implements Plugin and ExecutablePlugin.
func (*ExecutablePluginWrapper) Tag ¶ added in v0.19.1
func (p *ExecutablePluginWrapper) Tag() string
func (*ExecutablePluginWrapper) Type ¶ added in v0.19.1
func (p *ExecutablePluginWrapper) Type() string
type IfBlockConfig ¶ added in v0.20.0
type MatcherPlugin ¶ added in v0.10.0
func GetMatcherPlugin ¶ added in v0.10.0
func GetMatcherPlugin(tag string) (p MatcherPlugin, err error)
type MatcherPluginWrapper ¶ added in v0.10.0
type MatcherPluginWrapper struct { Matcher // contains filtered or unexported fields }
func WrapMatcherPlugin ¶ added in v0.10.0
func WrapMatcherPlugin(tag, typ string, matcher Matcher) *MatcherPluginWrapper
WrapMatcherPlugin returns a *MatcherPluginWrapper which implements Plugin and MatcherPlugin.
func (*MatcherPluginWrapper) Tag ¶ added in v0.10.0
func (c *MatcherPluginWrapper) Tag() string
func (*MatcherPluginWrapper) Type ¶ added in v0.10.0
func (c *MatcherPluginWrapper) Type() string
type NewPluginFunc ¶
type PipeContext ¶ added in v0.17.1
type PipeContext struct {
// contains filtered or unexported fields
}
func NewPipeContext ¶ added in v0.17.1
func NewPipeContext(s []string, logger *logrus.Entry) *PipeContext
func (*PipeContext) ExecNextPlugin ¶ added in v0.17.1
func (c *PipeContext) ExecNextPlugin(ctx context.Context, qCtx *Context) error
type ResponseWriter ¶ added in v0.15.0
ResponseWriter can write msg to the client.
type ServerHandler ¶ added in v0.15.0
type ServerHandler interface { // ServeDNS uses ctx to control deadline, exchanges qCtx, and writes response to w. ServeDNS(ctx context.Context, qCtx *Context, w ResponseWriter) }