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 private function parseAddresses(string $type,Collection $addresses,Collection &$rogue): Collection
{ {
static $aos = NULL;
if (! $aos)
$aos = collect();
$nodes = collect(); $nodes = collect();
$net = NULL; $net = NULL;
@ -706,23 +701,37 @@ class Message extends FTNBase
if ($this->fdomain && $this->fdomain->flatten) { if ($this->fdomain && $this->fdomain->flatten) {
$ao = Address::findZone($this->fdomain,$net&DomainController::NUMBER_MAX,$node&DomainController::NUMBER_MAX,0); $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; $aoid = $ao?->id;
if (! $ao)
$ftn = sprintf('%d:%d/%d',0,$net&DomainController::NUMBER_MAX,$node&DomainController::NUMBER_MAX);
} else { } else {
$ftn = sprintf('%d:%d/%d',$this->fz,$net&DomainController::NUMBER_MAX,$node&DomainController::NUMBER_MAX); $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. switch ($type) {
if ($aos->has($ftn)) case 'path':
$aoid = $aos->get($ftn); if (! $aoid) {
else $ao = (Address::findFTN($ftn,TRUE));
$aos->put($ftn,($aoid=(Address::findFTN($ftn))?->id)); $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) { 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); $rogue->push($ftn);
} else { } else {

View File

@ -431,8 +431,9 @@ abstract class Protocol
// Add unknown FTNs to the DB // Add unknown FTNs to the DB
if ($this->node->aka_remote_authed->count()) { if ($this->node->aka_remote_authed->count()) {
$so = $this->node->aka_remote_authed->first()->system; $so = $this->node->aka_remote_authed->first()->system;
} else { } else {
$so = System::where('name','Discovered System')->single(); $so = System::where('name','Discovered System')->first();
} }
if ($so && $so->exists) { if ($so && $so->exists) {

View File

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

View File

@ -33,7 +33,7 @@
{{ $do->name }} {{ $do->name }}
@endif @endif
</td> </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->active ? 'YES' : 'NO' }}</td>
<td class="text-end">{{ $do->managed() ? 'YES' : 'NO' }}</td> <td class="text-end">{{ $do->managed() ? 'YES' : 'NO' }}</td>
<td> <td>