Added SEEN-BY/PATH processing, dont show networks that are not public, minor other formatting
This commit is contained in:
@@ -22,6 +22,8 @@ use App\Traits\EncodeUTF8;
|
||||
*/
|
||||
class Message extends FTNBase
|
||||
{
|
||||
private const LOGKEY = 'FM-';
|
||||
|
||||
use EncodeUTF8;
|
||||
|
||||
private const cast_utf8 = [
|
||||
@@ -103,7 +105,11 @@ class Message extends FTNBase
|
||||
private array $point; // Point the message belongs to (Netmail)
|
||||
|
||||
private Collection $path; // FTS-0004.001 The message PATH lines
|
||||
private Collection $pathaddress; // Collection of Addresses after parsing seenby
|
||||
private Collection $rogue_path; // Collection of FTNs in the Seen-by that are not defined
|
||||
private Collection $seenby; // FTS-0004.001 The message SEEN-BY lines
|
||||
private Collection $seenaddress; // Collection of Addresses after parsing seenby
|
||||
private Collection $rogue_seen; // Collection of FTNs in the Seen-by that are not defined
|
||||
private Collection $via; // The path the message has gone using Via lines (Netmail)
|
||||
private Collection $unknown; // Temporarily hold attributes we have no logic for.
|
||||
|
||||
@@ -179,6 +185,8 @@ class Message extends FTNBase
|
||||
|
||||
$this->path = collect();
|
||||
$this->seenby = collect();
|
||||
$this->rogue_seen = collect();
|
||||
$this->rogue_path = collect();
|
||||
$this->via = collect();
|
||||
$this->unknown = collect();
|
||||
}
|
||||
@@ -297,6 +305,10 @@ class Message extends FTNBase
|
||||
case 'kludge':
|
||||
case 'path':
|
||||
case 'seenby':
|
||||
case 'pathaddress':
|
||||
case 'seenaddress':
|
||||
case 'rogue_path':
|
||||
case 'rogue_seen':
|
||||
case 'via':
|
||||
|
||||
case 'errors':
|
||||
@@ -436,7 +448,6 @@ class Message extends FTNBase
|
||||
$return .= sprintf(" * Origin: %s\r",$this->origin);
|
||||
|
||||
} else {
|
||||
dump([__METHOD__=>'NOT LOCAL']);
|
||||
$return .= $this->message."\r";
|
||||
}
|
||||
|
||||
@@ -518,6 +529,46 @@ class Message extends FTNBase
|
||||
return ($this->flags & $flag);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the Seenby/path lines and return a collection of addresses
|
||||
*
|
||||
* @param string $type
|
||||
* @param Collection $addresses
|
||||
* @param Collection $rogue
|
||||
* @return Collection
|
||||
* @throws \Exception
|
||||
*/
|
||||
private function parseAddresses(string $type,Collection $addresses,Collection &$rogue): Collection
|
||||
{
|
||||
$nodes = collect();
|
||||
|
||||
$net = NULL;
|
||||
foreach ($addresses as $line) {
|
||||
foreach (explode(' ',$line) as $item) {
|
||||
if (($x=strpos($item,'/')) !== FALSE) {
|
||||
$net = (int)substr($item,0,$x);
|
||||
$node = (int)substr($item,$x+1);
|
||||
|
||||
} else {
|
||||
$node = (int)$item;
|
||||
};
|
||||
|
||||
$ftn = sprintf('%d:%d/%d',$this->fz,$net&0x7fff,$node&0x7fff);
|
||||
$ao = Address::findFTN($ftn);
|
||||
|
||||
if (! $ao) {
|
||||
Log::alert(sprintf('%s:! Undefined Node [%s] in %s.',self::LOGKEY,$ftn,$type));
|
||||
$rogue->push($ftn);
|
||||
|
||||
} else {
|
||||
$nodes->push($ao);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $nodes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the data after the ORIGIN
|
||||
* There may be kludge lines after the origin - notably SEEN-BY
|
||||
@@ -687,6 +738,14 @@ class Message extends FTNBase
|
||||
else
|
||||
$this->unknown->push(chop($v,"\r"));
|
||||
}
|
||||
|
||||
// Parse SEEN-BY
|
||||
if ($this->seenby->count())
|
||||
$this->seenaddress = $this->parseAddresses('seenby',$this->seenby,$this->rogue_seen);
|
||||
|
||||
// Parse PATH
|
||||
if ($this->path->count())
|
||||
$this->pathaddress = $this->parseAddresses('path',$this->path,$this->rogue_path);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user