summaryrefslogtreecommitdiff
path: root/lib/custodian
diff options
context:
space:
mode:
authorSteve Kemp <steve@steve.org.uk>2013-05-20 16:25:48 +0100
committerSteve Kemp <steve@steve.org.uk>2013-05-20 16:25:48 +0100
commit57204630a6605e26ac2ed03d6d5886d51d6617c0 (patch)
tree5314567792d55c845722e385ade828223c21387f /lib/custodian
parent70796a4021f71384d7863be0bc216da68e4e201d (diff)
The banner matching now copes with a string or a regexp.
Diffstat (limited to 'lib/custodian')
-rw-r--r--lib/custodian/protocoltest/tcp.rb21
1 files changed, 17 insertions, 4 deletions
diff --git a/lib/custodian/protocoltest/tcp.rb b/lib/custodian/protocoltest/tcp.rb
index b4a23b2..e21e5a5 100644
--- a/lib/custodian/protocoltest/tcp.rb
+++ b/lib/custodian/protocoltest/tcp.rb
@@ -158,8 +158,10 @@ module Custodian
read = socket.sysread(1024) if ( do_read )
# trim to a sane length & strip newlines.
- read = read[0,255] unless ( read.nil? )
- read.gsub!(/[\n\r]/, "") unless ( read.nil? )
+ if ( ! read.nil? )
+ read = read[0,255]
+ read.gsub!(/[\n\r]/, "")
+ end
socket.close()
@@ -168,8 +170,19 @@ module Custodian
return true
else
# test for banner
- if ( ( !read.nil? ) && ( banner.match(read) ) )
- return true
+
+ # regexp.
+ if ( banner.class == "Regexp" )
+ if ( ( !read.nil? ) && ( banner.match(read) ) )
+ return true
+ end
+ end
+
+ # string.
+ if ( banner.class == "String" )
+ if ( ( !read.nil? ) && ( read =~ /#{banner}/i ) )
+ return true
+ end
end
@error = "We expected a banner matching '#{banner}' but we got '#{read}'"