net-ping 1.6.2-universal-mingw32 → 1.7.0-universal-mingw32
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 +8 -8
- data/CHANGES +7 -0
- data/doc/ping.txt +2 -30
- data/lib/net/ping/ping.rb +1 -1
- data/lib/net/ping/tcp.rb +43 -23
- data/net-ping.gemspec +4 -1
- data/test/test_net_ping.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NmM3YTQyZGEwZDc5Nzg0MzY5MTUzZjY0ZTE5NTQyZTJhMDEzYzExMQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
Mjg1MGNmNzdiYmQ2M2QyZTQ0NzZmMjljNWYxMzQyY2Q4ODMwNzEzMA==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MmM3MTNjZWYwY2VmMjc1M2I5MGFmNGI0M2RlYWZiNTM2N2QzYjc2ZGE4YWU1
|
10
|
+
ZDQ5MGY0ZjZlOTk4MDUxNmY5ZDc0OWUyOWNkNGJlZTVlMmI1YWJjYTYzNTg2
|
11
|
+
ZTI3ZmJkMWMyMmYyZjllMWU1MTEwMTM4MDY3YTY1NDc2MGU1N2Q=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NDViZTU1NTRiM2E5NDE3NzM5NWZmZWVkNTgyMGQ0OTJiOTg1YWQyODg5OTQz
|
14
|
+
YzZiZGFlODk0NDg2MDM1Njc0YWVhMjUzNjA2MTRiYjdjMGMzYjhiM2ZjZTdm
|
15
|
+
MjNiY2I3YzI4YzUzOThhOTBiMGI4MGFjMjU3OGI4YzQyYmUwZGE=
|
data/CHANGES
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
== 1.7.0 - 25-Aug-2013
|
2
|
+
* Now requires Ruby 1.9.x or later.
|
3
|
+
* Replaced the main ping code for the Ping::TCP class. The timeout module
|
4
|
+
really doesn't work very well with sockets, and so a raw socket approach
|
5
|
+
combined with IO.select is now used instead.
|
6
|
+
* Updates to the doc/ping.txt file.
|
7
|
+
|
1
8
|
== 1.6.2 - 8-Aug-2013
|
2
9
|
* Fixed a bug in the ICMP ping helper module. Thanks go to Yuichi
|
3
10
|
Tsunematsu for the spot.
|
data/doc/ping.txt
CHANGED
@@ -48,7 +48,7 @@
|
|
48
48
|
All Ping classes are children of the Ping parent class (which should
|
49
49
|
never be instantiated directly).
|
50
50
|
|
51
|
-
The Ping::ICMP class requires root privileges
|
51
|
+
The Ping::ICMP class requires root/administrative privileges.
|
52
52
|
|
53
53
|
The Ping::WMI class only works on MS Windows.
|
54
54
|
|
@@ -136,30 +136,6 @@ Ping::WMI#ping(host, options={})
|
|
136
136
|
Ping::WMI#ping?(host, options={})
|
137
137
|
Returns whether or not the ping succeeded.
|
138
138
|
|
139
|
-
== Ping::LDAP
|
140
|
-
Ping::LDAP.new(uri=nil, timeout=5)
|
141
|
-
Performs a 'ping' to an LDAP server in the form of either an anonymous
|
142
|
-
or an authenticated LDAP bind.
|
143
|
-
Identical to Net::Ping.new except that, instead of a host, the first
|
144
|
-
argument is a URI.
|
145
|
-
The default +timeout+ is 5 seconds.
|
146
|
-
|
147
|
-
+uri+ string is expected to be a full URI with scheme (ldap/ldaps)
|
148
|
-
and optionally the port (else default port is assumed) e.g.
|
149
|
-
ldap://my.ldap.host.com
|
150
|
-
ldap://my.ldap.host.com:1389
|
151
|
-
ldaps://my.ldap.host.com
|
152
|
-
ldaps://my.ldap.host.com:6636
|
153
|
-
|
154
|
-
If a plain hostname is provided as the +uri+, a default port of 389 is assumed
|
155
|
-
|
156
|
-
Ping::LDAP#encryption
|
157
|
-
Set/get the encyption method. By default is nil, but may be set to :simple_tls
|
158
|
-
|
159
|
-
Ping::LDAP#username
|
160
|
-
Ping::LDAP#password
|
161
|
-
set/get the username and password for ping using and authenticated bind.
|
162
|
-
|
163
139
|
= Common Instance Methods
|
164
140
|
Ping#exception
|
165
141
|
Returns the error string that was set if a ping call failed. If an exception
|
@@ -242,10 +218,6 @@ Ping#warning
|
|
242
218
|
You may see a test failure from the test_net_ping_tcp test case. You can
|
243
219
|
ignore these.
|
244
220
|
|
245
|
-
The socket library that ships with the Windows One-Click installer has
|
246
|
-
known issues. This may cause the Ping::ICMP class to fail. In fact, I
|
247
|
-
make an effort to skip those tests if I detect the one-click installer.
|
248
|
-
|
249
221
|
UDP pings may not work with older versions of Ruby 1.9.x.
|
250
222
|
|
251
223
|
Please report any bugs on the project page at
|
@@ -263,7 +235,7 @@ Ping#warning
|
|
263
235
|
Artistic 2.0
|
264
236
|
|
265
237
|
= Copyright
|
266
|
-
(C) 2003-
|
238
|
+
(C) 2003-2013 Daniel J. Berger, All Rights Reserved
|
267
239
|
|
268
240
|
= Warranty
|
269
241
|
This package is provided "as is" and without any express or
|
data/lib/net/ping/ping.rb
CHANGED
data/lib/net/ping/tcp.rb
CHANGED
@@ -11,14 +11,14 @@ module Net
|
|
11
11
|
|
12
12
|
# Returns whether or not Errno::ECONNREFUSED is considered a successful
|
13
13
|
# ping. The default is false.
|
14
|
-
#
|
14
|
+
#
|
15
15
|
def self.service_check
|
16
16
|
@@service_check
|
17
17
|
end
|
18
18
|
|
19
19
|
# Sets whether or not an Errno::ECONNREFUSED should be considered a
|
20
20
|
# successful ping.
|
21
|
-
#
|
21
|
+
#
|
22
22
|
def self.service_check=(bool)
|
23
23
|
unless bool.kind_of?(TrueClass) || bool.kind_of?(FalseClass)
|
24
24
|
raise ArgumentError, 'argument must be true or false'
|
@@ -29,38 +29,58 @@ module Net
|
|
29
29
|
# This method attempts to ping a host and port using a TCPSocket with
|
30
30
|
# the host, port and timeout values passed in the constructor. Returns
|
31
31
|
# true if successful, or false otherwise.
|
32
|
-
#
|
32
|
+
#
|
33
33
|
# Note that, by default, an Errno::ECONNREFUSED return result will be
|
34
34
|
# considered a failed ping. See the documentation for the
|
35
35
|
# Ping::TCP.service_check= method if you wish to change this behavior.
|
36
|
-
#
|
36
|
+
#
|
37
37
|
def ping(host=@host)
|
38
38
|
super(host)
|
39
39
|
|
40
40
|
bool = false
|
41
|
-
tcp = nil
|
42
41
|
start_time = Time.now
|
43
42
|
|
43
|
+
# Failure here most likely means bad host, so just bail.
|
44
44
|
begin
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
45
|
+
addr = Socket.getaddrinfo(host, port)
|
46
|
+
rescue SocketError => err
|
47
|
+
@exception = err
|
48
|
+
bool = false
|
49
|
+
return
|
50
|
+
end
|
51
|
+
|
52
|
+
begin
|
53
|
+
# Where addr[0][0] is likely AF_INET.
|
54
|
+
sock = Socket.new(Socket.const_get(addr[0][0]), Socket::SOCK_STREAM, 0)
|
55
|
+
|
56
|
+
# This may not be entirely necessary
|
57
|
+
sock.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1)
|
58
|
+
|
59
|
+
begin
|
60
|
+
# Where addr[0][3] is an IP address
|
61
|
+
sock.connect_nonblock(Socket.pack_sockaddr_in(port, addr[0][3]))
|
62
|
+
rescue Errno::EINPROGRESS
|
63
|
+
# No-op, continue below
|
64
|
+
rescue Exception => err
|
65
|
+
# Something has gone horribly wrong
|
66
|
+
@exception = err
|
67
|
+
return false
|
68
|
+
end
|
69
|
+
|
70
|
+
resp = IO.select(nil, [sock], nil, timeout)
|
71
|
+
|
72
|
+
# Assume ECONNREFUSED at this point
|
73
|
+
if resp.nil?
|
74
|
+
if @@service_check
|
57
75
|
bool = true
|
76
|
+
else
|
77
|
+
@exception = Errno::ECONNREFUSED
|
58
78
|
end
|
59
|
-
|
60
|
-
|
61
|
-
|
79
|
+
else
|
80
|
+
bool = true
|
81
|
+
end
|
62
82
|
ensure
|
63
|
-
|
83
|
+
sock.close if sock
|
64
84
|
end
|
65
85
|
|
66
86
|
# There is no duration if the ping failed
|
@@ -71,13 +91,13 @@ module Net
|
|
71
91
|
|
72
92
|
alias ping? ping
|
73
93
|
alias pingecho ping
|
74
|
-
|
94
|
+
|
75
95
|
# Class method aliases. DEPRECATED.
|
76
96
|
class << self
|
77
97
|
alias econnrefused service_check
|
78
98
|
alias econnrefused= service_check=
|
79
99
|
alias ecr service_check
|
80
|
-
alias ecr= service_check=
|
100
|
+
alias ecr= service_check=
|
81
101
|
end
|
82
102
|
end
|
83
103
|
end
|
data/net-ping.gemspec
CHANGED
@@ -3,7 +3,7 @@ require 'rbconfig'
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |spec|
|
5
5
|
spec.name = 'net-ping'
|
6
|
-
spec.version = '1.
|
6
|
+
spec.version = '1.7.0'
|
7
7
|
spec.license = 'Artistic 2.0'
|
8
8
|
spec.author = 'Daniel J. Berger'
|
9
9
|
spec.email = 'djberg96@gmail.com'
|
@@ -15,6 +15,9 @@ Gem::Specification.new do |spec|
|
|
15
15
|
spec.rubyforge_project = 'shards'
|
16
16
|
spec.extra_rdoc_files = ['README', 'CHANGES', 'doc/ping.txt']
|
17
17
|
|
18
|
+
# The TCP Ping class requires this for non-blocking sockets.
|
19
|
+
spec.required_ruby_version = ">= 1.9.1"
|
20
|
+
|
18
21
|
spec.add_dependency('ffi', '>= 1.0.0')
|
19
22
|
|
20
23
|
spec.add_development_dependency('test-unit', '>= 2.5.0')
|
data/test/test_net_ping.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: net-ping
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.7.0
|
5
5
|
platform: universal-mingw32
|
6
6
|
authors:
|
7
7
|
- Daniel J. Berger
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-08-
|
11
|
+
date: 2013-08-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|
@@ -129,7 +129,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
129
129
|
requirements:
|
130
130
|
- - ! '>='
|
131
131
|
- !ruby/object:Gem::Version
|
132
|
-
version:
|
132
|
+
version: 1.9.1
|
133
133
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
134
134
|
requirements:
|
135
135
|
- - ! '>='
|