summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSteve Kemp <steve@steve.org.uk>2012-11-17 15:31:29 +0000
committerSteve Kemp <steve@steve.org.uk>2012-11-17 15:31:29 +0000
commit6f95b7b540e045bdb87e20d51c5875e9d12be7f6 (patch)
treeb177f07e41a08ed47c2461292bb6fc51708b8b0c /lib
parente7c69a0dda13d719de97d30070f4f14345cf5ee8 (diff)
New TCP test.
Diffstat (limited to 'lib')
-rw-r--r--lib/custodian.rb1
-rwxr-xr-xlib/custodian/protocol-tests/tcp.rb25
2 files changed, 16 insertions, 10 deletions
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