Handle packets with errors differently
This commit is contained in:
@@ -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 {
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user