fix(session): detect canceled lookup correctly

cancelation is not DNSError, so UnwrapDNSErr() returns "" as reason

Signed-off-by: Martin Matous <m@matous.dev>
This commit is contained in:
Martin Matous 2023-08-24 18:17:08 +02:00 committed by fox.cpp
parent ede85b4cd1
commit c67955ef0d
No known key found for this signature in database
GPG key ID: 5B991F6215D2FCC0

View file

@ -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)