From f6023b395eab5e14209a181df68c4ceb70a68cf2 Mon Sep 17 00:00:00 2001 From: Simon Zolin Date: Wed, 24 Apr 2019 12:38:05 +0300 Subject: [PATCH] - dnsfilter: prevent recursion when both parental control and safebrowsing are enabled --- dnsfilter/dnsfilter.go | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/dnsfilter/dnsfilter.go b/dnsfilter/dnsfilter.go index e58b0350..1b12d8b5 100644 --- a/dnsfilter/dnsfilter.go +++ b/dnsfilter/dnsfilter.go @@ -185,6 +185,10 @@ func (d *Dnsfilter) CheckHost(host string) (Result, error) { return Result{Reason: NotFilteredNotFound}, nil } host = strings.ToLower(host) + // prevent recursion + if host == d.parentalServer || host == d.safeBrowsingServer { + return Result{}, nil + } // try filter lists first result, err := d.matchHost(host) @@ -674,10 +678,6 @@ func (d *Dnsfilter) checkSafeBrowsing(host string) (Result, error) { defer timer.LogElapsed("SafeBrowsing HTTP lookup for %s", host) } - // prevent recursion -- checking the host of safebrowsing server makes no sense - if host == d.safeBrowsingServer { - return Result{}, nil - } format := func(hashparam string) string { url := fmt.Sprintf(defaultSafebrowsingURL, d.safeBrowsingServer, hashparam) return url @@ -720,10 +720,6 @@ func (d *Dnsfilter) checkParental(host string) (Result, error) { defer timer.LogElapsed("Parental HTTP lookup for %s", host) } - // prevent recursion -- checking the host of parental safety server makes no sense - if host == d.parentalServer { - return Result{}, nil - } format := func(hashparam string) string { url := fmt.Sprintf(defaultParentalURL, d.parentalServer, hashparam, d.ParentalSensitivity) return url