| 1 | ############################################################################ | ||
| 2 | # Net::Inspect::L5::Unknown | ||
| 3 | # guessing handler for connections which are not handled by anything else | ||
| 4 | ############################################################################ | ||
| 5 | use warnings; | ||
| 6 | use strict; | ||
| 7 | package Net::Inspect::L5::Unknown; | ||
| 8 | use base 'Net::Inspect::Connection'; | ||
| 9 | use fields qw(replay); | ||
| 10 | use Net::Inspect::Debug; | ||
| 11 | |||
| 12 | sub guess_protocol { | ||
| 13 | my ($self,$guess,$dir,$data,$eof,$time,$meta) = @_; | ||
| 14 | |||
| 15 | # keep all calls for replaying later | ||
| 16 | push @{ $self->{replay} ||=[] },[$dir,$data,$eof,$time]; | ||
| 17 | |||
| 18 | $guess->attached == 1 or return; # let others try first | ||
| 19 | |||
| 20 | # it's just me left | ||
| 21 | my $obj = $self->new_connection($meta); | ||
| 22 | if ( ! $obj ) { | ||
| 23 | $guess->detach($self); | ||
| 24 | return; | ||
| 25 | } | ||
| 26 | |||
| 27 | # replay all | ||
| 28 | $obj->in(@$_) for @{ $self->{replay} }; | ||
| 29 | undef $self->{replay}; | ||
| 30 | return ($obj,length($data)); | ||
| 31 | } | ||
| 32 | |||
| 33 | sub new_connection { | ||
| 34 | my ($class,$meta) = @_; | ||
| 35 | return $class->new; | ||
| 36 | } | ||
| 37 | |||
| 38 | sub in { | ||
| 39 | my ($self,$dir,$data,$eof,$time) = @_; | ||
| 40 | $self->{expire} = $time + 500; | ||
| 41 | return length($data); # ignores | ||
| 42 | } | ||
| 43 | |||
| 44 | sub fatal { | ||
| 45 | my ($self,$reason,$dir,$time) = @_; | ||
| 46 | trace($reason); | ||
| 47 | } | ||
| 48 | |||
| 49 | 1; | ||
| 50 | |||
| 51 | __END__ |