From ee8f0419381db9afa008f7d8d395852a8d2458a9 Mon Sep 17 00:00:00 2001 From: Dimitri Herzog Date: Thu, 9 Sep 2021 22:57:05 +0200 Subject: [PATCH] refactoring: generate enums --- Makefile | 6 + api/api_suite_test.go | 2 +- cmd/serve_test.go | 2 +- codecov.yml | 1 + config/config.go | 103 +++++------ config/config_enum.go | 172 ++++++++++++++++++ config/config_suite_test.go | 2 +- config/config_test.go | 57 ++---- go.mod | 34 +++- go.sum | 73 ++++++++ lists/list_cache.go | 22 +-- lists/list_cache_enum.go | 77 ++++++++ lists/list_cache_test.go | 24 +-- lists/list_suite_test.go | 2 +- log/logger.go | 38 ++-- log/logger_enum.go | 160 ++++++++++++++++ metrics/metrics_event_publisher.go | 4 +- model/models.go | 58 ++---- model/models_enum.go | 160 ++++++++++++++++ querylog/database_writer_test.go | 4 +- querylog/file_writer_test.go | 12 +- querylog/logger_writer_test.go | 2 +- querylog/querylog_suite_test.go | 2 +- resolver/blocking_resolver.go | 6 +- resolver/blocking_resolver_test.go | 42 ++--- resolver/caching_resolver.go | 4 +- resolver/caching_resolver_test.go | 28 +-- resolver/client_names_resolver_test.go | 2 +- resolver/conditionall_upstream_resolver.go | 2 +- .../conditionall_upstream_resolver_test.go | 8 +- resolver/custom_dns_resolver.go | 6 +- resolver/ipv6_disabling_resolver.go | 2 +- resolver/mocks.go | 2 +- resolver/parallel_best_resolver_test.go | 18 +- resolver/query_logging_resolver.go | 8 +- resolver/query_logging_resolver_test.go | 16 +- resolver/resolver.go | 4 +- resolver/resolver_suite_test.go | 2 +- resolver/stats_resolver.go | 2 +- resolver/upstream_resolver.go | 10 +- resolver/upstream_resolver_test.go | 12 +- server/server.go | 8 +- server/server_endpoints.go | 2 +- server/server_suite_test.go | 2 +- server/server_test.go | 15 +- stats/stats_suite_test.go | 2 +- util/bootstrap.go | 2 +- util/bootstrap_test.go | 4 +- util/util_suite_test.go | 2 +- 49 files changed, 916 insertions(+), 312 deletions(-) create mode 100644 config/config_enum.go create mode 100644 lists/list_cache_enum.go create mode 100644 log/logger_enum.go create mode 100644 model/models_enum.go diff --git a/Makefile b/Makefile index d48851bb7..9984f69bb 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,5 @@ +#!/usr/bin/env bash + .PHONY: all clean build swagger test lint run help .DEFAULT_GOAL := help @@ -7,6 +9,8 @@ DOCKER_IMAGE_NAME="spx01/blocky" BINARY_NAME=blocky BIN_OUT_DIR=bin +export PATH=$(shell go env GOPATH)/bin:$(shell echo $$PATH) + all: test lint build ## Build binary (with tests) clean: ## cleans output directory @@ -23,6 +27,8 @@ serve_docs: ## serves online docs mkdocs serve build: ## Build binary + go install github.com/abice/go-enum + go generate ./... go build -v -ldflags="-w -s -X github.com/0xERR0R/blocky/util.Version=${VERSION} -X github.com/0xERR0R/blocky/util.BuildTime=${BUILD_TIME}" -o $(BIN_OUT_DIR)/$(BINARY_NAME)$(BINARY_SUFFIX) test: ## run tests diff --git a/api/api_suite_test.go b/api/api_suite_test.go index e57150991..e9ea295c3 100644 --- a/api/api_suite_test.go +++ b/api/api_suite_test.go @@ -9,7 +9,7 @@ import ( ) func TestResolver(t *testing.T) { - ConfigureLogger("Warn", "text", true) + ConfigureLogger(LevelFatal, FormatTypeText, true) RegisterFailHandler(Fail) RunSpecs(t, "API Suite") } diff --git a/cmd/serve_test.go b/cmd/serve_test.go index e0f177266..3c66661a1 100644 --- a/cmd/serve_test.go +++ b/cmd/serve_test.go @@ -12,7 +12,7 @@ var _ = Describe("Serve command", func() { When("Serve command is called", func() { It("should start DNS server", func() { config.GetConfig().BootstrapDNS = config.Upstream{ - Net: "tcp+udp", + Net: config.NetProtocolTcpTls, Host: "1.1.1.1", Port: 53, } diff --git a/codecov.yml b/codecov.yml index 8cb21aad2..729cff401 100644 --- a/codecov.yml +++ b/codecov.yml @@ -1,2 +1,3 @@ ignore: - "resolver/mocks.go" + - "**/*_enum.go" diff --git a/config/config.go b/config/config.go index 7ce87db1a..cad18a07b 100644 --- a/config/config.go +++ b/config/config.go @@ -1,3 +1,4 @@ +//go:generate go-enum -f=$GOFILE --marshal --names package config import ( @@ -15,38 +16,37 @@ import ( "gopkg.in/yaml.v2" ) +// NetProtocol resolver protocol ENUM( +// udp // Deprecated: use tcp+udp instead +// tcp // Deprecated: use tcp+udp instead +// tcp+udp // TCP and UDP protocols +// tcp-tls // TCP-TLS protocol +// https // HTTPS protocol +// ) +type NetProtocol uint16 + +// QueryLogType type of the query log ENUM( +// none // use logger as fallback +// mysql // MySQL or MariaDB database +// csv // CSV file per day +// csv-client // CSV file per day and client +// ) +type QueryLogType int16 + const ( validUpstream = `(?P(?:\[[^\]]+\])|[^\s/:]+):?(?P[^\s/:]*)?(?P/[^\s]*)?` - // NetUDP UDP protocol (deprecated) - NetUDP = "udp" - - // NetTCP TCP protocol (deprecated) - NetTCP = "tcp" - - // NetTCPUDP TCP and UDP protocols - NetTCPUDP = "tcp+udp" - - // NetTCPTLS TCP-TLS protocol - NetTCPTLS = "tcp-tls" - - // NetHTTPS HTTPS protocol - NetHTTPS = "https" - - QueryLogTypeMySQL = "mysql" - QueryLogTypeCSV = "csv" - QueryLogTypeCSVPerClient = "csv-client" ) // nolint:gochecknoglobals -var netDefaultPort = map[string]uint16{ - NetTCPUDP: 53, - NetTCPTLS: 853, - NetHTTPS: 443, +var netDefaultPort = map[NetProtocol]uint16{ + NetProtocolTcpUdp: 53, + NetProtocolTcpTls: 853, + NetProtocolHttps: 443, } // Upstream is the definition of external DNS server type Upstream struct { - Net string + Net NetProtocol Host string Port uint16 Path string @@ -133,7 +133,7 @@ func ParseUpstream(upstream string) (result Upstream, err error) { return Upstream{}, nil } - var n string + var n NetProtocol n, upstream = extractNet(upstream) @@ -168,31 +168,31 @@ func ParseUpstream(upstream string) (result Upstream, err error) { return Upstream{Net: n, Host: host, Port: port, Path: path}, nil } -func extractNet(upstream string) (string, string) { - if strings.HasPrefix(upstream, NetTCP+":") { +func extractNet(upstream string) (NetProtocol, string) { + if strings.HasPrefix(upstream, NetProtocolTcp.String()+":") { log.Log().Warnf("net prefix tcp is deprecated, using tcp+udp as default fallback") - return NetTCPUDP, strings.Replace(upstream, NetTCP+":", "", 1) + return NetProtocolTcpUdp, strings.Replace(upstream, NetProtocolTcp.String()+":", "", 1) } - if strings.HasPrefix(upstream, NetUDP+":") { + if strings.HasPrefix(upstream, NetProtocolUdp.String()+":") { log.Log().Warnf("net prefix udp is deprecated, using tcp+udp as default fallback") - return NetTCPUDP, strings.Replace(upstream, NetUDP+":", "", 1) + return NetProtocolTcpUdp, strings.Replace(upstream, NetProtocolUdp.String()+":", "", 1) } - if strings.HasPrefix(upstream, NetTCPUDP+":") { - return NetTCPUDP, strings.Replace(upstream, NetTCPUDP+":", "", 1) + if strings.HasPrefix(upstream, NetProtocolTcpUdp.String()+":") { + return NetProtocolTcpUdp, strings.Replace(upstream, NetProtocolTcpUdp.String()+":", "", 1) } - if strings.HasPrefix(upstream, NetTCPTLS+":") { - return NetTCPTLS, strings.Replace(upstream, NetTCPTLS+":", "", 1) + if strings.HasPrefix(upstream, NetProtocolTcpTls.String()+":") { + return NetProtocolTcpTls, strings.Replace(upstream, NetProtocolTcpTls.String()+":", "", 1) } - if strings.HasPrefix(upstream, NetHTTPS+":") { - return NetHTTPS, strings.Replace(upstream, NetHTTPS+":", "", 1) + if strings.HasPrefix(upstream, NetProtocolHttps.String()+":") { + return NetProtocolHttps, strings.Replace(upstream, NetProtocolHttps.String()+":", "", 1) } - return NetTCPUDP, upstream + return NetProtocolTcpUdp, upstream } const ( @@ -211,8 +211,8 @@ type Config struct { Caching CachingConfig `yaml:"caching"` QueryLog QueryLogConfig `yaml:"queryLog"` Prometheus PrometheusConfig `yaml:"prometheus"` - LogLevel string `yaml:"logLevel"` - LogFormat string `yaml:"logFormat"` + LogLevel log.Level `yaml:"logLevel"` + LogFormat log.FormatType `yaml:"logFormat"` LogPrivacy bool `yaml:"logPrivacy"` LogTimestamp bool `yaml:"logTimestamp"` Port string `yaml:"port"` @@ -289,10 +289,10 @@ type QueryLogConfig struct { // Deprecated Dir string `yaml:"dir"` // Deprecated - PerClient bool `yaml:"perClient"` - Target string `yaml:"target"` - Type string `yaml:"type"` - LogRetentionDays uint64 `yaml:"logRetentionDays"` + PerClient bool `yaml:"perClient"` + Target string `yaml:"target"` + Type QueryLogType `yaml:"type"` + LogRetentionDays uint64 `yaml:"logRetentionDays"` } // nolint:gochecknoglobals @@ -327,17 +327,6 @@ func LoadConfig(path string, mandatory bool) { } func validateConfig(cfg *Config) { - if cfg.LogFormat != log.CfgLogFormatText && cfg.LogFormat != log.CfgLogFormatJSON { - log.Log().Fatal("LogFormat should be 'text' or 'json'") - } - - queryLogType := strings.ToLower(cfg.QueryLog.Type) - if queryLogType != "" && queryLogType != QueryLogTypeMySQL && - queryLogType != QueryLogTypeCSV && queryLogType != QueryLogTypeCSVPerClient { - log.Log().Fatalf("queryLog.type should be one of: %s", - strings.Join([]string{QueryLogTypeMySQL, QueryLogTypeCSV, QueryLogTypeCSVPerClient}, ", ")) - } - if cfg.QueryLog.Dir != "" { log.Log().Warnf("queryLog.Dir is deprecated, use 'queryLog.target' instead") @@ -345,11 +334,11 @@ func validateConfig(cfg *Config) { cfg.QueryLog.Target = cfg.QueryLog.Dir } - if cfg.QueryLog.Type == "" { + if cfg.QueryLog.Type == QueryLogTypeNone { if cfg.QueryLog.PerClient { - cfg.QueryLog.Type = QueryLogTypeCSVPerClient + cfg.QueryLog.Type = QueryLogTypeCsvClient } else { - cfg.QueryLog.Type = QueryLogTypeCSV + cfg.QueryLog.Type = QueryLogTypeCsv } } } @@ -362,8 +351,6 @@ func GetConfig() *Config { func setDefaultValues(cfg *Config) { cfg.Port = cfgDefaultPort - cfg.LogLevel = "info" - cfg.LogFormat = log.CfgLogFormatText cfg.LogTimestamp = true cfg.Prometheus.Path = cfgDefaultPrometheusPath } diff --git a/config/config_enum.go b/config/config_enum.go new file mode 100644 index 000000000..8f6fbb744 --- /dev/null +++ b/config/config_enum.go @@ -0,0 +1,172 @@ +// Code generated by go-enum DO NOT EDIT. +// Version: +// Revision: +// Build Date: +// Built By: + +package config + +import ( + "fmt" + "strings" +) + +const ( + // NetProtocolUdp is a NetProtocol of type Udp. + // Deprecated: use tcp+udp instead + NetProtocolUdp NetProtocol = iota + // NetProtocolTcp is a NetProtocol of type Tcp. + // Deprecated: use tcp+udp instead + NetProtocolTcp + // NetProtocolTcpUdp is a NetProtocol of type Tcp+Udp. + // TCP and UDP protocols + NetProtocolTcpUdp + // NetProtocolTcpTls is a NetProtocol of type Tcp-Tls. + // TCP-TLS protocol + NetProtocolTcpTls + // NetProtocolHttps is a NetProtocol of type Https. + // HTTPS protocol + NetProtocolHttps +) + +const _NetProtocolName = "udptcptcp+udptcp-tlshttps" + +var _NetProtocolNames = []string{ + _NetProtocolName[0:3], + _NetProtocolName[3:6], + _NetProtocolName[6:13], + _NetProtocolName[13:20], + _NetProtocolName[20:25], +} + +// NetProtocolNames returns a list of possible string values of NetProtocol. +func NetProtocolNames() []string { + tmp := make([]string, len(_NetProtocolNames)) + copy(tmp, _NetProtocolNames) + return tmp +} + +var _NetProtocolMap = map[NetProtocol]string{ + 0: _NetProtocolName[0:3], + 1: _NetProtocolName[3:6], + 2: _NetProtocolName[6:13], + 3: _NetProtocolName[13:20], + 4: _NetProtocolName[20:25], +} + +// String implements the Stringer interface. +func (x NetProtocol) String() string { + if str, ok := _NetProtocolMap[x]; ok { + return str + } + return fmt.Sprintf("NetProtocol(%d)", x) +} + +var _NetProtocolValue = map[string]NetProtocol{ + _NetProtocolName[0:3]: 0, + _NetProtocolName[3:6]: 1, + _NetProtocolName[6:13]: 2, + _NetProtocolName[13:20]: 3, + _NetProtocolName[20:25]: 4, +} + +// ParseNetProtocol attempts to convert a string to a NetProtocol +func ParseNetProtocol(name string) (NetProtocol, error) { + if x, ok := _NetProtocolValue[name]; ok { + return x, nil + } + return NetProtocol(0), fmt.Errorf("%s is not a valid NetProtocol, try [%s]", name, strings.Join(_NetProtocolNames, ", ")) +} + +// MarshalText implements the text marshaller method +func (x NetProtocol) MarshalText() ([]byte, error) { + return []byte(x.String()), nil +} + +// UnmarshalText implements the text unmarshaller method +func (x *NetProtocol) UnmarshalText(text []byte) error { + name := string(text) + tmp, err := ParseNetProtocol(name) + if err != nil { + return err + } + *x = tmp + return nil +} + +const ( + // QueryLogTypeNone is a QueryLogType of type None. + // use logger as fallback + QueryLogTypeNone QueryLogType = iota + // QueryLogTypeMysql is a QueryLogType of type Mysql. + // MySQL or MariaDB database + QueryLogTypeMysql + // QueryLogTypeCsv is a QueryLogType of type Csv. + // CSV file per day + QueryLogTypeCsv + // QueryLogTypeCsvClient is a QueryLogType of type Csv-Client. + // CSV file per day and client + QueryLogTypeCsvClient +) + +const _QueryLogTypeName = "nonemysqlcsvcsv-client" + +var _QueryLogTypeNames = []string{ + _QueryLogTypeName[0:4], + _QueryLogTypeName[4:9], + _QueryLogTypeName[9:12], + _QueryLogTypeName[12:22], +} + +// QueryLogTypeNames returns a list of possible string values of QueryLogType. +func QueryLogTypeNames() []string { + tmp := make([]string, len(_QueryLogTypeNames)) + copy(tmp, _QueryLogTypeNames) + return tmp +} + +var _QueryLogTypeMap = map[QueryLogType]string{ + 0: _QueryLogTypeName[0:4], + 1: _QueryLogTypeName[4:9], + 2: _QueryLogTypeName[9:12], + 3: _QueryLogTypeName[12:22], +} + +// String implements the Stringer interface. +func (x QueryLogType) String() string { + if str, ok := _QueryLogTypeMap[x]; ok { + return str + } + return fmt.Sprintf("QueryLogType(%d)", x) +} + +var _QueryLogTypeValue = map[string]QueryLogType{ + _QueryLogTypeName[0:4]: 0, + _QueryLogTypeName[4:9]: 1, + _QueryLogTypeName[9:12]: 2, + _QueryLogTypeName[12:22]: 3, +} + +// ParseQueryLogType attempts to convert a string to a QueryLogType +func ParseQueryLogType(name string) (QueryLogType, error) { + if x, ok := _QueryLogTypeValue[name]; ok { + return x, nil + } + return QueryLogType(0), fmt.Errorf("%s is not a valid QueryLogType, try [%s]", name, strings.Join(_QueryLogTypeNames, ", ")) +} + +// MarshalText implements the text marshaller method +func (x QueryLogType) MarshalText() ([]byte, error) { + return []byte(x.String()), nil +} + +// UnmarshalText implements the text unmarshaller method +func (x *QueryLogType) UnmarshalText(text []byte) error { + name := string(text) + tmp, err := ParseQueryLogType(name) + if err != nil { + return err + } + *x = tmp + return nil +} diff --git a/config/config_suite_test.go b/config/config_suite_test.go index 5a84bf747..7476b6da8 100644 --- a/config/config_suite_test.go +++ b/config/config_suite_test.go @@ -9,7 +9,7 @@ import ( ) func TestConfig(t *testing.T) { - ConfigureLogger("Warn", "Text", true) + ConfigureLogger(LevelFatal, FormatTypeText, true) RegisterFailHandler(Fail) RunSpecs(t, "Config Suite") } diff --git a/config/config_test.go b/config/config_test.go index d093d65db..305a20142 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -66,26 +66,10 @@ var _ = Describe("Config", func() { }) }) - When("wrong value types are specified", func() { - It("should log with fatal", func() { - helpertest.ShouldLogFatal(func() { - validateConfig(&Config{LogFormat: "wrongFormat"}) - }) - - helpertest.ShouldLogFatal(func() { - validateConfig(&Config{QueryLog: QueryLogConfig{ - Type: "wrong type", - }}) - - }) - }) - }) - When("deprecated querylog.dir parameter is used", func() { It("should be mapped to csv writer", func() { By("per client", func() { c := &Config{ - LogFormat: "text", QueryLog: QueryLogConfig{ Dir: "/somedir", PerClient: true, @@ -93,12 +77,11 @@ var _ = Describe("Config", func() { validateConfig(c) Expect(c.QueryLog.Target).Should(Equal("/somedir")) - Expect(c.QueryLog.Type).Should(Equal(QueryLogTypeCSVPerClient)) + Expect(c.QueryLog.Type).Should(Equal(QueryLogTypeCsvClient)) }) By("one file", func() { c := &Config{ - LogFormat: "text", QueryLog: QueryLogConfig{ Dir: "/somedir", PerClient: false, @@ -106,7 +89,7 @@ var _ = Describe("Config", func() { validateConfig(c) Expect(c.QueryLog.Target).Should(Equal("/somedir")) - Expect(c.QueryLog.Type).Should(Equal(QueryLogTypeCSV)) + Expect(c.QueryLog.Type).Should(Equal(QueryLogTypeCsv)) }) }) @@ -132,7 +115,7 @@ var _ = Describe("Config", func() { LoadConfig("config.yml", false) - Expect(config.LogLevel).Should(Equal("info")) + Expect(config.LogLevel).Should(Equal(LevelInfo)) }) }) }) @@ -149,63 +132,63 @@ var _ = Describe("Config", func() { }, Entry("udp with port", "udp:4.4.4.4:531", - Upstream{Net: "tcp+udp", Host: "4.4.4.4", Port: 531}, + Upstream{Net: NetProtocolTcpUdp, Host: "4.4.4.4", Port: 531}, false), Entry("udp without port, use default", "udp:4.4.4.4", - Upstream{Net: "tcp+udp", Host: "4.4.4.4", Port: 53}, + Upstream{Net: NetProtocolTcpUdp, Host: "4.4.4.4", Port: 53}, false), Entry("tcp with port", "tcp:4.4.4.4:4711", - Upstream{Net: "tcp+udp", Host: "4.4.4.4", Port: 4711}, + Upstream{Net: NetProtocolTcpUdp, Host: "4.4.4.4", Port: 4711}, false), Entry("tcp without port, use default", "tcp:4.4.4.4", - Upstream{Net: "tcp+udp", Host: "4.4.4.4", Port: 53}, + Upstream{Net: NetProtocolTcpUdp, Host: "4.4.4.4", Port: 53}, false), Entry("tcp-tls without port, use default", "tcp-tls:4.4.4.4", - Upstream{Net: "tcp-tls", Host: "4.4.4.4", Port: 853}, + Upstream{Net: NetProtocolTcpTls, Host: "4.4.4.4", Port: 853}, false), Entry("DoH without port, use default", "https:4.4.4.4", - Upstream{Net: "https", Host: "4.4.4.4", Port: 443}, + Upstream{Net: NetProtocolHttps, Host: "4.4.4.4", Port: 443}, false), Entry("DoH with port", "https:4.4.4.4:888", - Upstream{Net: "https", Host: "4.4.4.4", Port: 888}, + Upstream{Net: NetProtocolHttps, Host: "4.4.4.4", Port: 888}, false), Entry("DoH named", "https://dns.google/dns-query", - Upstream{Net: "https", Host: "dns.google", Port: 443, Path: "/dns-query"}, + Upstream{Net: NetProtocolHttps, Host: "dns.google", Port: 443, Path: "/dns-query"}, false), Entry("DoH named, path with multiple slashes", "https://dns.google/dns-query/a/b", - Upstream{Net: "https", Host: "dns.google", Port: 443, Path: "/dns-query/a/b"}, + Upstream{Net: NetProtocolHttps, Host: "dns.google", Port: 443, Path: "/dns-query/a/b"}, false), Entry("DoH named with port", "https://dns.google:888/dns-query", - Upstream{Net: "https", Host: "dns.google", Port: 888, Path: "/dns-query"}, + Upstream{Net: NetProtocolHttps, Host: "dns.google", Port: 888, Path: "/dns-query"}, false), Entry("empty", "", - Upstream{Net: ""}, + Upstream{Net: 0}, false), Entry("udpIpv6WithPort", "udp:[fd00::6cd4:d7e0:d99d:2952]:53", - Upstream{Net: "tcp+udp", Host: "fd00::6cd4:d7e0:d99d:2952", Port: 53}, + Upstream{Net: NetProtocolTcpUdp, Host: "fd00::6cd4:d7e0:d99d:2952", Port: 53}, false), Entry("udpIpv6WithPort2", "udp://[2001:4860:4860::8888]:53", - Upstream{Net: "tcp+udp", Host: "2001:4860:4860::8888", Port: 53}, + Upstream{Net: NetProtocolTcpUdp, Host: "2001:4860:4860::8888", Port: 53}, false), Entry("default net, default port", "1.1.1.1", - Upstream{Net: "tcp+udp", Host: "1.1.1.1", Port: 53}, + Upstream{Net: NetProtocolTcpUdp, Host: "1.1.1.1", Port: 53}, false), Entry("default net with port", "1.1.1.1:153", - Upstream{Net: "tcp+udp", Host: "1.1.1.1", Port: 153}, + Upstream{Net: NetProtocolTcpUdp, Host: "1.1.1.1", Port: 153}, false), Entry("with negative port", "tcp:4.4.4.4:-1", @@ -225,11 +208,11 @@ var _ = Describe("Config", func() { true), Entry("tcp+udp", "tcp+udp:1.1.1.1:53", - Upstream{Net: "tcp+udp", Host: "1.1.1.1", Port: 53}, + Upstream{Net: NetProtocolTcpUdp, Host: "1.1.1.1", Port: 53}, false), Entry("tcp+udp default port", "tcp+udp:1.1.1.1", - Upstream{Net: "tcp+udp", Host: "1.1.1.1", Port: 53}, + Upstream{Net: NetProtocolTcpUdp, Host: "1.1.1.1", Port: 53}, false), ) }) diff --git a/go.mod b/go.mod index 740ef0b82..ecd858457 100644 --- a/go.mod +++ b/go.mod @@ -4,6 +4,7 @@ go 1.17 require ( github.com/0xERR0R/go-cache v1.5.0 + github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 github.com/asaskevich/EventBus v0.0.0-20200907212545-49d423059eef github.com/go-chi/chi v4.1.2+incompatible github.com/go-chi/cors v1.2.0 @@ -20,6 +21,7 @@ require ( github.com/sirupsen/logrus v1.8.1 github.com/spf13/cobra v1.2.1 github.com/stretchr/testify v1.7.0 + github.com/swaggo/swag v1.7.1 github.com/x-cray/logrus-prefixed-formatter v0.5.2 golang.org/x/net v0.0.0-20210428140749-89ef3d95e781 gopkg.in/yaml.v2 v2.4.0 @@ -29,39 +31,65 @@ require ( ) require ( + github.com/KyleBanks/depth v1.2.1 // indirect + github.com/Masterminds/goutils v1.1.1 // indirect + github.com/Masterminds/semver v1.5.0 // indirect + github.com/Masterminds/sprig v2.22.0+incompatible // indirect + github.com/PuerkitoBio/purell v1.1.1 // indirect + github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect + github.com/abice/go-enum v0.3.8 // indirect github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/cespare/xxhash/v2 v2.1.1 // indirect + github.com/cpuguy83/go-md2man/v2 v2.0.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/fsnotify/fsnotify v1.4.9 // indirect github.com/go-openapi/errors v0.19.2 // indirect + github.com/go-openapi/jsonpointer v0.19.5 // indirect + github.com/go-openapi/jsonreference v0.19.5 // indirect + github.com/go-openapi/spec v0.20.3 // indirect + github.com/go-openapi/swag v0.19.14 // indirect github.com/go-sql-driver/mysql v1.6.0 // indirect github.com/go-stack/stack v1.8.0 // indirect + github.com/golang/mock v1.6.0 // indirect github.com/golang/protobuf v1.5.2 // indirect github.com/google/uuid v1.2.0 // indirect + github.com/huandu/xstrings v1.3.2 // indirect + github.com/imdario/mergo v0.3.12 // indirect github.com/inconshreveable/mousetrap v1.0.0 // indirect github.com/jinzhu/inflection v1.0.0 // indirect github.com/jinzhu/now v1.1.2 // indirect - github.com/kr/text v0.2.0 // indirect + github.com/josharian/intern v1.0.0 // indirect + github.com/kevinburke/go-bindata v3.22.0+incompatible // indirect + github.com/labstack/gommon v0.3.0 // indirect + github.com/mailru/easyjson v0.7.6 // indirect github.com/mattn/go-isatty v0.0.12 // indirect github.com/mattn/go-sqlite3 v1.14.5 // indirect + github.com/mattn/goveralls v0.0.9 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect + github.com/mitchellh/copystructure v1.1.2 // indirect github.com/mitchellh/mapstructure v1.4.1 // indirect - github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect + github.com/mitchellh/reflectwalk v1.0.1 // indirect github.com/nxadm/tail v1.4.8 // indirect + github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/prometheus/client_model v0.2.0 // indirect github.com/prometheus/common v0.26.0 // indirect github.com/prometheus/procfs v0.6.0 // indirect + github.com/russross/blackfriday/v2 v2.0.1 // indirect + github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect github.com/spf13/pflag v1.0.5 // indirect github.com/stretchr/objx v0.2.0 // indirect + github.com/urfave/cli/v2 v2.3.0 // indirect go.mongodb.org/mongo-driver v1.0.3 // indirect golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a // indirect + golang.org/x/mod v0.4.2 // indirect golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c // indirect golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 // indirect golang.org/x/text v0.3.6 // indirect + golang.org/x/tools v0.1.5 // indirect + golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect google.golang.org/protobuf v1.26.0 // indirect - gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect ) diff --git a/go.sum b/go.sum index 47cd7e1e0..49bb9f6f8 100644 --- a/go.sum +++ b/go.sum @@ -41,7 +41,22 @@ github.com/0xERR0R/go-cache v1.5.0 h1:iA8LS0XvQbhxJ9q+nDBh86y9un9+Nvf8AFV+1y/FxI github.com/0xERR0R/go-cache v1.5.0/go.mod h1:ngsTQjvR6Aq/zvQI88HsfVJwIz9M78r0xNZi1QYY3jE= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= +github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc= +github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE= +github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI= +github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU= +github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww= +github.com/Masterminds/semver v1.5.0/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y= +github.com/Masterminds/sprig v2.22.0+incompatible h1:z4yfnGrZ7netVz+0EDJ0Wi+5VZCSYp4Z0m2dk6cEM60= +github.com/Masterminds/sprig v2.22.0+incompatible/go.mod h1:y6hNFY5UBTIWBxnzTeuNhlNS5hqE0NB0E6fgfo2Br3o= +github.com/PuerkitoBio/purell v1.1.1 h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tNFfI= +github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= +github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M= +github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= +github.com/abice/go-enum v0.3.8 h1:eo0no8lN+S4dZKXXp5af1NgPuQBPMZBGJQPtz3iyRns= +github.com/abice/go-enum v0.3.8/go.mod h1:8JK+mo1Pm2Kb7CQ3sLlaB54rOrJlmzAMj7pzDJwOO7E= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 h1:JYp7IbQjafoB+tBA3gMyHYHrpOtNuDiK/uB5uXxq5wM= github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= @@ -60,6 +75,7 @@ github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/bketelsen/crypt v0.0.4/go.mod h1:aI6NrJ0pMGgvZKL1iVgXLnfIFJtfV+bKCoqOes/6LfM= +github.com/bradleyjkemp/cupaloy v2.2.0+incompatible/go.mod h1:Au1Xw1sgaJ5iSFktEhYsS0dbQiS1B0/XMXl+42y9Ilk= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= @@ -72,6 +88,8 @@ github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnht github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= +github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= +github.com/cpuguy83/go-md2man/v2 v2.0.0 h1:EoUDS0afbrsXAZ9YQ9jdu/mZ2sXgT1/2yyNng4PGlyM= github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -104,8 +122,18 @@ github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= github.com/go-openapi/errors v0.19.2 h1:a2kIyV3w+OS3S97zxUndRVD46+FhGOUBDFY7nmu4CsY= github.com/go-openapi/errors v0.19.2/go.mod h1:qX0BLWsyaKfvhluLejVpVNwNRdXZhEbTA4kxxpKBC94= +github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= +github.com/go-openapi/jsonpointer v0.19.5 h1:gZr+CIYByUqjcgeLXnQu2gHYQC9o73G2XUeOFYEICuY= +github.com/go-openapi/jsonpointer v0.19.5/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= +github.com/go-openapi/jsonreference v0.19.5 h1:1WJP/wi4OjB4iV8KVbH73rQaoialJrqv8gitZLxGLtM= +github.com/go-openapi/jsonreference v0.19.5/go.mod h1:RdybgQwPxbL4UEjuAruzK1x3nE69AqPYEJeo/TWfEeg= +github.com/go-openapi/spec v0.20.3 h1:uH9RQ6vdyPSs2pSy9fL8QPspDF2AMIMPtmK5coSSjtQ= +github.com/go-openapi/spec v0.20.3/go.mod h1:gG4F8wdEDN+YPBMVnzE85Rbhf+Th2DTvA9nFPQ5AYEg= github.com/go-openapi/strfmt v0.19.4 h1:eRvaqAhpL0IL6Trh5fDsGnGhiXndzHFuA05w6sXH6/g= github.com/go-openapi/strfmt v0.19.4/go.mod h1:eftuHTlB/dI8Uq8JJOyRlieZf+WkkxUuk0dgdHXr2Qk= +github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= +github.com/go-openapi/swag v0.19.14 h1:gm3vOOXfiuw5i9p5N9xJvfjvuofpyvLA9Wr6QfK5Fng= +github.com/go-openapi/swag v0.19.14/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ= github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE= github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk= @@ -126,6 +154,8 @@ github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= github.com/golang/mock v1.5.0/go.mod h1:CWnOUgYIOo4TcNZ0wHX3YZCqsaM1I1Jvs6v3mP3KVu8= +github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= +github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -203,8 +233,12 @@ github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0m github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I= github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= +github.com/huandu/xstrings v1.3.2 h1:L18LIDzqlW6xN2rEkpdV8+oL/IXWJ1APd+vsdYy4Wdw= +github.com/huandu/xstrings v1.3.2/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= +github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU= +github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/jedib0t/go-pretty v4.3.0+incompatible h1:CGs8AVhEKg/n9YbUenWmNStRW2PHJzaeDodcfvRAbIo= @@ -214,6 +248,8 @@ github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkr github.com/jinzhu/now v1.1.1/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= github.com/jinzhu/now v1.1.2 h1:eVKgfIdy9b6zbWBMgFpfDPoAMifwSZagU9HmEU6zgiI= github.com/jinzhu/now v1.1.2/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= +github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= +github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= @@ -223,6 +259,8 @@ github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/X github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= +github.com/kevinburke/go-bindata v3.22.0+incompatible h1:/JmqEhIWQ7GRScV0WjX/0tqBrC5D21ALg0H0U/KZ/ts= +github.com/kevinburke/go-bindata v3.22.0+incompatible/go.mod h1:/pEEZ72flUW2p0yi30bslSp9YqD9pysLxunQDdb2CPM= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= @@ -230,21 +268,33 @@ github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxv github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/labstack/gommon v0.3.0 h1:JEeO0bvc78PKdyHxloTKiF8BD5iGrH8T6MSeGvSgob0= +github.com/labstack/gommon v0.3.0/go.mod h1:MULnywXg0yavhxWKc+lOruYdAhDwPK9wf0OL7NoOu+k= github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= +github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +github.com/mailru/easyjson v0.7.6 h1:8yTIVnZgCoiM1TgqoeTl+LfU5Jg6/xL3QhGQnimLYnA= +github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= +github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= github.com/mattn/go-colorable v0.1.8 h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8= github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= +github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= +github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ= github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0= github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/mattn/go-sqlite3 v1.14.5 h1:1IdxlwTNazvbKJQSxoJ5/9ECbEeaTTyeU7sEAZ5KKTQ= github.com/mattn/go-sqlite3 v1.14.5/go.mod h1:WVKg1VTActs4Qso6iwGbiFih2UIHo0ENGwNd0Lj+XmI= +github.com/mattn/goveralls v0.0.9 h1:XmIwwrO9a9pqSW6IpI89BSCShzQxx0j/oKnnvELQNME= +github.com/mattn/goveralls v0.0.9/go.mod h1:FRbM1PS8oVsOe9JtdzAAXM+DsvDMMHcM1C7drGJD8HY= github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b h1:j7+1HpAFS1zy5+Q4qx1fWh90gTKwiN4QCGoY9TWyyO4= @@ -253,6 +303,8 @@ github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3N github.com/miekg/dns v1.1.43 h1:JKfpVSCB84vrAmHzyrsxB5NAr5kLoMXZArPSw7Qlgyg= github.com/miekg/dns v1.1.43/go.mod h1:+evo5L0630/F6ca/Z9+GAqzhjGyn8/c+TBaOyfEl0V4= github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= +github.com/mitchellh/copystructure v1.1.2 h1:Th2TIvG1+6ma3e/0/bopBKohOTY7s4dA8V2q4EUcBJ0= +github.com/mitchellh/copystructure v1.1.2/go.mod h1:EBArHfARyrSWO/+Wyr9zwEkc6XMFB9XyNgFNmRkZZU4= github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg= @@ -261,6 +313,8 @@ github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:F github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.4.1 h1:CpVNEelQCZBooIPDn+AR3NpivK/TIKU8bDxdASFVQag= github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/mitchellh/reflectwalk v1.0.1 h1:FVzMWA5RllMAKIdUSC8mdWo3XtwoecrH79BY70sEEpE= +github.com/mitchellh/reflectwalk v1.0.1/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= @@ -286,6 +340,7 @@ github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FI github.com/pelletier/go-toml v1.9.3/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= @@ -312,9 +367,11 @@ github.com/prometheus/procfs v0.6.0 h1:mxy4L2jP6qMonqmq+aTtOx1ifVWUgG/TAmntgbh3x github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= +github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= @@ -343,8 +400,14 @@ github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= +github.com/swaggo/swag v1.7.1 h1:gY9ZakXlNWg/i/v5bQBic7VMZ4teq4m89lpiao74p/s= +github.com/swaggo/swag v1.7.1/go.mod h1:gAiHxNTb9cIpNmA/VEGUP+CyZMCP/EW7mdtc8Bny+p8= github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4= github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= +github.com/urfave/cli/v2 v2.3.0 h1:qph92Y649prgesehzOrQjdWyxFOp/QVM+6imKHad91M= +github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI= +github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= +github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8= github.com/x-cray/logrus-prefixed-formatter v0.5.2 h1:00txxvfBM9muc0jiLIEAkAcIMJzfthRT6usrui8uGmg= github.com/x-cray/logrus-prefixed-formatter v0.5.2/go.mod h1:2duySbKsL6M18s5GU7VPsoEPHyzalCE06qoARUCeBBE= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= @@ -375,6 +438,7 @@ golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20210506145944-38f3c27a63bf/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8= golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a h1:kr2P4QFmQr29mSLA43kwrOcgcReGTfbE9N577tCTuBc= golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -411,6 +475,7 @@ golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.4.2 h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -429,6 +494,7 @@ golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -485,6 +551,7 @@ golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -493,6 +560,7 @@ golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -602,7 +670,10 @@ golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4f golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= +golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/tools v0.1.5 h1:ouewzE6p+/VEB31YYnTbEJdi8pFqKp4P4n85vwo3DHA= +golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -717,6 +788,7 @@ gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU= gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/ini.v1 v1.62.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= @@ -732,6 +804,7 @@ gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gorm.io/driver/mysql v1.1.2 h1:OofcyE2lga734MxwcCW9uB4mWNXMr50uaGRVwQL2B0M= diff --git a/lists/list_cache.go b/lists/list_cache.go index af60eb7d0..28aac12f6 100644 --- a/lists/list_cache.go +++ b/lists/list_cache.go @@ -1,5 +1,6 @@ package lists +//go:generate go-enum -f=$GOFILE --marshal --names import ( "bufio" "errors" @@ -24,25 +25,12 @@ const ( defaultRefreshPeriod = 4 * time.Hour ) -// ListCacheType represents the type of cached list +// ListCacheType represents the type of cached list ENUM( +// blacklist // is a list with blocked domains +// whitelist // is a list with whitelisted domains / IPs +// ) type ListCacheType int -const ( - // BLACKLIST is a list with blocked domains / IPs - BLACKLIST ListCacheType = iota - - // WHITELIST is a list with whitelisted domains / IPs - WHITELIST -) - -func (l ListCacheType) String() string { - names := [...]string{ - "blacklist", - "whitelist"} - - return names[l] -} - // nolint:gochecknoglobals var timeout = 60 * time.Second diff --git a/lists/list_cache_enum.go b/lists/list_cache_enum.go new file mode 100644 index 000000000..efa359d4d --- /dev/null +++ b/lists/list_cache_enum.go @@ -0,0 +1,77 @@ +// Code generated by go-enum DO NOT EDIT. +// Version: +// Revision: +// Build Date: +// Built By: + +package lists + +import ( + "fmt" + "strings" +) + +const ( + // ListCacheTypeBlacklist is a ListCacheType of type Blacklist. + // is a list with blocked domains + ListCacheTypeBlacklist ListCacheType = iota + // ListCacheTypeWhitelist is a ListCacheType of type Whitelist. + // is a list with whitelisted domains / IPs + ListCacheTypeWhitelist +) + +const _ListCacheTypeName = "blacklistwhitelist" + +var _ListCacheTypeNames = []string{ + _ListCacheTypeName[0:9], + _ListCacheTypeName[9:18], +} + +// ListCacheTypeNames returns a list of possible string values of ListCacheType. +func ListCacheTypeNames() []string { + tmp := make([]string, len(_ListCacheTypeNames)) + copy(tmp, _ListCacheTypeNames) + return tmp +} + +var _ListCacheTypeMap = map[ListCacheType]string{ + 0: _ListCacheTypeName[0:9], + 1: _ListCacheTypeName[9:18], +} + +// String implements the Stringer interface. +func (x ListCacheType) String() string { + if str, ok := _ListCacheTypeMap[x]; ok { + return str + } + return fmt.Sprintf("ListCacheType(%d)", x) +} + +var _ListCacheTypeValue = map[string]ListCacheType{ + _ListCacheTypeName[0:9]: 0, + _ListCacheTypeName[9:18]: 1, +} + +// ParseListCacheType attempts to convert a string to a ListCacheType +func ParseListCacheType(name string) (ListCacheType, error) { + if x, ok := _ListCacheTypeValue[name]; ok { + return x, nil + } + return ListCacheType(0), fmt.Errorf("%s is not a valid ListCacheType, try [%s]", name, strings.Join(_ListCacheTypeNames, ", ")) +} + +// MarshalText implements the text marshaller method +func (x ListCacheType) MarshalText() ([]byte, error) { + return []byte(x.String()), nil +} + +// UnmarshalText implements the text unmarshaller method +func (x *ListCacheType) UnmarshalText(text []byte) error { + name := string(text) + tmp, err := ParseListCacheType(name) + if err != nil { + return err + } + *x = tmp + return nil +} diff --git a/lists/list_cache_test.go b/lists/list_cache_test.go index 0eb89abdd..6b99fae66 100644 --- a/lists/list_cache_test.go +++ b/lists/list_cache_test.go @@ -48,7 +48,7 @@ var _ = Describe("ListCache", func() { lists := map[string][]string{ "gr0": {emptyFile.Name()}, } - sut := NewListCache(BLACKLIST, lists, 0) + sut := NewListCache(ListCacheTypeBlacklist, lists, 0) found, group := sut.Match("", []string{"gr0"}) Expect(found).Should(BeFalse()) @@ -61,7 +61,7 @@ var _ = Describe("ListCache", func() { lists := map[string][]string{ "gr1": {emptyFile.Name()}, } - sut := NewListCache(BLACKLIST, lists, 0) + sut := NewListCache(ListCacheTypeBlacklist, lists, 0) found, group := sut.Match("google.com", []string{"gr1"}) Expect(found).Should(BeFalse()) @@ -88,7 +88,7 @@ var _ = Describe("ListCache", func() { } timeout = 100 * time.Millisecond - sut := NewListCache(BLACKLIST, lists, 0) + sut := NewListCache(ListCacheTypeBlacklist, lists, 0) time.Sleep(time.Second) found, group := sut.Match("blocked1.com", []string{"gr1"}) Expect(found).Should(BeTrue()) @@ -115,7 +115,7 @@ var _ = Describe("ListCache", func() { } timeout = 100 * time.Millisecond - sut := NewListCache(BLACKLIST, lists, 0) + sut := NewListCache(ListCacheTypeBlacklist, lists, 0) time.Sleep(time.Second) By("Lists loaded without timeout", func() { found, group := sut.Match("blocked1.com", []string{"gr1"}) @@ -151,7 +151,7 @@ var _ = Describe("ListCache", func() { "gr1": {s.URL}, } - sut := NewListCache(BLACKLIST, lists, 0) + sut := NewListCache(ListCacheTypeBlacklist, lists, 0) time.Sleep(time.Second) By("Lists loaded without error", func() { found, group := sut.Match("blocked1.com", []string{"gr1"}) @@ -175,7 +175,7 @@ var _ = Describe("ListCache", func() { "gr2": {server3.URL}, } - sut := NewListCache(BLACKLIST, lists, 0) + sut := NewListCache(ListCacheTypeBlacklist, lists, 0) found, group := sut.Match("blocked1.com", []string{"gr1", "gr2"}) Expect(found).Should(BeTrue()) @@ -196,7 +196,7 @@ var _ = Describe("ListCache", func() { "withDeadLink": {"http://wrong.host.name"}, } - sut := NewListCache(BLACKLIST, lists, 0) + sut := NewListCache(ListCacheTypeBlacklist, lists, 0) found, group := sut.Match("blocked1.com", []string{}) Expect(found).Should(BeFalse()) @@ -215,7 +215,7 @@ var _ = Describe("ListCache", func() { resultCnt = cnt }) - sut := NewListCache(BLACKLIST, lists, 0) + sut := NewListCache(ListCacheTypeBlacklist, lists, 0) found, group := sut.Match("blocked1.com", []string{}) Expect(found).Should(BeFalse()) @@ -230,7 +230,7 @@ var _ = Describe("ListCache", func() { "gr2": {"file://" + file3.Name()}, } - sut := NewListCache(BLACKLIST, lists, 0) + sut := NewListCache(ListCacheTypeBlacklist, lists, 0) found, group := sut.Match("blocked1.com", []string{"gr1", "gr2"}) Expect(found).Should(BeTrue()) @@ -251,7 +251,7 @@ var _ = Describe("ListCache", func() { "gr1": {"inlinedomain1.com\n#some comment\n#inlinedomain2.com"}, } - sut := NewListCache(BLACKLIST, lists, 0) + sut := NewListCache(ListCacheTypeBlacklist, lists, 0) found, group := sut.Match("inlinedomain1.com", []string{"gr1"}) Expect(found).Should(BeTrue()) @@ -270,7 +270,7 @@ var _ = Describe("ListCache", func() { "gr1": {server1.URL, server2.URL}, } - sut := NewListCache(BLACKLIST, lists, 0) + sut := NewListCache(ListCacheTypeBlacklist, lists, 0) c := sut.Configuration() Expect(c).Should(HaveLen(8)) @@ -282,7 +282,7 @@ var _ = Describe("ListCache", func() { "gr1": {"file1", "file2"}, } - sut := NewListCache(BLACKLIST, lists, -1) + sut := NewListCache(ListCacheTypeBlacklist, lists, -1) c := sut.Configuration() Expect(c).Should(ContainElement("refresh: disabled")) diff --git a/lists/list_suite_test.go b/lists/list_suite_test.go index 2f4a15b64..04cdbe261 100644 --- a/lists/list_suite_test.go +++ b/lists/list_suite_test.go @@ -10,7 +10,7 @@ import ( ) func TestLists(t *testing.T) { - ConfigureLogger("Warn", "text", true) + ConfigureLogger(LevelFatal, FormatTypeText, true) RegisterFailHandler(Fail) RunSpecs(t, "Lists Suite") } diff --git a/log/logger.go b/log/logger.go index a3ecd3553..0b62bf27b 100644 --- a/log/logger.go +++ b/log/logger.go @@ -1,5 +1,7 @@ package log +//go:generate go-enum -f=$GOFILE --marshal --names + import ( "github.com/sirupsen/logrus" prefixed "github.com/x-cray/logrus-prefixed-formatter" @@ -9,19 +11,27 @@ import ( // nolint:gochecknoglobals var logger *logrus.Logger -const ( - // CfgLogFormatText logging as text - CfgLogFormatText = "text" +// FormatType format for logging ENUM( +// text // logging as text +// json // JSON format +// ) +type FormatType int - // CfgLogFormatJSON as JSON - CfgLogFormatJSON = "json" -) +// Level log level ENUM( +// info +// trace +// debug +// warn +// error +// fatal +// ) +type Level int // nolint:gochecknoinits func init() { logger = logrus.New() - ConfigureLogger("info", "text", true) + ConfigureLogger(LevelInfo, FormatTypeText, true) } // Log returns the global logger @@ -35,18 +45,15 @@ func PrefixedLog(prefix string) *logrus.Entry { } // ConfigureLogger applies configuration to the global logger -func ConfigureLogger(logLevel, logFormat string, logTimestamp bool) { - if len(logLevel) == 0 { - logLevel = "info" - } - - if level, err := logrus.ParseLevel(logLevel); err != nil { +func ConfigureLogger(logLevel Level, formatType FormatType, logTimestamp bool) { + if level, err := logrus.ParseLevel(logLevel.String()); err != nil { logger.Fatalf("invalid log level %s %v", logLevel, err) } else { logger.SetLevel(level) } - if logFormat == CfgLogFormatText { + switch formatType { + case FormatTypeText: logFormatter := &prefixed.TextFormatter{ TimestampFormat: "2006-01-02 15:04:05", FullTimestamp: true, @@ -61,9 +68,8 @@ func ConfigureLogger(logLevel, logFormat string, logTimestamp bool) { }) logger.SetFormatter(logFormatter) - } - if logFormat == CfgLogFormatJSON { + case FormatTypeJson: logger.SetFormatter(&logrus.JSONFormatter{}) } } diff --git a/log/logger_enum.go b/log/logger_enum.go new file mode 100644 index 000000000..dd30ea211 --- /dev/null +++ b/log/logger_enum.go @@ -0,0 +1,160 @@ +// Code generated by go-enum DO NOT EDIT. +// Version: +// Revision: +// Build Date: +// Built By: + +package log + +import ( + "fmt" + "strings" +) + +const ( + // FormatTypeText is a FormatType of type Text. + // logging as text + FormatTypeText FormatType = iota + // FormatTypeJson is a FormatType of type Json. + // JSON format + FormatTypeJson +) + +const _FormatTypeName = "textjson" + +var _FormatTypeNames = []string{ + _FormatTypeName[0:4], + _FormatTypeName[4:8], +} + +// FormatTypeNames returns a list of possible string values of FormatType. +func FormatTypeNames() []string { + tmp := make([]string, len(_FormatTypeNames)) + copy(tmp, _FormatTypeNames) + return tmp +} + +var _FormatTypeMap = map[FormatType]string{ + 0: _FormatTypeName[0:4], + 1: _FormatTypeName[4:8], +} + +// String implements the Stringer interface. +func (x FormatType) String() string { + if str, ok := _FormatTypeMap[x]; ok { + return str + } + return fmt.Sprintf("FormatType(%d)", x) +} + +var _FormatTypeValue = map[string]FormatType{ + _FormatTypeName[0:4]: 0, + _FormatTypeName[4:8]: 1, +} + +// ParseFormatType attempts to convert a string to a FormatType +func ParseFormatType(name string) (FormatType, error) { + if x, ok := _FormatTypeValue[name]; ok { + return x, nil + } + return FormatType(0), fmt.Errorf("%s is not a valid FormatType, try [%s]", name, strings.Join(_FormatTypeNames, ", ")) +} + +// MarshalText implements the text marshaller method +func (x FormatType) MarshalText() ([]byte, error) { + return []byte(x.String()), nil +} + +// UnmarshalText implements the text unmarshaller method +func (x *FormatType) UnmarshalText(text []byte) error { + name := string(text) + tmp, err := ParseFormatType(name) + if err != nil { + return err + } + *x = tmp + return nil +} + +const ( + // LevelInfo is a Level of type Info. + LevelInfo Level = iota + // LevelTrace is a Level of type Trace. + LevelTrace + // LevelDebug is a Level of type Debug. + LevelDebug + // LevelWarn is a Level of type Warn. + LevelWarn + // LevelError is a Level of type Error. + LevelError + // LevelFatal is a Level of type Fatal. + LevelFatal +) + +const _LevelName = "infotracedebugwarnerrorfatal" + +var _LevelNames = []string{ + _LevelName[0:4], + _LevelName[4:9], + _LevelName[9:14], + _LevelName[14:18], + _LevelName[18:23], + _LevelName[23:28], +} + +// LevelNames returns a list of possible string values of Level. +func LevelNames() []string { + tmp := make([]string, len(_LevelNames)) + copy(tmp, _LevelNames) + return tmp +} + +var _LevelMap = map[Level]string{ + 0: _LevelName[0:4], + 1: _LevelName[4:9], + 2: _LevelName[9:14], + 3: _LevelName[14:18], + 4: _LevelName[18:23], + 5: _LevelName[23:28], +} + +// String implements the Stringer interface. +func (x Level) String() string { + if str, ok := _LevelMap[x]; ok { + return str + } + return fmt.Sprintf("Level(%d)", x) +} + +var _LevelValue = map[string]Level{ + _LevelName[0:4]: 0, + _LevelName[4:9]: 1, + _LevelName[9:14]: 2, + _LevelName[14:18]: 3, + _LevelName[18:23]: 4, + _LevelName[23:28]: 5, +} + +// ParseLevel attempts to convert a string to a Level +func ParseLevel(name string) (Level, error) { + if x, ok := _LevelValue[name]; ok { + return x, nil + } + return Level(0), fmt.Errorf("%s is not a valid Level, try [%s]", name, strings.Join(_LevelNames, ", ")) +} + +// MarshalText implements the text marshaller method +func (x Level) MarshalText() ([]byte, error) { + return []byte(x.String()), nil +} + +// UnmarshalText implements the text unmarshaller method +func (x *Level) UnmarshalText(text []byte) error { + name := string(text) + tmp, err := ParseLevel(name) + if err != nil { + return err + } + *x = tmp + return nil +} diff --git a/metrics/metrics_event_publisher.go b/metrics/metrics_event_publisher.go index 59c709647..e904b8ee5 100644 --- a/metrics/metrics_event_publisher.go +++ b/metrics/metrics_event_publisher.go @@ -64,9 +64,9 @@ func registerBlockingEventListeners() { subscribe(evt.BlockingCacheGroupChanged, func(listType lists.ListCacheType, groupName string, cnt int) { lastListGroupRefresh.Set(float64(time.Now().Unix())) switch listType { - case lists.BLACKLIST: + case lists.ListCacheTypeBlacklist: blacklistCnt.WithLabelValues(groupName).Set(float64(cnt)) - case lists.WHITELIST: + case lists.ListCacheTypeWhitelist: whitelistCnt.WithLabelValues(groupName).Set(float64(cnt)) } }) diff --git a/model/models.go b/model/models.go index 64b1b73db..3c0be0322 100644 --- a/model/models.go +++ b/model/models.go @@ -1,5 +1,6 @@ package model +//go:generate go-enum -f=$GOFILE --marshal --names import ( "net" "time" @@ -8,37 +9,15 @@ import ( "github.com/sirupsen/logrus" ) -// ResponseType represents the type of the response +// ResponseType represents the type of the response ENUM( +// RESOLVED // the response was resolved by the external upstream resolver +// CACHED // the response was resolved from cache +// BLOCKED // the query was blocked +// CONDITIONAL // the query was resolved by the conditional upstream resolver +// CUSTOMDNS // the query was resolved by a custom rule +// ) type ResponseType int -const ( - // RESOLVED the response was resolved by the external upstream resolver - RESOLVED ResponseType = iota - - // CACHED the response was resolved from cache - CACHED - - // BLOCKED the query was blocked - BLOCKED - - // CONDITIONAL the query was resolved by the conditional upstream resolver - CONDITIONAL - - // CUSTOMDNS the query was resolved by a custom rule - CUSTOMDNS -) - -func (r ResponseType) String() string { - names := [...]string{ - "RESOLVED", - "CACHED", - "BLOCKED", - "CONDITIONAL", - "CUSTOMDNS"} - - return names[r] -} - // Response represents the response of a DNS query type Response struct { Res *dns.Msg @@ -46,25 +25,12 @@ type Response struct { RType ResponseType } -// RequestProtocol represents the server protocol +// RequestProtocol represents the server protocol ENUM( +// TCP // is the TPC protocol +// UDP // is the UDP protocol +// ) type RequestProtocol uint8 -const ( - // TCP is the TPC protocol - TCP RequestProtocol = iota - - // UDP is the UDP protocol - UDP -) - -func (r RequestProtocol) String() string { - names := [...]string{ - "TCP", - "UDP"} - - return names[r] -} - // Request represents client's DNS request type Request struct { ClientIP net.IP diff --git a/model/models_enum.go b/model/models_enum.go new file mode 100644 index 000000000..0d040c366 --- /dev/null +++ b/model/models_enum.go @@ -0,0 +1,160 @@ +// Code generated by go-enum DO NOT EDIT. +// Version: +// Revision: +// Build Date: +// Built By: + +package model + +import ( + "fmt" + "strings" +) + +const ( + // RequestProtocolTCP is a RequestProtocol of type TCP. + // is the TPC protocol + RequestProtocolTCP RequestProtocol = iota + // RequestProtocolUDP is a RequestProtocol of type UDP. + // is the UDP protocol + RequestProtocolUDP +) + +const _RequestProtocolName = "TCPUDP" + +var _RequestProtocolNames = []string{ + _RequestProtocolName[0:3], + _RequestProtocolName[3:6], +} + +// RequestProtocolNames returns a list of possible string values of RequestProtocol. +func RequestProtocolNames() []string { + tmp := make([]string, len(_RequestProtocolNames)) + copy(tmp, _RequestProtocolNames) + return tmp +} + +var _RequestProtocolMap = map[RequestProtocol]string{ + 0: _RequestProtocolName[0:3], + 1: _RequestProtocolName[3:6], +} + +// String implements the Stringer interface. +func (x RequestProtocol) String() string { + if str, ok := _RequestProtocolMap[x]; ok { + return str + } + return fmt.Sprintf("RequestProtocol(%d)", x) +} + +var _RequestProtocolValue = map[string]RequestProtocol{ + _RequestProtocolName[0:3]: 0, + _RequestProtocolName[3:6]: 1, +} + +// ParseRequestProtocol attempts to convert a string to a RequestProtocol +func ParseRequestProtocol(name string) (RequestProtocol, error) { + if x, ok := _RequestProtocolValue[name]; ok { + return x, nil + } + return RequestProtocol(0), fmt.Errorf("%s is not a valid RequestProtocol, try [%s]", name, strings.Join(_RequestProtocolNames, ", ")) +} + +// MarshalText implements the text marshaller method +func (x RequestProtocol) MarshalText() ([]byte, error) { + return []byte(x.String()), nil +} + +// UnmarshalText implements the text unmarshaller method +func (x *RequestProtocol) UnmarshalText(text []byte) error { + name := string(text) + tmp, err := ParseRequestProtocol(name) + if err != nil { + return err + } + *x = tmp + return nil +} + +const ( + // ResponseTypeRESOLVED is a ResponseType of type RESOLVED. + // the response was resolved by the external upstream resolver + ResponseTypeRESOLVED ResponseType = iota + // ResponseTypeCACHED is a ResponseType of type CACHED. + // the response was resolved from cache + ResponseTypeCACHED + // ResponseTypeBLOCKED is a ResponseType of type BLOCKED. + // the query was blocked + ResponseTypeBLOCKED + // ResponseTypeCONDITIONAL is a ResponseType of type CONDITIONAL. + // the query was resolved by the conditional upstream resolver + ResponseTypeCONDITIONAL + // ResponseTypeCUSTOMDNS is a ResponseType of type CUSTOMDNS. + // the query was resolved by a custom rule + ResponseTypeCUSTOMDNS +) + +const _ResponseTypeName = "RESOLVEDCACHEDBLOCKEDCONDITIONALCUSTOMDNS" + +var _ResponseTypeNames = []string{ + _ResponseTypeName[0:8], + _ResponseTypeName[8:14], + _ResponseTypeName[14:21], + _ResponseTypeName[21:32], + _ResponseTypeName[32:41], +} + +// ResponseTypeNames returns a list of possible string values of ResponseType. +func ResponseTypeNames() []string { + tmp := make([]string, len(_ResponseTypeNames)) + copy(tmp, _ResponseTypeNames) + return tmp +} + +var _ResponseTypeMap = map[ResponseType]string{ + 0: _ResponseTypeName[0:8], + 1: _ResponseTypeName[8:14], + 2: _ResponseTypeName[14:21], + 3: _ResponseTypeName[21:32], + 4: _ResponseTypeName[32:41], +} + +// String implements the Stringer interface. +func (x ResponseType) String() string { + if str, ok := _ResponseTypeMap[x]; ok { + return str + } + return fmt.Sprintf("ResponseType(%d)", x) +} + +var _ResponseTypeValue = map[string]ResponseType{ + _ResponseTypeName[0:8]: 0, + _ResponseTypeName[8:14]: 1, + _ResponseTypeName[14:21]: 2, + _ResponseTypeName[21:32]: 3, + _ResponseTypeName[32:41]: 4, +} + +// ParseResponseType attempts to convert a string to a ResponseType +func ParseResponseType(name string) (ResponseType, error) { + if x, ok := _ResponseTypeValue[name]; ok { + return x, nil + } + return ResponseType(0), fmt.Errorf("%s is not a valid ResponseType, try [%s]", name, strings.Join(_ResponseTypeNames, ", ")) +} + +// MarshalText implements the text marshaller method +func (x ResponseType) MarshalText() ([]byte, error) { + return []byte(x.String()), nil +} + +// UnmarshalText implements the text unmarshaller method +func (x *ResponseType) UnmarshalText(text []byte) error { + name := string(text) + tmp, err := ParseResponseType(name) + if err != nil { + return err + } + *x = tmp + return nil +} diff --git a/querylog/database_writer_test.go b/querylog/database_writer_test.go index 80e75beaf..08c0b267c 100644 --- a/querylog/database_writer_test.go +++ b/querylog/database_writer_test.go @@ -33,7 +33,7 @@ var _ = Describe("DatabaseWriter", func() { response := &model.Response{ Res: res, Reason: "Resolved", - RType: model.RESOLVED, + RType: model.ResponseTypeRESOLVED, } writer.Write(&Entry{ Request: request, @@ -66,7 +66,7 @@ var _ = Describe("DatabaseWriter", func() { response := &model.Response{ Res: res, Reason: "Resolved", - RType: model.RESOLVED, + RType: model.ResponseTypeRESOLVED, } // one entry with now as timestamp diff --git a/querylog/file_writer_test.go b/querylog/file_writer_test.go index add65f95b..64adaba57 100644 --- a/querylog/file_writer_test.go +++ b/querylog/file_writer_test.go @@ -60,7 +60,7 @@ var _ = Describe("FileWriter", func() { Response: &model.Response{ Res: res, Reason: "Resolved", - RType: model.RESOLVED, + RType: model.ResponseTypeRESOLVED, }, Start: time.Now(), DurationMs: 20, @@ -77,7 +77,7 @@ var _ = Describe("FileWriter", func() { Response: &model.Response{ Res: res, Reason: "Resolved", - RType: model.RESOLVED, + RType: model.ResponseTypeRESOLVED, }, Start: time.Now(), DurationMs: 20, @@ -107,7 +107,7 @@ var _ = Describe("FileWriter", func() { Response: &model.Response{ Res: res, Reason: "Resolved", - RType: model.RESOLVED, + RType: model.ResponseTypeRESOLVED, }, Start: time.Now(), DurationMs: 20, @@ -124,7 +124,7 @@ var _ = Describe("FileWriter", func() { Response: &model.Response{ Res: res, Reason: "Resolved", - RType: model.RESOLVED, + RType: model.ResponseTypeRESOLVED, }, Start: time.Now(), DurationMs: 20, @@ -158,7 +158,7 @@ var _ = Describe("FileWriter", func() { Response: &model.Response{ Res: res, Reason: "Resolved", - RType: model.RESOLVED, + RType: model.ResponseTypeRESOLVED, }, Start: time.Now(), DurationMs: 20, @@ -174,7 +174,7 @@ var _ = Describe("FileWriter", func() { Response: &model.Response{ Res: res, Reason: "Resolved", - RType: model.RESOLVED, + RType: model.ResponseTypeRESOLVED, }, Start: time.Now().AddDate(0, 0, -2), DurationMs: 20, diff --git a/querylog/logger_writer_test.go b/querylog/logger_writer_test.go index df4685c37..0bf884fbe 100644 --- a/querylog/logger_writer_test.go +++ b/querylog/logger_writer_test.go @@ -32,7 +32,7 @@ var _ = Describe("LoggerWriter", func() { response := &model.Response{ Res: res, Reason: "Resolved", - RType: model.RESOLVED, + RType: model.ResponseTypeRESOLVED, } writer.Write(&Entry{ Request: request, diff --git a/querylog/querylog_suite_test.go b/querylog/querylog_suite_test.go index ea7af49dd..6b0bfde9e 100644 --- a/querylog/querylog_suite_test.go +++ b/querylog/querylog_suite_test.go @@ -10,7 +10,7 @@ import ( ) func TestResolver(t *testing.T) { - ConfigureLogger("Warn", "text", true) + ConfigureLogger(LevelFatal, FormatTypeText, true) RegisterFailHandler(Fail) RunSpecs(t, "Querylog Suite") } diff --git a/resolver/blocking_resolver.go b/resolver/blocking_resolver.go index 25220797c..30b8b01e5 100644 --- a/resolver/blocking_resolver.go +++ b/resolver/blocking_resolver.go @@ -82,8 +82,8 @@ type BlockingResolver struct { // NewBlockingResolver returns a new configured instance of the resolver func NewBlockingResolver(cfg config.BlockingConfig) ChainedResolver { blockHandler := createBlockHandler(cfg) - blacklistMatcher := lists.NewListCache(lists.BLACKLIST, cfg.BlackLists, cfg.RefreshPeriod) - whitelistMatcher := lists.NewListCache(lists.WHITELIST, cfg.WhiteLists, cfg.RefreshPeriod) + blacklistMatcher := lists.NewListCache(lists.ListCacheTypeBlacklist, cfg.BlackLists, cfg.RefreshPeriod) + whitelistMatcher := lists.NewListCache(lists.ListCacheTypeWhitelist, cfg.WhiteLists, cfg.RefreshPeriod) whitelistOnlyGroups := determineWhitelistOnlyGroups(&cfg) res := &BlockingResolver{ @@ -211,7 +211,7 @@ func (r *BlockingResolver) handleBlocked(logger *logrus.Entry, logger.Debugf("blocking request '%s'", reason) - return &model.Response{Res: response, RType: model.BLOCKED, Reason: reason}, nil + return &model.Response{Res: response, RType: model.ResponseTypeBLOCKED, Reason: reason}, nil } // Configuration returns the current resolver configuration diff --git a/resolver/blocking_resolver_test.go b/resolver/blocking_resolver_test.go index a098ca2e4..e893124cd 100644 --- a/resolver/blocking_resolver_test.go +++ b/resolver/blocking_resolver_test.go @@ -119,7 +119,7 @@ badcnamedomain.com`) }, BlockType: "ZeroIP", } - rType = BLOCKED + rType = ResponseTypeBLOCKED }) AfterEach(func() { Expect(resp.RType).Should(Equal(rType)) @@ -159,7 +159,7 @@ badcnamedomain.com`) }) When("Client CIDR (10.43.8.64 - 10.43.8.79) is defined in client groups block", func() { JustBeforeEach(func() { - rType = RESOLVED + rType = ResponseTypeRESOLVED }) It("should not block the query for 10.43.8.63 if domain is on the black list", func() { @@ -484,7 +484,7 @@ badcnamedomain.com`) // was delegated to next resolver m.AssertExpectations(GinkgoT()) - Expect(resp.RType).Should(Equal(RESOLVED)) + Expect(resp.RType).Should(Equal(ResponseTypeRESOLVED)) }) When("domain is not on the black list", func() { It("should delegate to next resolver", func() { @@ -520,13 +520,13 @@ badcnamedomain.com`) By("Perform query to ensure that the blocking status is active (defaultGroup)", func() { resp, err := sut.Resolve(newRequestWithClient("blocked3.com.", dns.TypeA, "1.2.1.2", "unknown")) Expect(err).Should(Succeed()) - Expect(resp.RType).Should(Equal(BLOCKED)) + Expect(resp.RType).Should(Equal(ResponseTypeBLOCKED)) }) By("Perform query to ensure that the blocking status is active (group1)", func() { resp, err := sut.Resolve(newRequestWithClient("domain1.com.", dns.TypeA, "1.2.1.2", "unknown")) Expect(err).Should(Succeed()) - Expect(resp.RType).Should(Equal(BLOCKED)) + Expect(resp.RType).Should(Equal(ResponseTypeBLOCKED)) }) By("Calling Rest API to deactivate all groups", func() { @@ -538,7 +538,7 @@ badcnamedomain.com`) // now is blocking disabled, query the url again resp, err := sut.Resolve(newRequestWithClient("blocked3.com.", dns.TypeA, "1.2.1.2", "unknown")) Expect(err).Should(Succeed()) - Expect(resp.RType).Should(Equal(RESOLVED)) + Expect(resp.RType).Should(Equal(ResponseTypeRESOLVED)) m.AssertExpectations(GinkgoT()) m.AssertNumberOfCalls(GinkgoT(), "Resolve", 1) @@ -548,7 +548,7 @@ badcnamedomain.com`) // now is blocking disabled, query the url again resp, err := sut.Resolve(newRequestWithClient("domain1.com.", dns.TypeA, "1.2.1.2", "unknown")) Expect(err).Should(Succeed()) - Expect(resp.RType).Should(Equal(RESOLVED)) + Expect(resp.RType).Should(Equal(ResponseTypeRESOLVED)) m.AssertExpectations(GinkgoT()) m.AssertNumberOfCalls(GinkgoT(), "Resolve", 2) @@ -563,7 +563,7 @@ badcnamedomain.com`) // now is blocking disabled, query the url again resp, err := sut.Resolve(newRequestWithClient("blocked3.com.", dns.TypeA, "1.2.1.2", "unknown")) Expect(err).Should(Succeed()) - Expect(resp.RType).Should(Equal(RESOLVED)) + Expect(resp.RType).Should(Equal(ResponseTypeRESOLVED)) m.AssertExpectations(GinkgoT()) m.AssertNumberOfCalls(GinkgoT(), "Resolve", 3) @@ -572,7 +572,7 @@ badcnamedomain.com`) By("Perform query to ensure that the blocking status is active (group1)", func() { resp, err := sut.Resolve(newRequestWithClient("domain1.com.", dns.TypeA, "1.2.1.2", "unknown")) Expect(err).Should(Succeed()) - Expect(resp.RType).Should(Equal(BLOCKED)) + Expect(resp.RType).Should(Equal(ResponseTypeBLOCKED)) }) }) }) @@ -582,12 +582,12 @@ badcnamedomain.com`) By("Perform query to ensure that the blocking status is active (defaultGroup)", func() { resp, err := sut.Resolve(newRequestWithClient("blocked3.com.", dns.TypeA, "1.2.1.2", "unknown")) Expect(err).Should(Succeed()) - Expect(resp.RType).Should(Equal(BLOCKED)) + Expect(resp.RType).Should(Equal(ResponseTypeBLOCKED)) }) By("Perform query to ensure that the blocking status is active (group1)", func() { resp, err := sut.Resolve(newRequestWithClient("domain1.com.", dns.TypeA, "1.2.1.2", "unknown")) Expect(err).Should(Succeed()) - Expect(resp.RType).Should(Equal(BLOCKED)) + Expect(resp.RType).Should(Equal(ResponseTypeBLOCKED)) }) By("Calling Rest API to deactivate blocking for 0.5 sec", func() { @@ -605,7 +605,7 @@ badcnamedomain.com`) // now is blocking disabled, query the url again resp, err := sut.Resolve(newRequestWithClient("blocked3.com.", dns.TypeA, "1.2.1.2", "unknown")) Expect(err).Should(Succeed()) - Expect(resp.RType).Should(Equal(RESOLVED)) + Expect(resp.RType).Should(Equal(ResponseTypeRESOLVED)) m.AssertExpectations(GinkgoT()) m.AssertNumberOfCalls(GinkgoT(), "Resolve", 1) @@ -614,7 +614,7 @@ badcnamedomain.com`) // now is blocking disabled, query the url again resp, err := sut.Resolve(newRequestWithClient("domain1.com.", dns.TypeA, "1.2.1.2", "unknown")) Expect(err).Should(Succeed()) - Expect(resp.RType).Should(Equal(RESOLVED)) + Expect(resp.RType).Should(Equal(ResponseTypeRESOLVED)) m.AssertExpectations(GinkgoT()) m.AssertNumberOfCalls(GinkgoT(), "Resolve", 2) @@ -631,11 +631,11 @@ badcnamedomain.com`) resp, err := sut.Resolve(newRequestWithClient("blocked3.com.", dns.TypeA, "1.2.1.2", "unknown")) Expect(err).Should(Succeed()) - Expect(resp.RType).Should(Equal(BLOCKED)) + Expect(resp.RType).Should(Equal(ResponseTypeBLOCKED)) resp, err = sut.Resolve(newRequestWithClient("domain1.com.", dns.TypeA, "1.2.1.2", "unknown")) Expect(err).Should(Succeed()) - Expect(resp.RType).Should(Equal(BLOCKED)) + Expect(resp.RType).Should(Equal(ResponseTypeBLOCKED)) }) }) }) @@ -645,12 +645,12 @@ badcnamedomain.com`) By("Perform query to ensure that the blocking status is active (defaultGroup)", func() { resp, err := sut.Resolve(newRequestWithClient("blocked3.com.", dns.TypeA, "1.2.1.2", "unknown")) Expect(err).Should(Succeed()) - Expect(resp.RType).Should(Equal(BLOCKED)) + Expect(resp.RType).Should(Equal(ResponseTypeBLOCKED)) }) By("Perform query to ensure that the blocking status is active (group1)", func() { resp, err := sut.Resolve(newRequestWithClient("domain1.com.", dns.TypeA, "1.2.1.2", "unknown")) Expect(err).Should(Succeed()) - Expect(resp.RType).Should(Equal(BLOCKED)) + Expect(resp.RType).Should(Equal(ResponseTypeBLOCKED)) }) By("Calling Rest API to deactivate blocking for one group for 0.5 sec", func() { @@ -668,14 +668,14 @@ badcnamedomain.com`) // now is blocking disabled, query the url again resp, err := sut.Resolve(newRequestWithClient("blocked3.com.", dns.TypeA, "1.2.1.2", "unknown")) Expect(err).Should(Succeed()) - Expect(resp.RType).Should(Equal(BLOCKED)) + Expect(resp.RType).Should(Equal(ResponseTypeBLOCKED)) }) By("perform the same query again to ensure that this query will not be blocked (group1)", func() { // now is blocking disabled, query the url again resp, err := sut.Resolve(newRequestWithClient("domain1.com.", dns.TypeA, "1.2.1.2", "unknown")) Expect(err).Should(Succeed()) - Expect(resp.RType).Should(Equal(RESOLVED)) + Expect(resp.RType).Should(Equal(ResponseTypeRESOLVED)) m.AssertExpectations(GinkgoT()) m.AssertNumberOfCalls(GinkgoT(), "Resolve", 1) @@ -692,11 +692,11 @@ badcnamedomain.com`) resp, err := sut.Resolve(newRequestWithClient("blocked3.com.", dns.TypeA, "1.2.1.2", "unknown")) Expect(err).Should(Succeed()) - Expect(resp.RType).Should(Equal(BLOCKED)) + Expect(resp.RType).Should(Equal(ResponseTypeBLOCKED)) resp, err = sut.Resolve(newRequestWithClient("domain1.com.", dns.TypeA, "1.2.1.2", "unknown")) Expect(err).Should(Succeed()) - Expect(resp.RType).Should(Equal(BLOCKED)) + Expect(resp.RType).Should(Equal(ResponseTypeBLOCKED)) }) }) }) diff --git a/resolver/caching_resolver.go b/resolver/caching_resolver.go index bda09a0b6..4f48652ab 100644 --- a/resolver/caching_resolver.go +++ b/resolver/caching_resolver.go @@ -165,12 +165,12 @@ func (r *CachingResolver) Resolve(request *model.Request) (response *model.Respo rr.Header().Ttl = remainingTTL } - return &model.Response{Res: resp, RType: model.CACHED, Reason: "CACHED"}, nil + return &model.Response{Res: resp, RType: model.ResponseTypeCACHED, Reason: "CACHED"}, nil } // Answer with response code != OK resp.Rcode = val.(int) - return &model.Response{Res: resp, RType: model.CACHED, Reason: "CACHED NEGATIVE"}, nil + return &model.Response{Res: resp, RType: model.ResponseTypeCACHED, Reason: "CACHED NEGATIVE"}, nil } evt.Bus().Publish(evt.CachingResultCacheMiss, domain) diff --git a/resolver/caching_resolver_test.go b/resolver/caching_resolver_test.go index 9299eb41c..eef39d4ac 100644 --- a/resolver/caching_resolver_test.go +++ b/resolver/caching_resolver_test.go @@ -125,7 +125,7 @@ var _ = Describe("CachingResolver", func() { resp, err = sut.Resolve(newRequest("example.com.", dns.TypeA)) Expect(err).Should(Succeed()) - Expect(resp.RType).Should(Equal(RESOLVED)) + Expect(resp.RType).Should(Equal(ResponseTypeRESOLVED)) Expect(m.Calls).Should(HaveLen(1)) Expect(resp.Res.Rcode).Should(Equal(dns.RcodeSuccess)) Expect(resp.Res.Answer).Should(BeDNSRecord("example.com.", dns.TypeA, 600, "123.122.121.120")) @@ -144,7 +144,7 @@ var _ = Describe("CachingResolver", func() { resp, err = sut.Resolve(newRequest("example.com.", dns.TypeA)) Expect(err).Should(Succeed()) - Expect(resp.RType).Should(Equal(CACHED)) + Expect(resp.RType).Should(Equal(ResponseTypeCACHED)) // still one call to upstream Expect(m.Calls).Should(HaveLen(1)) Expect(resp.Res.Rcode).Should(Equal(dns.RcodeSuccess)) @@ -166,7 +166,7 @@ var _ = Describe("CachingResolver", func() { By("first request", func() { resp, err = sut.Resolve(newRequest("example.com.", dns.TypeA)) Expect(err).Should(Succeed()) - Expect(resp.RType).Should(Equal(RESOLVED)) + Expect(resp.RType).Should(Equal(ResponseTypeRESOLVED)) Expect(resp.Res.Rcode).Should(Equal(dns.RcodeSuccess)) Expect(m.Calls).Should(HaveLen(1)) Expect(resp.Res.Answer).Should(BeDNSRecord("example.com.", dns.TypeA, 300, "123.122.121.120")) @@ -177,7 +177,7 @@ var _ = Describe("CachingResolver", func() { By("second request", func() { resp, err = sut.Resolve(newRequest("example.com.", dns.TypeA)) Expect(err).Should(Succeed()) - Expect(resp.RType).Should(Equal(CACHED)) + Expect(resp.RType).Should(Equal(ResponseTypeCACHED)) Expect(resp.Res.Rcode).Should(Equal(dns.RcodeSuccess)) // still one call to upstream Expect(m.Calls).Should(HaveLen(1)) @@ -198,7 +198,7 @@ var _ = Describe("CachingResolver", func() { By("first request", func() { resp, err = sut.Resolve(newRequest("example.com.", dns.TypeAAAA)) Expect(err).Should(Succeed()) - Expect(resp.RType).Should(Equal(RESOLVED)) + Expect(resp.RType).Should(Equal(ResponseTypeRESOLVED)) Expect(resp.Res.Rcode).Should(Equal(dns.RcodeSuccess)) Expect(m.Calls).Should(HaveLen(1)) Expect(resp.Res.Answer).Should(BeDNSRecord("example.com.", @@ -210,7 +210,7 @@ var _ = Describe("CachingResolver", func() { By("second request", func() { resp, err = sut.Resolve(newRequest("example.com.", dns.TypeAAAA)) Expect(err).Should(Succeed()) - Expect(resp.RType).Should(Equal(CACHED)) + Expect(resp.RType).Should(Equal(ResponseTypeCACHED)) Expect(resp.Res.Rcode).Should(Equal(dns.RcodeSuccess)) // still one call to upstream Expect(m.Calls).Should(HaveLen(1)) @@ -240,7 +240,7 @@ var _ = Describe("CachingResolver", func() { By("first request", func() { resp, err = sut.Resolve(newRequest("example.com.", dns.TypeAAAA)) Expect(err).Should(Succeed()) - Expect(resp.RType).Should(Equal(RESOLVED)) + Expect(resp.RType).Should(Equal(ResponseTypeRESOLVED)) Expect(resp.Res.Rcode).Should(Equal(dns.RcodeSuccess)) Expect(m.Calls).Should(HaveLen(1)) Expect(resp.Res.Answer).Should(BeDNSRecord("example.com.", @@ -252,7 +252,7 @@ var _ = Describe("CachingResolver", func() { By("second request", func() { resp, err = sut.Resolve(newRequest("example.com.", dns.TypeAAAA)) Expect(err).Should(Succeed()) - Expect(resp.RType).Should(Equal(RESOLVED)) + Expect(resp.RType).Should(Equal(ResponseTypeRESOLVED)) Expect(resp.Res.Rcode).Should(Equal(dns.RcodeSuccess)) // one more call to upstream Expect(m.Calls).Should(HaveLen(2)) @@ -272,7 +272,7 @@ var _ = Describe("CachingResolver", func() { By("first request", func() { resp, err = sut.Resolve(newRequest("example.com.", dns.TypeAAAA)) Expect(err).Should(Succeed()) - Expect(resp.RType).Should(Equal(RESOLVED)) + Expect(resp.RType).Should(Equal(ResponseTypeRESOLVED)) Expect(resp.Res.Rcode).Should(Equal(dns.RcodeSuccess)) Expect(m.Calls).Should(HaveLen(1)) Expect(resp.Res.Answer).Should(BeDNSRecord("example.com.", @@ -284,7 +284,7 @@ var _ = Describe("CachingResolver", func() { By("second request", func() { resp, err = sut.Resolve(newRequest("example.com.", dns.TypeAAAA)) Expect(err).Should(Succeed()) - Expect(resp.RType).Should(Equal(CACHED)) + Expect(resp.RType).Should(Equal(ResponseTypeCACHED)) Expect(resp.Res.Rcode).Should(Equal(dns.RcodeSuccess)) // still one call to upstream Expect(m.Calls).Should(HaveLen(1)) @@ -307,7 +307,7 @@ var _ = Describe("CachingResolver", func() { By("first request", func() { resp, err = sut.Resolve(newRequest("example.com.", dns.TypeAAAA)) Expect(err).Should(Succeed()) - Expect(resp.RType).Should(Equal(RESOLVED)) + Expect(resp.RType).Should(Equal(ResponseTypeRESOLVED)) Expect(resp.Res.Rcode).Should(Equal(dns.RcodeNameError)) Expect(m.Calls).Should(HaveLen(1)) }) @@ -317,7 +317,7 @@ var _ = Describe("CachingResolver", func() { By("second request", func() { resp, err = sut.Resolve(newRequest("example.com.", dns.TypeAAAA)) Expect(err).Should(Succeed()) - Expect(resp.RType).Should(Equal(CACHED)) + Expect(resp.RType).Should(Equal(ResponseTypeCACHED)) Expect(resp.Reason).Should(Equal("CACHED NEGATIVE")) Expect(resp.Res.Rcode).Should(Equal(dns.RcodeNameError)) // still one call to resolver @@ -337,7 +337,7 @@ var _ = Describe("CachingResolver", func() { By("first request", func() { resp, err = sut.Resolve(newRequest("google.de.", dns.TypeMX)) Expect(err).Should(Succeed()) - Expect(resp.RType).Should(Equal(RESOLVED)) + Expect(resp.RType).Should(Equal(ResponseTypeRESOLVED)) Expect(resp.Res.Rcode).Should(Equal(dns.RcodeSuccess)) Expect(m.Calls).Should(HaveLen(1)) Expect(resp.Res.Answer).Should(BeDNSRecord("google.de.", dns.TypeMX, 180, "alt1.aspmx.l.google.com.")) @@ -346,7 +346,7 @@ var _ = Describe("CachingResolver", func() { By("second request", func() { resp, err = sut.Resolve(newRequest("google.de.", dns.TypeMX)) Expect(err).Should(Succeed()) - Expect(resp.RType).Should(Equal(CACHED)) + Expect(resp.RType).Should(Equal(ResponseTypeCACHED)) Expect(resp.Res.Rcode).Should(Equal(dns.RcodeSuccess)) Expect(m.Calls).Should(HaveLen(1)) Expect(resp.Res.Answer).Should(BeDNSRecord("google.de.", dns.TypeMX, 179, "alt1.aspmx.l.google.com.")) diff --git a/resolver/client_names_resolver_test.go b/resolver/client_names_resolver_test.go index 43ce9d34b..b1351bacb 100644 --- a/resolver/client_names_resolver_test.go +++ b/resolver/client_names_resolver_test.go @@ -271,7 +271,7 @@ var _ = Describe("ClientResolver", func() { When("resolver is enabled", func() { BeforeEach(func() { sutConfig = config.ClientLookupConfig{ - Upstream: config.Upstream{Net: "tcp", Host: "host"}, + Upstream: config.Upstream{Net: config.NetProtocolTcpUdp, Host: "host"}, SingleNameOrder: []uint{1, 2}, ClientnameIPMapping: map[string][]net.IP{ "client8": {net.ParseIP("1.2.3.5")}, diff --git a/resolver/conditionall_upstream_resolver.go b/resolver/conditionall_upstream_resolver.go index 6eaf1c701..90bf55938 100644 --- a/resolver/conditionall_upstream_resolver.go +++ b/resolver/conditionall_upstream_resolver.go @@ -83,7 +83,7 @@ func (r *ConditionalUpstreamResolver) Resolve(request *model.Request) (*model.Re if err == nil { response.Reason = "CONDITIONAL" - response.RType = model.CONDITIONAL + response.RType = model.ResponseTypeCONDITIONAL response.Res.Question[0].Name = question.Name } diff --git a/resolver/conditionall_upstream_resolver_test.go b/resolver/conditionall_upstream_resolver_test.go index e7d6e3371..d86d48770 100644 --- a/resolver/conditionall_upstream_resolver_test.go +++ b/resolver/conditionall_upstream_resolver_test.go @@ -57,7 +57,7 @@ var _ = Describe("ConditionalUpstreamResolver", func() { Expect(resp.Res.Answer).Should(BeDNSRecord("fritz.box.", dns.TypeA, 123, "123.124.122.122")) // no call to next resolver Expect(m.Calls).Should(BeEmpty()) - Expect(resp.RType).Should(Equal(CONDITIONAL)) + Expect(resp.RType).Should(Equal(ResponseTypeCONDITIONAL)) }) }) Context("last mapping entry", func() { @@ -67,7 +67,7 @@ var _ = Describe("ConditionalUpstreamResolver", func() { Expect(resp.Res.Answer).Should(BeDNSRecord("other.box.", dns.TypeA, 250, "192.192.192.192")) // no call to next resolver Expect(m.Calls).Should(BeEmpty()) - Expect(resp.RType).Should(Equal(CONDITIONAL)) + Expect(resp.RType).Should(Equal(ResponseTypeCONDITIONAL)) }) }) }) @@ -78,7 +78,7 @@ var _ = Describe("ConditionalUpstreamResolver", func() { Expect(resp.Res.Answer).Should(BeDNSRecord("test.fritz.box.", dns.TypeA, 123, "123.124.122.122")) // no call to next resolver Expect(m.Calls).Should(BeEmpty()) - Expect(resp.RType).Should(Equal(CONDITIONAL)) + Expect(resp.RType).Should(Equal(ResponseTypeCONDITIONAL)) }) }) When("rewrite mapping is defined", func() { @@ -88,7 +88,7 @@ var _ = Describe("ConditionalUpstreamResolver", func() { Expect(resp.Res.Answer).Should(BeDNSRecord("test.fritz.box.", dns.TypeA, 123, "123.124.122.122")) // no call to next resolver Expect(m.Calls).Should(BeEmpty()) - Expect(resp.RType).Should(Equal(CONDITIONAL)) + Expect(resp.RType).Should(Equal(ResponseTypeCONDITIONAL)) }) It("Should delegate to next resolver if there is no subdomain after rewrite", func() { diff --git a/resolver/custom_dns_resolver.go b/resolver/custom_dns_resolver.go index ce6772605..ebd84d1a2 100644 --- a/resolver/custom_dns_resolver.go +++ b/resolver/custom_dns_resolver.go @@ -73,7 +73,7 @@ func (r *CustomDNSResolver) handleReverseDNS(request *model.Request) *model.Resp response.Answer = append(response.Answer, ptr) } - return &model.Response{Res: response, RType: model.CUSTOMDNS, Reason: "CUSTOM DNS"} + return &model.Response{Res: response, RType: model.ResponseTypeCUSTOMDNS, Reason: "CUSTOM DNS"} } } @@ -112,13 +112,13 @@ func (r *CustomDNSResolver) Resolve(request *model.Request) (*model.Response, er "domain": domain, }).Debugf("returning custom dns entry") - return &model.Response{Res: response, RType: model.CUSTOMDNS, Reason: "CUSTOM DNS"}, nil + return &model.Response{Res: response, RType: model.ResponseTypeCUSTOMDNS, Reason: "CUSTOM DNS"}, nil } // Mapping exists for this domain, but for another type // return NOERROR with empty result - return &model.Response{Res: response, RType: model.CUSTOMDNS, Reason: "CUSTOM DNS"}, nil + return &model.Response{Res: response, RType: model.ResponseTypeCUSTOMDNS, Reason: "CUSTOM DNS"}, nil } if i := strings.Index(domain, "."); i >= 0 { diff --git a/resolver/ipv6_disabling_resolver.go b/resolver/ipv6_disabling_resolver.go index dcb2aafd3..3261623eb 100644 --- a/resolver/ipv6_disabling_resolver.go +++ b/resolver/ipv6_disabling_resolver.go @@ -16,7 +16,7 @@ func (r *IPv6DisablingResolver) Resolve(request *model.Request) (*model.Response response := new(dns.Msg) response.SetRcode(request.Req, dns.RcodeSuccess) - return &model.Response{Res: response, RType: model.RESOLVED}, nil + return &model.Response{Res: response, RType: model.ResponseTypeRESOLVED}, nil } return r.next.Resolve(request) diff --git a/resolver/mocks.go b/resolver/mocks.go index e4c103636..495ba3dfe 100644 --- a/resolver/mocks.go +++ b/resolver/mocks.go @@ -124,5 +124,5 @@ func TestUDPUpstream(fn func(request *dns.Msg) (response *dns.Msg)) config.Upstr } }() - return config.Upstream{Net: "tcp+udp", Host: host, Port: port} + return config.Upstream{Net: config.NetProtocolTcpUdp, Host: host, Port: port} } diff --git a/resolver/parallel_best_resolver_test.go b/resolver/parallel_best_resolver_test.go index c05c95480..fa814b756 100644 --- a/resolver/parallel_best_resolver_test.go +++ b/resolver/parallel_best_resolver_test.go @@ -60,7 +60,7 @@ var _ = Describe("ParallelBestResolver", func() { Expect(err).Should(Succeed()) Expect(resp.Res.Rcode).Should(Equal(dns.RcodeSuccess)) - Expect(resp.RType).Should(Equal(RESOLVED)) + Expect(resp.RType).Should(Equal(ResponseTypeRESOLVED)) Expect(resp.Res.Answer).Should(BeDNSRecord("example.com.", dns.TypeA, 123, "123.124.122.122")) }) }) @@ -84,7 +84,7 @@ var _ = Describe("ParallelBestResolver", func() { Expect(err).Should(Succeed()) Expect(resp.Res.Rcode).Should(Equal(dns.RcodeSuccess)) - Expect(resp.RType).Should(Equal(RESOLVED)) + Expect(resp.RType).Should(Equal(ResponseTypeRESOLVED)) Expect(resp.Res.Answer).Should(BeDNSRecord("example.com.", dns.TypeA, 123, "123.124.122.123")) }) }) @@ -152,7 +152,7 @@ var _ = Describe("ParallelBestResolver", func() { resp, err = sut.Resolve(request) Expect(resp.Res.Rcode).Should(Equal(dns.RcodeSuccess)) - Expect(resp.RType).Should(Equal(RESOLVED)) + Expect(resp.RType).Should(Equal(ResponseTypeRESOLVED)) Expect(resp.Res.Answer).Should(BeDNSRecord("example.com.", dns.TypeA, 123, "123.124.122.122")) }) It("Should use client specific resolver if client name matches exact", func() { @@ -160,7 +160,7 @@ var _ = Describe("ParallelBestResolver", func() { resp, err = sut.Resolve(request) Expect(resp.Res.Rcode).Should(Equal(dns.RcodeSuccess)) - Expect(resp.RType).Should(Equal(RESOLVED)) + Expect(resp.RType).Should(Equal(ResponseTypeRESOLVED)) Expect(resp.Res.Answer).Should(BeDNSRecord("example.com.", dns.TypeA, 123, "123.124.122.123")) }) It("Should use client specific resolver if client name matches with wildcard", func() { @@ -168,7 +168,7 @@ var _ = Describe("ParallelBestResolver", func() { resp, err = sut.Resolve(request) Expect(resp.Res.Rcode).Should(Equal(dns.RcodeSuccess)) - Expect(resp.RType).Should(Equal(RESOLVED)) + Expect(resp.RType).Should(Equal(ResponseTypeRESOLVED)) Expect(resp.Res.Answer).Should(BeDNSRecord("example.com.", dns.TypeA, 123, "123.124.122.124")) }) It("Should use client specific resolver if client name matches with range wildcard", func() { @@ -176,7 +176,7 @@ var _ = Describe("ParallelBestResolver", func() { resp, err = sut.Resolve(request) Expect(resp.Res.Rcode).Should(Equal(dns.RcodeSuccess)) - Expect(resp.RType).Should(Equal(RESOLVED)) + Expect(resp.RType).Should(Equal(ResponseTypeRESOLVED)) Expect(resp.Res.Answer).Should(BeDNSRecord("example.com.", dns.TypeA, 123, "123.124.122.124")) }) It("Should use client specific resolver if client IP matches", func() { @@ -184,7 +184,7 @@ var _ = Describe("ParallelBestResolver", func() { resp, err = sut.Resolve(request) Expect(resp.Res.Rcode).Should(Equal(dns.RcodeSuccess)) - Expect(resp.RType).Should(Equal(RESOLVED)) + Expect(resp.RType).Should(Equal(ResponseTypeRESOLVED)) Expect(resp.Res.Answer).Should(BeDNSRecord("example.com.", dns.TypeA, 123, "123.124.122.125")) }) It("Should use client specific resolver if client's CIDR (10.43.8.64 - 10.43.8.79) matches", func() { @@ -192,7 +192,7 @@ var _ = Describe("ParallelBestResolver", func() { resp, err = sut.Resolve(request) Expect(resp.Res.Rcode).Should(Equal(dns.RcodeSuccess)) - Expect(resp.RType).Should(Equal(RESOLVED)) + Expect(resp.RType).Should(Equal(ResponseTypeRESOLVED)) Expect(resp.Res.Answer).Should(BeDNSRecord("example.com.", dns.TypeA, 123, "123.124.122.126")) }) }) @@ -212,7 +212,7 @@ var _ = Describe("ParallelBestResolver", func() { resp, err = sut.Resolve(request) Expect(resp.Res.Rcode).Should(Equal(dns.RcodeSuccess)) - Expect(resp.RType).Should(Equal(RESOLVED)) + Expect(resp.RType).Should(Equal(ResponseTypeRESOLVED)) Expect(resp.Res.Answer).Should(BeDNSRecord("example.com.", dns.TypeA, 123, "123.124.122.122")) }) }) diff --git a/resolver/query_logging_resolver.go b/resolver/query_logging_resolver.go index 746b130bc..96f018580 100644 --- a/resolver/query_logging_resolver.go +++ b/resolver/query_logging_resolver.go @@ -30,13 +30,13 @@ func NewQueryLoggingResolver(cfg config.QueryLogConfig) ChainedResolver { var writer querylog.Writer switch cfg.Type { - case config.QueryLogTypeCSV: + case config.QueryLogTypeCsv: writer = querylog.NewCSVWriter(cfg.Target, false, cfg.LogRetentionDays) - case config.QueryLogTypeCSVPerClient: + case config.QueryLogTypeCsvClient: writer = querylog.NewCSVWriter(cfg.Target, true, cfg.LogRetentionDays) - case config.QueryLogTypeMySQL: + case config.QueryLogTypeMysql: writer = querylog.NewDatabaseWriter(cfg.Target, cfg.LogRetentionDays) - default: + case config.QueryLogTypeNone: writer = querylog.NewLoggerWriter() } diff --git a/resolver/query_logging_resolver_test.go b/resolver/query_logging_resolver_test.go index 5d6a6bda6..46823026e 100644 --- a/resolver/query_logging_resolver_test.go +++ b/resolver/query_logging_resolver_test.go @@ -76,14 +76,14 @@ var _ = Describe("QueryLoggingResolver", func() { resp, err = sut.Resolve(newRequest("example.com.", dns.TypeA)) m.AssertExpectations(GinkgoT()) - Expect(resp.RType).Should(Equal(RESOLVED)) + Expect(resp.RType).Should(Equal(ResponseTypeRESOLVED)) }) }) When("Configuration with logging per client", func() { BeforeEach(func() { sutConfig = config.QueryLogConfig{ Target: tmpDir, - Type: config.QueryLogTypeCSVPerClient, + Type: config.QueryLogTypeCsvClient, } mockAnswer, _ = util.NewMsgWithAnswer("example.com.", 300, dns.TypeA, "123.122.121.120") }) @@ -127,7 +127,7 @@ var _ = Describe("QueryLoggingResolver", func() { BeforeEach(func() { sutConfig = config.QueryLogConfig{ Target: tmpDir, - Type: config.QueryLogTypeCSV, + Type: config.QueryLogTypeCsv, } mockAnswer, _ = util.NewMsgWithAnswer("example.com.", 300, dns.TypeA, "123.122.121.120") }) @@ -193,7 +193,7 @@ var _ = Describe("QueryLoggingResolver", func() { BeforeEach(func() { sutConfig = config.QueryLogConfig{ Target: tmpDir, - Type: config.QueryLogTypeCSVPerClient, + Type: config.QueryLogTypeCsvClient, LogRetentionDays: 0, } }) @@ -226,7 +226,7 @@ var _ = Describe("QueryLoggingResolver", func() { Log().ExitFunc = func(int) { fatal = true } _ = NewQueryLoggingResolver(config.QueryLogConfig{ Target: "notExists", - Type: config.QueryLogTypeCSV, + Type: config.QueryLogTypeCsv, }) Expect(fatal).Should(BeTrue()) @@ -242,7 +242,7 @@ var _ = Describe("QueryLoggingResolver", func() { sut := NewQueryLoggingResolver(config.QueryLogConfig{ Target: "wrongDir", - Type: config.QueryLogTypeCSV, + Type: config.QueryLogTypeCsv, LogRetentionDays: 7, }).(*QueryLoggingResolver) @@ -275,7 +275,7 @@ var _ = Describe("QueryLoggingResolver", func() { sut := NewQueryLoggingResolver(config.QueryLogConfig{ Target: tmpDir, - Type: config.QueryLogTypeCSV, + Type: config.QueryLogTypeCsv, LogRetentionDays: 7, }) @@ -301,7 +301,7 @@ var _ = Describe("Wrong target configuration", func() { helpertest.ShouldLogFatal(func() { sutConfig := config.QueryLogConfig{ Target: "dummy", - Type: config.QueryLogTypeMySQL, + Type: config.QueryLogTypeMysql, } NewQueryLoggingResolver(sutConfig) }) diff --git a/resolver/resolver.go b/resolver/resolver.go index db6536920..43f687da2 100644 --- a/resolver/resolver.go +++ b/resolver/resolver.go @@ -24,7 +24,7 @@ func newRequest(question string, rType uint16, logger ...*logrus.Entry) *model.R return &model.Request{ Req: util.NewMsgWithQuestion(question, rType), Log: loggerEntry, - Protocol: model.UDP, + Protocol: model.RequestProtocolUDP, } } @@ -35,7 +35,7 @@ func newRequestWithClient(question string, rType uint16, ip string, clientNames Req: util.NewMsgWithQuestion(question, rType), Log: logrus.NewEntry(log.Log()), RequestTS: time.Time{}, - Protocol: model.UDP, + Protocol: model.RequestProtocolUDP, } } diff --git a/resolver/resolver_suite_test.go b/resolver/resolver_suite_test.go index ceb66c9cb..d72c44153 100644 --- a/resolver/resolver_suite_test.go +++ b/resolver/resolver_suite_test.go @@ -10,7 +10,7 @@ import ( ) func TestResolver(t *testing.T) { - ConfigureLogger("Warn", "text", true) + ConfigureLogger(LevelFatal, FormatTypeText, true) RegisterFailHandler(Fail) RunSpecs(t, "Resolver Suite") } diff --git a/resolver/stats_resolver.go b/resolver/stats_resolver.go index 0932dd85b..bb146b2fa 100644 --- a/resolver/stats_resolver.go +++ b/resolver/stats_resolver.go @@ -122,7 +122,7 @@ func createRecorders() []*resolverStatRecorder { return util.ExtractDomain(e.request.Req.Question[0]) }), newRecorderWithMax("Top 20 blocked queries", 20, func(e *statsEntry) string { - if e.response.RType == model.BLOCKED { + if e.response.RType == model.ResponseTypeBLOCKED { return util.ExtractDomain(e.request.Req.Question[0]) } return "" diff --git a/resolver/upstream_resolver.go b/resolver/upstream_resolver.go index 173033777..458229fb2 100644 --- a/resolver/upstream_resolver.go +++ b/resolver/upstream_resolver.go @@ -28,7 +28,7 @@ type UpstreamResolver struct { NextResolver upstreamURL string upstreamClient upstreamClient - net string + net config.NetProtocol } type upstreamClient interface { @@ -45,7 +45,7 @@ type httpUpstreamClient struct { } func createUpstreamClient(cfg config.Upstream) (client upstreamClient, upstreamURL string) { - if cfg.Net == config.NetHTTPS { + if cfg.Net == config.NetProtocolHttps { return &httpUpstreamClient{ client: &http.Client{ Transport: &http.Transport{ @@ -57,10 +57,10 @@ func createUpstreamClient(cfg config.Upstream) (client upstreamClient, upstreamU }, fmt.Sprintf("%s://%s:%d%s", cfg.Net, cfg.Host, cfg.Port, cfg.Path) } - if cfg.Net == config.NetTCPTLS { + if cfg.Net == config.NetProtocolTcpTls { return &dnsUpstreamClient{ tcpClient: &dns.Client{ - Net: cfg.Net, + Net: cfg.Net.String(), Timeout: defaultTimeout, Dialer: util.Dialer(config.GetConfig()), }, @@ -129,7 +129,7 @@ func (r *httpUpstreamClient) callExternal(msg *dns.Msg, func (r *dnsUpstreamClient) callExternal(msg *dns.Msg, upstreamURL string, protocol model.RequestProtocol) (response *dns.Msg, rtt time.Duration, err error) { - if protocol == model.TCP { + if protocol == model.RequestProtocolTCP { response, rtt, err = r.tcpClient.Exchange(msg, upstreamURL) if err != nil { // try UDP as fallback diff --git a/resolver/upstream_resolver_test.go b/resolver/upstream_resolver_test.go index 5c0bddbc2..38dbc9e58 100644 --- a/resolver/upstream_resolver_test.go +++ b/resolver/upstream_resolver_test.go @@ -32,7 +32,7 @@ var _ = Describe("UpstreamResolver", func() { resp, err := sut.Resolve(newRequest("example.com.", dns.TypeA)) Expect(err).Should(Succeed()) Expect(resp.Res.Rcode).Should(Equal(dns.RcodeSuccess)) - Expect(resp.RType).Should(Equal(RESOLVED)) + Expect(resp.RType).Should(Equal(ResponseTypeRESOLVED)) Expect(resp.Res.Answer).Should(BeDNSRecord("example.com.", dns.TypeA, 123, "123.124.122.122")) Expect(resp.Reason).Should(Equal(fmt.Sprintf("RESOLVED (%s:%d)", upstream.Host, upstream.Port))) }) @@ -50,7 +50,7 @@ var _ = Describe("UpstreamResolver", func() { resp, err := sut.Resolve(newRequest("example.com.", dns.TypeA)) Expect(err).Should(Succeed()) Expect(resp.Res.Rcode).Should(Equal(dns.RcodeNameError)) - Expect(resp.RType).Should(Equal(RESOLVED)) + Expect(resp.RType).Should(Equal(ResponseTypeRESOLVED)) Expect(resp.Reason).Should(Equal(fmt.Sprintf("RESOLVED (%s:%d)", upstream.Host, upstream.Port))) }) }) @@ -92,7 +92,7 @@ var _ = Describe("UpstreamResolver", func() { Expect(err).Should(Succeed()) Expect(resp.Res.Rcode).Should(Equal(dns.RcodeSuccess)) Expect(resp.Res.Answer).Should(BeDNSRecord("example.com.", dns.TypeA, 123, "123.124.122.122")) - Expect(resp.RType).Should(Equal(RESOLVED)) + Expect(resp.RType).Should(Equal(ResponseTypeRESOLVED)) }) By("3 attempts with timeout -> should return error", func() { @@ -141,7 +141,7 @@ var _ = Describe("UpstreamResolver", func() { resp, err := sut.Resolve(newRequest("example.com.", dns.TypeA)) Expect(err).Should(Succeed()) Expect(resp.Res.Rcode).Should(Equal(dns.RcodeSuccess)) - Expect(resp.RType).Should(Equal(RESOLVED)) + Expect(resp.RType).Should(Equal(ResponseTypeRESOLVED)) Expect(resp.Res.Answer).Should(BeDNSRecord("example.com.", dns.TypeA, 123, "123.124.122.122")) Expect(resp.Reason).Should(Equal(fmt.Sprintf("RESOLVED (https://%s:%d)", upstream.Host, upstream.Port))) }) @@ -184,7 +184,7 @@ var _ = Describe("UpstreamResolver", func() { }) When("Configured DOH resolver does not respond", func() { JustBeforeEach(func() { - sut = NewUpstreamResolver(config.Upstream{Net: "https", Host: "wronghost.example.com"}) + sut = NewUpstreamResolver(config.Upstream{Net: config.NetProtocolHttps, Host: "wronghost.example.com"}) }) It("should return error", func() { _, err := sut.Resolve(newRequest("example.com.", dns.TypeA)) @@ -194,7 +194,7 @@ var _ = Describe("UpstreamResolver", func() { }) When("Configured DOH resolver receives wrong request", func() { JustBeforeEach(func() { - sut = NewUpstreamResolver(config.Upstream{Net: "https", Host: "host"}) + sut = NewUpstreamResolver(config.Upstream{Net: config.NetProtocolHttps, Host: "host"}) }) It("should return error", func() { wrongReq := new(dns.Msg) diff --git a/server/server.go b/server/server.go index ad8590fa5..a298f74c9 100644 --- a/server/server.go +++ b/server/server.go @@ -50,7 +50,7 @@ func getServerAddress(addr string) string { func NewServer(cfg *config.Config) (server *Server, err error) { address := getServerAddress(cfg.Port) - log.ConfigureLogger(cfg.LogLevel, cfg.LogFormat, cfg.LogTimestamp) + log.ConfigureLogger(log.LevelInfo, cfg.LogFormat, cfg.LogTimestamp) udpServer := createUDPServer(address) tcpServer := createTCPServer(address) @@ -326,10 +326,10 @@ func (s *Server) OnHealthCheck(w dns.ResponseWriter, request *dns.Msg) { func resolveClientIPAndProtocol(addr net.Addr) (ip net.IP, protocol model.RequestProtocol) { if t, ok := addr.(*net.UDPAddr); ok { - return t.IP, model.UDP + return t.IP, model.RequestProtocolUDP } else if t, ok := addr.(*net.TCPAddr); ok { - return t.IP, model.TCP + return t.IP, model.RequestProtocolTCP } - return nil, model.TCP + return nil, model.RequestProtocolUDP } diff --git a/server/server_endpoints.go b/server/server_endpoints.go index cf2e3ab55..36d24ab31 100644 --- a/server/server_endpoints.go +++ b/server/server_endpoints.go @@ -94,7 +94,7 @@ func (s *Server) processDohMessage(rawMsg []byte, rw http.ResponseWriter, req *h return } - r := newRequest(net.ParseIP(extractIP(req)), model.TCP, msg) + r := newRequest(net.ParseIP(extractIP(req)), model.RequestProtocolTCP, msg) resResponse, err := s.queryResolver.Resolve(r) diff --git a/server/server_suite_test.go b/server/server_suite_test.go index f58203de3..5ee29202b 100644 --- a/server/server_suite_test.go +++ b/server/server_suite_test.go @@ -9,7 +9,7 @@ import ( ) func TestDNSServer(t *testing.T) { - ConfigureLogger("Warn", "text", true) + ConfigureLogger(LevelFatal, FormatTypeText, true) RegisterFailHandler(Fail) RunSpecs(t, "Server Suite") } diff --git a/server/server_test.go b/server/server_test.go index c008df965..7e025784e 100644 --- a/server/server_test.go +++ b/server/server_test.go @@ -102,7 +102,6 @@ var _ = Describe("Running DNS server", func() { Port: "55555", HTTPPort: "4000", - LogLevel: "info", Prometheus: config.PrometheusConfig{ Enable: true, Path: "/metrics", @@ -476,7 +475,7 @@ var _ = Describe("Running DNS server", func() { server, err := NewServer(&config.Config{ Upstream: config.UpstreamConfig{ ExternalResolvers: map[string][]config.Upstream{ - "default": {config.Upstream{Net: "tcp+udp", Host: "4.4.4.4", Port: 53}}}}, + "default": {config.Upstream{Net: config.NetProtocolTcpUdp, Host: "4.4.4.4", Port: 53}}}}, CustomDNS: config.CustomDNSConfig{ Mapping: config.CustomDNSMapping{ HostIPs: map[string][]net.IP{ @@ -484,8 +483,7 @@ var _ = Describe("Running DNS server", func() { "lan.home": {net.ParseIP("192.168.178.56")}, }, }}, - Port: ":55556", - LogLevel: "info", + Port: ":55556", }) Expect(err).Should(Succeed()) @@ -523,7 +521,7 @@ var _ = Describe("Running DNS server", func() { server, err := NewServer(&config.Config{ Upstream: config.UpstreamConfig{ ExternalResolvers: map[string][]config.Upstream{ - "default": {config.Upstream{Net: "tcp+udp", Host: "4.4.4.4", Port: 53}}}}, + "default": {config.Upstream{Net: config.NetProtocolTcpUdp, Host: "4.4.4.4", Port: 53}}}}, CustomDNS: config.CustomDNSConfig{ Mapping: config.CustomDNSMapping{ HostIPs: map[string][]net.IP{ @@ -532,8 +530,7 @@ var _ = Describe("Running DNS server", func() { }, }}, - Port: "127.0.0.1:55557", - LogLevel: "info", + Port: "127.0.0.1:55557", }) Expect(err).Should(Succeed()) @@ -565,14 +562,14 @@ var _ = Describe("Running DNS server", func() { It("should correct resolve client IP", func() { ip, protocol := resolveClientIPAndProtocol(&net.UDPAddr{IP: net.ParseIP("192.168.178.88")}) Expect(ip).Should(Equal(net.ParseIP("192.168.178.88"))) - Expect(protocol).Should(Equal(model.UDP)) + Expect(protocol).Should(Equal(model.RequestProtocolUDP)) }) }) Context("TCP address", func() { It("should correct resolve client IP", func() { ip, protocol := resolveClientIPAndProtocol(&net.TCPAddr{IP: net.ParseIP("192.168.178.88")}) Expect(ip).Should(Equal(net.ParseIP("192.168.178.88"))) - Expect(protocol).Should(Equal(model.TCP)) + Expect(protocol).Should(Equal(model.RequestProtocolTCP)) }) }) }) diff --git a/stats/stats_suite_test.go b/stats/stats_suite_test.go index b424299ac..aa879fe5a 100644 --- a/stats/stats_suite_test.go +++ b/stats/stats_suite_test.go @@ -9,7 +9,7 @@ import ( ) func TestStats(t *testing.T) { - ConfigureLogger("Warn", "text", true) + ConfigureLogger(LevelFatal, FormatTypeText, true) RegisterFailHandler(Fail) RunSpecs(t, "Stats Suite") } diff --git a/util/bootstrap.go b/util/bootstrap.go index cd2147a65..584b8bc3a 100644 --- a/util/bootstrap.go +++ b/util/bootstrap.go @@ -15,7 +15,7 @@ func Dialer(cfg *config.Config) *net.Dialer { var resolver *net.Resolver if cfg.BootstrapDNS != (config.Upstream{}) { - if cfg.BootstrapDNS.Net == config.NetTCPUDP { + if cfg.BootstrapDNS.Net == config.NetProtocolTcpUdp { dns := net.JoinHostPort(cfg.BootstrapDNS.Host, fmt.Sprint(cfg.BootstrapDNS.Port)) log.Log().Debugf("using %s as bootstrap dns server", dns) diff --git a/util/bootstrap_test.go b/util/bootstrap_test.go index e29334f2e..8aa99ca94 100644 --- a/util/bootstrap_test.go +++ b/util/bootstrap_test.go @@ -19,7 +19,7 @@ var _ = Describe("Bootstrap resolver configuration", func() { When("BootstrapDns is configured UDP resolver", func() { dialer := Dialer(&config.Config{ BootstrapDNS: config.Upstream{ - Net: config.NetTCPUDP, + Net: config.NetProtocolTcpUdp, Host: "0.0.0.0", Port: 53, }, @@ -36,7 +36,7 @@ var _ = Describe("Bootstrap resolver configuration", func() { helpertest.ShouldLogFatal(func() { Dialer(&config.Config{ BootstrapDNS: config.Upstream{ - Net: config.NetHTTPS, + Net: config.NetProtocolHttps, Host: "1.1.1.1", Port: 53, }, diff --git a/util/util_suite_test.go b/util/util_suite_test.go index 4248edc8e..e47dc46f8 100644 --- a/util/util_suite_test.go +++ b/util/util_suite_test.go @@ -9,7 +9,7 @@ import ( ) func TestLists(t *testing.T) { - ConfigureLogger("Warn", "text", true) + ConfigureLogger(LevelError, FormatTypeText, true) RegisterFailHandler(Fail) RunSpecs(t, "Util Suite") }