Dont enable rogue_path - it looses our true path for messages - instead create addresses in the path we dont know about.

This commit is contained in:
Deon George 2023-09-15 16:59:46 +10:00
parent 6e133770fc
commit c1d6d48a3c
4 changed files with 38 additions and 19 deletions

View File

@ -684,11 +684,6 @@ class Message extends FTNBase
*/
private function parseAddresses(string $type,Collection $addresses,Collection &$rogue): Collection
{
static $aos = NULL;
if (! $aos)
$aos = collect();
$nodes = collect();
$net = NULL;
@ -706,23 +701,37 @@ class Message extends FTNBase
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',0,$net&DomainController::NUMBER_MAX,$node&DomainController::NUMBER_MAX,$this->fdomain->name);
$aoid = $ao?->id;
if (! $ao)
$ftn = sprintf('%d:%d/%d',0,$net&DomainController::NUMBER_MAX,$node&DomainController::NUMBER_MAX);
} else {
$ftn = sprintf('%d:%d/%d',$this->fz,$net&DomainController::NUMBER_MAX,$node&DomainController::NUMBER_MAX);
$aoid = NULL;
}
// @todo This should be enhanced to include the address at the time of the message.
if ($aos->has($ftn))
$aoid = $aos->get($ftn);
else
$aos->put($ftn,($aoid=(Address::findFTN($ftn))?->id));
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));
Log::alert(sprintf('%s:! Undefined Node [%s] in [%s].',self::LOGKEY,$ftn,$type));
$rogue->push($ftn);
} else {

View File

@ -431,8 +431,9 @@ 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')->single();
$so = System::where('name','Discovered System')->first();
}
if ($so && $so->exists) {

View File

@ -472,8 +472,16 @@ class Address extends Model
}
if ($create) {
if (! $so)
throw new \Exception(sprintf('%s:AKA create requested for [%s], but system not provided',self::LOGKEY,$address));
if (! $so) {
System::unguard();
$so = System::firstOrCreate([
'name' => 'Discovered System',
'sysop' => 'Unknown',
'location' => '',
'active' => TRUE,
]);
System::reguard();
}
if (! $ftn['d']) {
Log::alert(sprintf('%s:! Refusing to create address [%s] no domain available',self::LOGKEY,$address));
@ -503,7 +511,7 @@ class Address extends Model
if (! $zo->exists) {
$zo->active = TRUE;
$zo->notes = 'Auto created';
$zo->system_id = System::where('name','Discovered System')->single()->id;
$zo->system_id = System::where('name','Discovered System')->first()->id;
$do->zones()->save($zo);
}
@ -525,6 +533,7 @@ class Address extends Model
try {
$so->addresses()->save($o);
} catch (\Exception $e) {
Log::error(sprintf('%s:! ERROR creating address [%s] (%s)',self::LOGKEY,$x->toSql(),get_class($e)),['bindings'=>$x->getBindings()]);
return NULL;

View File

@ -33,7 +33,7 @@
{{ $do->name }}
@endif
</td>
<td>{{ $do->zones->pluck('zone_id')->sort()->join(', ') }}</td>
<td>{{ $do->zones->where('active',TRUE)->pluck('zone_id')->sort()->join(', ') }}</td>
<td class="text-end">{{ $do->active ? 'YES' : 'NO' }}</td>
<td class="text-end">{{ $do->managed() ? 'YES' : 'NO' }}</td>
<td>