Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

application startup should fail if initial download of a single list failed (#310) #313

Merged
merged 17 commits into from
Oct 13, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Revert "added GetInitErrors to blocking_resolver"
This reverts commit 940bf9b.
  • Loading branch information
kwitsch committed Oct 11, 2021
commit 5c9581dca8b6acb2663e2e0314e0b4e8e04f5e0a
18 changes: 2 additions & 16 deletions resolver/blocking_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 66,6 @@ type status struct {
disabledGroups []string
enableTimer *time.Timer
disableEnd time.Time
initErrors []error
}

// BlockingResolver checks request's question (domain name) against black and white lists
Expand All @@ -85,17 84,10 @@ func NewBlockingResolver(cfg config.BlockingConfig) ChainedResolver {
blockHandler := createBlockHandler(cfg)
refreshPeriod := time.Duration(cfg.RefreshPeriod)
timeout := time.Duration(cfg.DownloadTimeout)
blacklistMatcher, blErr := lists.NewListCache(lists.ListCacheTypeBlacklist, cfg.BlackLists, refreshPeriod, timeout)
whitelistMatcher, wlErr := lists.NewListCache(lists.ListCacheTypeWhitelist, cfg.WhiteLists, refreshPeriod, timeout)
blacklistMatcher := lists.NewListCache(lists.ListCacheTypeBlacklist, cfg.BlackLists, refreshPeriod, timeout)
whitelistMatcher := lists.NewListCache(lists.ListCacheTypeWhitelist, cfg.WhiteLists, refreshPeriod, timeout)
whitelistOnlyGroups := determineWhitelistOnlyGroups(&cfg)

var initErrors []error
if len(blErr) > 0 {
initErrors = append(initErrors, blErr...)
}
if len(wlErr) > 0 {
initErrors = append(initErrors, wlErr...)
}
res := &BlockingResolver{
blockHandler: blockHandler,
cfg: cfg,
Expand All @@ -105,18 97,12 @@ func NewBlockingResolver(cfg config.BlockingConfig) ChainedResolver {
status: &status{
enabled: true,
enableTimer: time.NewTimer(0),
initErrors: initErrors,
},
}

return res
}

//returns a list of errors which occurred during the initialisation
func (c *BlockingResolver) GetInitErrors() []error {
return c.status.initErrors
}

// RefreshLists triggers the refresh of all black and white lists in the cache
func (r *BlockingResolver) RefreshLists() {
r.blacklistMatcher.Refresh()
Expand Down
4 changes: 0 additions & 4 deletions resolver/caching_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 52,6 @@ func NewCachingResolver(cfg config.CachingConfig) ChainedResolver {
return c
}

func (c *CachingResolver) GetInitErrors() []error {
return []error{}
}

func createQueryResultCache(cfg *config.CachingConfig) *cache.Cache {
return cache.NewWithLRU(15*time.Minute, 15*time.Second, cfg.MaxItemsCount)
}
Expand Down
4 changes: 0 additions & 4 deletions resolver/client_names_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 39,6 @@ func NewClientNamesResolver(cfg config.ClientLookupConfig) ChainedResolver {
}
}

func (c *ClientNamesResolver) GetInitErrors() []error {
return []error{}
}

// Configuration returns current resolver configuration
func (r *ClientNamesResolver) Configuration() (result []string) {
if r.externalResolver != nil || len(r.clientIPMapping) > 0 {
Expand Down
4 changes: 0 additions & 4 deletions resolver/conditionall_upstream_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 37,6 @@ func NewConditionalUpstreamResolver(cfg config.ConditionalUpstreamConfig) Chaine
return &ConditionalUpstreamResolver{mapping: m, rewrite: rewrite}
}

func (c *ConditionalUpstreamResolver) GetInitErrors() []error {
return []error{}
}

// Configuration returns current configuration
func (r *ConditionalUpstreamResolver) Configuration() (result []string) {
if len(r.mapping) > 0 {
Expand Down
4 changes: 0 additions & 4 deletions resolver/custom_dns_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 39,6 @@ func NewCustomDNSResolver(cfg config.CustomDNSConfig) ChainedResolver {
return &CustomDNSResolver{mapping: m, reverseAddresses: reverse}
}

func (c *CustomDNSResolver) GetInitErrors() []error {
return []error{}
}

// Configuration returns current resolver configuration
func (r *CustomDNSResolver) Configuration() (result []string) {
if len(r.mapping) > 0 {
Expand Down
4 changes: 0 additions & 4 deletions resolver/ipv6_disabling_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 35,3 @@ func (r *IPv6DisablingResolver) Configuration() (result []string) {
func NewIPv6Checker(disable bool) ChainedResolver {
return &IPv6DisablingResolver{disableAAAA: disable}
}

func (c *IPv6DisablingResolver) GetInitErrors() []error {
return []error{}
}
4 changes: 0 additions & 4 deletions resolver/metrics_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 84,6 @@ func NewMetricsResolver(cfg config.PrometheusConfig) ChainedResolver {
}
}

func (c *MetricsResolver) GetInitErrors() []error {
return []error{}
}

func totalQueriesMetric() *prometheus.CounterVec {
return prometheus.NewCounterVec(
prometheus.CounterOpts{
Expand Down
4 changes: 0 additions & 4 deletions resolver/mocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 37,6 @@ func (r *resolverMock) Resolve(req *model.Request) (*model.Response, error) {
return nil, args.Error(1)
}

func (c *resolverMock) GetInitErrors() []error {
return []error{}
}

// TestDOHUpstream creates a mock DoH Upstream
func TestDOHUpstream(fn func(request *dns.Msg) (response *dns.Msg),
reqFn ...func(w http.ResponseWriter)) config.Upstream {
Expand Down
4 changes: 0 additions & 4 deletions resolver/parallel_best_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 175,6 @@ func (r *ParallelBestResolver) Resolve(request *model.Request) (*model.Response,
r1.resolver, r2.resolver, collectedErrors)
}

func (c *ParallelBestResolver) GetInitErrors() []error {
return []error{}
}

// pick 2 different random resolvers from the resolver pool
func pickRandom(resolvers []*upstreamResolverStatus) (resolver1, resolver2 *upstreamResolverStatus) {
resolver1 = weightedRandom(resolvers, nil)
Expand Down
4 changes: 0 additions & 4 deletions resolver/query_logging_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 57,6 @@ func NewQueryLoggingResolver(cfg config.QueryLogConfig) ChainedResolver {
return &resolver
}

func (c *QueryLoggingResolver) GetInitErrors() []error {
return []error{}
}

// triggers periodically cleanup of old log files
func (r *QueryLoggingResolver) periodicCleanUp() {
ticker := time.NewTicker(cleanUpRunPeriod)
Expand Down
3 changes: 0 additions & 3 deletions resolver/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 47,6 @@ type Resolver interface {

// Configuration prints current resolver configuration
Configuration() []string

//returns a list of errors which occurred during the initialisation
GetInitErrors() []error
}

// ChainedResolver represents a resolver, which can delegate result to the next one
Expand Down
4 changes: 0 additions & 4 deletions resolver/upstream_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 204,3 @@ func (r *UpstreamResolver) Resolve(request *model.Request) (response *model.Resp

return response, err
}

func (c *UpstreamResolver) GetInitErrors() []error {
return []error{}
}