hidemyass 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -20,7 +20,33 @@ Or install it yourself as:
20
20
 
21
21
  ## Usage
22
22
 
23
- TODO: Write usage instructions
23
+ @uri = URI('http://www.iana.org/domains/example/')
24
+ @request = Net::HTTP::Get.new(@uri.request_uri)
25
+ @request['Referer'] = @uri.host
26
+
27
+ response = Hidemyass::HTTP.start(@uri.host, @uri.port) do |http|
28
+ http.request(@request)
29
+ end
30
+
31
+ response
32
+ => #<Net::HTTPOK 200 OK readbody=true>
33
+
34
+ This method defaults to return on HTTPSuccess (2xx)
35
+ If you want more control to follow redirections or whatever, you can retrieve the proxies list and connect manually
36
+
37
+ Hidemyass.proxies.each do |proxy|
38
+ response = Net::HTTP::Proxy(proxy[:host], proxy[:port]).start(@uri.host, @uri.port) do |http|
39
+ http.request(@request)
40
+ end
41
+ if response.class.ancestors.include?(Net::HTTPRedirection)
42
+ # ...
43
+ end
44
+ end
45
+
46
+ To try connecting through local machine before trying proxies
47
+
48
+ Hidemyass.options[:local] = true
49
+ Hidemyass::HTTP.start ...
24
50
 
25
51
  ## Contributing
26
52
 
data/lib/hidemyass.rb CHANGED
@@ -1,12 +1,11 @@
1
1
  require 'nokogiri'
2
2
  require 'open-uri'
3
3
  require 'net/http'
4
- require 'logger'
5
-
6
4
  require 'hidemyass/version'
7
- require 'hidemyass/railtie'
8
- require 'hidemyass/logger'
9
5
  require 'hidemyass/http'
6
+ require 'hidemyass/logger'
7
+ require 'hidemyass/railtie'
8
+ require 'logger'
10
9
 
11
10
  module Hidemyass
12
11
  extend Logger
@@ -24,7 +23,8 @@ module Hidemyass
24
23
 
25
24
  def self.options
26
25
  @options ||= {
27
- :log => true
26
+ :log => true,
27
+ :local => false
28
28
  }
29
29
  end
30
30
 
@@ -1,14 +1,13 @@
1
1
  module Hidemyass
2
2
  module HTTP
3
- def HTTP.start(address, opts = { :try_local => false }, *arg, &block)
4
- Hidemyass.log 'Connecting to ' + address + ' from:'
3
+ def HTTP.start(address, *arg, &block)
4
+ Hidemyass.log 'Connecting to ' + address + ' through:'
5
5
  response = nil
6
6
 
7
- if opts[:try_local]
7
+ if Hidemyass.options[:local]
8
8
  begin
9
9
  Hidemyass.log 'localhost...'
10
10
  response = Net::HTTP.start(address, *arg, &block)
11
- Hidemyass.log response.class.to_s
12
11
  if response.class.ancestors.include?(Net::HTTPSuccess)
13
12
  return response
14
13
  end
@@ -1,3 +1,3 @@
1
1
  module Hidemyass
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.9"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hidemyass
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: