From dcbe3dd4051f421553eb7782af67378f3d9ce85b Mon Sep 17 00:00:00 2001 From: Eugene Bujak Date: Mon, 17 Sep 2018 01:41:39 +0300 Subject: [PATCH] dnsfilter -- compare full hashes when parsing parental lookup result. Closes #337. --- dnsfilter/dnsfilter.go | 4 ++++ dnsfilter/dnsfilter_test.go | 2 ++ 2 files changed, 6 insertions(+) diff --git a/dnsfilter/dnsfilter.go b/dnsfilter/dnsfilter.go index 90db03b7..02e72b39 100644 --- a/dnsfilter/dnsfilter.go +++ b/dnsfilter/dnsfilter.go @@ -542,6 +542,7 @@ func (d *Dnsfilter) checkParental(host string) (Result, error) { Blocked bool `json:"blocked"` ClientTTL int `json:"clientTtl"` Reason string `json:"reason"` + Hash string `json:"hash"` } err := json.Unmarshal(body, &m) if err != nil { @@ -553,6 +554,9 @@ func (d *Dnsfilter) checkParental(host string) (Result, error) { result := Result{} for i := range m { + if !hashes[m[i].Hash] { + continue + } if m[i].Blocked { result.IsFiltered = true result.Reason = FilteredParental diff --git a/dnsfilter/dnsfilter_test.go b/dnsfilter/dnsfilter_test.go index 387a58a1..48b70c3c 100644 --- a/dnsfilter/dnsfilter_test.go +++ b/dnsfilter/dnsfilter_test.go @@ -356,6 +356,8 @@ func TestParentalControl(t *testing.T) { if stats.Parental.Requests != l { t.Errorf("Parental lookup negative cache is not working") } + + d.checkMatchEmpty(t, "api.jquery.com") } func TestSafeSearch(t *testing.T) {