Packet header fixes, correctly identify packets from/to points

This commit is contained in:
Deon George
2021-06-29 23:23:59 +10:00
parent 987b4040fb
commit 7356bedfa2
2 changed files with 27 additions and 7 deletions

View File

@@ -81,6 +81,7 @@ class Message extends FTNBase
private string $origin; // FTS-0004.001
private ?string $echoarea = NULL; // FTS-0004.001
private array $zone; // Zone the message belongs to. (src/dst - for netmail)
private array $point; // Point the message belongs to (Netmail)
private array $netmail; // Netmail details
private Collection $path; // FTS-0004.001 The message PATH lines
@@ -98,6 +99,7 @@ class Message extends FTNBase
$this->_other = collect();
$this->unknown = collect();
$this->zone = [];
$this->point = [];
$this->header = unpack($this->unpackheader(self::header),substr($msg,0,self::HEADER_LEN));
@@ -133,14 +135,14 @@ class Message extends FTNBase
case 'fz': return Arr::get($this->zone,'src',0);
case 'fn': return Arr::get($this->header,'onet');
case 'ff': return Arr::get($this->header,'onode');
case 'fp': return 0; // @todo
case 'fp': return Arr::get($this->point,'src');
// To Addresses
// Echomail doesnt have a zone, so we'll use the source zone
case 'tz': return Arr::get($this->zone,$this->echoarea ? 'src' : 'dst',0);
case 'tn': return Arr::get($this->header,'dnet');
case 'tf': return Arr::get($this->header,'dnode');
case 'tp': return 0; // @todo
case 'tp': return Arr::get($this->point,'dst');
case 'fftn':
case 'tftn':
@@ -347,6 +349,7 @@ class Message extends FTNBase
}
$this->zone['src'] = $ftn['z'];
$this->point['src'] = $ftn['p'];
// The message is the rest?
} elseif (strlen($v) > $x+1) {
@@ -369,7 +372,7 @@ class Message extends FTNBase
// From point: <SOH>"FMPT <point number><CR>
if ($t = $this->kludge('FMPT ',$v))
$this->_other->push($t);
$this->point['src'] = $t;
/*
* The INTL control paragraph shall be used to give information about
@@ -381,7 +384,24 @@ class Message extends FTNBase
elseif ($t = $this->kludge('INTL ',$v)) {
$this->netmail['intl'] = $t;
// INTL kludge is in Netmail, so we'll do some validation:
list($this->netmail['dst'],$this->netmail['src']) = explode(' ',$t);
$src = Address::parseFTN($this->netmail['src']);
if (($src['n'] !== $this->fn) || ($src['f'] !== $this->ff)) {
Log::error(sprintf('INTL src address [%s] doesnt match packet',$this->netmail['src']));
} else {
// We'll set our source zone
$this->zone['src'] = $src['z'];
}
$dst = Address::parseFTN($this->netmail['dst']);
if (($dst['n'] !== $this->tn) || ($dst['f'] !== $this->tf)) {
Log::error(sprintf('INTL dst address [%s] doesnt match packet',$this->netmail['dst']));
} else {
// We'll set our source zone
$this->zone['dst'] = $dst['z'];
}
}
elseif ($t = $this->kludge('PATH: ',$v))
@@ -389,7 +409,7 @@ class Message extends FTNBase
// To Point: <SOH>TOPT <point number><CR>
elseif ($t = $this->kludge('TOPT ',$v))
$this->_other->push($t);
$this->point['dst'] = $t;
// <SOH>Via <FTN Address> @YYYYMMDD.HHMMSS[.Precise][.Time Zone] <Program Name> <Version> [Serial Number]<CR>
elseif ($t = $this->kludge('Via ',$v))