Skip to content

Commit

Permalink
Make saving IP and CNAMEs more defensive
Browse files Browse the repository at this point in the history
  • Loading branch information
dhaavi committed Nov 12, 2024
1 parent 07acb9b commit f4b96e1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions service/firewall/dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,11 +302,11 @@ func UpdateIPsAndCNAMEs(q *resolver.Query, rrCache *resolver.RRCache, conn *netw
Expires: rrCache.Expires,
}

// Resolve all CNAMEs in the correct order and add the to the record.
// Resolve all CNAMEs in the correct order and add the to the record - up to max 50 layers.
domain := q.FQDN
for {
for range 50 {
nextDomain, isCNAME := cnames[domain]
if !isCNAME {
if !isCNAME || nextDomain == domain {
break
}

Expand Down
2 changes: 1 addition & 1 deletion service/nameserver/nameserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,8 @@ func handleRequest(ctx context.Context, w dns.ResponseWriter, request *dns.Msg)
}

// Save the request as open, as we don't know if there will be a connection or not.
network.SaveOpenDNSRequest(q, rrCache, conn)
firewall.UpdateIPsAndCNAMEs(q, rrCache, conn)
network.SaveOpenDNSRequest(q, rrCache, conn)

case network.VerdictUndeterminable:
fallthrough
Expand Down

0 comments on commit f4b96e1

Please sign in to comment.