From 6bace2c9053e8bdfc2689c3c92a9fc066d124401 Mon Sep 17 00:00:00 2001 From: Grex Date: Wed, 17 Aug 2022 12:13:24 +0200 Subject: [PATCH] Add explicit DNS timeout This makes DNS timeouts occur much more quickly and avoid clients with nonfunctional reverse DNS timing out while waiting for a response to their EHLO requests. --- lib/postal/smtp_server/client.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/postal/smtp_server/client.rb b/lib/postal/smtp_server/client.rb index 831b1054..be9f0743 100644 --- a/lib/postal/smtp_server/client.rb +++ b/lib/postal/smtp_server/client.rb @@ -105,7 +105,10 @@ def log(text) private def resolve_hostname - @hostname = Resolv.new.getname(@ip_address) rescue @ip_address + Resolv::DNS.open do |dns| + dns.timeouts = [10,5] + @hostname = dns.getname(@ip_address) rescue @ip_address + end end def proxy(data)