File: socks5.rb

package info (click to toggle)
ruby-em-http-request 0.3.0-1
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 424 kB
  • sloc: ruby: 2,381; ansic: 999; makefile: 2
file content (26 lines) | stat: -rw-r--r-- 594 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
require 'rubygems'
require 'eventmachine'
require '../lib/em-http'

EM.run do
  # Establish a SOCKS5 tunnel via SSH
  # ssh -D 8000 some_remote_machine

  # http = EM::HttpRequest.new('http://whatismyip.org/').get({
  http = EM::HttpRequest.new('http://igvita.com/').get({
    :proxy => {:host => '127.0.0.1', :port => 8000, :type => :socks},
    :redirects => 2
  })

  http.callback {
    puts "#{http.response_header.status} - #{http.response.length} bytes\n"
    puts http.response
    EM.stop
  }

  http.errback {
    puts "Error: " + http.error
    puts http.inspect
    EM.stop
  }
end