Add new connections to internal state on creation
This commit is contained in:
@@ -265,6 +265,10 @@ func NewConnectionFromDNSRequest(ctx context.Context, fqdn string, cnames []stri
|
|||||||
dnsConn.Internal = true
|
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
|
return dnsConn
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -295,6 +299,10 @@ func NewConnectionFromExternalDNSRequest(ctx context.Context, fqdn string, cname
|
|||||||
dnsConn.Internal = localProfile.Internal
|
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
|
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())
|
ipinfo, err := resolver.GetIPInfo(proc.Profile().LocalProfile().ID, pkt.Info().RemoteIP().String())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// Try again with the global scope, in case DNS went through the system resolver.
|
// 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 {
|
if err == nil {
|
||||||
lastResolvedDomain := ipinfo.MostRecentDomain()
|
lastResolvedDomain := ipinfo.MostRecentDomain()
|
||||||
@@ -407,6 +415,10 @@ func NewConnectionFromFirstPacket(pkt packet.Packet) *Connection {
|
|||||||
newConn.Internal = localProfile.Internal
|
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
|
return newConn
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user