Skip to content

Commit c67955e

Browse files
mmatousfoxcpp
authored andcommitted
fix(session): detect canceled lookup correctly
cancelation is not DNSError, so UnwrapDNSErr() returns "" as reason Signed-off-by: Martin Matous <[email protected]>
1 parent ede85b4 commit c67955e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

internal/endpoint/smtp/session.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -319,13 +319,13 @@ func (s *Session) fetchRDNSName(ctx context.Context) {
319319
return
320320
}
321321

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

327+
reason, misc := exterrors.UnwrapDNSErr(err)
328+
misc["reason"] = reason
329329
s.log.Error("rDNS error", exterrors.WithFields(err, misc), "src_ip", s.connState.RemoteAddr)
330330
}
331331
s.connState.RDNSName.Set(nil, err)

0 commit comments

Comments
 (0)