mirror of
https://github.com/safing/portmaster
synced 2025-09-02 18:49:14 +00:00
Improve logging and context usage
This commit is contained in:
parent
e5a0f06f97
commit
eac91ae627
2 changed files with 8 additions and 5 deletions
|
@ -116,9 +116,9 @@ func resetAllConnectionVerdicts() {
|
||||||
|
|
||||||
// Create tracing context.
|
// Create tracing context.
|
||||||
ctx, tracer := log.AddTracer(context.Background())
|
ctx, tracer := log.AddTracer(context.Background())
|
||||||
defer tracer.Submit()
|
|
||||||
|
|
||||||
// Re-evaluate all connections.
|
// Re-evaluate all connections.
|
||||||
|
var changedVerdicts int
|
||||||
for _, conn := range network.GetAllConnections() {
|
for _, conn := range network.GetAllConnections() {
|
||||||
func() {
|
func() {
|
||||||
conn.Lock()
|
conn.Lock()
|
||||||
|
@ -129,11 +129,11 @@ func resetAllConnectionVerdicts() {
|
||||||
// - Redirected DNS requests
|
// - Redirected DNS requests
|
||||||
// - SPN Uplink to Home Hub
|
// - SPN Uplink to Home Hub
|
||||||
if conn.Internal {
|
if conn.Internal {
|
||||||
log.Tracef("skipping internal connection %s", conn)
|
tracer.Tracef("filter: skipping internal connection %s", conn)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Tracer(ctx).Debugf("filter: re-evaluating verdict of %s", conn)
|
tracer.Debugf("filter: re-evaluating verdict of %s", conn)
|
||||||
previousVerdict := conn.Verdict.Firewall
|
previousVerdict := conn.Verdict.Firewall
|
||||||
|
|
||||||
// Apply privacy filter and check tunneling.
|
// Apply privacy filter and check tunneling.
|
||||||
|
@ -143,7 +143,7 @@ func resetAllConnectionVerdicts() {
|
||||||
if conn.Verdict.Active != network.VerdictRerouteToTunnel && conn.TunnelContext != nil {
|
if conn.Verdict.Active != network.VerdictRerouteToTunnel && conn.TunnelContext != nil {
|
||||||
err := conn.TunnelContext.StopTunnel()
|
err := conn.TunnelContext.StopTunnel()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Debugf("filter: failed to stopped unneeded tunnel: %s", err)
|
tracer.Debugf("filter: failed to stopped unneeded tunnel: %s", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,11 +151,14 @@ func resetAllConnectionVerdicts() {
|
||||||
if conn.Verdict.Firewall != previousVerdict {
|
if conn.Verdict.Firewall != previousVerdict {
|
||||||
conn.Save()
|
conn.Save()
|
||||||
tracer.Infof("filter: verdict of connection %s changed from %s to %s", conn, previousVerdict.Verb(), conn.VerdictVerb())
|
tracer.Infof("filter: verdict of connection %s changed from %s to %s", conn, previousVerdict.Verb(), conn.VerdictVerb())
|
||||||
|
changedVerdicts++
|
||||||
} else {
|
} else {
|
||||||
tracer.Tracef("filter: verdict to connection %s unchanged at %s", conn, conn.VerdictVerb())
|
tracer.Tracef("filter: verdict to connection %s unchanged at %s", conn, conn.VerdictVerb())
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
tracer.Infof("profile: changed verdict on %d connections", changedVerdicts)
|
||||||
|
tracer.Submit()
|
||||||
|
|
||||||
err := interception.ResetVerdictOfAllConnections()
|
err := interception.ResetVerdictOfAllConnections()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -238,7 +238,7 @@ func loadProcess(ctx context.Context, pid int) (*Process, error) {
|
||||||
// Current working directory
|
// Current working directory
|
||||||
// not yet implemented for windows
|
// not yet implemented for windows
|
||||||
if runtime.GOOS != "windows" {
|
if runtime.GOOS != "windows" {
|
||||||
process.Cwd, err = pInfo.Cwd()
|
process.Cwd, err = pInfo.CwdWithContext(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warningf("process: failed to get Cwd: %s", err)
|
log.Warningf("process: failed to get Cwd: %s", err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue