tor 0.1.4 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (6) hide show
  1. checksums.yaml +5 -5
  2. data/AUTHORS +1 -0
  3. data/README +1 -1
  4. data/VERSION +1 -1
  5. data/lib/tor/dnsel.rb +9 -57
  6. metadata +12 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: cfccedfae1deb3bfeb415f8df82f0429c7ba5006
4
- data.tar.gz: 7e08802cf5ab8d0385cc4d436a5c28f849326ce5
2
+ SHA256:
3
+ metadata.gz: 7be2c2b80fea90e1b3e9567624a442d4b3d1a92946f72d6b465280ad4b5d0ec8
4
+ data.tar.gz: 96358536b8479ea4fba83fb236dabb6b743074c058a48a6fbfe435bf00ab5bbc
5
5
  SHA512:
6
- metadata.gz: c52ab924220a91cbc2613cdad24e922cb79cef86ab87b765b9096fc1ebf5e2c718be35ec58f46adf127815b4021291258fe26e04cb89818a265966fcf47b55d1
7
- data.tar.gz: e51397feb8954645d47ac639b238ca8dddda36d6c2591d4f4c93ef147eeeff4e0e841b9d1a0c1771394e319180d10feb088eaa6ffb879cb6a7869541359a56c4
6
+ metadata.gz: b961dc19ac6f692cbade5226a895782c311cf6463fd228595ee4044085de9340f6948e852c981649c63abfd0abd01665d3fd7cabf2970815be6f87541b8158ee
7
+ data.tar.gz: cbecd4beddfd8d543d79233ea2f116609204550f0366a091aacac9573eae593e08c2d5c663020b56713ea6fc46b6dbb2ca39aa6b4e0e1686bb30d6ae7c7b2a7c
data/AUTHORS CHANGED
@@ -1 +1,2 @@
1
1
  * Arto Bendiken <arto.bendiken@gmail.com>
2
+ * Łukasz Wieczorek <wieczorek1990@gmail.com>
data/README CHANGED
@@ -1 +1 @@
1
- README.md
1
+ ./README.md
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.4
1
+ 0.1.5
data/lib/tor/dnsel.rb CHANGED
@@ -1,49 +1,12 @@
1
1
  require 'resolv' unless defined?(Resolv)
2
2
 
3
3
  module Tor
4
- ##
5
- # Tor DNS Exit List (DNSEL) client.
6
- #
7
- # Unless the target IP address and port are explicitly specified, the
8
- # query will be performed using a target IP address of "8.8.8.8" and a
9
- # target port of 53. These correspond to the DNS protocol port on one of
10
- # the [Google Public DNS](http://code.google.com/speed/public-dns/)
11
- # servers, and they are guaranteed to be reachable from Tor's default exit
12
- # policy.
13
- #
14
- # @example Checking source IP addresses
15
- # Tor::DNSEL.include?("185.220.101.21") #=> true
16
- # Tor::DNSEL.include?("1.2.3.4") #=> false
17
- #
18
- # @example Checking source hostnames
19
- # Tor::DNSEL.include?("ennui.lostinthenoise.net") #=> true
20
- # Tor::DNSEL.include?("myhost.example.org") #=> false
21
- #
22
- # @example Specifying an explicit target port
23
- # Tor::DNSEL.include?("185.220.101.21", :port => 80) #=> true
24
- # Tor::DNSEL.include?("185.220.101.21", :port => 25) #=> false
25
- #
26
- # @example Specifying an explicit target IP address and port
27
- # Tor::DNSEL.include?(source_addr, :addr => target_addr, :port => target_port)
28
- # Tor::DNSEL.include?("185.220.101.21", :addr => myip, :port => myport)
29
- #
30
- # @example Using from a Rack application
31
- # Tor::DNSEL.include?(env['REMOTE_ADDR'] || env['REMOTE_HOST'], {
32
- # :addr => env['SERVER_NAME'],
33
- # :port => env['SERVER_PORT'],
34
- # })
35
- #
36
- # @see https://www.torproject.org/tordnsel/
37
- # @see https://trac.torproject.org/projects/tor/wiki/TheOnionRouter/TorDNSExitList
38
- # @see http://gitweb.torproject.org/tor.git?a=blob_plain;hb=HEAD;f=doc/contrib/torel-design.txt
39
4
  module DNSEL
40
5
  RESOLVER = Resolv::DefaultResolver unless defined?(RESOLVER)
41
- TARGET_ADDR = '8.8.8.8'.freeze unless defined?(TARGET_ADDR) # Google Public DNS
42
- TARGET_PORT = 53 unless defined?(TARGET_PORT) # DNS
43
- DNS_SUFFIX = 'ip-port.exitlist.torproject.org'.freeze
6
+ DNS_SUFFIX = 'dnsel.torproject.org'.freeze
44
7
 
45
8
  ##
46
- # Returns `true` if the Tor DNSEL includes `host`, `false` otherwise.
9
+ # Returns `true` if `host` is a Tor Exit Node, `false` otherwise.
47
10
  #
48
11
  # If the DNS server is unreachable or the DNS query times out, returns
49
12
  # `nil` to indicate that we don't have a definitive answer one way or
@@ -54,13 +17,10 @@ module Tor
54
17
  # Tor::DNSEL.include?("1.2.3.4") #=> false
55
18
  #
56
19
  # @param [String, #to_s] host
57
- # @param [Hash{Symbol => Object}] options
58
- # @option options [String, #to_s] :addr ("8.8.8.8")
59
- # @option options [Integer, #to_i] :port (53)
60
20
  # @return [Boolean]
61
- def self.include?(host, options = {})
21
+ def self.include?(host)
62
22
  begin
63
- query(host, options) == '127.0.0.2'
23
+ query(host) == '127.0.0.2'
64
24
  rescue Resolv::ResolvError # NXDOMAIN
65
25
  false
66
26
  rescue Resolv::ResolvTimeout
@@ -81,31 +41,23 @@ module Tor
81
41
  # Tor::DNSEL.query("1.2.3.4") #=> Resolv::ResolvError
82
42
  #
83
43
  # @param [String, #to_s] host
84
- # @param [Hash{Symbol => Object}] options
85
- # @option options [String, #to_s] :addr ("8.8.8.8")
86
- # @option options [Integer, #to_i] :port (53)
87
44
  # @return [String]
88
45
  # @raise [Resolv::ResolvError] for an NXDOMAIN response
89
- def self.query(host, options = {})
90
- getaddress(dnsname(host, options))
46
+ def self.query(host)
47
+ getaddress(dnsname(host))
91
48
  end
92
49
 
93
50
  ##
94
51
  # Returns the DNS name used for Tor DNSEL queries of `host`.
95
52
  #
96
53
  # @example
97
- # Tor::DNSEL.dnsname("1.2.3.4") #=> "4.3.2.1.53.8.8.8.8.ip-port.exitlist.torproject.org"
54
+ # Tor::DNSEL.dnsname("1.2.3.4") #=> "4.3.2.1.dnsel.torproject.org"
98
55
  #
99
56
  # @param [String, #to_s] host
100
- # @param [Hash{Symbol => Object}] options
101
- # @option options [String, #to_s] :addr ("8.8.8.8")
102
- # @option options [Integer, #to_i] :port (53)
103
57
  # @return [String]
104
- def self.dnsname(host, options = {})
58
+ def self.dnsname(host)
105
59
  source_addr = getaddress(host, true)
106
- target_addr = getaddress(options[:addr] || TARGET_ADDR, true)
107
- target_port = options[:port] || TARGET_PORT
108
- [source_addr, target_port, target_addr, DNS_SUFFIX].join('.')
60
+ "#{source_addr}.#{DNS_SUFFIX}"
109
61
  end
110
62
  class << self; alias_method :hostname, :dnsname; end
111
63
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arto Bendiken
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-06-07 00:00:00.000000000 Z
11
+ date: 2021-03-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: yard
@@ -17,6 +17,9 @@ dependencies:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 0.6.0
20
+ - - "~>"
21
+ - !ruby/object:Gem::Version
22
+ version: '0.6'
20
23
  type: :development
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -24,18 +27,21 @@ dependencies:
24
27
  - - ">="
25
28
  - !ruby/object:Gem::Version
26
29
  version: 0.6.0
30
+ - - "~>"
31
+ - !ruby/object:Gem::Version
32
+ version: '0.6'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: rspec
29
35
  requirement: !ruby/object:Gem::Requirement
30
36
  requirements:
31
- - - ">="
37
+ - - "~>"
32
38
  - !ruby/object:Gem::Version
33
39
  version: '3'
34
40
  type: :development
35
41
  prerelease: false
36
42
  version_requirements: !ruby/object:Gem::Requirement
37
43
  requirements:
38
- - - ">="
44
+ - - "~>"
39
45
  - !ruby/object:Gem::Version
40
46
  version: '3'
41
47
  description: Tor.rb is a Ruby library for interacting with the Tor anonymity network.
@@ -56,7 +62,7 @@ files:
56
62
  - lib/tor/version.rb
57
63
  homepage: http://cypherpunk.rubyforge.org/tor/
58
64
  licenses:
59
- - Public Domain
65
+ - Unlicense
60
66
  metadata: {}
61
67
  post_install_message:
62
68
  rdoc_options: []
@@ -74,8 +80,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
80
  version: '0'
75
81
  requirements:
76
82
  - Tor (>= 0.2.1.25)
77
- rubyforge_project: cypherpunk
78
- rubygems_version: 2.5.2.3
83
+ rubygems_version: 3.0.3
79
84
  signing_key:
80
85
  specification_version: 4
81
86
  summary: Onion routing for Ruby.