Skip to content

Commit

Permalink
fix(session): detect canceled lookup correctly
Browse files Browse the repository at this point in the history
cancelation is not DNSError, so UnwrapDNSErr() returns "" as reason

Signed-off-by: Martin Matous <m@matous.dev>
  • Loading branch information
mmatous authored and foxcpp committed Jan 21, 2024
1 parent ede85b4 commit c67955e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions internal/endpoint/smtp/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,13 +319,13 @@ func (s *Session) fetchRDNSName(ctx context.Context) {
return
}

reason, misc := exterrors.UnwrapDNSErr(err)
misc["reason"] = reason
if !strings.HasSuffix(reason, "canceled") {
if !errors.Is(err, context.Canceled) {
// Often occurs when transaction completes before rDNS lookup and
// rDNS name was not actually needed. So do not log cancelation
// error if that's the case.

reason, misc := exterrors.UnwrapDNSErr(err)
misc["reason"] = reason
s.log.Error("rDNS error", exterrors.WithFields(err, misc), "src_ip", s.connState.RemoteAddr)
}
s.connState.RDNSName.Set(nil, err)
Expand Down

0 comments on commit c67955e

Please sign in to comment.