Handle packets with errors differently
This commit is contained in:
parent
05f387aab7
commit
385290d18c
@ -55,12 +55,13 @@ class Packet extends FTNBase
|
|||||||
|
|
||||||
public File $file; // Packet filename
|
public File $file; // Packet filename
|
||||||
public Collection $messages; // Messages in the Packet
|
public Collection $messages; // Messages in the Packet
|
||||||
|
public Collection $errors; // Messages that fail validation
|
||||||
private string $name; // Packet name
|
private string $name; // Packet name
|
||||||
public bool $hasErrors = FALSE; // Packet has validation errors
|
|
||||||
|
|
||||||
public function __construct(Address $o=NULL)
|
public function __construct(Address $o=NULL)
|
||||||
{
|
{
|
||||||
$this->messages = collect();
|
$this->messages = collect();
|
||||||
|
$this->errors = collect();
|
||||||
$this->domain = NULL;
|
$this->domain = NULL;
|
||||||
$this->name = sprintf('%08x',timew());
|
$this->name = sprintf('%08x',timew());
|
||||||
|
|
||||||
@ -130,6 +131,12 @@ class Packet extends FTNBase
|
|||||||
$addchars = self::PACKED_MSG_HEADER_LEN-strlen($message);
|
$addchars = self::PACKED_MSG_HEADER_LEN-strlen($message);
|
||||||
$message .= substr($readbuf,$buf_ptr,$addchars);
|
$message .= substr($readbuf,$buf_ptr,$addchars);
|
||||||
$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
|
// 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 the message is invalid, we'll ignore it
|
||||||
if ($msg->errors && $msg->errors->messages()->has('from')) {
|
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'))));
|
Log::error(sprintf('%s:%s Skipping...',self::LOGKEY,join('|',$msg->errors->messages()->get('from'))));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -125,7 +125,7 @@ final class Receive extends Item
|
|||||||
ProcessPacket::dispatchSync($msg);
|
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));
|
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
|
// If we want to keep the packet, we could do that logic here
|
||||||
|
@ -45,6 +45,7 @@ class PacketInfo extends Command
|
|||||||
$this->info(sprintf('Messages: %d',$pkt->messages->count()));
|
$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('Tosser %d (%s) version %s',$pkt->software->code,$pkt->software->name,$pkt->software_ver));
|
||||||
$this->info(sprintf('Capabilities: %x',$pkt->capability));
|
$this->info(sprintf('Capabilities: %x',$pkt->capability));
|
||||||
|
$this->info(sprintf('Has Errors: %s',$pkt->errors->count() ? 'YES' : 'No'));
|
||||||
|
|
||||||
foreach ($pkt->messages as $msg) {
|
foreach ($pkt->messages as $msg) {
|
||||||
$this->warn(sprintf('- Date: %s',$msg->date));
|
$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(' - From: %s (%s)',$msg->user_from,$msg->fftn));
|
||||||
$this->warn(sprintf(' - To: %s (%s)',$msg->user_to,$msg->tftn));
|
$this->warn(sprintf(' - To: %s (%s)',$msg->user_to,$msg->tftn));
|
||||||
$this->warn(sprintf(' - Subject: %s',$msg->subject));
|
$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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user