Documentation ¶
Index ¶
- Variables
- func CreateNewHandlerCtx() context.Context
- func IsNoCache(ctx context.Context) bool
- func LogMsgWithPrefix(prefixKey, prefixVal string, ctx context.Context, msg *dns.Msg) error
- func LogRfc8427Style(ctx context.Context, msg *dns.Msg) error
- func LogRfc8427StyleWithPrefix(prefixKey, prefixVal string, ctx context.Context, msg *dns.Msg) error
- func LogTextStyle(ctx context.Context, msg *dns.Msg) error
- func PrintPluginHelp(pluginName string, config interface{}, out io.Writer)
- func PrintPlugins[P Plugin](out io.Writer)
- func QueryCtx(ctx context.Context) context.Context
- func QueryMetadata(ctx context.Context) map[string]interface{}
- func RegisterPlugin(plugin Plugin)
- func ResponseCtx(ctx context.Context) context.Context
- func ResponseMetadata(ctx context.Context) map[string]interface{}
- func RunForAllPlugins(f func(p Plugin) error) error
- func SetNoCache(ctx context.Context, val bool)
- func UnmarshalConfiguration(config map[string]interface{}, v interface{}) error
- type CacheKeyFunc
- type CachePlugin
- func (c *CachePlugin) Configure(ctx context.Context, config map[string]interface{}) error
- func (q *CachePlugin) Name() string
- func (c *CachePlugin) PrintHelp(out io.Writer)
- func (c *CachePlugin) Query(ctx context.Context, msg *dns.Msg) error
- func (c *CachePlugin) Response(ctx context.Context, msg *dns.Msg) error
- func (c *CachePlugin) StartClient(ctx context.Context, handler Handler) error
- func (c *CachePlugin) StopClient(ctx context.Context) error
- type CachePluginConfig
- type DO53ClientPlugin
- func (d *DO53ClientPlugin) Configure(ctx context.Context, config map[string]interface{}) error
- func (d *DO53ClientPlugin) Name() string
- func (d *DO53ClientPlugin) PrintHelp(out io.Writer)
- func (d *DO53ClientPlugin) Query(ctx context.Context, msg *dns.Msg) error
- func (d *DO53ClientPlugin) StartClient(ctx context.Context, handler Handler) error
- func (d *DO53ClientPlugin) StopClient(ctx context.Context) error
- type DO53ClientPluginConfig
- type DO53GnetServerPlugin
- func (d *DO53GnetServerPlugin) Configure(ctx context.Context, config map[string]interface{}) error
- func (d *DO53GnetServerPlugin) ListenTCP() error
- func (d *DO53GnetServerPlugin) ListenUDP() error
- func (d *DO53GnetServerPlugin) Name() string
- func (d *DO53GnetServerPlugin) OnBoot(eng gnet.Engine) (action gnet.Action)
- func (d *DO53GnetServerPlugin) OnClose(c gnet.Conn, err error) (action gnet.Action)
- func (d *DO53GnetServerPlugin) OnOpen(c gnet.Conn) (out []byte, action gnet.Action)
- func (d *DO53GnetServerPlugin) OnShutdown(eng gnet.Engine)
- func (d *DO53GnetServerPlugin) OnTick() (delay time.Duration, action gnet.Action)
- func (d *DO53GnetServerPlugin) OnTraffic(c gnet.Conn) (action gnet.Action)
- func (d *DO53GnetServerPlugin) PrintHelp(out io.Writer)
- func (d *DO53GnetServerPlugin) Response(ctx context.Context, msg *dns.Msg) error
- func (d *DO53GnetServerPlugin) StartServer(sctx context.Context, handler Handler) error
- func (d *DO53GnetServerPlugin) StopServer(ctx context.Context) error
- type DO53GnetServerPluginConfig
- type DO53ServerPlugin
- func (d *DO53ServerPlugin) Configure(ctx context.Context, config map[string]interface{}) error
- func (d *DO53ServerPlugin) ListenTCP() (*dns.Server, error)
- func (d *DO53ServerPlugin) ListenUDP() (*dns.Server, error)
- func (d *DO53ServerPlugin) Name() string
- func (d *DO53ServerPlugin) PrintHelp(out io.Writer)
- func (d *DO53ServerPlugin) Response(ctx context.Context, msg *dns.Msg) error
- func (d *DO53ServerPlugin) StartServer(sctx context.Context, handler Handler) error
- func (d *DO53ServerPlugin) StopServer(ctx context.Context) error
- type DO53ServerPluginConfig
- type Handler
- type HandlerFunc
- type MemoryPlugin
- type MemoryPluginConfig
- type MetricsPlugin
- type MetricsPluginConfig
- type Plugin
- type ProtocolClientPlugin
- type ProtocolServerPlugin
- type QueryLoggerPlugin
- func (q *QueryLoggerPlugin) Configure(ctx context.Context, config map[string]interface{}) error
- func (q *QueryLoggerPlugin) Name() string
- func (q *QueryLoggerPlugin) PrintHelp(out io.Writer)
- func (q *QueryLoggerPlugin) Query(ctx context.Context, msg *dns.Msg) error
- func (q *QueryLoggerPlugin) Response(ctx context.Context, msg *dns.Msg) error
- type QueryLoggerPluginConfig
- type QueryPlugin
- type ReconfigurablePlugin
- type ResponsePlugin
Constants ¶
This section is empty.
Variables ¶
var (
ErrBreakProcessing = errors.New("processing stopped")
)
Functions ¶
func CreateNewHandlerCtx ¶
func LogMsgWithPrefix ¶
func LogRfc8427StyleWithPrefix ¶
func LogRfc8427StyleWithPrefix(prefixKey, prefixVal string, ctx context.Context, msg *dns.Msg) error
This version is significantly slower (~6x) than the text-based version
func PrintPluginHelp ¶
Add a "comment" tag to the plugin configuration struct to provide help
func PrintPlugins ¶
func QueryMetadata ¶
func ResponseMetadata ¶
func RunForAllPlugins ¶
func SetNoCache ¶
func UnmarshalConfiguration ¶
Types ¶
type CachePlugin ¶
type CachePlugin struct { CacheKey CacheKeyFunc // contains filtered or unexported fields }
func (*CachePlugin) Configure ¶
func (c *CachePlugin) Configure(ctx context.Context, config map[string]interface{}) error
Configure the plugin.
func (*CachePlugin) Name ¶
func (q *CachePlugin) Name() string
func (*CachePlugin) PrintHelp ¶
func (c *CachePlugin) PrintHelp(out io.Writer)
PrintHelp prints the configuration help for the plugin.
func (*CachePlugin) StartClient ¶
func (c *CachePlugin) StartClient(ctx context.Context, handler Handler) error
Start the protocol plugin.
func (*CachePlugin) StopClient ¶
func (c *CachePlugin) StopClient(ctx context.Context) error
Stop the protocol plugin.
type CachePluginConfig ¶
type CachePluginConfig struct { MaxElements int `toml:"maxElements" comment:"Max Elements in cache" default:"1000"` MaxStaleElements int `toml:"maxStaleElements" comment:"Max Elements in stale cache" default:"10000"` StaleDuration time.Duration `toml:"staleDuration" comment:"Duration of stale cache" default:"24h"` StaleCache bool `toml:"staleCache" comment:"Enable Stale Caching" default:"false"` StaleTTL time.Duration `toml:"staleTTL" comment:"Max TTL of record for a Stale Cache response" default:"30s"` NegativeAnswers bool `toml:"negativeAnswers" comment:"Enable Negative Answers Caching" default:"false"` }
type DO53ClientPlugin ¶
type DO53ClientPlugin struct {
// contains filtered or unexported fields
}
func (*DO53ClientPlugin) Configure ¶
func (d *DO53ClientPlugin) Configure(ctx context.Context, config map[string]interface{}) error
Configure the plugin.
func (*DO53ClientPlugin) Name ¶
func (d *DO53ClientPlugin) Name() string
func (*DO53ClientPlugin) PrintHelp ¶
func (d *DO53ClientPlugin) PrintHelp(out io.Writer)
PrintHelp prints the configuration help for the plugin.
func (*DO53ClientPlugin) StartClient ¶
func (d *DO53ClientPlugin) StartClient(ctx context.Context, handler Handler) error
Start the protocol plugin.
func (*DO53ClientPlugin) StopClient ¶
func (d *DO53ClientPlugin) StopClient(ctx context.Context) error
func createTCPConn() *net.TCPConn { lAddr, err := net.ResolveTCPAddr(tcpProto, ":0") if err != nil { log.Error().Err(err).Msg("ResolveTCPAddr failed") } conn, err := net.ListenTCP(tcpProto, lAddr) if err != nil { log.Error().Err(err).Msg("ListenTCP failed") } return conn }
Stop the protocol plugin.
type DO53ClientPluginConfig ¶
type DO53ClientPluginConfig struct { AlwaysRetryOverTcp bool `toml:"alwaysRetryOverTCP" comment:"Always Retry a Failed UDP Query over TCP" default:"true"` Upstream []string `toml:"upstream" comment:"Address and Port of upstream nameserver"` UdpConnPoolSize int `toml:"udpConnectionPoolSize" comment:"UDP Connection Pool Size" default:"8000"` Timeout string `toml:"timeout" comment:"Timeout duration" default:"2s"` // contains filtered or unexported fields }
type DO53GnetServerPlugin ¶
type DO53GnetServerPlugin struct {
// contains filtered or unexported fields
}
func (*DO53GnetServerPlugin) Configure ¶
func (d *DO53GnetServerPlugin) Configure(ctx context.Context, config map[string]interface{}) error
Configure the plugin.
func (*DO53GnetServerPlugin) ListenTCP ¶
func (d *DO53GnetServerPlugin) ListenTCP() error
func (*DO53GnetServerPlugin) ListenUDP ¶
func (d *DO53GnetServerPlugin) ListenUDP() error
func (*DO53GnetServerPlugin) Name ¶
func (d *DO53GnetServerPlugin) Name() string
func (*DO53GnetServerPlugin) OnBoot ¶
func (d *DO53GnetServerPlugin) OnBoot(eng gnet.Engine) (action gnet.Action)
Gnet Events
func (*DO53GnetServerPlugin) OnClose ¶
func (d *DO53GnetServerPlugin) OnClose(c gnet.Conn, err error) (action gnet.Action)
func (*DO53GnetServerPlugin) OnOpen ¶
func (d *DO53GnetServerPlugin) OnOpen(c gnet.Conn) (out []byte, action gnet.Action)
func (*DO53GnetServerPlugin) OnShutdown ¶
func (d *DO53GnetServerPlugin) OnShutdown(eng gnet.Engine)
func (*DO53GnetServerPlugin) OnTick ¶
func (d *DO53GnetServerPlugin) OnTick() (delay time.Duration, action gnet.Action)
func (*DO53GnetServerPlugin) OnTraffic ¶
func (d *DO53GnetServerPlugin) OnTraffic(c gnet.Conn) (action gnet.Action)
func (*DO53GnetServerPlugin) PrintHelp ¶
func (d *DO53GnetServerPlugin) PrintHelp(out io.Writer)
PrintHelp prints the configuration help for the plugin.
func (*DO53GnetServerPlugin) StartServer ¶
func (d *DO53GnetServerPlugin) StartServer(sctx context.Context, handler Handler) error
Start the protocol plugin.
func (*DO53GnetServerPlugin) StopServer ¶
func (d *DO53GnetServerPlugin) StopServer(ctx context.Context) error
Stop the protocol plugin.
type DO53GnetServerPluginConfig ¶
type DO53GnetServerPluginConfig struct { Listen string `toml:"listen" comment:"Listen Address and Port" default:"53"` PoolSizeTCP int `toml:"tcpPoolSize" comment:"Worker Pool Size" default:"10"` PoolSizeUDP int `toml:"udpPoolSize" comment:"Worker Pool Size" default:"10"` TcpEventLoopCount int `toml:"tcpEventLoopCount" comment:"Count of TCP Event Loops"` UdpEventLoopCount int `toml:"udpEventLoopCount" comment:"Count of TCP Event Loops"` TcpBufferSize int `toml:"tcpBufferSize" comment:"Size TCP socket buffers" default:"10240"` UdpBufferSize int `toml:"udpBufferSize" comment:"Size UDP socket buffers" default:"10240"` MaxQueriesPerTCP int `toml:"maxQueriesPerTCPStream" comment:"Size UDP socket buffers" default:"50"` TcpKeepAlive time.Duration `toml:"tcpKeepAlive" comment:"time to maintain tcp keep-alive" default:"10s"` EnableLogging bool `toml:"enableLogging" comment:"Enable Logging on gnet" default:"false"` }
type DO53ServerPlugin ¶
type DO53ServerPlugin struct {
// contains filtered or unexported fields
}
func (*DO53ServerPlugin) Configure ¶
func (d *DO53ServerPlugin) Configure(ctx context.Context, config map[string]interface{}) error
Configure the plugin.
func (*DO53ServerPlugin) Name ¶
func (d *DO53ServerPlugin) Name() string
func (*DO53ServerPlugin) PrintHelp ¶
func (d *DO53ServerPlugin) PrintHelp(out io.Writer)
PrintHelp prints the configuration help for the plugin.
func (*DO53ServerPlugin) StartServer ¶
func (d *DO53ServerPlugin) StartServer(sctx context.Context, handler Handler) error
Start the protocol plugin.
func (*DO53ServerPlugin) StopServer ¶
func (d *DO53ServerPlugin) StopServer(ctx context.Context) error
Stop the protocol plugin.
type DO53ServerPluginConfig ¶
type HandlerFunc ¶
type MemoryPlugin ¶
type MemoryPlugin struct {
// contains filtered or unexported fields
}
func (*MemoryPlugin) Configure ¶
func (m *MemoryPlugin) Configure(ctx context.Context, config map[string]interface{}) (err error)
Configure the plugin.
func (*MemoryPlugin) Name ¶
func (m *MemoryPlugin) Name() string
func (*MemoryPlugin) PrintHelp ¶
func (c *MemoryPlugin) PrintHelp(out io.Writer)
PrintHelp prints the configuration help for the plugin.
type MemoryPluginConfig ¶
type MemoryPluginConfig struct { Cap string `toml:"cap" comment:"Cap Memory Use, either size (10MB) or % of available" default:"0b"` // contains filtered or unexported fields }
type MetricsPlugin ¶
type MetricsPlugin struct {
// contains filtered or unexported fields
}
func (*MetricsPlugin) Configure ¶
func (c *MetricsPlugin) Configure(ctx context.Context, config map[string]interface{}) error
Configure the plugin.
func (*MetricsPlugin) Name ¶
func (q *MetricsPlugin) Name() string
func (*MetricsPlugin) PrintHelp ¶
func (c *MetricsPlugin) PrintHelp(out io.Writer)
PrintHelp prints the configuration help for the plugin.
func (*MetricsPlugin) StartHttpEndpoint ¶
func (c *MetricsPlugin) StartHttpEndpoint()
type MetricsPluginConfig ¶
type MetricsPluginConfig struct {
Port int `toml:"port" comment:"Metrics HTTP Port" default:"8080"`
}
type Plugin ¶
type Plugin interface { Name() string // PrintHelp prints the configuration help for the plugin. PrintHelp(out io.Writer) // Configure the plugin. Configure(ctx context.Context, config map[string]interface{}) error }
Plugin is a DNS plugin
type ProtocolClientPlugin ¶
type ProtocolClientPlugin interface { QueryPlugin // Start the protocol plugin. StartClient(ctx context.Context, handler Handler) error // Stop the protocol plugin. StopClient(ctx context.Context) error }
func GetClientPlugins ¶
func GetClientPlugins() []ProtocolClientPlugin
type ProtocolServerPlugin ¶
type ProtocolServerPlugin interface { ResponsePlugin // Start the protocol plugin. StartServer(ctx context.Context, handler Handler) error // Stop the protocol plugin. StopServer(ctx context.Context) error }
ProtocolPlugin is a plugin that handles DNS protocol specific logic.
func GetServerPlugins ¶
func GetServerPlugins() []ProtocolServerPlugin
type QueryLoggerPlugin ¶
type QueryLoggerPlugin struct {
// contains filtered or unexported fields
}
func (*QueryLoggerPlugin) Configure ¶
func (q *QueryLoggerPlugin) Configure(ctx context.Context, config map[string]interface{}) error
Configure the plugin.
func (*QueryLoggerPlugin) Name ¶
func (q *QueryLoggerPlugin) Name() string
func (*QueryLoggerPlugin) PrintHelp ¶
func (q *QueryLoggerPlugin) PrintHelp(out io.Writer)
PrintHelp prints the configuration help for the plugin.
type QueryLoggerPluginConfig ¶
type QueryLoggerPluginConfig struct { Format string `toml:"format" comment:"Query logging format (text, rfc8427)" default:"text"` // contains filtered or unexported fields }
type QueryPlugin ¶
type QueryPlugin interface { Plugin // Process a Query before it is sent to the upstream server. Query(ctx context.Context, msg *dns.Msg) error }
func GetQueryPlugins ¶
func GetQueryPlugins() []QueryPlugin
type ReconfigurablePlugin ¶
type ResponsePlugin ¶
type ResponsePlugin interface { Plugin // Process a Response from the upstream server. Response(ctx context.Context, msg *dns.Msg) error }
func GetResponsePlugins ¶
func GetResponsePlugins() []ResponsePlugin