Pull request 1841: AG-21462-safebrowsing-parental-http-tests
Merge in DNS/adguard-home from AG-21462-safebrowsing-parental-http-tests to master Squashed commit of the following: commit 22a83ebad08a27939a443530137a7c195f512ee4 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed May 3 17:39:46 2023 +0300 filtering: fix test commit c3ca8b4987245cdd552f6f09759804e716bcae80 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed May 3 16:43:35 2023 +0300 filtering: imp tests even more commit 7643bfae350373b5b6dfb61b64e57da66c6ab952 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed May 3 16:17:42 2023 +0300 filtering: imp tests more commit 399c05ee4d479a727b61378b7a07158a568d0181 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed May 3 14:45:41 2023 +0300 filtering: imp tests commit f361df39e784ec9c5191666736a6c64b332928e8 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue May 2 12:49:26 2023 +0300 filtering: add tests
This commit is contained in:
@@ -1035,3 +1035,69 @@ func (d *DNSFilter) Start() {
|
||||
// So for now we just start this periodic task from here.
|
||||
go d.periodicallyRefreshFilters()
|
||||
}
|
||||
|
||||
// Safe browsing and parental control methods.
|
||||
|
||||
// TODO(a.garipov): Unify with checkParental.
|
||||
func (d *DNSFilter) checkSafeBrowsing(
|
||||
host string,
|
||||
_ uint16,
|
||||
setts *Settings,
|
||||
) (res Result, err error) {
|
||||
if !setts.ProtectionEnabled || !setts.SafeBrowsingEnabled {
|
||||
return Result{}, nil
|
||||
}
|
||||
|
||||
if log.GetLevel() >= log.DEBUG {
|
||||
timer := log.StartTimer()
|
||||
defer timer.LogElapsed("safebrowsing lookup for %q", host)
|
||||
}
|
||||
|
||||
res = Result{
|
||||
Rules: []*ResultRule{{
|
||||
Text: "adguard-malware-shavar",
|
||||
FilterListID: SafeBrowsingListID,
|
||||
}},
|
||||
Reason: FilteredSafeBrowsing,
|
||||
IsFiltered: true,
|
||||
}
|
||||
|
||||
block, err := d.safeBrowsingChecker.Check(host)
|
||||
if !block || err != nil {
|
||||
return Result{}, err
|
||||
}
|
||||
|
||||
return res, nil
|
||||
}
|
||||
|
||||
// TODO(a.garipov): Unify with checkSafeBrowsing.
|
||||
func (d *DNSFilter) checkParental(
|
||||
host string,
|
||||
_ uint16,
|
||||
setts *Settings,
|
||||
) (res Result, err error) {
|
||||
if !setts.ProtectionEnabled || !setts.ParentalEnabled {
|
||||
return Result{}, nil
|
||||
}
|
||||
|
||||
if log.GetLevel() >= log.DEBUG {
|
||||
timer := log.StartTimer()
|
||||
defer timer.LogElapsed("parental lookup for %q", host)
|
||||
}
|
||||
|
||||
res = Result{
|
||||
Rules: []*ResultRule{{
|
||||
Text: "parental CATEGORY_BLACKLISTED",
|
||||
FilterListID: ParentalListID,
|
||||
}},
|
||||
Reason: FilteredParental,
|
||||
IsFiltered: true,
|
||||
}
|
||||
|
||||
block, err := d.parentalControlChecker.Check(host)
|
||||
if !block || err != nil {
|
||||
return Result{}, err
|
||||
}
|
||||
|
||||
return res, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user