diff --git a/app/dns/dns.go b/app/dns/dns.go index 85f82521..2f272989 100644 --- a/app/dns/dns.go +++ b/app/dns/dns.go @@ -288,6 +288,7 @@ func (s *DNS) sortClients(domain string) []*Client { clientNames = append(clientNames, client.Name()) hasMatch = true if client.finalQuery { + logDecision(s.ctx, domain, domainRules, clientNames) return clients } } @@ -302,17 +303,13 @@ func (s *DNS) sortClients(domain string) []*Client { clients = append(clients, client) clientNames = append(clientNames, client.Name()) if client.finalQuery { + logDecision(s.ctx, domain, domainRules, clientNames) return clients } } } - if len(domainRules) > 0 { - errors.LogDebug(s.ctx, "domain ", domain, " matches following rules: ", domainRules) - } - if len(clientNames) > 0 { - errors.LogDebug(s.ctx, "domain ", domain, " will use DNS in order: ", clientNames) - } + logDecision(s.ctx, domain, domainRules, clientNames) if len(clients) == 0 { if len(s.clients) > 0 { @@ -327,6 +324,15 @@ func (s *DNS) sortClients(domain string) []*Client { return clients } +func logDecision(ctx context.Context, domain string, domainRules []string, clientNames []string) { + if len(domainRules) > 0 { + errors.LogDebug(ctx, "domain ", domain, " matches following rules: ", domainRules) + } + if len(clientNames) > 0 { + errors.LogDebug(ctx, "domain ", domain, " will use DNS in order: ", clientNames) + } +} + func mergeQueryErrors(domain string, errs []error) error { if len(errs) == 0 { return dns.ErrEmptyResponse