Pull request 1983: 5720-wildcard-ignored-domains

Updates #5720.

Squashed commit of the following:

commit e8093c990f15e2efc496f1a04f87360825e34e96
Merge: df5413eef 28fefaff1
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date:   Tue Sep 5 15:06:33 2023 +0300

    Merge branch 'master' into 5720-wildcard-ignored-domains

commit df5413eefeac2c7e34eb725db9e2908b5b2d08cb
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date:   Tue Sep 5 14:49:05 2023 +0300

    confmigrate: imp docs

commit 1644d99b730cc7f22c9d75b8e990149d3ce5b32a
Merge: 9542ee161 1e4517898
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date:   Tue Sep 5 14:23:42 2023 +0300

    Merge branch 'master' into 5720-wildcard-ignored-domains

commit 9542ee1616c1dd4bdb6ec9a2af79a2af3858a7e3
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date:   Tue Sep 5 12:48:48 2023 +0300

    all: upd chlog

commit 183f84a7f73c7bd33669bd108076f60514ca101e
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date:   Fri Sep 1 17:11:31 2023 +0300

    all: imp chlog

commit a704325352a577a9b6652f011b82180ec3a6e095
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date:   Thu Aug 31 18:59:52 2023 +0300

    all: imp code

commit fe99c3b883500850399b1feb72c914ab878b3107
Merge: 7f11e9460 0182b9ec1
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date:   Thu Aug 31 18:43:09 2023 +0300

    Merge branch 'master' into 5720-wildcard-ignored-domains

commit 7f11e94609027ed821a125d27a1ffde03f37334a
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date:   Wed Aug 30 19:57:51 2023 +0300

    aghnet: add tests

commit f10f9190ce1064a5d03155e8b6bba61db977897b
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date:   Wed Aug 30 18:32:07 2023 +0300

    all: add conf migration

commit a53c14df129765366966c5230dd53aa29bdd25c5
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date:   Wed Aug 30 13:37:30 2023 +0300

    all: add ignore engine
This commit is contained in:
Stanislav Chzhen
2023-09-05 15:13:35 +03:00
parent 28fefaff1a
commit 42291cd547
22 changed files with 577 additions and 64 deletions

View File

@@ -5,8 +5,8 @@ import (
"net"
"testing"
"github.com/AdguardTeam/AdGuardHome/internal/aghnet"
"github.com/AdguardTeam/AdGuardHome/internal/filtering"
"github.com/AdguardTeam/golibs/stringutil"
"github.com/AdguardTeam/golibs/testutil"
"github.com/AdguardTeam/golibs/timeutil"
"github.com/miekg/dns"
@@ -256,10 +256,21 @@ func TestQueryLogFileDisabled(t *testing.T) {
func TestQueryLogShouldLog(t *testing.T) {
const (
ignored1 = "ignor.ed"
ignored2 = "ignored.to"
ignored1 = "ignor.ed"
ignored2 = "ignored.to"
ignoredWildcard = "*.ignored.com"
ignoredRoot = "|.^"
)
set := stringutil.NewSet(ignored1, ignored2)
ignored := []string{
ignored1,
ignored2,
ignoredWildcard,
ignoredRoot,
}
engine, err := aghnet.NewIgnoreEngine(ignored)
require.NoError(t, err)
findClient := func(ids []string) (c *Client, err error) {
log := ids[0] == "no_log"
@@ -268,7 +279,7 @@ func TestQueryLogShouldLog(t *testing.T) {
}
l, err := newQueryLog(Config{
Ignored: set,
Ignored: engine,
Enabled: true,
RotationIvl: timeutil.Day,
MemSize: 100,
@@ -297,6 +308,16 @@ func TestQueryLogShouldLog(t *testing.T) {
host: ignored2,
ids: []string{"whatever"},
wantLog: false,
}, {
name: "no_log_ignored_wildcard",
host: "www.ignored.com",
ids: []string{"whatever"},
wantLog: false,
}, {
name: "no_log_ignored_root",
host: ".",
ids: []string{"whatever"},
wantLog: false,
}, {
name: "no_log_client_ignore",
host: "example.com",