mirror of
https://github.com/safing/portmaster
synced 2025-09-02 10:39:22 +00:00
Fix dns request handling when failing
This commit is contained in:
parent
b84cb08792
commit
b716f56eaf
2 changed files with 8 additions and 1 deletions
|
@ -150,6 +150,12 @@ func handleRequest(ctx context.Context, w dns.ResponseWriter, request *dns.Msg)
|
||||||
// For undecided or accepted connections we don't save them yet, because
|
// For undecided or accepted connections we don't save them yet, because
|
||||||
// that will happen later anyway.
|
// that will happen later anyway.
|
||||||
case network.VerdictUndecided, network.VerdictAccept:
|
case network.VerdictUndecided, network.VerdictAccept:
|
||||||
|
// Check if we have a response.
|
||||||
|
if rrCache == nil {
|
||||||
|
conn.Failed("internal error: no reply", "")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// Save the request as open, as we don't know if there will be a connection or not.
|
// Save the request as open, as we don't know if there will be a connection or not.
|
||||||
network.SaveOpenDNSRequest(q, rrCache, conn)
|
network.SaveOpenDNSRequest(q, rrCache, conn)
|
||||||
firewall.UpdateIPsAndCNAMEs(q, rrCache, conn)
|
firewall.UpdateIPsAndCNAMEs(q, rrCache, conn)
|
||||||
|
@ -191,6 +197,7 @@ func handleRequest(ctx context.Context, w dns.ResponseWriter, request *dns.Msg)
|
||||||
rrCache, err = resolver.Resolve(ctx, q)
|
rrCache, err = resolver.Resolve(ctx, q)
|
||||||
// Handle error.
|
// Handle error.
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
conn.Failed(fmt.Sprintf("query failed: %s", err), "")
|
||||||
switch {
|
switch {
|
||||||
case errors.Is(err, resolver.ErrNotFound):
|
case errors.Is(err, resolver.ErrNotFound):
|
||||||
tracer.Tracef("nameserver: %s", err)
|
tracer.Tracef("nameserver: %s", err)
|
||||||
|
|
|
@ -52,7 +52,7 @@ func removeOpenDNSRequest(pid int, fqdn string) {
|
||||||
// SaveOpenDNSRequest saves a dns request connection that was allowed to proceed.
|
// SaveOpenDNSRequest saves a dns request connection that was allowed to proceed.
|
||||||
func SaveOpenDNSRequest(q *resolver.Query, rrCache *resolver.RRCache, conn *Connection) {
|
func SaveOpenDNSRequest(q *resolver.Query, rrCache *resolver.RRCache, conn *Connection) {
|
||||||
// Only save requests that actually went out to reduce clutter.
|
// Only save requests that actually went out to reduce clutter.
|
||||||
if rrCache.ServedFromCache {
|
if rrCache == nil || rrCache.ServedFromCache {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue