From c0bab9d14de57552dde2ed616e7607c639611ee3 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Thu, 1 Aug 2002 17:14:13 +0000 Subject: [PATCH] Report where we get invalid status messages from --- src/spong-server.pl | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/spong-server.pl b/src/spong-server.pl index d297da6..634b576 100755 --- a/src/spong-server.pl +++ b/src/spong-server.pl @@ -6,7 +6,7 @@ # There are one or more update processes that listen for status updates # from client programs. -# $Id: spong-server.pl,v 1.53 2002/07/09 22:41:23 sljohnson Exp $ +# $Id: spong-server.pl,v 1.54 2002/08/01 17:14:13 supermathie Exp $ use lib "@@LIBDIR@@"; @@ -305,7 +305,8 @@ sub listen_for_updates { # that can process the message. Currently valid messages are "status", # "ack", "config", and "stat". - if( $header =~ /^status\b/ ) { &save_status( $header, $message ); } + if( $header =~ /^status\b/ ) { + &save_status( $header, $message, $paddr ); } if( $header =~ /^ack-del\b/ ) { &del_ack( $header, $message ); } if( $header =~ /^ack\ / ) { &save_ack( $header, $message ); } # if( $header =~ /^config\b/ ) { &save_config( $header, $message ); } @@ -589,33 +590,35 @@ sub client_get { # spong-message and let it decide if it should page/email someone... sub save_status { - my( $header, $message ) = @_; + my( $header, $message, $peer ) = @_; my( $cmd, $host, $service, $color, $time, $sum, $path, $start, $duration ); my( $ttl ) = 0; # Do some checking on the message. If it appears bogus, then just # log a message, and close the connection. + if(!defined($peer)) { $peer = ""; } + else { $peer = " received from $peer"; } if( $header =~ /^(\w+) (\S+) (\w+) (\w+) ([:0-9]+) (.*)$/ ) { ($cmd, $host, $service, $color, $time, $sum) = ($1, $2, $3, $4, $5, $6); if( $host !~ m/^[a-zA-Z0-9_\-\.]+$/ ) { - &error( "save_status: invalid host [$host]" ); return; } + &error( "save_status: invalid host [$host]$peer" ); return; } if( $service !~ m/^[a-z0-9_\-\.]+$/ ) { - &error( "save_status: invalid service [$service]" ); return; } + &error( "save_status: invalid service [$service]$peer" ); return; } if( $color !~ m/red|yellow|green|purple|clear/ ) { - &error( "save_status: invalid color [$color]" ); return;} + &error( "save_status: invalid color [$color]$peer" ); return;} if ( $time =~ /(\d+):(\d+)/ ) { $time = $1; $ttl = $2; } if( $time !~ m/^\d+$/ ) { - &error( "save_status: invalid time [$time]" ); return; } + &error( "save_status: invalid time [$time]$peer" ); return; } if( $ttl !~ m/^\d+$/ ) { - &error( "save_status: invalid time to live [$ttl]" ); return; } + &error( "save_status: invalid time to live [$ttl]$peer" ); return; } } else { - &error( "save_status: invalid header [$header]" ); return; + &error( "save_status: invalid header [$header]$peer" ); return; } if ($main::HOSTS{$host} eq "") { - &error("save_status: undefined host [$host]"); + &error("save_status: undefined host [$host]$peer"); return; } -- 2.30.2