mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2025-05-07 00:12:59 +03:00
Pull request: 4939 Client update
Merge in DNS/adguard-home from 4939-client-upd to master Updates #4939. Squashed commit of the following: commit 34f35822afcc8020a674cd023a5907b5b3edcb65 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Fri Feb 10 14:01:57 2023 +0300 all: imp code, docs commit 1cd8767a38f6494c92fb5ceff26abe228fcca638 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Thu Feb 9 17:20:56 2023 +0300 all: different ttls commit 66d951ba3dd72cb698b89b432cbbbdd65cb421a2 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Thu Feb 9 14:24:47 2023 +0300 all: imp code commit 3fb8d08310296dad90783f13ba46a1d0ea11da2e Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Wed Feb 8 19:35:29 2023 +0300 home: fix rdns check logic
This commit is contained in:
parent
b89105e3b5
commit
ec19a85ed0
7 changed files with 119 additions and 76 deletions
internal/home
|
@ -76,7 +76,7 @@ func TestRDNS_Begin(t *testing.T) {
|
|||
|
||||
ipCache := cache.New(cache.Config{
|
||||
EnableLRU: true,
|
||||
MaxCount: defaultRDNSCacheSize,
|
||||
MaxCount: revDNSCacheSize,
|
||||
})
|
||||
ttl := make([]byte, binary.Size(uint64(0)))
|
||||
binary.BigEndian.PutUint64(ttl, uint64(time.Now().Add(100*time.Hour).Unix()))
|
||||
|
@ -153,7 +153,7 @@ func TestRDNS_ensurePrivateCache(t *testing.T) {
|
|||
|
||||
ipCache := cache.New(cache.Config{
|
||||
EnableLRU: true,
|
||||
MaxCount: defaultRDNSCacheSize,
|
||||
MaxCount: revDNSCacheSize,
|
||||
})
|
||||
|
||||
ex := &rDNSExchanger{
|
||||
|
@ -200,25 +200,29 @@ func TestRDNS_WorkerLoop(t *testing.T) {
|
|||
errUpstream := aghtest.NewErrorUpstream()
|
||||
|
||||
testCases := []struct {
|
||||
ups upstream.Upstream
|
||||
cliIP netip.Addr
|
||||
wantLog string
|
||||
name string
|
||||
ups upstream.Upstream
|
||||
cliIP netip.Addr
|
||||
wantLog string
|
||||
name string
|
||||
wantClientSource clientSource
|
||||
}{{
|
||||
ups: locUpstream,
|
||||
cliIP: localIP,
|
||||
wantLog: "",
|
||||
name: "all_good",
|
||||
ups: locUpstream,
|
||||
cliIP: localIP,
|
||||
wantLog: "",
|
||||
name: "all_good",
|
||||
wantClientSource: ClientSourceRDNS,
|
||||
}, {
|
||||
ups: errUpstream,
|
||||
cliIP: netip.MustParseAddr("192.168.1.2"),
|
||||
wantLog: `rdns: resolving "192.168.1.2": test upstream error`,
|
||||
name: "resolve_error",
|
||||
ups: errUpstream,
|
||||
cliIP: netip.MustParseAddr("192.168.1.2"),
|
||||
wantLog: `rdns: resolving "192.168.1.2": test upstream error`,
|
||||
name: "resolve_error",
|
||||
wantClientSource: ClientSourceNone,
|
||||
}, {
|
||||
ups: locUpstream,
|
||||
cliIP: netip.MustParseAddr("2a00:1450:400c:c06::93"),
|
||||
wantLog: "",
|
||||
name: "ipv6_good",
|
||||
ups: locUpstream,
|
||||
cliIP: netip.MustParseAddr("2a00:1450:400c:c06::93"),
|
||||
wantLog: "",
|
||||
name: "ipv6_good",
|
||||
wantClientSource: ClientSourceRDNS,
|
||||
}}
|
||||
|
||||
for _, tc := range testCases {
|
||||
|
@ -237,6 +241,10 @@ func TestRDNS_WorkerLoop(t *testing.T) {
|
|||
},
|
||||
clients: cc,
|
||||
ipCh: ch,
|
||||
ipCache: cache.New(cache.Config{
|
||||
EnableLRU: true,
|
||||
MaxCount: revDNSCacheSize,
|
||||
}),
|
||||
}
|
||||
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
|
@ -253,11 +261,9 @@ func TestRDNS_WorkerLoop(t *testing.T) {
|
|||
|
||||
if tc.wantLog != "" {
|
||||
assert.Contains(t, w.String(), tc.wantLog)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
assert.True(t, cc.exists(tc.cliIP, ClientSourceRDNS))
|
||||
assert.Equal(t, tc.wantClientSource, cc.clientSource(tc.cliIP))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue