resolver_replace 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aaf2d6d3e1a9b1b8343440183c70d570a1d0a2c4
4
- data.tar.gz: 5d1c057c384ddc95a09b62d08d323d5dec73a5e3
3
+ metadata.gz: 2d7be38119515d08fdb024771a094aebbe81ff6a
4
+ data.tar.gz: 37cb391072b4c8fa64485ae7f5ae0880fb86586f
5
5
  SHA512:
6
- metadata.gz: c9dc86bdb74db1b6fbfff10336f4bb25a36a464153a0974a83e82678b2bddad989da5b9160ea3d64635e4f92938f12a81414aaefba9e23fcbb3b7f8e4b59d940
7
- data.tar.gz: 7d4233e457e5448abb47aeec0f242e92c10aff38c0ad36fdf5bd3347641bea99d126a01543a80a43925c76e6b398cc86b8b74df1626ddeb53ccb52d647633488
6
+ metadata.gz: 8d9ba209c965612564954dba47a1048049c55cf7dac223c52018117660142b09dac52188d4dd1f39bf1cd7d7d5380b11d82d030b2bf7ae943fe5396aed6847f8
7
+ data.tar.gz: 7f57f57ad114affb76ab0868019058c84158fe44ce6b4454181e0b067c33def5570ed5b608e41d75f3846eea40fe719cdf4f2eef508479199e62db8c6c3df8df
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 0.0.3 (2014/07/17)
2
+
3
+ Changes:
4
+
5
+ * Fix not to apply resolver_replace just by `require`. Calling `ResolverReplace.register!` is required to apply now.
6
+
1
7
  ## 0.0.2 (2014/06/27)
2
8
 
3
9
  Enhancements:
data/example/example.rb CHANGED
@@ -1,11 +1,16 @@
1
- require 'resolve'
1
+ require 'resolv'
2
+ require 'resolver_replace'
2
3
 
3
4
  resolver = Resolv::DNS.new(:nameserver => ['210.251.121.21'],
4
5
  :search => ['ruby-lang.org'],
5
6
  :ndots => 1)
6
7
 
7
- ResolverReplace.configure(
8
- getaddress_proc: Proc.new {|host| resolver.getaddress(host) },
9
- getaddresses_proc: Proc.new {|host| resolver.getaddresses(host) },
8
+ addr = IPSocket.getaddress('ruby-lang.org') # Should not use ResolverReplace yet
9
+
10
+ ResolverReplace.register!(
11
+ getaddress: Proc.new {|host| resolver.getaddress(host) },
12
+ getaddresses: Proc.new {|host| resolver.getaddresses(host) },
10
13
  error_class: Resolv::ResolvError,
11
14
  )
15
+
16
+ addr = IPSocket.getaddress('ruby-lang.org') # Should use ResolverReplace
@@ -0,0 +1,75 @@
1
+ # reference: ruby/lib/resolv-replace.rb
2
+ require 'socket'
3
+ require 'resolver_replace'
4
+
5
+ class << IPSocket
6
+ # :stopdoc:
7
+ alias original_resolver_getaddress getaddress
8
+ # :startdoc:
9
+ def getaddress(host)
10
+ begin
11
+ return ResolverReplace.getaddress(host).to_s
12
+ rescue ResolverReplace.error_class => e
13
+ raise SocketError, "#{e.class} #{e.message}"
14
+ end
15
+ end
16
+ end
17
+
18
+ class TCPSocket < IPSocket
19
+ # :stopdoc:
20
+ alias original_resolver_initialize initialize
21
+ # :startdoc:
22
+ def initialize(host, serv, *rest)
23
+ rest[0] = IPSocket.getaddress(rest[0]) unless rest.empty?
24
+ original_resolver_initialize(IPSocket.getaddress(host), serv, *rest)
25
+ end
26
+ end
27
+
28
+ class UDPSocket < IPSocket
29
+ # :stopdoc:
30
+ alias original_resolver_bind bind
31
+ # :startdoc:
32
+ def bind(host, port)
33
+ host = IPSocket.getaddress(host) if host != ""
34
+ original_resolver_bind(host, port)
35
+ end
36
+
37
+ # :stopdoc:
38
+ alias original_resolver_connect connect
39
+ # :startdoc:
40
+ def connect(host, port)
41
+ original_resolver_connect(IPSocket.getaddress(host), port)
42
+ end
43
+
44
+ # :stopdoc:
45
+ alias original_resolver_send send
46
+ # :startdoc:
47
+ def send(mesg, flags, *rest)
48
+ if rest.length == 2
49
+ host, port = rest
50
+ begin
51
+ addrs = ResolverReplace.getaddresses(host)
52
+ rescue ResolverReplace.error_class => e
53
+ raise SocketError, "#{e.class} #{e.message}"
54
+ end
55
+ addrs[0...-1].each {|addr|
56
+ begin
57
+ return original_resolver_send(mesg, flags, addr, port)
58
+ rescue SystemCallError
59
+ end
60
+ }
61
+ original_resolver_send(mesg, flags, addrs[-1], port)
62
+ else
63
+ original_resolver_send(mesg, flags, *rest)
64
+ end
65
+ end
66
+ end
67
+
68
+ class SOCKSSocket < TCPSocket
69
+ # :stopdoc:
70
+ alias original_resolver_initialize initialize
71
+ # :startdoc:
72
+ def initialize(host, serv)
73
+ original_resolver_initialize(IPSocket.getaddress(host), port)
74
+ end
75
+ end if defined? SOCKSSocket
@@ -9,6 +9,7 @@ class ResolverReplace
9
9
  raise ArgumentError, 'getaddresses is required'
10
10
  end
11
11
  @error_class = params[:error_class] || StandardError
12
+ require 'resolver_replace/replace.rb'
12
13
  end
13
14
 
14
15
  def self.getaddress(host)
@@ -28,77 +29,3 @@ class ResolverReplace
28
29
  end
29
30
  end
30
31
 
31
- # reference: ruby/lib/resolv-replace.rb
32
- require 'socket'
33
-
34
- class << IPSocket
35
- # :stopdoc:
36
- alias original_resolver_getaddress getaddress
37
- # :startdoc:
38
- def getaddress(host)
39
- begin
40
- return ResolverReplace.getaddress(host).to_s
41
- rescue ResolverReplace.error_class => e
42
- raise SocketError, "#{e.class} #{e.message}"
43
- end
44
- end
45
- end
46
-
47
- class TCPSocket < IPSocket
48
- # :stopdoc:
49
- alias original_resolver_initialize initialize
50
- # :startdoc:
51
- def initialize(host, serv, *rest)
52
- rest[0] = IPSocket.getaddress(rest[0]) unless rest.empty?
53
- original_resolver_initialize(IPSocket.getaddress(host), serv, *rest)
54
- end
55
- end
56
-
57
- class UDPSocket < IPSocket
58
- # :stopdoc:
59
- alias original_resolver_bind bind
60
- # :startdoc:
61
- def bind(host, port)
62
- host = IPSocket.getaddress(host) if host != ""
63
- original_resolver_bind(host, port)
64
- end
65
-
66
- # :stopdoc:
67
- alias original_resolver_connect connect
68
- # :startdoc:
69
- def connect(host, port)
70
- original_resolver_connect(IPSocket.getaddress(host), port)
71
- end
72
-
73
- # :stopdoc:
74
- alias original_resolver_send send
75
- # :startdoc:
76
- def send(mesg, flags, *rest)
77
- if rest.length == 2
78
- host, port = rest
79
- begin
80
- addrs = ResolverReplace.getaddresses(host)
81
- rescue ResolverReplace.error_class => e
82
- raise SocketError, "#{e.class} #{e.message}"
83
- end
84
- addrs[0...-1].each {|addr|
85
- begin
86
- return original_resolver_send(mesg, flags, addr, port)
87
- rescue SystemCallError
88
- end
89
- }
90
- original_resolver_send(mesg, flags, addrs[-1], port)
91
- else
92
- original_resolver_send(mesg, flags, *rest)
93
- end
94
- end
95
- end
96
-
97
- class SOCKSSocket < TCPSocket
98
- # :stopdoc:
99
- alias original_resolver_initialize initialize
100
- # :startdoc:
101
- def initialize(host, serv)
102
- original_resolver_initialize(IPSocket.getaddress(host), port)
103
- end
104
- end if defined? SOCKSSocket
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "resolver_replace"
7
- spec.version = "0.0.2"
7
+ spec.version = "0.0.3"
8
8
  spec.authors = ["Naotoshi Seo"]
9
9
  spec.email = ["sonots@gmail.com"]
10
10
  spec.summary = %q{Replace the DNS resolver}
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
17
17
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
18
  spec.require_paths = ["lib"]
19
19
 
20
- spec.add_development_dependency "bundler", "~> 1.6"
20
+ spec.add_development_dependency "bundler"
21
21
  spec.add_development_dependency "rake"
22
22
  spec.add_development_dependency "rspec"
23
23
  spec.add_development_dependency "pry"
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resolver_replace
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Naotoshi Seo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-27 00:00:00.000000000 Z
11
+ date: 2014-07-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '1.6'
19
+ version: '0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '1.6'
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -90,7 +90,6 @@ files:
90
90
  - ".gitignore"
91
91
  - CHANGELOG.md
92
92
  - Gemfile
93
- - Gemfile.lock
94
93
  - LICENSE.txt
95
94
  - README.md
96
95
  - Rakefile
@@ -98,6 +97,7 @@ files:
98
97
  - lib/resolver_replace.rb
99
98
  - lib/resolver_replace/error.rb
100
99
  - lib/resolver_replace/plugins/mysql2.rb
100
+ - lib/resolver_replace/replace.rb
101
101
  - resolver_replace.gemspec
102
102
  - spec/resolver_replace_spec.rb
103
103
  - spec/spec_helper.rb
@@ -121,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
121
121
  version: '0'
122
122
  requirements: []
123
123
  rubyforge_project:
124
- rubygems_version: 2.2.2
124
+ rubygems_version: 2.2.0
125
125
  signing_key:
126
126
  specification_version: 4
127
127
  summary: Replace the DNS resolver
data/Gemfile.lock DELETED
@@ -1,44 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- resolver_replace (0.0.2)
5
-
6
- GEM
7
- remote: https://rubygems.org/
8
- specs:
9
- coderay (1.1.0)
10
- diff-lcs (1.2.5)
11
- method_source (0.8.2)
12
- mysql2 (0.3.16)
13
- pry (0.9.12.6)
14
- coderay (~> 1.0)
15
- method_source (~> 0.8)
16
- slop (~> 3.4)
17
- pry-nav (0.2.3)
18
- pry (~> 0.9.10)
19
- rake (10.3.2)
20
- rspec (3.0.0)
21
- rspec-core (~> 3.0.0)
22
- rspec-expectations (~> 3.0.0)
23
- rspec-mocks (~> 3.0.0)
24
- rspec-core (3.0.2)
25
- rspec-support (~> 3.0.0)
26
- rspec-expectations (3.0.2)
27
- diff-lcs (>= 1.2.0, < 2.0)
28
- rspec-support (~> 3.0.0)
29
- rspec-mocks (3.0.2)
30
- rspec-support (~> 3.0.0)
31
- rspec-support (3.0.2)
32
- slop (3.5.0)
33
-
34
- PLATFORMS
35
- ruby
36
-
37
- DEPENDENCIES
38
- bundler (~> 1.6)
39
- mysql2
40
- pry
41
- pry-nav
42
- rake
43
- resolver_replace!
44
- rspec