lib/bitcoin/connection.rb in bitcoin-ruby-0.0.6 vs lib/bitcoin/connection.rb in bitcoin-ruby-0.0.7

- old
+ new

@@ -1,10 +1,11 @@ # encoding: ascii-8bit require 'socket' require 'eventmachine' require 'bitcoin' +require 'resolv' module Bitcoin module ConnectionHandler def on_inv_transaction(hash) @@ -105,10 +106,10 @@ end def self.connect_random_from_dns(connections) seeds = Bitcoin.network[:dns_seeds] if seeds.any? - host = `nslookup #{seeds.sample}`.scan(/Address\: (.+)$/).flatten.sample + host = Resolv::DNS.new.getaddresses(seeds.sample).map {|a| a.to_s}.sample connect(host, Bitcoin::network[:default_port], connections) else raise "No DNS seeds available. Provide IP, configure seeds, or use different network." end end