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.
|
|
|
module CryptCheck
|
|
|
|
module Tls
|
|
|
|
module Xmpp
|
|
|
|
def self.analyze(hostname, type = :s2s)
|
|
|
|
service, port = case type
|
|
|
|
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
|
|
|
|
|
|
|
|
hosts.collect { |args| Host.new *args, domain: hostname }
|
|
|
|
p hosts
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|