Merge pull request #24 in DNS/adguard-dns from parental_fullhash to master

* commit 'dcbe3dd4051f421553eb7782af67378f3d9ce85b':
  dnsfilter -- compare full hashes when parsing parental lookup result.
This commit is contained in:
Eugene Bujak 2018-09-17 01:50:09 +03:00
commit 5d046c5c16
2 changed files with 6 additions and 0 deletions

View File

@ -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

View File

@ -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) {