Small fixes

This commit is contained in:
Vladimir Stoilov
2022-09-20 16:44:31 +02:00
committed by Daniel
parent ecce16ee78
commit 5ed133d578
4 changed files with 14 additions and 12 deletions

View File

@@ -6,6 +6,7 @@ import (
"encoding/binary"
ct "github.com/florianl/go-conntrack"
"github.com/safing/portbase/log"
"github.com/safing/portmaster/netenv"
)
@@ -36,7 +37,9 @@ func deleteMarkedConnections(nfct *ct.Nfct, f ct.Family) {
filter.MarkMask = []byte{0xFF, 0xFF, 0xFF, 0xFF}
filter.Mark = []byte{0x00, 0x00, 0x00, 0x00} // 4 zeros starting value
// get all connections from the specified family (ipv4 or ipv6)
numberOfErrors := 0
var deleteError error = nil
// Get all connections from the specified family (ipv4 or ipv6)
for _, mark := range permanentFlags {
binary.BigEndian.PutUint32(filter.Mark, mark) // Little endian is in reverse not sure why. BigEndian makes it in correct order.
currentConnections, err := nfct.Query(ct.Conntrack, f, filter)
@@ -45,16 +48,15 @@ func deleteMarkedConnections(nfct *ct.Nfct, f ct.Family) {
continue
}
numberOfErrors := 0
for _, connection := range currentConnections {
err = nfct.Delete(ct.Conntrack, ct.IPv4, connection)
deleteError = nfct.Delete(ct.Conntrack, ct.IPv4, connection)
if err != nil {
numberOfErrors++
}
}
}
if numberOfErrors > 0 {
log.Warningf("nfq: failed to delete %d conntrack entries last error is: %s", numberOfErrors, err)
}
if numberOfErrors > 0 {
log.Warningf("nfq: failed to delete %d conntrack entries last error is: %s", numberOfErrors, deleteError)
}
}

View File

@@ -95,7 +95,7 @@ func Init(dllPath, driverPath string) error {
new.clearCache, err = new.dll.FindProc("PortmasterClearCache")
if err != nil {
// the loaded dll is an old version
log.Errorf("could not find proc PortmasterClearCache (v0.x.x+) in dll: %s", err)
log.Errorf("could not find proc PortmasterClearCache (v1.0.12+) in dll: %s", err)
}
// initialize dll/kext