You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
cryptcheck/lib/cryptcheck/tls/xmpp.rb

26 lines
624 B

8 years ago
module CryptCheck
module Tls
module Xmpp
6 years ago
def self.analyze(hostname, type = :s2s)
service, port = case type
6 years ago
when :s2s
['_xmpp-server', 5269]
when :c2s
['_xmpp-client', 5222]
end
srv = Resolv::DNS.new.getresources("#{service}._tcp.#{hostname}",
Resolv::DNS::Resource::IN::SRV)
.sort_by &:priority
hosts = if srv.empty?
[[hostname, port]]
else
srv.collect { |s| [s.target.to_s, s.port] }
end
8 years ago
6 years ago
hosts.collect { |args| Host.new *args, domain: hostname }
p hosts
8 years ago
end
end
end
end