Skip to content

Commit

Permalink
neater logging
Browse files Browse the repository at this point in the history
  • Loading branch information
liamg committed Jun 19, 2019
1 parent 7b16fad commit 1ac36e6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
2 changes: 0 additions & 2 deletions internal/app/philter/server/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"time"

"github.com/miekg/dns"
log "github.com/sirupsen/logrus"
)

type Cache struct {
Expand Down Expand Up @@ -44,7 +43,6 @@ func (c *Cache) cleanse() {
for key, val := range c.cache {
if now.After(val.expires) {
c.lock.Lock()
log.Infof("Removing expired item from cache: %s", key)
delete(c.cache, key)
c.lock.Unlock()
}
Expand Down
8 changes: 4 additions & 4 deletions internal/app/philter/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (s *Server) handleQuery(m *dns.Msg) {

answer, found := s.cache.Read(q)
if found {
log.Printf("Query for %s returned from cache", q.Name)
log.Printf("cache <- %s ", q.Name)
m.Answer = answer
continue
}
Expand All @@ -75,7 +75,7 @@ func (s *Server) handleQuery(m *dns.Msg) {
if s.blacklist != nil && s.blacklist.Includes(q.Name) {
rr, err := dns.NewRR(fmt.Sprintf("%s A 127.0.0.1", q.Name))
if err == nil {
log.Printf("Query for %s blocked", q.Name)
log.Printf("block <- %s", q.Name)
m.Answer = append(m.Answer, rr)
continue
}
Expand All @@ -84,7 +84,7 @@ func (s *Server) handleQuery(m *dns.Msg) {
if s.blacklist != nil && s.blacklist.Includes(q.Name) {
rr, err := dns.NewRR(fmt.Sprintf("%s AAAA ::1", q.Name))
if err == nil {
log.Printf("Query for %s blocked", q.Name)
log.Printf("block <- %s", q.Name)
m.Answer = append(m.Answer, rr)
continue
}
Expand All @@ -107,7 +107,7 @@ func (s *Server) handleQuery(m *dns.Msg) {
return
}

log.Printf("Query for %s allowed", q.Name)
log.Printf("allow <- %s", q.Name)
m.Answer = r.Answer
go s.cache.Write(q, r.Answer)
}
Expand Down

0 comments on commit 1ac36e6

Please sign in to comment.