Skip to content
Snippets Groups Projects
Verified Commit 5d5315c9 authored by Alexander Olofsson's avatar Alexander Olofsson
Browse files

Improve WDS server IP detection

parent bbf50574
No related branches found
No related tags found
No related merge requests found
......@@ -111,8 +111,11 @@ class WdsServer < ApplicationRecord
end
def next_server_ip
Resolv.getaddresses(URI(url).host).select { |str| IPAddr.new(str).ipv4? }.first
rescue Resolv::ResolvError => e
res = Resolv::DNS.open { |dns| dns.getaddresses(URI(url).host) }.select { |addr| addr.is_a? Resolv::IPv4 }.first
return res.to_s if res
IPSocket.getaddress URI(url).host
rescue StandardError => e
::Rails.logger.info "Failed to look up IP of WDS server #{name}. #{e.class}: #{e}"
nil
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment