Pull request: all: add string set

Merge in DNS/adguard-home from add-strset to master

Squashed commit of the following:

commit 2500df1805dee425eafd0503983ec631de02af0b
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Tue Apr 20 15:09:59 2021 +0300

    all: add string set
This commit is contained in:
Ainar Garipov
2021-04-20 16:26:19 +03:00
parent 71030bafd8
commit 93638a1936
9 changed files with 100 additions and 125 deletions

View File

@@ -82,7 +82,6 @@ func TestIsBlockedIP(t *testing.T) {
}
t.Run(prefix+tc.name, func(t *testing.T) {
aCtx := &accessCtx{}
allowedRules := rules
var disallowedRules []string
@@ -90,7 +89,8 @@ func TestIsBlockedIP(t *testing.T) {
allowedRules, disallowedRules = disallowedRules, allowedRules
}
require.Nil(t, aCtx.Init(allowedRules, disallowedRules, nil))
aCtx, err := newAccessCtx(allowedRules, disallowedRules, nil)
require.NoError(t, err)
disallowed, rule := aCtx.IsBlockedIP(tc.ip)
assert.Equal(t, tc.wantDis, disallowed)
@@ -100,12 +100,12 @@ func TestIsBlockedIP(t *testing.T) {
}
func TestIsBlockedDomain(t *testing.T) {
aCtx := &accessCtx{}
require.Nil(t, aCtx.Init(nil, nil, []string{
aCtx, err := newAccessCtx(nil, nil, []string{
"host1",
"*.host.com",
"||host3.com^",
}))
})
require.NoError(t, err)
testCases := []struct {
name string