Fix incoming TCP connection direction

This fixes a bug where incoming TCP connections without a matching process would be falsely classified as an outgoing connection.
This commit is contained in:
Daniel 2020-07-22 14:07:19 +02:00
parent 1e62b9bb59
commit 3b063e9057
2 changed files with 2 additions and 8 deletions

View file

@ -107,7 +107,7 @@ func (table *tcpTable) lookup(pktInfo *packet.Info) (
} }
} }
return socket.UnidentifiedProcessID, false, ErrConnectionNotFound return socket.UnidentifiedProcessID, pktInfo.Inbound, ErrConnectionNotFound
} }
func (table *udpTable) lookup(pktInfo *packet.Info) ( func (table *udpTable) lookup(pktInfo *packet.Info) (

View file

@ -2,7 +2,6 @@ package process
import ( import (
"context" "context"
"errors"
"github.com/safing/portmaster/network/state" "github.com/safing/portmaster/network/state"
@ -10,11 +9,6 @@ import (
"github.com/safing/portmaster/network/packet" "github.com/safing/portmaster/network/packet"
) )
// Errors
var (
ErrProcessNotFound = errors.New("could not find process in system state tables")
)
// GetProcessByConnection returns the process that owns the described connection. // GetProcessByConnection returns the process that owns the described connection.
func GetProcessByConnection(ctx context.Context, pktInfo *packet.Info) (process *Process, connInbound bool, err error) { func GetProcessByConnection(ctx context.Context, pktInfo *packet.Info) (process *Process, connInbound bool, err error) {
if !enableProcessDetection() { if !enableProcessDetection() {
@ -27,7 +21,7 @@ func GetProcessByConnection(ctx context.Context, pktInfo *packet.Info) (process
pid, connInbound, err = state.Lookup(pktInfo) pid, connInbound, err = state.Lookup(pktInfo)
if err != nil { if err != nil {
log.Tracer(ctx).Debugf("process: failed to find PID of connection: %s", err) log.Tracer(ctx).Debugf("process: failed to find PID of connection: %s", err)
return nil, connInbound, err return nil, pktInfo.Inbound, err
} }
process, err = GetOrFindPrimaryProcess(ctx, pid) process, err = GetOrFindPrimaryProcess(ctx, pid)