tor_proxy 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
@@ -0,0 +1 @@
1
+ 1.9.3-p125-perf
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in tor_proxy.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Huned Botee
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,46 @@
1
+ # Tor::Proxy
2
+
3
+ The simple way to HTTP GET over Tor with ruby. See [http://github.com/huned/tor_proxy](http://gitub.com/huned/tor_proxy)
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'tor_proxy'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install tor_proxy
18
+
19
+ ## Usage
20
+
21
+ By default, assumes a Tor proxy server is running at localhost:9050.
22
+
23
+ # returns the body of the http request
24
+ Tor::Proxy.get('https://www.torproject.org')
25
+
26
+ Use an instance to set your Tor proxy server's host and port.
27
+
28
+ Tor::Proxy.new('localhost', 9050).get('https://www.torproject.org')
29
+
30
+ ## Development
31
+
32
+ Running tests
33
+
34
+ bundle install
35
+
36
+ then
37
+
38
+ bundle exec rspec spec
39
+
40
+ ## Contributing
41
+
42
+ 1. Fork it
43
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
44
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
45
+ 4. Push to the branch (`git push origin my-new-feature`)
46
+ 5. Create new Pull Request
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,28 @@
1
+ require "tor_proxy/version"
2
+ require 'net/http'
3
+ require 'socksify/http'
4
+ require 'tor'
5
+
6
+ module Tor
7
+ class Proxy
8
+ def initialize host = 'localhost', port = 9050
9
+ unless Tor.available?
10
+ raise <<-EOS
11
+ Tor isn't installed. Install Tor to use this module.
12
+ See http://torproject.org or `brew install tor`.
13
+ EOS
14
+ end
15
+
16
+ @proxy = Net::HTTP.SOCKSProxy host, port
17
+ end
18
+
19
+ def get url
20
+ @proxy.get URI.parse(url)
21
+ end
22
+
23
+ def self.get url
24
+ @@proxy ||= self.new
25
+ @@proxy.get url
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,5 @@
1
+ module Tor
2
+ class Proxy
3
+ VERSION = "0.0.3"
4
+ end
5
+ end
@@ -0,0 +1,58 @@
1
+ require 'tor_proxy'
2
+
3
+ describe Tor::Proxy do
4
+ describe '.new' do
5
+ context 'without tor' do
6
+ before do
7
+ Tor.stub(:available?).and_return(false)
8
+ end
9
+
10
+ it "should raise if Tor isn't installed" do
11
+ lambda {
12
+ Tor::Proxy.new
13
+ }.should raise_error(RuntimeError, /Tor isn't installed/)
14
+ end
15
+ end
16
+
17
+ context 'with tor' do
18
+ before do
19
+ Tor.stub(:available?).and_return(true)
20
+ lambda {
21
+ @tor_proxy = Tor::Proxy.new
22
+ @socks_proxy = @tor_proxy.instance_variable_get(:@proxy)
23
+ }.should_not raise_error
24
+ end
25
+
26
+ it "should not raise error" do
27
+ lambda {
28
+ Tor::Proxy.new
29
+ }.should_not raise_error
30
+ end
31
+
32
+ it "should use localhost:9050 by default" do
33
+ proxy = Tor::Proxy.new
34
+ socks_proxy = proxy.instance_variable_get(:@proxy)
35
+ socks_proxy.socks_server.should == 'localhost'
36
+ socks_proxy.socks_port.should == 9050
37
+ end
38
+
39
+ it "should use custom host and port" do
40
+ proxy = Tor::Proxy.new 'tor.local', 1337
41
+ socks_proxy = proxy.instance_variable_get(:@proxy)
42
+ socks_proxy.socks_server.should == 'tor.local'
43
+ socks_proxy.socks_port.should == 1337
44
+ end
45
+ end
46
+ end
47
+
48
+ describe '#get' do
49
+ before do
50
+ @proxy = Tor::Proxy.new
51
+ Net::HTTP.stub(:get).and_return('fake response')
52
+ end
53
+
54
+ it 'should delegate to Net::HTTP' do
55
+ @proxy.get('http://example.com').should == 'fake response'
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/tor_proxy/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Huned Botee"]
6
+ gem.email = ["huned@734m.com"]
7
+ gem.summary = %q{The simple way to HTTP GET over Tor with ruby.}
8
+ gem.description = %q{The simple way to HTTP GET over Tor with ruby.}
9
+ gem.homepage = "http://github.com/huned/tor_proxy"
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "tor_proxy"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Tor::Proxy::VERSION
17
+
18
+ gem.add_dependency 'socksify'
19
+ gem.add_dependency 'tor'
20
+
21
+ gem.add_development_dependency 'debugger'
22
+ gem.add_development_dependency 'rspec'
23
+ end
metadata ADDED
@@ -0,0 +1,100 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tor_proxy
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Huned Botee
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-05-08 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: socksify
16
+ requirement: &70322218576180 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70322218576180
25
+ - !ruby/object:Gem::Dependency
26
+ name: tor
27
+ requirement: &70322218575640 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70322218575640
36
+ - !ruby/object:Gem::Dependency
37
+ name: debugger
38
+ requirement: &70322218575000 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *70322218575000
47
+ - !ruby/object:Gem::Dependency
48
+ name: rspec
49
+ requirement: &70322218574120 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *70322218574120
58
+ description: The simple way to HTTP GET over Tor with ruby.
59
+ email:
60
+ - huned@734m.com
61
+ executables: []
62
+ extensions: []
63
+ extra_rdoc_files: []
64
+ files:
65
+ - .gitignore
66
+ - .rbenv-version
67
+ - Gemfile
68
+ - LICENSE
69
+ - README.md
70
+ - Rakefile
71
+ - lib/tor_proxy.rb
72
+ - lib/tor_proxy/version.rb
73
+ - spec/tor_proxy_spec.rb
74
+ - tor_proxy.gemspec
75
+ homepage: http://github.com/huned/tor_proxy
76
+ licenses: []
77
+ post_install_message:
78
+ rdoc_options: []
79
+ require_paths:
80
+ - lib
81
+ required_ruby_version: !ruby/object:Gem::Requirement
82
+ none: false
83
+ requirements:
84
+ - - ! '>='
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ required_rubygems_version: !ruby/object:Gem::Requirement
88
+ none: false
89
+ requirements:
90
+ - - ! '>='
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ requirements: []
94
+ rubyforge_project:
95
+ rubygems_version: 1.8.11
96
+ signing_key:
97
+ specification_version: 3
98
+ summary: The simple way to HTTP GET over Tor with ruby.
99
+ test_files:
100
+ - spec/tor_proxy_spec.rb