mirror of
https://git.kescher.at/CatCatNya/catstodon.git
synced 2024-11-25 17:51:36 +01:00
23 lines
392 B
Ruby
23 lines
392 B
Ruby
|
# frozen_string_literal: true
|
||
|
|
||
|
class DomainResource
|
||
|
attr_reader :domain
|
||
|
|
||
|
RESOLVE_TIMEOUT = 5
|
||
|
|
||
|
def initialize(domain)
|
||
|
@domain = domain
|
||
|
end
|
||
|
|
||
|
def mx
|
||
|
Resolv::DNS.open do |dns|
|
||
|
dns.timeouts = RESOLVE_TIMEOUT
|
||
|
dns
|
||
|
.getresources(domain, Resolv::DNS::Resource::IN::MX)
|
||
|
.to_a
|
||
|
.map { |mx| mx.exchange.to_s }
|
||
|
.compact_blank
|
||
|
end
|
||
|
end
|
||
|
end
|