fix: no initial cache refresh with "fast" start strategy (#804)

This commit is contained in:
Dimitri Herzog 2022-12-17 23:06:58 +01:00 committed by GitHub
parent 8b137bb1ed
commit 3c40ce5d3b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 1 deletions

View File

@ -114,6 +114,9 @@ func NewListCache(t ListCacheType, groupToLinks map[string][]string, refreshPeri
var initError error
if async {
initError = nil
// start list refresh in the background
go b.Refresh()
} else {
initError = b.refresh(true)
}

View File

@ -74,7 +74,6 @@ var _ = Describe("BlockingResolver", Label("blockingResolver"), func() {
Expect(err).Should(Succeed())
sut = tmp.(*BlockingResolver)
sut.Next(m)
sut.RefreshLists()
})
AfterEach(func() {
@ -152,6 +151,33 @@ var _ = Describe("BlockingResolver", Label("blockingResolver"), func() {
})
})
Describe("Blocking with fast start strategy", func() {
BeforeEach(func() {
sutConfig = config.BlockingConfig{
BlockType: "ZEROIP",
BlockTTL: config.Duration(time.Minute),
BlackLists: map[string][]string{
"gr1": {"\n/regex/"},
},
ClientGroupsBlock: map[string][]string{
"default": {"gr1"},
},
StartStrategy: config.StartStrategyTypeFast,
}
})
When("Domain is on the black list", func() {
It("should block request", func() {
Eventually(func(g Gomega) {
resp, err = sut.Resolve(newRequestWithClient("regex.com.", dns.Type(dns.TypeA), "1.2.1.2", "client1"))
g.Expect(err).Should(Succeed())
g.Expect(resp.Res.Answer).Should(BeDNSRecord("regex.com.", dns.TypeA, 60, "0.0.0.0"))
}).Should(Succeed())
})
})
})
Describe("Blocking requests", func() {
var rType ResponseType
BeforeEach(func() {