From 86279f19b0b5bce37a83c05c88511fb82441c730 Mon Sep 17 00:00:00 2001 From: Aleksey Dmitrevskiy Date: Mon, 25 Feb 2019 17:15:50 +0300 Subject: [PATCH] Add TODO --- dnsfilter/dnsfilter.go | 1 + dnsforward/dnsforward_test.go | 15 ++++++++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/dnsfilter/dnsfilter.go b/dnsfilter/dnsfilter.go index 7e6c01f0..dd5fe2e4 100644 --- a/dnsfilter/dnsfilter.go +++ b/dnsfilter/dnsfilter.go @@ -631,6 +631,7 @@ func (d *Dnsfilter) checkSafeSearch(host string) (Result, error) { return res, nil } + // TODO this address should be resolved with upstream that was configured in dnsforward addrs, err := net.LookupIP(safeHost) if err != nil { log.Tracef("SafeSearchDomain for %s was found but failed to lookup for %s cause %s", host, safeHost, err) diff --git a/dnsforward/dnsforward_test.go b/dnsforward/dnsforward_test.go index 843d57db..df14b8ae 100644 --- a/dnsforward/dnsforward_test.go +++ b/dnsforward/dnsforward_test.go @@ -16,6 +16,7 @@ import ( "time" "github.com/AdguardTeam/dnsproxy/proxy" + "github.com/stretchr/testify/assert" "github.com/AdguardTeam/AdGuardHome/dnsfilter" @@ -152,7 +153,7 @@ func TestSafeSearch(t *testing.T) { } // Test safe search for yandex. We already know safe search ip - addr := s.dnsProxy.Addr("udp") + addr := s.dnsProxy.Addr(proxy.ProtoUDP) client := dns.Client{Net: "udp"} yandexDomains := []string{"yandex.com.", "yandex.by.", "yandex.kz.", "yandex.ru.", "yandex.com."} for _, host := range yandexDomains { @@ -185,17 +186,17 @@ func TestSafeSearch(t *testing.T) { } // Check aggregated stats - assert.Equal(t, s.GetAggregatedStats()["replaced_safesearch"], float64(len(yandexDomains) + len(googleDomains))) - assert.Equal(t, s.GetAggregatedStats()["blocked_filtering"], float64(len(yandexDomains) + len(googleDomains))) - assert.Equal(t, s.GetAggregatedStats()["dns_queries"], float64(len(yandexDomains) + len(googleDomains))) + assert.Equal(t, s.GetAggregatedStats()["replaced_safesearch"], float64(len(yandexDomains)+len(googleDomains))) + assert.Equal(t, s.GetAggregatedStats()["blocked_filtering"], float64(len(yandexDomains)+len(googleDomains))) + assert.Equal(t, s.GetAggregatedStats()["dns_queries"], float64(len(yandexDomains)+len(googleDomains))) // Do one more exchange exchangeAndAssertResponse(t, client, addr, "google-public-dns-a.google.com.", "8.8.8.8") // Check aggregated stats - assert.Equal(t, s.GetAggregatedStats()["replaced_safesearch"], float64(len(yandexDomains) + len(googleDomains))) - assert.Equal(t, s.GetAggregatedStats()["blocked_filtering"], float64(len(yandexDomains) + len(googleDomains))) - assert.Equal(t, s.GetAggregatedStats()["dns_queries"], float64(len(yandexDomains) + len(googleDomains) + 1)) + assert.Equal(t, s.GetAggregatedStats()["replaced_safesearch"], float64(len(yandexDomains)+len(googleDomains))) + assert.Equal(t, s.GetAggregatedStats()["blocked_filtering"], float64(len(yandexDomains)+len(googleDomains))) + assert.Equal(t, s.GetAggregatedStats()["dns_queries"], float64(len(yandexDomains)+len(googleDomains)+1)) // Count of blocked domains (there is `yandex.com` duplicate in yandexDomains array) blockedCount := len(yandexDomains) - 1 + len(googleDomains)