pirj / tor-privoxy

Tor-privoxy is a Ruby Mechanize wrapper to access the web with mechanize via Tor/Privoxy It allows to use multiple Privoxy instances, switch endpoints, switch proxy when you get 4xx HTTP code Useful for web robots, scanners, grabbers when accessing sites which may ban/block you unexpectedly
83 stars 28 forks source link

Connection Refused #3

Closed paladini closed 10 years ago

paladini commented 10 years ago

Hello, how are you friend?

First of all, thanks for your brilliant gem. Well, I really loved your proposal, but I'm having some problems. I try to make a test "Rake Task", exactly as following:

task test: :environment do
    require 'tor-privoxy'
    agent ||= TorPrivoxy::Agent.new '127.0.0.1', '', {8123 => 9051} do |agent|
      sleep 10
      puts "New IP is #{agent.ip}"
    end
end

And I'm getting the following error on Terminal:

rake aborted!
connection refused: 127.0.0.1:8123
/home/paladini/.rvm/gems/ruby-2.0.0-p353@earn_litecoin/gems/net-http-persistent-2.9/lib/net/http/persistent.rb:640:in `rescue in connection_for'
/home/paladini/.rvm/gems/ruby-2.0.0-p353@earn_litecoin/gems/net-http-persistent-2.9/lib/net/http/persistent.rb:589:in `connection_for'
/home/paladini/.rvm/gems/ruby-2.0.0-p353@earn_litecoin/gems/net-http-persistent-2.9/lib/net/http/persistent.rb:981:in `request'
/home/paladini/.rvm/gems/ruby-2.0.0-p353@earn_litecoin/gems/mechanize-2.6.0/lib/mechanize/http/agent.rb:263:in `fetch'
/home/paladini/.rvm/gems/ruby-2.0.0-p353@earn_litecoin/gems/mechanize-2.6.0/lib/mechanize.rb:431:in `get'
/home/paladini/.rvm/gems/ruby-2.0.0-p353@earn_litecoin/gems/tor-privoxy-0.1.1/lib/tor-privoxy/agent.rb:38:in `ip'
/home/paladini/Documents/Projetos/earn_litecoin/lib/tasks/hack.rake:9:in `block (3 levels) in <top (required)>'
/home/paladini/.rvm/gems/ruby-2.0.0-p353@earn_litecoin/gems/tor-privoxy-0.1.1/lib/tor-privoxy/agent.rb:11:in `call'
/home/paladini/.rvm/gems/ruby-2.0.0-p353@earn_litecoin/gems/tor-privoxy-0.1.1/lib/tor-privoxy/agent.rb:11:in `initialize'
/home/paladini/Documents/Projetos/earn_litecoin/lib/tasks/hack.rake:7:in `new'
/home/paladini/Documents/Projetos/earn_litecoin/lib/tasks/hack.rake:7:in `block (2 levels) in <top (required)>'

And one thing that I doesn't understand in your gem: only this code can provide me access to a website, changing IP Address every time? (stopping issues like blocks and bans). It's like a Proxy changer?

pirj commented 10 years ago

Hi Fernando!

The gem is forcing the connections to be made via Tor network. The only way to do so is to have Tor and Polipo (or Privoxy) installed. Though this chain all your HTTP requests are being made.

Tor has a concept of "endpoint", a machine somewhere on the network that sends your requests to target machine. If for some reason server blocks that machine by IP, you should "swich endpoint" to have a new IP address. To do so, you should run:

agent.switch_circuit

Hope that helps.

BR, Phil

2014/1/22 Fernando Paladini notifications@github.com

Hello, how are you friend?

First of all, thanks for your brilliant gem. Well, I really loved your proposal, but I'm having some problems. I try to make a test "Rake Task", exactly as following:

task test: :environment do require 'tor-privoxy' agent ||= TorPrivoxy::Agent.new '127.0.0.1', '', {8123 => 9051} do |agent| sleep 10 puts "New IP is #{agent.ip}" endend

And I'm getting the following error on Terminal:

rake aborted! connection refused: 127.0.0.1:8123 /home/paladini/.rvm/gems/ruby-2.0.0-p353@earn_litecoin/gems/net-http-persistent-2.9/lib/net/http/persistent.rb:640:in rescue in connection_for' /home/paladini/.rvm/gems/ruby-2.0.0-p353@earn_litecoin/gems/net-http-persistent-2.9/lib/net/http/persistent.rb:589:inconnection_for' /home/paladini/.rvm/gems/ruby-2.0.0-p353@earn_litecoin/gems/net-http-persistent-2.9/lib/net/http/persistent.rb:981:in request' /home/paladini/.rvm/gems/ruby-2.0.0-p353@earn_litecoin/gems/mechanize-2.6.0/lib/mechanize/http/agent.rb:263:infetch' /home/paladini/.rvm/gems/ruby-2.0.0-p353@earn_litecoin/gems/mechanize-2.6.0/lib/mechanize.rb:431:in get' /home/paladini/.rvm/gems/ruby-2.0.0-p353@earn_litecoin/gems/tor-privoxy-0.1.1/lib/tor-privoxy/agent.rb:38:inip' /home/paladini/Documents/Projetos/earn_litecoin/lib/tasks/hack.rake:9:in block (3 levels) in <top (required)>' /home/paladini/.rvm/gems/ruby-2.0.0-p353@earn_litecoin/gems/tor-privoxy-0.1.1/lib/tor-privoxy/agent.rb:11:incall' /home/paladini/.rvm/gems/ruby-2.0.0-p353@earn_litecoin/gems/tor-privoxy-0.1.1/lib/tor-privoxy/agent.rb:11:in initialize' /home/paladini/Documents/Projetos/earn_litecoin/lib/tasks/hack.rake:7:innew' /home/paladini/Documents/Projetos/earn_litecoin/lib/tasks/hack.rake:7:in `block (2 levels) in <top (required)>'

And one thing that I doesn't understand in your gem: only this code can provide me access to a website, changing IP Address every time? (stopping issues like blocks and bans). It's like a Proxy changer?

— Reply to this email directly or view it on GitHubhttps://github.com/pirj/tor-privoxy/issues/3 .

paladini commented 10 years ago

Thanks, tonight I will try run again my project, now I'm at work. Later I come back here and post what I've done.

Again, thanks! :)

paladini commented 10 years ago

Hi @pirj , I install Tor and Privoxy in my Ubuntu 12.04, but I still receiving the same error (and same log) that I posted above.

If I check the installation on my Terminal, I receive the following:

dpkg -s tor
# Package: tor
# Status: install ok installed

dpkg -s privoxy
# Package: privoxy
# Status: install ok installed

Do I need config something else? Thanks for your awesome gem and I'll be glad if you can help me until we fix this issue :)

pirj commented 10 years ago

Check if "Control port" is turned on and is set to 9051 in tor configuration. Make sure that Privoxy is accepting connections at 8123 (assuming this is a default port for Polipo, not Privoxy). Make sure that Privoxy is using tor's SOCKS proxy at port 9050. Should work in this case.

pirj commented 10 years ago

Closing as there's no reply from topicstarter