diff options
| author | Steve Kemp <steve@steve.org.uk> | 2013-05-20 16:25:48 +0100 | 
|---|---|---|
| committer | Steve Kemp <steve@steve.org.uk> | 2013-05-20 16:25:48 +0100 | 
| commit | 57204630a6605e26ac2ed03d6d5886d51d6617c0 (patch) | |
| tree | 5314567792d55c845722e385ade828223c21387f /lib/custodian/protocoltest | |
| parent | 70796a4021f71384d7863be0bc216da68e4e201d (diff) | |
  The banner matching now copes with a string or a regexp.
Diffstat (limited to 'lib/custodian/protocoltest')
| -rw-r--r-- | lib/custodian/protocoltest/tcp.rb | 21 | 
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}'" | 
