mirror of
https://github.com/safing/portmaster
synced 2025-09-02 10:39:22 +00:00
Small fixes
This commit is contained in:
parent
ecce16ee78
commit
5ed133d578
4 changed files with 14 additions and 12 deletions
|
@ -72,7 +72,7 @@ func interceptionPrep() error {
|
||||||
configChangeEvent,
|
configChangeEvent,
|
||||||
"reset connection verdicts",
|
"reset connection verdicts",
|
||||||
func(ctx context.Context, _ interface{}) error {
|
func(ctx context.Context, _ interface{}) error {
|
||||||
resetPersistentVerdicts()
|
resetAllConnectionVerdicts()
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
@ -86,7 +86,7 @@ func interceptionPrep() error {
|
||||||
profileConfigChangeEvent,
|
profileConfigChangeEvent,
|
||||||
"reset connection verdicts",
|
"reset connection verdicts",
|
||||||
func(ctx context.Context, _ interface{}) error {
|
func(ctx context.Context, _ interface{}) error {
|
||||||
resetPersistentVerdicts()
|
resetAllConnectionVerdicts()
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
@ -101,7 +101,7 @@ func interceptionPrep() error {
|
||||||
onSPNConnectEvent,
|
onSPNConnectEvent,
|
||||||
"reset connection verdicts",
|
"reset connection verdicts",
|
||||||
func(ctx context.Context, _ interface{}) error {
|
func(ctx context.Context, _ interface{}) error {
|
||||||
resetPersistentVerdicts()
|
resetAllConnectionVerdicts()
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
@ -116,7 +116,7 @@ func interceptionPrep() error {
|
||||||
return prepAPIAuth()
|
return prepAPIAuth()
|
||||||
}
|
}
|
||||||
|
|
||||||
func resetPersistentVerdicts() {
|
func resetAllConnectionVerdicts() {
|
||||||
// Resetting will force all the connection to be evaluated by the firewall again
|
// Resetting will force all the connection to be evaluated by the firewall again
|
||||||
// this will set new verdicts if configuration was update or spn has been disabled or enabled.
|
// this will set new verdicts if configuration was update or spn has been disabled or enabled.
|
||||||
log.Info("interception: reevaluating all connection trough the firewall")
|
log.Info("interception: reevaluating all connection trough the firewall")
|
||||||
|
|
|
@ -6,6 +6,7 @@ import (
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
|
|
||||||
ct "github.com/florianl/go-conntrack"
|
ct "github.com/florianl/go-conntrack"
|
||||||
|
|
||||||
"github.com/safing/portbase/log"
|
"github.com/safing/portbase/log"
|
||||||
"github.com/safing/portmaster/netenv"
|
"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.MarkMask = []byte{0xFF, 0xFF, 0xFF, 0xFF}
|
||||||
filter.Mark = []byte{0x00, 0x00, 0x00, 0x00} // 4 zeros starting value
|
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 {
|
for _, mark := range permanentFlags {
|
||||||
binary.BigEndian.PutUint32(filter.Mark, mark) // Little endian is in reverse not sure why. BigEndian makes it in correct order.
|
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)
|
currentConnections, err := nfct.Query(ct.Conntrack, f, filter)
|
||||||
|
@ -45,16 +48,15 @@ func deleteMarkedConnections(nfct *ct.Nfct, f ct.Family) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
numberOfErrors := 0
|
|
||||||
for _, connection := range currentConnections {
|
for _, connection := range currentConnections {
|
||||||
err = nfct.Delete(ct.Conntrack, ct.IPv4, connection)
|
deleteError = nfct.Delete(ct.Conntrack, ct.IPv4, connection)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
numberOfErrors++
|
numberOfErrors++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if numberOfErrors > 0 {
|
if numberOfErrors > 0 {
|
||||||
log.Warningf("nfq: failed to delete %d conntrack entries last error is: %s", numberOfErrors, err)
|
log.Warningf("nfq: failed to delete %d conntrack entries last error is: %s", numberOfErrors, deleteError)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,7 +95,7 @@ func Init(dllPath, driverPath string) error {
|
||||||
new.clearCache, err = new.dll.FindProc("PortmasterClearCache")
|
new.clearCache, err = new.dll.FindProc("PortmasterClearCache")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// the loaded dll is an old version
|
// 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
|
// initialize dll/kext
|
||||||
|
|
|
@ -448,7 +448,7 @@ func GetConnection(id string) (*Connection, bool) {
|
||||||
|
|
||||||
// GetAllConnections Gets all connection.
|
// GetAllConnections Gets all connection.
|
||||||
func GetAllConnections() []*Connection {
|
func GetAllConnections() []*Connection {
|
||||||
return append(conns.list(), dnsConns.list()...)
|
return conns.list()
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetLocalIP sets the local IP address together with its network scope. The
|
// SetLocalIP sets the local IP address together with its network scope. The
|
||||||
|
|
Loading…
Add table
Reference in a new issue