diff --git a/app/Classes/FTN/Packet.php b/app/Classes/FTN/Packet.php index 13a1575..6db0e53 100644 --- a/app/Classes/FTN/Packet.php +++ b/app/Classes/FTN/Packet.php @@ -55,12 +55,13 @@ class Packet extends FTNBase public File $file; // Packet filename public Collection $messages; // Messages in the Packet + public Collection $errors; // Messages that fail validation private string $name; // Packet name - public bool $hasErrors = FALSE; // Packet has validation errors public function __construct(Address $o=NULL) { $this->messages = collect(); + $this->errors = collect(); $this->domain = NULL; $this->name = sprintf('%08x',timew()); @@ -130,6 +131,12 @@ class Packet extends FTNBase $addchars = self::PACKED_MSG_HEADER_LEN-strlen($message); $message .= substr($readbuf,$buf_ptr,$addchars); $buf_ptr += $addchars; + + // If our buffer wasnt big enough... + if ($buf_ptr >= strlen($readbuf)) { + $buf_ptr = 0; + continue; + } } // If we didnt find a packet end, perhaps there are no more @@ -354,7 +361,7 @@ class Packet extends FTNBase // If the message is invalid, we'll ignore it if ($msg->errors && $msg->errors->messages()->has('from')) { - $this->hasErrors = TRUE; + $this->errors->push($msg); Log::error(sprintf('%s:%s Skipping...',self::LOGKEY,join('|',$msg->errors->messages()->get('from')))); } else { diff --git a/app/Classes/File/Receive.php b/app/Classes/File/Receive.php index 3c17149..6e157e4 100644 --- a/app/Classes/File/Receive.php +++ b/app/Classes/File/Receive.php @@ -125,7 +125,7 @@ final class Receive extends Item ProcessPacket::dispatchSync($msg); } - if ($po->hasErrors) { + if ($po->errors->count()) { Log::info(sprintf('%s: - Not deleting packet [%s], as it has validation errors',__METHOD__,$this->file)); // If we want to keep the packet, we could do that logic here diff --git a/app/Console/Commands/PacketInfo.php b/app/Console/Commands/PacketInfo.php index a85e272..e15bae3 100644 --- a/app/Console/Commands/PacketInfo.php +++ b/app/Console/Commands/PacketInfo.php @@ -45,6 +45,7 @@ class PacketInfo extends Command $this->info(sprintf('Messages: %d',$pkt->messages->count())); $this->info(sprintf('Tosser %d (%s) version %s',$pkt->software->code,$pkt->software->name,$pkt->software_ver)); $this->info(sprintf('Capabilities: %x',$pkt->capability)); + $this->info(sprintf('Has Errors: %s',$pkt->errors->count() ? 'YES' : 'No')); foreach ($pkt->messages as $msg) { $this->warn(sprintf('- Date: %s',$msg->date)); @@ -52,6 +53,20 @@ class PacketInfo extends Command $this->warn(sprintf(' - From: %s (%s)',$msg->user_from,$msg->fftn)); $this->warn(sprintf(' - To: %s (%s)',$msg->user_to,$msg->tftn)); $this->warn(sprintf(' - Subject: %s',$msg->subject)); + + foreach ($msg->errors->errors()->all() as $error) + $this->line(' - '.$error); + } + + foreach ($pkt->errors as $msg) { + $this->error(sprintf('- Date: %s',$msg->date)); + $this->error(sprintf(' - FLAGS: %s',$msg->flags()->filter()->keys()->join(', '))); + $this->error(sprintf(' - From: %s (%s)',$msg->user_from,$msg->fftn)); + $this->error(sprintf(' - To: %s (%s)',$msg->user_to,$msg->tftn)); + $this->error(sprintf(' - Subject: %s',$msg->subject)); + + foreach ($msg->errors->errors()->all() as $error) + $this->line(' - '.$error); } } }