Skip to content

Commit

Permalink
fix: no initial cache refresh with "fast" start strategy (#804)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xERR0R committed Dec 17, 2022
1 parent 8b137bb commit 3c40ce5
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
3 changes: 3 additions & 0 deletions lists/list_cache.go
Expand Up @@ -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)
}
Expand Down
28 changes: 27 additions & 1 deletion resolver/blocking_resolver_test.go
Expand Up @@ -74,7 +74,6 @@ var _ = Describe("BlockingResolver", Label("blockingResolver"), func() {
Expect(err).Should(Succeed())
sut = tmp.(*BlockingResolver)
sut.Next(m)
sut.RefreshLists()
})

AfterEach(func() {
Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit 3c40ce5

Please sign in to comment.