Implement review suggestions

This commit is contained in:
Daniel
2020-04-20 13:57:07 +02:00
parent 033dceab5b
commit a33808685c
15 changed files with 90 additions and 61 deletions

View File

@@ -41,7 +41,7 @@ type Connection struct { //nolint:maligned // TODO: fix alignment
VerdictPermanent bool
Inspecting bool
Encrypted bool // TODO
Hidden bool
Internal bool // Portmaster internal connections are marked in order to easily filter these out in the UI
pktQueue chan packet.Packet
firewallHandler FirewallHandler

View File

@@ -5,6 +5,8 @@ import (
"strconv"
"sync"
"time"
"github.com/safing/portmaster/process"
)
var (
@@ -16,6 +18,9 @@ var (
// duration after which DNS requests without a following connection are logged
openDNSRequestLimit = 3 * time.Second
// scope prefix
unidentifiedProcessScopePrefix = strconv.Itoa(process.UnidentifiedProcessID) + "/"
)
func removeOpenDNSRequest(pid int, fqdn string) {
@@ -26,12 +31,9 @@ func removeOpenDNSRequest(pid int, fqdn string) {
_, ok := openDNSRequests[key]
if ok {
delete(openDNSRequests, key)
return
}
// check if there is an open dns request from an unidentified process
if pid >= 0 {
delete(openDNSRequests, "-1/"+fqdn)
} else if pid != process.UnidentifiedProcessID {
// check if there is an open dns request from an unidentified process
delete(openDNSRequests, unidentifiedProcessScopePrefix+fqdn)
}
}