Rails 4.2.7 kullanıyorum ve birkaç Tor gems var. IP adresimi Ruby/Tor kullanarak nasıl değiştirebilirim?
gem 'tor'
gem 'tor_requests'
gem 'tor-privoxy'
gem 'net-telnet'
ben (Mac El Capitan üzerinde çalışan) benim Tor tarayıcısını başladı ve periyodik olarak (her 20 istek) Benim TOR web istekleri nereden kaynaklandığını IP adresini değiştirmek istiyorum. Bu nedenle, bu aşağıdaki hatayla sonuçlandı: Ancak, bu, aşağıdaki hatayla sonuçlanır. Yukarıdaki işleri yapabilmem için başka şeyleri nasıl yapılandırmam gerektiğine dair kafam karıştı.
Error during processing: Failed to open TCP connection to 127.0.0.1:8118 (general SOCKS server failure)
/Users/davea/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/net/http.rb:882:in `rescue in block in connect'
/Users/davea/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/net/http.rb:879:in `block in connect'
/Users/davea/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/timeout.rb:91:in `block in timeout'
/Users/davea/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/timeout.rb:101:in `timeout'
/Users/davea/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/net/http.rb:878:in `connect'
/Users/davea/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/net/http.rb:863:in `do_start'
/Users/davea/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/net/http.rb:858:in `start'
/Users/davea/.rvm/gems/ruby-2.3.0/gems/net-http-persistent-2.9.4/lib/net/http/persistent.rb:700:in `start'
/Users/davea/.rvm/gems/ruby-2.3.0/gems/net-http-persistent-2.9.4/lib/net/http/persistent.rb:631:in `connection_for'
/Users/davea/.rvm/gems/ruby-2.3.0/gems/net-http-persistent-2.9.4/lib/net/http/persistent.rb:994:in `request'
/Users/davea/.rvm/gems/ruby-2.3.0/gems/mechanize-2.7.5/lib/mechanize/http/agent.rb:274:in `fetch'
/Users/davea/.rvm/gems/ruby-2.3.0/gems/mechanize-2.7.5/lib/mechanize.rb:464:in `get'
/Users/davea/.rvm/gems/ruby-2.3.0/gems/tor-privoxy-0.1.1/lib/tor-privoxy/agent.rb:38:in `ip'
/Users/davea/Documents/workspace/myproject/app/helpers/webpage_helper.rb:57:in `block in get_content'
/Users/davea/.rvm/gems/ruby-2.3.0/gems/tor-privoxy-0.1.1/lib/tor-privoxy/agent.rb:11:in `initialize'
/Users/davea/Documents/workspace/myproject/app/helpers/webpage_helper.rb:55:in `new'
/Users/davea/Documents/workspace/myproject/app/helpers/webpage_helper.rb:55:in `rescue in get_content'
/Users/davea/Documents/workspace/myproject/app/helpers/webpage_helper.rb:50:in `get_content'
/Users/davea/Documents/workspace/myproject/app/helpers/webpage_helper.rb:14:in `get_url'
/Users/davea/Documents/workspace/myproject/app/services/onlinerr_race_finder_service.rb:41:in `get_race_list'
/Users/davea/Documents/workspace/myproject/app/services/abstract_race_finder_service.rb:26:in `process_data'
/Users/davea/Documents/workspace/myproject/app/services/run_crawlers_service.rb:18:in `block in run_all_crawlers'
/Users/davea/.rvm/gems/ruby-2.3.0/gems/activerecord-4.2.7.1/lib/active_record/relation/delegation.rb:46:in `each'
/Users/davea/.rvm/gems/ruby-2.3.0/gems/activerecord-4.2.7.1/lib/active_record/relation/delegation.rb:46:in `each'
/Users/davea/Documents/workspace/myproject/app/services/run_crawlers_service.rb:5:in `run_all_crawlers'
(irb):2:in `irb_binding'
/Users/davea/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/irb/workspace.rb:87:in `eval'
/Users/davea/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/irb/workspace.rb:87:in `evaluate'
/Users/davea/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/irb/context.rb:380:in `evaluate'
/Users/davea/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/irb.rb:489:in `block (2 levels) in eval_input'
/Users/davea/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/irb.rb:623:in `signal_status'
/Users/davea/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/irb.rb:486:in `block in eval_input'
/Users/davea/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/irb/ruby-lex.rb:246:in `block (2 levels) in each_top_level_statement'
/Users/davea/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/irb/ruby-lex.rb:232:in `loop'
/Users/davea/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/irb/ruby-lex.rb:232:in `block in each_top_level_statement'
/Users/davea/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/irb/ruby-lex.rb:231:in `catch'
/Users/davea/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/irb/ruby-lex.rb:231:in `each_top_level_statement'
/Users/davea/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/irb.rb:485:in `eval_input'
/Users/davea/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/irb.rb:395:in `block in start'
/Users/davea/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/irb.rb:394:in `catch'
/Users/davea/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/irb.rb:394:in `start'
Bir IP adresi değişikliğini Ruby/Tor kullanarak nasıl değiştirebilirim? Düzenleme
: ... İşte benim yardımcı dosyasına dahil ne olduğunu ve aşağıda
require 'rubygems'
$:.unshift "./tor/lib"
require 'tor'
…
cookie_file = '/Users/davea/Library/Application Support/TorBrowser-Data/Tor/control_auth_cookie'
file = File.open(cookie_file, 'rb')
cookie = file.read # read contents of auth cookie to string
file.close
Tor::Controller.connect(:port => 9150, :cookie => cookie) do |tor|
tor.signal('NEWNYM') # send NEWNYM signal (gets new IP)
end
raylar konsolda sonuçlanan hata sonuçlanır hatadır
Error during processing: undefined method `signal' for #<Tor::Controller:0x007fe044b1e550>
/Users/davea/Documents/workspace/myproject/app/helpers/webpage_helper.rb:87:in `block in get_content'
/Users/davea/.rvm/gems/ruby-2.3.0/gems/tor-0.1.2/lib/tor/control.rb:38:in `connect'
/Users/davea/Documents/workspace/myproject/app/helpers/webpage_helper.rb:86:in `rescue in get_content'
Düzenleme 2 :
Bunu Gemfile dosyasına ekledikten sonra
gem 'tor', :git => 'https://github.com/dryruby/tor.rb.git'
Ben yukarıdaki kodu koştum ve şimdi hata var ...
Error during processing: end of file reached
/Users/davea/.rvm/gems/ruby-2.3.0/bundler/gems/tor.rb-08e589d17196/lib/tor/control.rb:301:in `readline'
/Users/davea/.rvm/gems/ruby-2.3.0/bundler/gems/tor.rb-08e589d17196/lib/tor/control.rb:301:in `read_reply'
/Users/davea/.rvm/gems/ruby-2.3.0/bundler/gems/tor.rb-08e589d17196/lib/tor/control.rb:194:in `authenticate'
/Users/davea/.rvm/gems/ruby-2.3.0/bundler/gems/tor.rb-08e589d17196/lib/tor/control.rb:282:in `send_command'
/Users/davea/.rvm/gems/ruby-2.3.0/bundler/gems/tor.rb-08e589d17196/lib/tor/control.rb:269:in `signal'
/Users/davea/Documents/workspace/myproject/app/helpers/webpage_helper.rb:90:in `block in get_content'
Bahsettiğim gibi, Mac El Capitan kullanıyorum, bu yüzden "cookie_file =" için ne koymam gerekiyor? Makinemin herhangi bir yerinde "control_auth_cookie" dosyası yok. – Dave
Tor Browser'ın diğer tüm ağ verileri ve durum dosyalarıyla birlikte oluşturduğu Tor veri dizininde olmalıdır. – drew010
Cool, onu buldum.Kodumu çalıştırmaya dayanarak hatayı listelemek için cevabımı güncelledim (hata "İşlem sırasında hata: undefined method" sinyali için # oldu ") –
Dave