mirror of https://github.com/0xERR0R/blocky.git
fix: no initial cache refresh with "fast" start strategy (#804)
This commit is contained in:
parent
8b137bb1ed
commit
3c40ce5d3b
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Reference in New Issue