0
0
Fork 0

Fix NULL MX handling and tighten DNS resolving specs (#28607)

This commit is contained in:
Claire 2024-01-05 12:07:57 +01:00 committed by GitHub
parent 9699ea22d6
commit 6ad0fb5a77
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 1 deletions

View file

@ -47,6 +47,7 @@ class EmailMxValidator < ActiveModel::Validator
dns.timeouts = 5
records = dns.getresources(domain, Resolv::DNS::Resource::IN::MX).to_a.map { |e| e.exchange.to_s }
next if records == [''] # This domain explicitly rejects emails
([domain] + records).uniq.each do |hostname|
ips.concat(dns.getresources(hostname, Resolv::DNS::Resource::IN::A).to_a.map { |e| e.address.to_s })