Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type Config struct {
Timeout int
Expire uint32
Maxcount int
QuestionCacheNonblocked bool
QuestionCacheCap int
TTL uint32
Blocklist []string
Expand Down Expand Up @@ -117,6 +118,9 @@ maxcount = 0
# question cache capacity, 0 for infinite but not recommended (this is used for storing logs)
questioncachecap = 5000

# should questions for non-blocked hosts be cached/logged?
questioncachenonblocked = true

# manual blocklist entries
blocklist = []

Expand Down
8 changes: 5 additions & 3 deletions handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,11 @@ func (h *DNSHandler) do(config *Config, blockCache *MemoryBlockCache, questionCa

logger.Noticef("%s found in blocklist\n", Q.Qname)

// log query
NewEntry := QuestionCacheEntry{Date: time.Now().Unix(), Remote: remote.String(), Query: Q, Blocked: true}
go questionCache.Add(NewEntry)
if config.QuestionCacheNonblocked {
// log query
NewEntry := QuestionCacheEntry{Date: time.Now().Unix(), Remote: remote.String(), Query: Q, Blocked: true}
go questionCache.Add(NewEntry)
}

// cache the block; we don't know the true TTL for blocked entries: we just enforce our config
err := h.cache.Set(key, m, true)
Expand Down