More work to decommission rogue_path

This commit is contained in:
2023-09-15 22:57:32 +10:00
parent c1d6d48a3c
commit 708d9a9f67
12 changed files with 218 additions and 231 deletions

View File

@@ -12,7 +12,7 @@ use Illuminate\Validation\Validator as ValidatorResult;
use App\Classes\FTN as FTNBase;
use App\Http\Controllers\DomainController;
use App\Models\{Address,Domain,Zone};
use App\Models\{Address,Domain,System,Zone};
use App\Rules\{TwoByteInteger,TwoByteIntegerWithZero};
use App\Traits\EncodeUTF8;
@@ -139,10 +139,9 @@ class Message extends FTNBase
private Collection $rescanned; // Message was created as a result of a rescan
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 $rogue_seenby; // 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_seenby; // 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.
@@ -225,11 +224,10 @@ class Message extends FTNBase
$this->kludge = collect();
$this->rescanned = collect();
$this->path = collect();
$this->rogue_seenby = collect();
$this->seenby = collect();
$this->seenaddress = collect();
$this->pathaddress = collect();
$this->rogue_seenby = collect();
$this->rogue_path = collect();
$this->via = collect();
$this->unknown = collect();
}
@@ -367,9 +365,8 @@ class Message extends FTNBase
case 'path':
case 'seenby':
case 'pathaddress':
case 'seenaddress':
case 'rogue_path':
case 'rogue_seenby':
case 'seenaddress':
case 'unknown':
case 'via':
@@ -697,46 +694,47 @@ class Message extends FTNBase
$node = (int)$item;
}
$aoid = NULL;
// If domain should be flattened, look for node regardless of zone (within the list of zones for the domain)
if ($this->fdomain && $this->fdomain->flatten) {
$ao = Address::findZone($this->fdomain,$net&DomainController::NUMBER_MAX,$node&DomainController::NUMBER_MAX,0);
$ftn = sprintf('%d:%d/%d@%s',$this->fz,$net&DomainController::NUMBER_MAX,$node&DomainController::NUMBER_MAX,$this->fdomain->name);
$ftn = sprintf('%d:%d/%d@%s',0,$net&DomainController::NUMBER_MAX,$node&DomainController::NUMBER_MAX,$this->fdomain->name);
$aoid = $ao?->id;
} elseif ($this->fdomain) {
$ftn = sprintf('%d:%d/%d@%s',$this->fz,$net&DomainController::NUMBER_MAX,$node&DomainController::NUMBER_MAX,$this->fdomain->name);
} else {
$ftn = sprintf('%d:%d/%d',$this->fz,$net&DomainController::NUMBER_MAX,$node&DomainController::NUMBER_MAX);
$aoid = NULL;
}
switch ($type) {
case 'path':
if (! $aoid) {
$ao = (Address::findFTN($ftn,TRUE));
$aoid = $ao?->id;
}
break;
case 'seenby':
if (! $aoid) {
$ao = (Address::findFTN($ftn));
$aoid = $ao?->id;
}
break;
default:
throw new \Exception('Unknown type: '.$type);
}
if (! $aoid) {
Log::alert(sprintf('%s:! Undefined Node [%s] in [%s].',self::LOGKEY,$ftn,$type));
$rogue->push($ftn);
if (! ($ao=Address::findFTN($ftn))) {
Log::alert(sprintf('%s:! Undefined Node [%s] in [%s] - auto created.',self::LOGKEY,$ftn,$type));
} else {
$nodes->push($aoid);
$ao = Address::createFTN($ftn,System::createUnknownSystem());
}
$aoid = $ao?->id;
}
switch ($type) {
case 'seenby':
if (! $ao) {
$rogue->push(sprintf('%d:%d/%d',$this->fz,$net&DomainController::NUMBER_MAX,$node&DomainController::NUMBER_MAX));
continue 2;
}
case 'path':
if (! $aoid)
throw new \Exception(sprintf('Didnt get an address for [%s]',$ftn));
break;
}
$nodes->push($aoid);
}
}
@@ -793,11 +791,10 @@ class Message extends FTNBase
* <FTN Address> @YYYYMMDD.HHMMSS[.Precise][.Time Zone] <Program Name> <Version> [Serial Number]
*
* @param Collection $via
* @param Collection $rogue
* @return Collection
* @throws \Exception
*/
private function parseVia(Collection $via,Collection &$rogue): Collection
private function parseVia(Collection $via): Collection
{
$nodes = collect();
@@ -1017,13 +1014,14 @@ class Message extends FTNBase
if ($this->seenby->count())
$this->seenaddress = $this->parseAddresses('seenby',$this->seenby,$this->rogue_seenby);
$dummy = collect();
// Parse PATH
if ($this->path->count())
$this->pathaddress = $this->parseAddresses('path',$this->path,$this->rogue_path);
$this->pathaddress = $this->parseAddresses('path',$this->path,$dummy);
// Parse VIA
if ($this->via->count())
$this->pathaddress = $this->parseVia($this->via,$this->rogue_path);
$this->pathaddress = $this->parseVia($this->via);
}
/**

View File

@@ -449,14 +449,8 @@ class Packet extends FTNBase implements \Iterator, \Countable
$ao->role = Address::NODE_UNKNOWN;
System::unguard();
$so = System::firstOrCreate([
'name' => 'Discovered System',
'sysop' => 'Unknown',
'location' => '',
'active' => TRUE,
]);
System::reguard();
$so = System::createUnknownSystem();
// @todo Remove this debugging line
if ($so->id !== 443)
Log::alert(sprintf('%s:? Just created Discovered System for MSGID [%s] A',self::LOGKEY,$msg->msgid));
@@ -490,14 +484,8 @@ class Packet extends FTNBase implements \Iterator, \Countable
$ao->role = Address::NODE_UNKNOWN;
System::unguard();
$so = System::firstOrCreate([
'name' => 'Discovered System',
'sysop' => 'Unknown',
'location' => '',
'active' => TRUE,
]);
System::reguard();
$so = System::createUnknownSystem();
// @todo Remvoe this debugging line
if ($so->id !== 443)
Log::alert(sprintf('%s:? Just created Discovered System for MSGID [%s] B',self::LOGKEY,$msg->msgid));

View File

@@ -10,7 +10,7 @@ use Illuminate\Support\Facades\Storage;
use League\Flysystem\UnableToWriteFile;
use App\Classes\FTN as FTNBase;
use App\Models\{Address,File,Filearea,Setup};
use App\Models\{Address,File,Filearea,Setup,System};
use App\Traits\EncodeUTF8;
/**
@@ -67,7 +67,6 @@ class Tic extends FTNBase
$this->fo->kludges = collect();
$this->fo->set_path = collect();
$this->fo->set_seenby = collect();
$this->fo->rogue_path = collect();
$this->fo->rogue_seenby = collect();
$this->values = collect();
@@ -240,22 +239,23 @@ class Tic extends FTNBase
preg_match(sprintf('#^[Pp]ath (%s)\ ?([0-9]+)\ ?(.*)$#',Address::ftn_regex),$line,$x);
$ao = Address::findFTN($x[1]);
if (! $ao) {
$this->fo->rogue_path->push($matches[2]);
} else {
$this->fo->set_path->push(['address'=>$ao,'datetime'=>Carbon::createFromTimestamp($x[8]),'extra'=>$x[9]]);
}
if (! $ao)
$ao = Address::createFTN($x[1],System::createUnknownSystem());
$this->fo->set_path->push(['address'=>$ao,'datetime'=>Carbon::createFromTimestamp($x[8]),'extra'=>$x[9]]);
break;
case 'seenby':
$ao = Address::findFTN($matches[2]);
if (! $ao) {
if (! $ao)
$ao = Address::createFTN($x[1],System::createUnknownSystem());
if (! $ao)
$this->fo->rogue_seenby->push($matches[2]);
} else {
else
$this->fo->set_seenby->push($ao->id);
}
break;
}

View File

@@ -429,17 +429,14 @@ abstract class Protocol
));
// Add unknown FTNs to the DB
if ($this->node->aka_remote_authed->count()) {
$so = $this->node->aka_remote_authed->first()->system;
} else {
$so = System::where('name','Discovered System')->first();
}
$so = ($this->node->aka_remote_authed->count())
? $this->node->aka_remote_authed->first()->system
: System::createUnknownSystem();
if ($so && $so->exists) {
foreach ($this->node->aka_other as $aka) {
Address::findFTN($aka,TRUE,$so);
}
foreach ($this->node->aka_other as $aka)
if (! Address::findFTN($aka))
Address::createFTN($aka,$so);
// Log session in DB
$slo = new SystemLog;

View File

@@ -685,7 +685,7 @@ final class Binkp extends BaseProtocol
while ($rem_aka=$this->strsep($buf,' ')) {
try {
if (! ($o=Address::findFTN($rem_aka,FALSE,NULL,TRUE))) {
if (! ($o=Address::findFTN($rem_aka,TRUE))) {
// @todo when we have multiple inactive records, this returns more than 1, so pluck the active record if there is one
Log::alert(sprintf('%s:? AKA is UNKNOWN [%s]',self::LOGKEY,$rem_aka));