Pull request: all: allow local non-top-level domains

Updates #2961.

Squashed commit of the following:

commit 207eeb85caf6caee81a669302daf4e10a5b61585
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Thu Apr 15 18:48:50 2021 +0300

    all: allow local non-top-level domains
This commit is contained in:
Ainar Garipov
2021-04-15 19:00:31 +03:00
parent a1450c5595
commit d83091fc1f
11 changed files with 128 additions and 54 deletions

View File

@@ -90,7 +90,7 @@ func TestServer_ProcessInternalHosts_localRestriction(t *testing.T) {
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
s := &Server{
autohostSuffix: defaultAutohostSuffix,
localDomainSuffix: defaultLocalDomainSuffix,
tableHostToIP: hostToIPTable{
"example": knownIP,
},
@@ -157,35 +157,35 @@ func TestServer_ProcessInternalHosts(t *testing.T) {
}{{
name: "success_external",
host: examplecom,
suffix: defaultAutohostSuffix,
suffix: defaultLocalDomainSuffix,
wantIP: nil,
wantRes: resultCodeSuccess,
qtyp: dns.TypeA,
}, {
name: "success_external_non_a",
host: examplecom,
suffix: defaultAutohostSuffix,
suffix: defaultLocalDomainSuffix,
wantIP: nil,
wantRes: resultCodeSuccess,
qtyp: dns.TypeCNAME,
}, {
name: "success_internal",
host: examplelan,
suffix: defaultAutohostSuffix,
suffix: defaultLocalDomainSuffix,
wantIP: knownIP,
wantRes: resultCodeSuccess,
qtyp: dns.TypeA,
}, {
name: "success_internal_unknown",
host: "example-new.lan",
suffix: defaultAutohostSuffix,
suffix: defaultLocalDomainSuffix,
wantIP: nil,
wantRes: resultCodeFinish,
qtyp: dns.TypeA,
}, {
name: "success_internal_aaaa",
host: examplelan,
suffix: defaultAutohostSuffix,
suffix: defaultLocalDomainSuffix,
wantIP: nil,
wantRes: resultCodeSuccess,
qtyp: dns.TypeAAAA,
@@ -201,7 +201,7 @@ func TestServer_ProcessInternalHosts(t *testing.T) {
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
s := &Server{
autohostSuffix: tc.suffix,
localDomainSuffix: tc.suffix,
tableHostToIP: hostToIPTable{
"example": knownIP,
},