mirror of
https://github.com/safing/portmaster
synced 2025-09-01 18:19:12 +00:00
Add new connections to internal state on creation
This commit is contained in:
parent
101159be8d
commit
a879d2715a
1 changed files with 13 additions and 1 deletions
|
@ -265,6 +265,10 @@ func NewConnectionFromDNSRequest(ctx context.Context, fqdn string, cnames []stri
|
|||
dnsConn.Internal = true
|
||||
}
|
||||
|
||||
// DNS Requests are saved by the nameserver depending on the result of the
|
||||
// query. Blocked requests are saved immediately, accepted ones are only
|
||||
// saved if they are not "used" by a connection.
|
||||
|
||||
return dnsConn
|
||||
}
|
||||
|
||||
|
@ -295,6 +299,10 @@ func NewConnectionFromExternalDNSRequest(ctx context.Context, fqdn string, cname
|
|||
dnsConn.Internal = localProfile.Internal
|
||||
}
|
||||
|
||||
// DNS Requests are saved by the nameserver depending on the result of the
|
||||
// query. Blocked requests are saved immediately, accepted ones are only
|
||||
// saved if they are not "used" by a connection.
|
||||
|
||||
return dnsConn, nil
|
||||
}
|
||||
|
||||
|
@ -340,7 +348,7 @@ func NewConnectionFromFirstPacket(pkt packet.Packet) *Connection {
|
|||
ipinfo, err := resolver.GetIPInfo(proc.Profile().LocalProfile().ID, pkt.Info().RemoteIP().String())
|
||||
if err != nil {
|
||||
// Try again with the global scope, in case DNS went through the system resolver.
|
||||
ipinfo, err = resolver.GetIPInfo(resolver.IPInfoProfileScopeGlobal, pkt.Info().Dst.String())
|
||||
ipinfo, err = resolver.GetIPInfo(resolver.IPInfoProfileScopeGlobal, pkt.Info().RemoteIP().String())
|
||||
}
|
||||
if err == nil {
|
||||
lastResolvedDomain := ipinfo.MostRecentDomain()
|
||||
|
@ -407,6 +415,10 @@ func NewConnectionFromFirstPacket(pkt packet.Packet) *Connection {
|
|||
newConn.Internal = localProfile.Internal
|
||||
}
|
||||
|
||||
// Save connection to internal state in order to mitigate creation of
|
||||
// duplicates. Do not propagate yet, as there is no verdict yet.
|
||||
conns.add(newConn)
|
||||
|
||||
return newConn
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue