net-ping 1.6.2-universal-mingw32 → 1.7.0-universal-mingw32

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MDdiZmQ1OWMyOGEzZWQwYWFiOWM1ZDc3OTNiNGZkM2RjZTYxMzc0Zg==
4
+ NmM3YTQyZGEwZDc5Nzg0MzY5MTUzZjY0ZTE5NTQyZTJhMDEzYzExMQ==
5
5
  data.tar.gz: !binary |-
6
- ZGUyOTBlYmQ5ZGEyYjJmOGUwMjA0M2U2ZWI0MWQ4YmQzMTdjOWNhMw==
6
+ Mjg1MGNmNzdiYmQ2M2QyZTQ0NzZmMjljNWYxMzQyY2Q4ODMwNzEzMA==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- ODZiZDg3YjdhYzZhNDUxMzkxZjY2MjliODk2MGFiMzNiOWU2ZTAzNTM1NTM4
10
- MjEzYzkyMzE3YmM5OTU4ZWRmOGE3OTViMzQyNTYzN2U2ZjI1MzllMTBjYTgy
11
- ZGU2YTliYzFlOGUxMzAzMDg3NDQ1YjJjZDE1MmFlNTU2NWMyMjU=
9
+ MmM3MTNjZWYwY2VmMjc1M2I5MGFmNGI0M2RlYWZiNTM2N2QzYjc2ZGE4YWU1
10
+ ZDQ5MGY0ZjZlOTk4MDUxNmY5ZDc0OWUyOWNkNGJlZTVlMmI1YWJjYTYzNTg2
11
+ ZTI3ZmJkMWMyMmYyZjllMWU1MTEwMTM4MDY3YTY1NDc2MGU1N2Q=
12
12
  data.tar.gz: !binary |-
13
- ZDI4MjZhMmY3NDYxMTIyMjFlZjZmNmQyNWYzNDE0ODliYzRhMjRmZjVmNWI2
14
- NTJiM2VhNWUzZDNkNjhmMDVhNjZiOGVhMDBjMTdiOWQ4YzY3MjRiYmRmM2Q4
15
- NDdkZGU1ZTNjZWY3ZWEwMDNjOTNhOTIxNDJiYzhkYmYwM2E4MjU=
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 on UNIX systems.
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-2010 Daniel J. Berger, All Rights Reserved
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
@@ -10,7 +10,7 @@ module Net
10
10
  #
11
11
  class Ping
12
12
  # The version of the net-ping library.
13
- VERSION = '1.6.2'
13
+ VERSION = '1.7.0'
14
14
 
15
15
  # The host to ping. In the case of Ping::HTTP, this is the URI.
16
16
  attr_accessor :host
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
- Timeout.timeout(@timeout){
46
- begin
47
- tcp = TCPSocket.new(host, @port)
48
- rescue Errno::ECONNREFUSED => err
49
- if @@service_check
50
- bool = true
51
- else
52
- @exception = err
53
- end
54
- rescue Exception => err
55
- @exception = err
56
- else
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
- rescue Timeout::Error => err
61
- @exception = err
79
+ else
80
+ bool = true
81
+ end
62
82
  ensure
63
- tcp.close if tcp
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.2'
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')
@@ -28,7 +28,7 @@ end
28
28
 
29
29
  class TC_Net_Ping < Test::Unit::TestCase
30
30
  def test_net_ping_version
31
- assert_equal('1.6.2', Net::Ping::VERSION)
31
+ assert_equal('1.7.0', Net::Ping::VERSION)
32
32
  end
33
33
  end
34
34
 
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.6.2
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-08 00:00:00.000000000 Z
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: '0'
132
+ version: 1.9.1
133
133
  required_rubygems_version: !ruby/object:Gem::Requirement
134
134
  requirements:
135
135
  - - ! '>='