Permalink
Browse files

Merge pull request #1 from djberg96/master

sync with upstream
  • Loading branch information...
olbrich committed Apr 5, 2013
2 parents e473da9 + 4cc9eb4 commit d9db7f4ec418e6821d19e166f9553ada0ad6cd84
Showing with 9 additions and 346 deletions.
  1. +5 −2 CHANGES
  2. +0 −11 Rakefile
  3. +0 −22 examples/example_pingldap.rb
  4. +1 −2 lib/net/ping.rb
  5. +0 −107 lib/net/ping/ldap.rb
  6. +1 −1 lib/net/ping/ping.rb
  7. +1 −3 net-ping.gemspec
  8. +1 −1 test/test_net_ping.rb
  9. +0 −197 test/test_net_ping_ldap.rb
View
@@ -1,6 +1,9 @@
-== 1.6.0 - ???
-* Split out the ldap portion of the code into its own library.
+== 1.6.0 - 19-Mar-2013
+* Split out the ldap portion of the code into its own branch.
* Don't require resolv-replace on Ruby 1.9.3 or later.
+* Now gets proxy information from the http_proxy, https_proxy, and
+ no_proxy environment variables and uses that when making requests.
+ Thanks go to Kevin Olbrich for the patch.
== 1.5.3 - 29-Feb-2012
* Removed the Windows::Console dependency and replaced it with FFI since there
View
@@ -39,11 +39,6 @@ namespace 'example' do
task :udp do
ruby '-Ilib examples/example_pingudp.rb'
end
-
- desc 'Run the ldap ping example program'
- task :ldap do
- ruby '-Ilib examples/example_pingldap.rb'
- end
end
Rake::TestTask.new do |t|
@@ -89,12 +84,6 @@ namespace 'test' do
t.verbose = true
t.test_files = FileList['test/test_net_ping_wmi.rb']
end
-
- Rake::TestTask.new('ldap') do |t|
- t.warning = true
- t.verbose = true
- t.test_files = FileList['test/test_net_ping_ldap.rb']
- end
end
task :default => :test
@@ -1,22 +0,0 @@
-########################################################################
-# example_pingldap.rb
-#
-# A short sample program demonstrating an ldap ping. You can run
-# this program via the example:ldap task. Modify as you see fit.
-########################################################################
-require 'net/ping/ldap'
-
-good = 'ldap://localhost'
-bad = 'ldap://example.com'
-
-puts "== Good ping (if you have an ldap server at #{good})"
-
-p1 = Net::Ping::LDAP.new(good)
-p p1.ping?
-
-puts "== Bad ping"
-
-p2 = Net::Ping::LDAP.new(bad)
-p p2.ping?
-p p2.warning
-p p2.exception
View
@@ -9,10 +9,9 @@
require File.join(File.dirname(__FILE__), 'ping/icmp')
require File.join(File.dirname(__FILE__), 'ping/external')
require File.join(File.dirname(__FILE__), 'ping/http')
-require File.join(File.dirname(__FILE__), 'ping/ldap')
RbConfig = Config unless Object.const_defined?(:RbConfig)
-if RbConfig::CONFIG['host_os'] =~ /msdos|mswin|cygwin|mingw|win32|windows/i
+if File::ALT_SEPARATOR
require File.join(File.dirname(__FILE__), 'ping/wmi')
end
View
@@ -1,107 +0,0 @@
-require File.join(File.dirname(__FILE__), 'ping')
-require 'net/ldap'
-require 'uri'
-
-
-# The Net module serves as a namespace only.
-module Net
-
- # The Ping::LDAP class encapsulates methods for LDAP pings.
- class Ping::LDAP < Ping
-
- # uri contains the URI object for the request
- #
- attr_accessor :uri
-
- # username and password may be set for ping using
- # an authenticated LDAP bind
- #
- attr_accessor :username
- attr_accessor :password
-
- # set/get the encryption method. By default nil,
- # but may be set to :simple_tls
- #
- attr_accessor :encryption
- def encryption=(value)
- @encryption = (value.is_a? Symbol) ? value : value.to_sym
- end
-
- # Creates and returns a new Ping::LDAP object.
- # The default +timeout+ is 5 seconds.
- #
- # +uri+ string is expected to be a full URI with scheme (ldap/ldaps)
- # and optionally the port (else default port is assumed) e.g.
- # ldap://my.ldap.host.com
- # ldap://my.ldap.host.com:1389
- # ldaps://my.ldap.host.com
- # ldaps://my.ldap.host.com:6636
- #
- # If a plain hostname is provided as the +uri+, a default port of 389 is assumed
- #
- def initialize(uri=nil, timeout=5)
- host, port = decode_uri(uri)
- super(host, port, timeout)
- end
-
- # method used to decode uri string
- #
- def decode_uri(value)
- @uri = URI.parse(value)
- if uri.scheme =~ /ldap/
- p = @port = uri.port
- h = @host = uri.host
- @encryption = uri.scheme=='ldaps' ? :simple_tls : nil
- else
- h = value
- p = 389
- end
- [h, p]
- end
-
- # constructs the LDAP configuration structure
- #
- def config
- {
- :host => uri.host,
- :port => uri.port,
- :encryption => encryption
- }.merge(
- (username && password) ?
- { :auth => {:method => :simple, :username => username, :password => password} } :
- { :auth => {:method => :anonymous} }
- )
- end
-
- # perform ping, optionally providing the ping destination uri
- #
- def ping(host = nil)
- decode_uri(host) if host
- super(@host)
-
- bool = false
-
- start_time = Time.now
-
- begin
- Timeout.timeout(@timeout) do
- Net::LDAP.new( config ).bind
- end
- rescue Net::LDAP::LdapError => e
- @exception = e.message
- rescue Exception => e
- @exception = e.message
- else
- bool = true
- end
-
- # There is no duration if the ping failed
- @duration = Time.now - start_time if bool
-
- bool
- end
-
- alias ping? ping
- alias pingecho ping
- end
-end
View
@@ -10,7 +10,7 @@ module Net
#
class Ping
# The version of the net-ping library.
- VERSION = '1.5.3'
+ VERSION = '1.6.0'
# The host to ping. In the case of Ping::HTTP, this is the URI.
attr_accessor :host
View
@@ -3,7 +3,7 @@ require 'rbconfig'
Gem::Specification.new do |spec|
spec.name = 'net-ping'
- spec.version = '1.5.3'
+ spec.version = '1.6.0'
spec.license = 'Artistic 2.0'
spec.author = 'Daniel J. Berger'
spec.email = 'djberg96@gmail.com'
@@ -15,12 +15,10 @@ Gem::Specification.new do |spec|
spec.rubyforge_project = 'shards'
spec.extra_rdoc_files = ['README', 'CHANGES', 'doc/ping.txt']
- spec.add_dependency('net-ldap', '~> 0.2.2')
spec.add_dependency('ffi', '>= 1.0.0')
spec.add_development_dependency('test-unit', '>= 2.5.0')
spec.add_development_dependency('fakeweb', '>= 1.3.0')
- spec.add_development_dependency('fakeldap', '~> 0.0.1')
if File::ALT_SEPARATOR && RUBY_PLATFORM != 'java'
spec.platform = Gem::Platform::CURRENT
View
@@ -28,7 +28,7 @@
class TC_Net_Ping < Test::Unit::TestCase
def test_net_ping_version
- assert_equal('1.5.3', Net::Ping::VERSION)
+ assert_equal('1.6.0', Net::Ping::VERSION)
end
end
Oops, something went wrong.

0 comments on commit d9db7f4

Please sign in to comment.