lib/mcrt.rb in mcrt-1.14.0 vs lib/mcrt.rb in mcrt-1.15.0
- old
+ new
@@ -124,23 +124,34 @@
end
end
def get_my_ip_addresses
addresses = Socket.ip_address_list.collect {|a| a.ip_address.to_s}
- begin
- addresses << `dig +short myip.opendns.com @resolver1.opendns.com`.strip
- rescue Exception
- # ignored
+ commands = [
+ "dig +short myip.opendns.com @resolver1.opendns.com",
+ "curl ifconfig.me",
+ "curl icanhazip.com",
+ "curl ipecho.net/plain",
+ "curl ifconfig.co",
+ "dig TXT +short o-o.myaddr.l.google.com @ns1.google.com | awk -F'\"' '{ print $2 }'"
+ ]
+ commands.each do |cmd|
+ begin
+ addresses << `#{cmd}`.strip
+ rescue Exception
+ # ignored
+ end
end
- begin
- addresses << Net::HTTP.get(URI('http://www.myexternalip.com/raw')).strip
- rescue Exception
- # ignored
- end
- begin
- addresses << Net::HTTP.get(URI('https://diagnostic.opendns.com/myip')).strip
- rescue Exception
- # ignored
+ urls = [
+ "http://www.myexternalip.com/raw",
+ "https://diagnostic.opendns.com/myip"
+ ]
+ urls.each do |url|
+ begin
+ addresses << Net::HTTP.get(URI(url)).strip
+ rescue Exception
+ # ignored
+ end
end
begin
addresses << JSON.parse(Net::HTTP.get(URI('https://api.ipify.org?format=json')))['ip']
rescue Exception
# ignored