net-ping 1.2.2-x86-mswin32-60

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES ADDED
@@ -0,0 +1,133 @@
1
+ == 1.2.2 - 22-Jan-2008
2
+ * Bug fix for Ping::External where it was not honoring the timeout value.
3
+ Thanks go to Chris Morris for the spot and the patch.
4
+ * Bug fix for Ping::External where non-English output could cause false
5
+ positives on MS Windows Vista or later. This library now requires the
6
+ windows-pr library on MS Windows systems as a result.
7
+ * Added the Ping::UDP.service_check and Ping::UDP.service_check= class
8
+ methods. This method controls whether or not Errno::ECONNREFUSED or
9
+ Errno::ECONNRESET are considered successful pings or not.
10
+ * The Ping::HTTP class no longer uses the resolv-replace library on MS Windows
11
+ because it was (ironically) causing timeouts.
12
+ * Changed the Ping::TCP.econnrefused method to Ping::TCP.service_check. I
13
+ changed it because I now use a similar method in Ping::UDP, but that handles
14
+ more than Errno::ECONNREFUSED. An alias is provided to provide backwards
15
+ compatibility, but it is considered deprecated and will be removed in the
16
+ 1.3.0 release.
17
+ * Removed the install.rb file. The Rakefile now handles installation.
18
+
19
+ == 1.2.1 - 6-Apr-2007
20
+ * For the Ping::External class, if a ping attempt results in 100% packet loss
21
+ it is now considered a failed ping, regardless of whether or not an error
22
+ was sent to stdout.
23
+ * Fixed the Ping::External class for OS X.
24
+ * Added a Rakefile. Installation and testing should now be run via Rake tasks.
25
+ * Minor fix for the Ping::ICMP class where I had accidentally dup'd some
26
+ aliases. This was harmless, but did cause warnings with -w.
27
+
28
+ == 1.2.0 - 5-Dec-2006
29
+ * Internal reorganization - each class now lives in its own file.
30
+ * Added the Ping::ICMP class. Thanks go to Jos Backus for contributing a
31
+ large part of the code.
32
+ * The host argument is now optional in the constructor. You can now specify
33
+ it in the ping method instead. Note that it must be specified in one place
34
+ or the other.
35
+ * Each PingXXX class is now Ping::XXX instead. However, class name aliases
36
+ have been setup for backwards compatibility for now.
37
+ * The constructor for each Ping types now yields self.
38
+ * Added the pingecho alias for the ping method for each Ping type.
39
+ * Added the Ping::HTTP#follow_redirect accessor.
40
+ * The Ping::HTTP#ping method now honors the timeout value.
41
+ * The Ping::HTTP class now follows redirects automatically, though this is
42
+ configurable with the follow_redirect accessor.
43
+ * The Ping::TCP.ecr and Ping::TCP.ecr= methods are now true class method
44
+ aliases (they were just wrappers previously).
45
+ * The Ping::UDP class now enforces a 64 character limit on data that can be
46
+ sent on a udp ping.
47
+ * Updated the gemspec. Specifically, MS Windows now has a dependency on
48
+ the win32-open3 package.
49
+ * Added inline rdoc.
50
+
51
+ == 1.1.1 - 15-Jun-2006
52
+ * Fixed a bug in PingTCP (bad variable name). Thanks go to Anoop Chandran
53
+ for the spot.
54
+ * Minor variable name refactoring.
55
+ * Minor test updates.
56
+
57
+ == 1.1.0 - 17-Jul-2005
58
+ * Fixed a bug in the PingHTTP#ping method where I was accidentally passing
59
+ the timeout value instead of the port number as the third argument to
60
+ Net::HTTP.get_response.
61
+ * The PingHTTP.new method now has a default port of 80.
62
+ * Minor doc update for PingHTTP.new.
63
+
64
+ == 1.0.1 - 22-Jun-2005
65
+ * Bug fix for the install.rb file. The gem is unaffected.
66
+
67
+ == 1.0.0 - 14-Jun-2005
68
+ * Renamed project from net-pingsimple to just net-ping.
69
+ * Added a PingHTTP subclass.
70
+ * Moved project to RubyForge.
71
+ * Added a gemspec.
72
+
73
+ == 0.3.1 - 9-Apr-2005
74
+ * Updated PingExternal to use win32/open3 on Win32 platforms.
75
+ * Minor error handling change for the PingSimple.econnrefused= method. It now
76
+ raises an ArgumentError if any values other than true or false are passed.
77
+ * PingSimple#warning and PingSimple#exception are now read-only methods.
78
+ * The warning and exception attributes are now reset to nil between each call
79
+ to ping.
80
+ * The data and data= methods are now unique to the PingUDP class.
81
+ * The time and time= methods have been changed to timeout and timeout=,
82
+ respectively.
83
+ * Removed the pingsimple.rd and pingsimple.html files. The pingsimple.txt file
84
+ has been reorganized and is now rdoc friendly.
85
+ * Added a few sample programs under the 'examples' directory.
86
+ * Some minor test updates and changes.
87
+ * Removed the INSTALL file. That information is now in the README file.
88
+ * Now requires Ruby 1.8.0 or later.
89
+
90
+ == 0.3.0 - 12-Feb-2004
91
+ * Fixed ping string for PingExternal class based on platform. The old
92
+ string was really only good for Linux and *BSD.
93
+ * Added Win32 support (requires win32_popen package).
94
+ * Added warranty info.
95
+
96
+ == 0.2.3 - 12-Aug-2003
97
+ * Fixed a bug in PingExternal that could consume file descriptors if used in a loop
98
+ * Added some initialization to avoid -w warnings
99
+ * Removed VERSION() class method. Use the constant instead
100
+ * Modified test suite slightly
101
+ * Moved rd2 docs to doc directory
102
+
103
+ == 0.2.2 - 3-Apr-2003
104
+ * Fixed handling of stdout in PingExternal
105
+
106
+ == 0.2.1 - 27-Mar-2003
107
+ * Fixed major bug with PingExternal class with regards to down hosts
108
+ * Exceptions and warnings from PingExternal are now chomp'd
109
+ * Modified test suite
110
+ * Doc updates
111
+
112
+ == 0.2.0 - 14-Feb-2003
113
+ * The default behavior of PingTCP with regards to ECONNREFUSED is now
114
+ configurable
115
+ * Added a VERSION constant and method (to the base class)
116
+ * Added a test suite (for those with testunit installed)
117
+ * Doc changes, rearrangement and general cleanup
118
+ * Manifest is now MANIFEST
119
+ * Added an INSTALL file
120
+
121
+ == 0.1.0 - 9-Dec-2002
122
+ * Added ping? alias for ping method
123
+ * Warnings now handled separately
124
+ * Corrected a mis-named variable in Ping::External
125
+ * Fixed the install.rb file
126
+ * Updated and added docs
127
+ * Renamed tarball to net-pingsimple to reflect RAA naming convention
128
+
129
+ == 0.0.1a
130
+ * Did this release ever happen?
131
+
132
+ == 0.0.1
133
+ * Initial release.
data/MANIFEST ADDED
@@ -0,0 +1,21 @@
1
+ * MANIFEST
2
+ * CHANGES
3
+ * Rakefile
4
+ * README
5
+ * net-ping.gemspec
6
+ * examples/test_pingexternal.rb
7
+ * examples/test_pinghttp.rb
8
+ * examples/test_pingtcp.rb
9
+ * examples/test_pingudp.rb
10
+ * lib/net/ping.rb
11
+ * lib/net/ping/icmp.rb
12
+ * lib/net/ping/tcp.rb
13
+ * lib/net/ping/udp.rb
14
+ * lib/net/ping/http.rb
15
+ * lib/net/ping/external.rb
16
+ * test/tc_pingexternal.rb
17
+ * test/tc_pinghttp.rb
18
+ * test/tc_pingicmp.rb
19
+ * test/tc_pingtcp.rb
20
+ * test/tc_pingudp.rb
21
+ * test/ts_ping.rb
data/README ADDED
@@ -0,0 +1,31 @@
1
+ == Description
2
+ A collection of classes that provide different ways to ping computers.
3
+
4
+ == Prerequisites
5
+ * Ruby 1.8.0 or later
6
+ * The win32-open3 and windows-pr libraries are required on MS Windows
7
+ when using the Net::Ping::External class.
8
+
9
+ == Installation
10
+ rake test (optional)
11
+ rake install (standard) OR rake gem_install (gems)
12
+
13
+ == Notes
14
+ Please read the documentation under the 'doc' directory. Especially pay
15
+ attention to the documentation pertaining to ECONNREFUSED and TCP pings.
16
+
17
+ Also note the documentation regarding down hosts.
18
+
19
+ == How to require net-ping
20
+ You can do either this:
21
+
22
+ require 'net/ping'
23
+
24
+ In which case you will get Net::Ping and all of its subclasses. Or,
25
+ you can load individual subclasses like this:
26
+
27
+ require 'net/ping/tcp'
28
+
29
+ The former has the advantage of being easier to remember and all inclusive,
30
+ not to mention backwards compatible. The latter has the advantage of
31
+ reducing your memory footprint.
data/Rakefile ADDED
@@ -0,0 +1,55 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+ include Config
4
+
5
+ desc "Install the net-ping package (non-gem)"
6
+ task :install do
7
+ dest1 = File.join(CONFIG['sitelibdir'], 'net')
8
+ dest2 = File.join(dest1, 'ping')
9
+
10
+ Dir.mkdir(dest1) unless File.exists?(dest1)
11
+ Dir.mkdir(dest2) unless File.exists?(dest2)
12
+
13
+ FileUtils.cp('lib/net/ping.rb', dest1, :verbose => true)
14
+
15
+ Dir['lib/net/ping/*.rb'].each{ |file|
16
+ FileUtils.cp(file, dest2, :verbose => true)
17
+ }
18
+ end
19
+
20
+ desc "Create and install a net-ping gem"
21
+ task :gem_install do
22
+ ruby 'net-ping.gemspec'
23
+ gem_file = Dir["*.gem"].first
24
+ sh "gem install #{gem_file}"
25
+ end
26
+
27
+ Rake::TestTask.new("test") do |t|
28
+ t.warning = true
29
+ t.test_files = FileList['test/ts_ping.rb']
30
+ end
31
+
32
+ Rake::TestTask.new("test_external") do |t|
33
+ t.warning = true
34
+ t.test_files = FileList['test/tc_pingexternal.rb']
35
+ end
36
+
37
+ Rake::TestTask.new("test_http") do |t|
38
+ t.warning = true
39
+ t.test_files = FileList['test/tc_pinghttp.rb']
40
+ end
41
+
42
+ Rake::TestTask.new("test_icmp") do |t|
43
+ t.warning = true
44
+ t.test_files = FileList['test/tc_pingicmp.rb']
45
+ end
46
+
47
+ Rake::TestTask.new("test_tcp") do |t|
48
+ t.warning = true
49
+ t.test_files = FileList['test/tc_pingtcp.rb']
50
+ end
51
+
52
+ Rake::TestTask.new("test_udp") do |t|
53
+ t.warning = true
54
+ t.test_files = FileList['test/tc_pingudp.rb']
55
+ end
data/doc/ping.txt ADDED
@@ -0,0 +1,231 @@
1
+ = Description
2
+ A simple Ruby interface to the 'ping' command.
3
+
4
+ = Synopsis
5
+ require "net/ping"
6
+ include Net
7
+
8
+ Ping::TCP.econnrefused = true
9
+
10
+ pt = Net::Ping::TCP.new(host)
11
+ pu = Net::Ping::UDP.new(host)
12
+ pe = Net::Ping::External.new(host)
13
+ ph = Net::Ping::HTTP.new(uri)
14
+
15
+ if pt.ping
16
+ puts "TCP ping successful"
17
+ else
18
+ puts "TCP ping unsuccessful: " + pt.exception
19
+ end
20
+
21
+ if pu.ping
22
+ puts "UDP ping successful"
23
+ else
24
+ puts "UDP ping unsuccessful: " + pu.exception
25
+ end
26
+
27
+ if pe.ping
28
+ puts "External ping successful"
29
+ else
30
+ puts "External ping unsuccessful: " + pe.exception
31
+ end
32
+
33
+ if ph.ping?
34
+ puts "HTTP ping successful"
35
+ else
36
+ puts "HTTP ping unsuccessful: " + ph.exception
37
+ end
38
+
39
+ = Ping Classes
40
+ * Ping::TCP
41
+ * Ping::UDP
42
+ * Ping::External
43
+ * Ping::HTTP
44
+ * Ping::ICMP
45
+
46
+ All Ping classes are children of the Ping parent class (which should
47
+ never be instantiated directly).
48
+
49
+ The Ping::ICMP class requires root privileges on UNIX systems.
50
+
51
+ == Net::Ping
52
+ Net::Ping.new(host=nil, port=7, timeout=5)
53
+ Creates and returns a new Ping object. If the host is not specified
54
+ in the constructor then it must be specified in the ping method.
55
+
56
+ == Net::Ping::TCP
57
+ Ping::TCP.service_check
58
+ Returns the setting for how ECONNREFUSED is handled. By default, this is
59
+ set to false, i.e. an ECONNREFUSED error is considered a failed ping.
60
+
61
+ Ping::TCP.service_check=(bool)
62
+ Sets the behavior for how ECONNREFUSED is handled. By default, this is
63
+ set to false, i.e. an ECONNREFUSED error is considered a failed ping.
64
+
65
+ Ping::TCP#ping(host=nil)
66
+ Attempts to open a connection using TCPSocket with a +host+ specified
67
+ either here or in the constructor. A successful open means the ping was
68
+ successful and true is returned. Otherwise, false is returned.
69
+
70
+ == Net::Ping::UDP
71
+ Ping::UDP#ping
72
+ Attempts to open a connection using UDPSocket and sends the value of
73
+ Ping::UDP#data as a string across the socket. If the return string matches,
74
+ then the ping was successful and true is returned. Otherwise, false is
75
+ returned.
76
+
77
+ Ping::UDP#data
78
+ Returns the string that is sent across the UDP socket.
79
+
80
+ Ping::UDP#data=(string)
81
+ Sets the string that is sent across the UDP socket. The default is "ping".
82
+ Note that the +string+ cannot be larger than MAX_DATA (64 characters).
83
+
84
+ == Net::Ping::External
85
+ Ping::External#ping
86
+ Uses the 'open3' module and calls your system's local 'ping' command with
87
+ various options, depending on platform. If nothing is sent to stderr, the
88
+ ping was successful and true is returned. Otherwise, false is returned.
89
+
90
+ The MS Windows platform requires the 'win32-open3' package.
91
+
92
+ == Ping::HTTP
93
+ Ping::HTTP.new(uri=nil, port=80, timeout=5)
94
+ Identical to Net::Ping.new except that, instead of a host, the first
95
+ argument is a URI.
96
+
97
+ Ping::HTTP#ping
98
+ Checks for a response against +uri+. As long as kind of Net::HTTPSuccess
99
+ response is returned, the ping is successful and true is returned.
100
+ Otherwise, false is returned and Ping::HTTP#exception is set to the error
101
+ message.
102
+
103
+ Note that redirects are automatically followed unless the
104
+ Ping::HTTP#follow_redirects method is set to false.
105
+
106
+ Ping::HTTP#follow_redirect
107
+ Indicates whether or not a redirect should be followed in a ping attempt.
108
+ By default this is set to true.
109
+
110
+ Ping::HTTP#follow_redirect=(bool)
111
+ Sets whether or not a redirect should be followed in a ping attempt. If
112
+ set to false, then any redirect is considered a failed ping.
113
+
114
+ Ping::HTTP#uri
115
+ An alias for Ping::HTTP#host.
116
+
117
+ Ping::HTTP#uri=(uri)
118
+ An alias for Ping::HTTP#host=.
119
+
120
+ == Ping::ICMP
121
+ Ping::ICMP#duration
122
+ The time it took to ping the host. Not a precise value but a good estimate.
123
+
124
+ = Common Instance Methods
125
+ Ping#exception
126
+ Returns the error string that was set if a ping call failed. If an exception
127
+ is raised, it is caught and stored in this attribute. It is not raised in
128
+ your code.
129
+
130
+ This should be nil if the ping succeeded.
131
+
132
+ Ping#host
133
+ Returns the host name that ping attempts will ping against.
134
+
135
+ Ping#host=(hostname)
136
+ Sets the host name that ping attempts will ping against.
137
+
138
+ Ping#port
139
+ Returns the port number that ping attempts will use.
140
+
141
+ Ping#port=(port)
142
+ Set the port number to open socket connections on. The default is 7 (or
143
+ whatever your 'echo' port is set to). Note that you can also specify a
144
+ string, such as "http".
145
+
146
+ Ping#timeout
147
+ Returns the amount of time before the timeout module raises a TimeoutError
148
+ during connection attempts. The default is 5 seconds.
149
+
150
+ Ping#timeout=(time)
151
+ Sets the amount of time before the timeout module raises a TimeoutError.
152
+ during connection attempts.
153
+
154
+ Ping#warning
155
+ Returns a warning string that was returned during the ping attempt. This
156
+ typically occurs only in the Ping::External class, or the Ping::HTTP class
157
+ if a redirect occurred.
158
+
159
+ == Notes
160
+ If a host is down *IT IS CONSIDERED A FAILED PING*, and the 'no answer from
161
+ +host+' text is assigned to the 'exception' attribute. You may disagree with
162
+ this behavior, in which case you need merely check the exception attribute
163
+ against a regex as a simple workaround.
164
+
165
+ == Pre-emptive FAQ
166
+ Q: "Why don't you return exceptions if a connection fails?"
167
+
168
+ A: Because ping is only meant to return one of two things - success or
169
+ failure. It's very simple. If you want to find out *why* the ping
170
+ failed, you can check the 'exception' attribute.
171
+
172
+ Q: "I know the host is alive, but a TCP or UDP ping tells me otherwise. What
173
+ gives?"
174
+
175
+ A: It's possible that the echo port has been disabled on the remote
176
+ host for security reasons. Your best best is to specify a different port
177
+ or to use Ping::ICMP or Ping::External instead.
178
+
179
+ In the case of UDP pings, they are often actively refused. It may be
180
+ more pragmatic to set Ping::UDP.service_check = false.
181
+
182
+ Q: "Why does a TCP ping return false when I know it should return true?"
183
+
184
+ A: By default ECONNREFUSED errors will return a value of false. This is
185
+ contrary to what most other folks do for TCP pings. The problem with
186
+ their philosophy is that you can get false positives if a firewall blocks
187
+ the route to the host. The problem with my philosophy is that you can
188
+ get false negatives if there is no firewall (or it's not blocking the
189
+ route). Given the alternatives I chose the latter.
190
+
191
+ You can always change the default behavior by using the +service_check+
192
+ class method.
193
+
194
+ A similar situation is true for UDP pings.
195
+
196
+ Q: "Couldn't you use traceroute information to tell for sure?"
197
+
198
+ A: I could but I won't so don't bug me about it. It's far more effort than
199
+ it's worth. If you want something like that, please port the
200
+ Net::Traceroute Perl module by Daniel Hagerty.
201
+
202
+ = Known Bugs
203
+ You may see a test failure from the tc_pingtcp test case. You can ignore
204
+ this.
205
+
206
+ Please report any bugs on the project page at
207
+ http://www.rubyforge.org/projects/shards.
208
+
209
+ = Acknowledgements
210
+ The Ping::ICMP#ping method is based largely on the identical method from
211
+ the Net::Ping Perl module by Rob Brown. Much of the code was ported by
212
+ Jos Backus on ruby-talk.
213
+
214
+ = Future Plans
215
+ Add support for syn pings.
216
+
217
+ = License
218
+ Ruby's
219
+
220
+ = Copyright
221
+ (C) 2003-2008 Daniel J. Berger, All Rights Reserved
222
+
223
+ = Warranty
224
+ This package is provided "as is" and without any express or
225
+ implied warranties, including, without limitation, the implied
226
+ warranties of merchantability and fitness for a particular purpose.
227
+
228
+ = Author
229
+ Daniel J. Berger
230
+ djberg96 at gmail dot com
231
+ imperator on IRC (irc.freenode.net)