Rewrite network tree saving and cleaning procedures

This commit is contained in:
Daniel
2019-05-22 16:10:05 +02:00
parent 1873999b38
commit fb4fb20d4b
9 changed files with 312 additions and 139 deletions

View File

@@ -139,6 +139,9 @@ func handleRequest(w dns.ResponseWriter, query *dns.Msg) {
nxDomain(w, query)
return
}
defer func() {
go comm.SaveIfNeeded()
}()
// check for possible DNS tunneling / data transmission
// TODO: improve this
@@ -152,6 +155,9 @@ func handleRequest(w dns.ResponseWriter, query *dns.Msg) {
// check profile before we even get intel and rr
firewall.DecideOnCommunicationBeforeIntel(comm, fqdn)
comm.Lock()
comm.SaveWhenFinished()
comm.Unlock()
if comm.GetVerdict() == network.VerdictBlock || comm.GetVerdict() == network.VerdictDrop {
log.InfoTracef(ctx, "nameserver: %s denied before intel, returning nxdomain", comm)
@@ -172,7 +178,6 @@ func handleRequest(w dns.ResponseWriter, query *dns.Msg) {
comm.Lock()
comm.Intel = domainIntel
comm.Unlock()
comm.Save()
// check with intel
firewall.DecideOnCommunicationAfterIntel(comm, fqdn, rrCache)