mirror of
https://github.com/safing/portmaster
synced 2025-09-02 02:29:12 +00:00
Save blocked DNS queries
This commit is contained in:
parent
249261a3da
commit
7da9e64c27
3 changed files with 12 additions and 9 deletions
|
@ -195,11 +195,11 @@ func handleRequest(ctx context.Context, w dns.ResponseWriter, query *dns.Msg) er
|
|||
case network.VerdictBlock:
|
||||
tracer.Infof("nameserver: %s blocked, returning nxdomain", conn)
|
||||
returnNXDomain(w, query)
|
||||
// FIXME: save denied dns connection
|
||||
conn.Save() // save blocked request
|
||||
return nil
|
||||
case network.VerdictDrop:
|
||||
tracer.Infof("nameserver: %s dropped, not replying", conn)
|
||||
// FIXME: save denied dns connection
|
||||
conn.Save() // save dropped request
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -218,7 +218,7 @@ func handleRequest(ctx context.Context, w dns.ResponseWriter, query *dns.Msg) er
|
|||
if rrCache == nil {
|
||||
tracer.Infof("nameserver: %s implicitly denied by filtering the dns response, returning nxdomain", conn)
|
||||
returnNXDomain(w, query)
|
||||
// FIXME: save denied dns connection
|
||||
conn.Save() // save blocked request
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -265,5 +265,8 @@ func handleRequest(ctx context.Context, w dns.ResponseWriter, query *dns.Msg) er
|
|||
_ = w.WriteMsg(m)
|
||||
tracer.Debugf("nameserver: returning response %s%s to %s", q.FQDN, q.QType, conn.Process())
|
||||
|
||||
// save dns request as open
|
||||
network.SaveOpenDNSRequest(conn)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -71,7 +71,6 @@ func NewConnectionFromDNSRequest(ctx context.Context, fqdn string, ip net.IP, po
|
|||
Started: timestamp,
|
||||
Ended: timestamp,
|
||||
}
|
||||
saveOpenDNSRequest(dnsConn)
|
||||
return dnsConn
|
||||
}
|
||||
|
||||
|
@ -218,8 +217,8 @@ func (conn *Connection) SaveWhenFinished() {
|
|||
conn.saveWhenFinished = true
|
||||
}
|
||||
|
||||
// save saves the link object in the storage and propagates the change.
|
||||
func (conn *Connection) save() {
|
||||
// Save saves the connection in the storage and propagates the change through the database system.
|
||||
func (conn *Connection) Save() {
|
||||
if conn.ID == "" {
|
||||
|
||||
// dns request
|
||||
|
@ -336,7 +335,7 @@ func (conn *Connection) packetHandler() {
|
|||
// must not be locked, will deadlock with cleaner functions
|
||||
if conn.saveWhenFinished {
|
||||
conn.saveWhenFinished = false
|
||||
conn.save()
|
||||
conn.Save()
|
||||
}
|
||||
// submit trace logs
|
||||
log.Tracer(pkt.Ctx()).Submit()
|
||||
|
|
|
@ -26,7 +26,8 @@ func removeOpenDNSRequest(pid int, fqdn string) {
|
|||
delete(openDNSRequests, key)
|
||||
}
|
||||
|
||||
func saveOpenDNSRequest(conn *Connection) {
|
||||
// SaveOpenDNSRequest saves a dns request connection that was allowed to proceed.
|
||||
func SaveOpenDNSRequest(conn *Connection) {
|
||||
openDNSRequestsLock.Lock()
|
||||
defer openDNSRequestsLock.Unlock()
|
||||
|
||||
|
@ -65,7 +66,7 @@ func writeOpenDNSRequestsToDB() {
|
|||
for id, conn := range openDNSRequests {
|
||||
conn.Lock()
|
||||
if conn.Ended < threshold {
|
||||
conn.save()
|
||||
conn.Save()
|
||||
delete(openDNSRequests, id)
|
||||
}
|
||||
conn.Unlock()
|
||||
|
|
Loading…
Add table
Reference in a new issue