diff options
author | Steve Kemp <steve@steve.org.uk> | 2012-11-17 15:31:29 +0000 |
---|---|---|
committer | Steve Kemp <steve@steve.org.uk> | 2012-11-17 15:31:29 +0000 |
commit | 6f95b7b540e045bdb87e20d51c5875e9d12be7f6 (patch) | |
tree | b177f07e41a08ed47c2461292bb6fc51708b8b0c /lib/custodian/protocol-tests | |
parent | e7c69a0dda13d719de97d30070f4f14345cf5ee8 (diff) |
New TCP test.
Diffstat (limited to 'lib/custodian/protocol-tests')
-rwxr-xr-x | lib/custodian/protocol-tests/tcp.rb | 25 |
1 files changed, 15 insertions, 10 deletions
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 |