handler

package
v0.0.0-...-4d64e5c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 27, 2021 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultHandlerTestConfig = DnsRequestHandlerConfig{
	Upstream: []upstream.Config{
		{
			Ip:       "1.1.1.1",
			Port:     53,
			Protocol: "udp",
			Timeout:  1000,
		},
	},
	GeoIp: geoip.Config{
		Enable:    true,
		CountryDB: "../../assets/geoCity.mmdb",
		ASNDB:     "../../assets/geoIsp.mmdb",
	},
}
View Source
var DefaultRedisDataTestConfig = storage.DataHandlerConfig{
	ZoneCacheSize:      10000,
	ZoneCacheTimeout:   60,
	ZoneReload:         60,
	RecordCacheSize:    1000000,
	RecordCacheTimeout: 60,
	MinTTL:             5,
	MaxTTL:             3600,
	Redis: hiredis.Config{
		Address:  "redis:6379",
		Net:      "tcp",
		DB:       0,
		Password: "",
		Prefix:   "test_",
		Suffix:   "_test",
		Connection: hiredis.ConnectionConfig{
			MaxIdleConnections:   10,
			MaxActiveConnections: 10,
			ConnectTimeout:       500,
			ReadTimeout:          500,
			IdleKeepAlive:        30,
			MaxKeepAlive:         0,
			WaitForConnection:    true,
		},
	},
}

Functions

func CenterText

func CenterText(s string, w int) string

func DefaultApplyAndVerify

func DefaultApplyAndVerify(testCase *TestCase, requestHandler *DnsRequestHandler, t *testing.T)

Types

type DnsRequestHandler

type DnsRequestHandler struct {
	Config    *DnsRequestHandlerConfig
	RedisData *storage.DataHandler
	// contains filtered or unexported fields
}

func DefaultInitialize

func DefaultInitialize(testCase *TestCase) (*DnsRequestHandler, error)

func NewHandler

func NewHandler(config *DnsRequestHandlerConfig, redisData *storage.DataHandler, requestLogger *zap.Logger) *DnsRequestHandler

func (*DnsRequestHandler) HandleRequest

func (h *DnsRequestHandler) HandleRequest(context *RequestContext)

func (*DnsRequestHandler) ShutDown

func (h *DnsRequestHandler) ShutDown()

type DnsRequestHandlerConfig

type DnsRequestHandlerConfig struct {
	Upstream          []upstream.Config `json:"upstream"`
	GeoIp             geoip.Config      `json:"geoip"`
	LogSourceLocation bool              `json:"log_source_location"`
}

type RequestContext

type RequestContext struct {
	request.Request
	StartTime time.Time
	Auth      bool
	Res       int

	Answer     []dns.RR
	Authority  []dns.RR
	Additional []dns.RR

	DomainUid     string
	SourceIp      net.IP
	SourceSubnet  string
	SourceCountry string
	SourceASN     uint
	// contains filtered or unexported fields
}

func NewRequestContext

func NewRequestContext(w dns.ResponseWriter, r *dns.Msg) *RequestContext

func (*RequestContext) RawName

func (context *RequestContext) RawName() string

func (*RequestContext) Response

func (context *RequestContext) Response()

type TestCase

type TestCase struct {
	Name            string
	Description     string
	Enabled         bool
	RedisDataConfig storage.DataHandlerConfig
	HandlerConfig   DnsRequestHandlerConfig
	Initialize      func(testCase *TestCase) (*DnsRequestHandler, error)
	ApplyAndVerify  func(testCase *TestCase, handler *DnsRequestHandler, t *testing.T)
	Zones           []string
	ZoneConfigs     []string
	Entries         [][][]string
	TestCases       []test.Case
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL