rubysl-resolv 2.1.0 → 2.1.1
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.
- checksums.yaml +4 -4
- data/MRI_LICENSE +56 -0
- data/lib/rubysl/resolv-replace.rb +1 -0
- data/lib/rubysl/resolv/resolv-replace.rb +74 -0
- data/lib/rubysl/resolv/resolv.rb +31 -17
- data/lib/rubysl/resolv/version.rb +1 -1
- metadata +23 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5a3b2d810058ec30f40edc3b93454a731d36630f
|
4
|
+
data.tar.gz: 23abe88f768bd21b940edc25c6dd4c6172941309
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a620c040ab64339559397406c5ddce07a380bac977e4a0cb07228067417be5ab068711f25eac57144bb9ba5f36c849ed69780a8bd926705da361ac7a55e7417
|
7
|
+
data.tar.gz: 19dccd59c66773232a5572c1553597e95b3e436fc59dc0d990c7f31bd19bc93af734da9e696b9f4a1529314a5f28e1ee12456327ca75f8d3e41517e32883c1c9
|
data/MRI_LICENSE
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
Ruby is copyrighted free software by Yukihiro Matsumoto <matz@netlab.jp>.
|
2
|
+
You can redistribute it and/or modify it under either the terms of the
|
3
|
+
2-clause BSDL (see the file BSDL), or the conditions below:
|
4
|
+
|
5
|
+
1. You may make and give away verbatim copies of the source form of the
|
6
|
+
software without restriction, provided that you duplicate all of the
|
7
|
+
original copyright notices and associated disclaimers.
|
8
|
+
|
9
|
+
2. You may modify your copy of the software in any way, provided that
|
10
|
+
you do at least ONE of the following:
|
11
|
+
|
12
|
+
a) place your modifications in the Public Domain or otherwise
|
13
|
+
make them Freely Available, such as by posting said
|
14
|
+
modifications to Usenet or an equivalent medium, or by allowing
|
15
|
+
the author to include your modifications in the software.
|
16
|
+
|
17
|
+
b) use the modified software only within your corporation or
|
18
|
+
organization.
|
19
|
+
|
20
|
+
c) give non-standard binaries non-standard names, with
|
21
|
+
instructions on where to get the original software distribution.
|
22
|
+
|
23
|
+
d) make other distribution arrangements with the author.
|
24
|
+
|
25
|
+
3. You may distribute the software in object code or binary form,
|
26
|
+
provided that you do at least ONE of the following:
|
27
|
+
|
28
|
+
a) distribute the binaries and library files of the software,
|
29
|
+
together with instructions (in the manual page or equivalent)
|
30
|
+
on where to get the original distribution.
|
31
|
+
|
32
|
+
b) accompany the distribution with the machine-readable source of
|
33
|
+
the software.
|
34
|
+
|
35
|
+
c) give non-standard binaries non-standard names, with
|
36
|
+
instructions on where to get the original software distribution.
|
37
|
+
|
38
|
+
d) make other distribution arrangements with the author.
|
39
|
+
|
40
|
+
4. You may modify and include the part of the software into any other
|
41
|
+
software (possibly commercial). But some files in the distribution
|
42
|
+
are not written by the author, so that they are not under these terms.
|
43
|
+
|
44
|
+
For the list of those files and their copying conditions, see the
|
45
|
+
file LEGAL.
|
46
|
+
|
47
|
+
5. The scripts and library files supplied as input to or produced as
|
48
|
+
output from the software do not automatically fall under the
|
49
|
+
copyright of the software, but belong to whomever generated them,
|
50
|
+
and may be sold commercially, and may be aggregated with this
|
51
|
+
software.
|
52
|
+
|
53
|
+
6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
|
54
|
+
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
55
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
56
|
+
PURPOSE.
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'rubysl/resolv/resolv-replace'
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'socket'
|
2
|
+
require 'resolv'
|
3
|
+
|
4
|
+
class << IPSocket
|
5
|
+
# :stopdoc:
|
6
|
+
alias original_resolv_getaddress getaddress
|
7
|
+
# :startdoc:
|
8
|
+
def getaddress(host)
|
9
|
+
begin
|
10
|
+
return Resolv.getaddress(host).to_s
|
11
|
+
rescue Resolv::ResolvError
|
12
|
+
raise SocketError, "Hostname not known: #{host}"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
class TCPSocket < IPSocket
|
18
|
+
# :stopdoc:
|
19
|
+
alias original_resolv_initialize initialize
|
20
|
+
# :startdoc:
|
21
|
+
def initialize(host, serv, *rest)
|
22
|
+
rest[0] = IPSocket.getaddress(rest[0]) if rest[0]
|
23
|
+
original_resolv_initialize(IPSocket.getaddress(host), serv, *rest)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
class UDPSocket < IPSocket
|
28
|
+
# :stopdoc:
|
29
|
+
alias original_resolv_bind bind
|
30
|
+
# :startdoc:
|
31
|
+
def bind(host, port)
|
32
|
+
host = IPSocket.getaddress(host) if host != ""
|
33
|
+
original_resolv_bind(host, port)
|
34
|
+
end
|
35
|
+
|
36
|
+
# :stopdoc:
|
37
|
+
alias original_resolv_connect connect
|
38
|
+
# :startdoc:
|
39
|
+
def connect(host, port)
|
40
|
+
original_resolv_connect(IPSocket.getaddress(host), port)
|
41
|
+
end
|
42
|
+
|
43
|
+
# :stopdoc:
|
44
|
+
alias original_resolv_send send
|
45
|
+
# :startdoc:
|
46
|
+
def send(mesg, flags, *rest)
|
47
|
+
if rest.length == 2
|
48
|
+
host, port = rest
|
49
|
+
begin
|
50
|
+
addrs = Resolv.getaddresses(host)
|
51
|
+
rescue Resolv::ResolvError
|
52
|
+
raise SocketError, "Hostname not known: #{host}"
|
53
|
+
end
|
54
|
+
addrs[0...-1].each {|addr|
|
55
|
+
begin
|
56
|
+
return original_resolv_send(mesg, flags, addr, port)
|
57
|
+
rescue SystemCallError
|
58
|
+
end
|
59
|
+
}
|
60
|
+
original_resolv_send(mesg, flags, addrs[-1], port)
|
61
|
+
else
|
62
|
+
original_resolv_send(mesg, flags, *rest)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
class SOCKSSocket < TCPSocket
|
68
|
+
# :stopdoc:
|
69
|
+
alias original_resolv_initialize initialize
|
70
|
+
# :startdoc:
|
71
|
+
def initialize(host, serv)
|
72
|
+
original_resolv_initialize(IPSocket.getaddress(host), port)
|
73
|
+
end
|
74
|
+
end if defined? SOCKSSocket
|
data/lib/rubysl/resolv/resolv.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'socket'
|
2
|
-
require 'fcntl'
|
3
2
|
require 'timeout'
|
4
3
|
require 'thread'
|
5
4
|
|
@@ -159,7 +158,7 @@ class Resolv
|
|
159
158
|
##
|
160
159
|
# Indicates a timeout resolving a name or address.
|
161
160
|
|
162
|
-
class ResolvTimeout <
|
161
|
+
class ResolvTimeout < Timeout::Error; end
|
163
162
|
|
164
163
|
##
|
165
164
|
# Resolv::Hosts is a hostname resolver that uses the system hosts file.
|
@@ -671,8 +670,8 @@ class Resolv
|
|
671
670
|
timelimit = start + tout
|
672
671
|
begin
|
673
672
|
sender.send
|
674
|
-
rescue Errno::EHOSTUNREACH
|
675
|
-
|
673
|
+
rescue Errno::EHOSTUNREACH, # multi-homed IPv6 may generate this
|
674
|
+
Errno::ENETUNREACH
|
676
675
|
raise ResolvTimeout
|
677
676
|
end
|
678
677
|
while true
|
@@ -1067,6 +1066,10 @@ class Resolv
|
|
1067
1066
|
candidates = []
|
1068
1067
|
end
|
1069
1068
|
candidates.concat(@search.map {|domain| Name.new(name.to_a + domain)})
|
1069
|
+
fname = Name.create("#{name}.")
|
1070
|
+
if !candidates.include?(fname)
|
1071
|
+
candidates << fname
|
1072
|
+
end
|
1070
1073
|
end
|
1071
1074
|
return candidates
|
1072
1075
|
end
|
@@ -1167,7 +1170,9 @@ class Resolv
|
|
1167
1170
|
class Str # :nodoc:
|
1168
1171
|
def initialize(string)
|
1169
1172
|
@string = string
|
1170
|
-
|
1173
|
+
# case insensivity of DNS labels doesn't apply non-ASCII characters. [RFC 4343]
|
1174
|
+
# This assumes @string is given in ASCII compatible encoding.
|
1175
|
+
@downcase = string.b.downcase
|
1171
1176
|
end
|
1172
1177
|
attr_reader :string, :downcase
|
1173
1178
|
|
@@ -1176,11 +1181,11 @@ class Resolv
|
|
1176
1181
|
end
|
1177
1182
|
|
1178
1183
|
def inspect
|
1179
|
-
return "#<#{self.class} #{self
|
1184
|
+
return "#<#{self.class} #{self}>"
|
1180
1185
|
end
|
1181
1186
|
|
1182
1187
|
def ==(other)
|
1183
|
-
return @downcase == other.downcase
|
1188
|
+
return self.class == other.class && @downcase == other.downcase
|
1184
1189
|
end
|
1185
1190
|
|
1186
1191
|
def eql?(other)
|
@@ -1216,12 +1221,20 @@ class Resolv
|
|
1216
1221
|
end
|
1217
1222
|
|
1218
1223
|
def initialize(labels, absolute=true) # :nodoc:
|
1224
|
+
labels = labels.map {|label|
|
1225
|
+
case label
|
1226
|
+
when String then Label::Str.new(label)
|
1227
|
+
when Label::Str then label
|
1228
|
+
else
|
1229
|
+
raise ArgumentError, "unexpected label: #{label.inspect}"
|
1230
|
+
end
|
1231
|
+
}
|
1219
1232
|
@labels = labels
|
1220
1233
|
@absolute = absolute
|
1221
1234
|
end
|
1222
1235
|
|
1223
1236
|
def inspect # :nodoc:
|
1224
|
-
"#<#{self.class}: #{self
|
1237
|
+
"#<#{self.class}: #{self}#{@absolute ? '.' : ''}>"
|
1225
1238
|
end
|
1226
1239
|
|
1227
1240
|
##
|
@@ -1233,7 +1246,8 @@ class Resolv
|
|
1233
1246
|
|
1234
1247
|
def ==(other) # :nodoc:
|
1235
1248
|
return false unless Name === other
|
1236
|
-
return
|
1249
|
+
return false unless @absolute == other.absolute?
|
1250
|
+
return @labels == other.to_a
|
1237
1251
|
end
|
1238
1252
|
|
1239
1253
|
alias eql? == # :nodoc:
|
@@ -1662,10 +1676,10 @@ class Resolv
|
|
1662
1676
|
return false unless self.class == other.class
|
1663
1677
|
s_ivars = self.instance_variables
|
1664
1678
|
s_ivars.sort!
|
1665
|
-
s_ivars.delete
|
1679
|
+
s_ivars.delete :@ttl
|
1666
1680
|
o_ivars = other.instance_variables
|
1667
1681
|
o_ivars.sort!
|
1668
|
-
o_ivars.delete
|
1682
|
+
o_ivars.delete :@ttl
|
1669
1683
|
return s_ivars == o_ivars &&
|
1670
1684
|
s_ivars.collect {|name| self.instance_variable_get name} ==
|
1671
1685
|
o_ivars.collect {|name| other.instance_variable_get name}
|
@@ -1678,7 +1692,7 @@ class Resolv
|
|
1678
1692
|
def hash # :nodoc:
|
1679
1693
|
h = 0
|
1680
1694
|
vars = self.instance_variables
|
1681
|
-
vars.delete
|
1695
|
+
vars.delete :@ttl
|
1682
1696
|
vars.each {|name|
|
1683
1697
|
h ^= self.instance_variable_get(name).hash
|
1684
1698
|
}
|
@@ -2347,7 +2361,7 @@ class Resolv
|
|
2347
2361
|
end
|
2348
2362
|
|
2349
2363
|
def inspect # :nodoc:
|
2350
|
-
return "#<#{self.class} #{self
|
2364
|
+
return "#<#{self.class} #{self}>"
|
2351
2365
|
end
|
2352
2366
|
|
2353
2367
|
##
|
@@ -2490,7 +2504,7 @@ class Resolv
|
|
2490
2504
|
end
|
2491
2505
|
|
2492
2506
|
def inspect # :nodoc:
|
2493
|
-
return "#<#{self.class} #{self
|
2507
|
+
return "#<#{self.class} #{self}>"
|
2494
2508
|
end
|
2495
2509
|
|
2496
2510
|
##
|
@@ -2640,7 +2654,7 @@ class Resolv
|
|
2640
2654
|
end
|
2641
2655
|
|
2642
2656
|
def inspect # :nodoc:
|
2643
|
-
return "#<#{self.class} #{self
|
2657
|
+
return "#<#{self.class} #{self}>"
|
2644
2658
|
end
|
2645
2659
|
|
2646
2660
|
def ==(other) # :nodoc:
|
@@ -2729,7 +2743,7 @@ class Resolv
|
|
2729
2743
|
end
|
2730
2744
|
|
2731
2745
|
def inspect # :nodoc:
|
2732
|
-
return "#<#{self.class} #{self
|
2746
|
+
return "#<#{self.class} #{self}>"
|
2733
2747
|
end
|
2734
2748
|
|
2735
2749
|
def ==(other) # :nodoc:
|
@@ -2791,7 +2805,7 @@ class Resolv
|
|
2791
2805
|
end
|
2792
2806
|
|
2793
2807
|
def inspect # :nodoc:
|
2794
|
-
return "#<#{self.class} #{self
|
2808
|
+
return "#<#{self.class} #{self}>"
|
2795
2809
|
end
|
2796
2810
|
|
2797
2811
|
def ==(other) # :nodoc:
|
metadata
CHANGED
@@ -1,67 +1,67 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubysl-resolv
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Shirai
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-02-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
|
15
|
-
|
14
|
+
type: :development
|
15
|
+
version_requirements: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.3'
|
20
|
-
|
20
|
+
name: bundler
|
21
21
|
prerelease: false
|
22
|
-
|
22
|
+
requirement: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.3'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
|
29
|
-
|
28
|
+
type: :development
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '10.0'
|
34
|
-
|
34
|
+
name: rake
|
35
35
|
prerelease: false
|
36
|
-
|
36
|
+
requirement: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '10.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
|
43
|
-
|
42
|
+
type: :development
|
43
|
+
version_requirements: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '1.5'
|
48
|
-
|
48
|
+
name: mspec
|
49
49
|
prerelease: false
|
50
|
-
|
50
|
+
requirement: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '1.5'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
|
57
|
-
|
56
|
+
type: :development
|
57
|
+
version_requirements: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '2.0'
|
62
|
-
|
62
|
+
name: rubysl-prettyprint
|
63
63
|
prerelease: false
|
64
|
-
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
@@ -77,10 +77,13 @@ files:
|
|
77
77
|
- ".travis.yml"
|
78
78
|
- Gemfile
|
79
79
|
- LICENSE
|
80
|
+
- MRI_LICENSE
|
80
81
|
- README.md
|
81
82
|
- Rakefile
|
82
83
|
- lib/resolv.rb
|
84
|
+
- lib/rubysl/resolv-replace.rb
|
83
85
|
- lib/rubysl/resolv.rb
|
86
|
+
- lib/rubysl/resolv/resolv-replace.rb
|
84
87
|
- lib/rubysl/resolv/resolv.rb
|
85
88
|
- lib/rubysl/resolv/version.rb
|
86
89
|
- rubysl-resolv.gemspec
|
@@ -108,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
108
111
|
version: '0'
|
109
112
|
requirements: []
|
110
113
|
rubyforge_project:
|
111
|
-
rubygems_version: 2.
|
114
|
+
rubygems_version: 2.4.5
|
112
115
|
signing_key:
|
113
116
|
specification_version: 4
|
114
117
|
summary: Ruby standard library resolv.
|
@@ -117,3 +120,4 @@ test_files:
|
|
117
120
|
- spec/get_addresses_spec.rb
|
118
121
|
- spec/get_name_spec.rb
|
119
122
|
- spec/get_names_spec.rb
|
123
|
+
has_rdoc:
|