From 776311397d4db04b63f883d60c3adf998129de74 Mon Sep 17 00:00:00 2001 From: Steve Kemp Date: Sat, 17 Nov 2012 15:31:29 +0000 Subject: New TCP test. --- lib/custodian.rb | 1 + lib/custodian/protocol-tests/tcp.rb | 25 +++++++++++++++---------- 2 files changed, 16 insertions(+), 10 deletions(-) (limited to 'lib') diff --git a/lib/custodian.rb b/lib/custodian.rb index 0b2caf6..821bf6d 100644 --- a/lib/custodian.rb +++ b/lib/custodian.rb @@ -22,6 +22,7 @@ require 'custodian/protocol-tests/ping.rb' require 'custodian/protocol-tests/rsync.rb' require 'custodian/protocol-tests/smtp.rb' require 'custodian/protocol-tests/ssh.rb' +require 'custodian/protocol-tests/tcp.rb' diff --git a/lib/custodian/protocol-tests/tcp.rb b/lib/custodian/protocol-tests/tcp.rb index 847062c..4408c7d 100755 --- a/lib/custodian/protocol-tests/tcp.rb +++ b/lib/custodian/protocol-tests/tcp.rb @@ -71,6 +71,8 @@ class TCPTest host = @test_data['target_host'] port = @test_data['test_port'] +@test_data['verbose'] = true + # # Get the banner we expect # @@ -94,17 +96,20 @@ class TCPTest socket.close() - if ( !banner.nil? ) - # test for bannerbanner - if ( read =~ /#{banner}/i ) - puts "We connected and matched the banner against '#{read}'" if ( @test_data['verbose'] ) - return true - end - @error = "We expected a banner matching '#{banner}' but we got '#{read}'" - return false + if ( banner.nil? ) + return true + else + # test for banner + if ( read =~ /#{banner}/i ) + puts "We connected and matched the banner against '#{read}'" if ( @test_data['verbose'] ) + return true + end + + @error = "We expected a banner matching '#{banner}' but we got '#{read}'" + return false end - rescue + rescue @error = "Exception connecting to host #{host}:#{port} - #{$!}" return false end @@ -113,7 +118,7 @@ class TCPTest @error = "TIMEOUT: #{e}" return false end - + @error = "Misc failure" return false end -- cgit v1.2.1