From 6f95b7b540e045bdb87e20d51c5875e9d12be7f6 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/protocol-tests/tcp.rb | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'lib/custodian') 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