Pull request: all: custom autohost tlds

Updates #2393.

Squashed commit of the following:

commit 87034134e240480938cdeec14d6b44294bf6442c
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Thu Mar 25 15:48:46 2021 +0300

    dnsforward: fix

commit abf3a1ce8ed7a148d1cc631007fb0422f6da4ae6
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Thu Mar 25 15:21:11 2021 +0300

    dnsforward: imp code, validation

commit fac389bdafc093ce17a7e0831166b89293b550be
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Thu Mar 25 14:54:45 2021 +0300

    all: add validation, imp docs, tests

commit 21b4532afe59f3b89383cb330c9a7d49ec124b6e
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Wed Mar 24 19:09:43 2021 +0300

    all: custom autohost tlds
This commit is contained in:
Ainar Garipov
2021-03-25 16:00:27 +03:00
parent ba3fc242ab
commit a7f9e0122b
12 changed files with 389 additions and 121 deletions

View File

@@ -118,7 +118,7 @@ func TestProcessClientID(t *testing.T) {
cliSrvName: "!!!.example.com",
wantClientID: "",
wantErrMsg: `client id check: invalid client id: invalid char '!' ` +
`at index 0 in client id "!!!"`,
`at index 0 in "!!!"`,
wantRes: resultCodeError,
strictSNI: true,
}, {
@@ -128,9 +128,9 @@ func TestProcessClientID(t *testing.T) {
cliSrvName: `abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmno` +
`pqrstuvwxyz0123456789.example.com`,
wantClientID: "",
wantErrMsg: `client id check: invalid client id: client id "abcdefghijklmno` +
wantErrMsg: `client id check: invalid client id: "abcdefghijklmno` +
`pqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789" ` +
`is too long, max: 64`,
`is too long, max: 63`,
wantRes: resultCodeError,
strictSNI: true,
}, {
@@ -182,9 +182,9 @@ func TestProcessClientID(t *testing.T) {
assert.Equal(t, tc.wantClientID, dctx.clientID)
if tc.wantErrMsg == "" {
assert.Nil(t, dctx.err)
assert.NoError(t, dctx.err)
} else {
require.NotNil(t, dctx.err)
require.Error(t, dctx.err)
assert.Equal(t, tc.wantErrMsg, dctx.err.Error())
}
})
@@ -239,7 +239,7 @@ func TestProcessClientID_https(t *testing.T) {
path: "/dns-query/!!!",
wantClientID: "",
wantErrMsg: `client id check: invalid client id: invalid char '!'` +
` at index 0 in client id "!!!"`,
` at index 0 in "!!!"`,
wantRes: resultCodeError,
}}
@@ -263,9 +263,10 @@ func TestProcessClientID_https(t *testing.T) {
assert.Equal(t, tc.wantClientID, dctx.clientID)
if tc.wantErrMsg == "" {
assert.Nil(t, dctx.err)
assert.NoError(t, dctx.err)
} else {
require.NotNil(t, dctx.err)
require.Error(t, dctx.err)
assert.Equal(t, tc.wantErrMsg, dctx.err.Error())
}
})