Compare commits

...

3 Commits

Author SHA1 Message Date
cd2efbd1d4 Added downstream(), and fixed failing tests in RoutingTest
All checks were successful
Create Docker Image / Build Docker Image (x86_64) (push) Successful in 42s
Create Docker Image / Build Docker Image (arm64) (push) Successful in 1m48s
Create Docker Image / Final Docker Image Manifest (push) Successful in 10s
2024-05-10 21:33:02 +10:00
edee0643ec Reorder functions, no functional changes 2024-05-09 21:31:50 +10:00
23159d19d5 Rework address roles, making Address::role optional, rework determining uplink/downlinks/parent/children 2024-05-09 21:22:30 +10:00
25 changed files with 989 additions and 709 deletions

View File

@ -420,7 +420,7 @@ class Packet extends FTNBase implements \Iterator, \Countable
'host_id' => $msg->tn,
'node_id' => $msg->tf,
'point_id' => $msg->tp,
'active' => TRUE,
'active' => TRUE, // @todo This should be false, as it hasnt been assigned to the node
]);
Address::reguard();
@ -433,8 +433,6 @@ class Packet extends FTNBase implements \Iterator, \Countable
return;
}
$ao->role = Address::NODE_UNKNOWN;
$so = System::createUnknownSystem();
$so->addresses()->save($ao);
@ -453,7 +451,7 @@ class Packet extends FTNBase implements \Iterator, \Countable
'host_id' => $msg->fn,
'node_id' => $msg->ff,
'point_id' => $msg->fp,
'active'=> TRUE,
'active'=> TRUE, // @todo This should be FALSE as it hasnt been assigned to the node
]);
Address::reguard();
@ -466,8 +464,6 @@ class Packet extends FTNBase implements \Iterator, \Countable
return;
}
$ao->role = Address::NODE_UNKNOWN;
$so = System::createUnknownSystem();
$so->addresses()->save($ao);

View File

@ -22,10 +22,12 @@ class AddressCheck extends Command
return Command::FAILURE;
}
$this->info(sprintf('Address: %s',$o->ftn));
$this->info(sprintf('Uplink: %s',$o->parent()?->ftn));
$this->info(sprintf('Address: %s (%s)',$o->ftn,$o->role_name));
$this->info(sprintf("Children: \n- %s",$o->children()->pluck('ftn4d')->join("\n- ")));
$this->info(sprintf("Downstream: \n- %s",$o->downstream()->pluck('ftn4d')->join("\n- ")));
$this->info(sprintf('Uplink: %s (Parent: %s)',$o->uplink()?->ftn,$o->parent()?->ftn));
$this->info(sprintf('Our Address: %s',our_address($o)?->ftn));
$this->info(sprintf('Domain Addresses: %s',our_address($o->zone->domain)->pluck('ftn4d')->join(',')));
$this->info(sprintf('- Domain Addresses: %s',our_address($o->zone->domain)->pluck('ftn4d')->join(',')));
return Command::SUCCESS;
}

View File

@ -0,0 +1,48 @@
<?php
namespace App\Console\Commands\Debug;
use App\Models\Address;
use Illuminate\Console\Command;
class AddressCheckRole extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'debug:address:check:role {--f|fix : Fix the role}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Check address roles and optionally fix';
/**
* Execute the console command.
*/
public function handle()
{
foreach (Address::withTrashed()->with(['zone.domain'])->cursor() as $o) {
// Trim the role bit from role, since we now work out a role automatically.
// @todo This doesnt work, because role_id returns back the overridden role, and thus would remove it
if (($o->role & Address::NODE_ALL) === $o->role_id) {
$o->role &= ~$o->role_id;
if ((! $o->role) || ($o->role === Address::NODE_UNKNOWN))
$o->role = NULL;
if ($o->getDirty())
if ($this->option('fix')) {
$o->save();
} else {
$this->warn(sprintf('Not changing [%s](%s) from [%d] to [%d]',$o->ftn,$o->role_name,$o->getOriginal('role'),$o->role));
}
}
}
}
}

View File

@ -4,7 +4,7 @@ namespace App\Console\Commands\Debug;
use Illuminate\Console\Command;
use App\Models\{Address,Domain};
use App\Models\Domain;
class ZoneCheck extends Command
{
@ -25,77 +25,23 @@ class ZoneCheck extends Command
$this->warn('Zone: '.$zo->zone_id);
$this->info(sprintf('- Our address(es): %s',our_address($do)->pluck('ftn4d')->join(',')));
$this->table(['id','ftn','role','parent','our_address','region_id','host_id','hub_id','system','notes'],$zo->addresses()->FTNorder()->active()->with(['system'])->get()->transform(function($item) {
$this->table(['id','ftn','role','parent','children','downlinks','uplink','send from','region_id','system','notes'],$zo->addresses()->FTNorder()->active()->with(['system'])->get()->transform(function($item) {
return [
'id'=>$item->id,
'ftn'=>$item->ftn4d,
'role'=>$item->role_name,
'parent'=>($x=$item->parent())?->ftn4d,
'our_address'=>$x ? our_address($item->parent())->ftn4d : '',
'parent'=>$item->parent()?->ftn4d,
'children'=>$item->children()->count(),
'downlinks'=>$item->downlinks()->count(),
'uplink'=>($x=$item->uplink())?->ftn4d,
'send from'=>$x ? our_address($item->uplink())?->ftn4d : '',
'region_id'=>$item->region_id,
'host_id'=>$item->host_id,
'hub_id'=>$item->hub_id,
'system'=>$item->system->name,
'notes'=>$this->check($item),
'notes'=>$item->isRoleOverride() ? 'Role Override' : '',
];
}));
}
return Command::SUCCESS;
}
/**
* Check that an address is defined correctly
*
* @param Address $ao
* @return string
*/
private function check(Address $ao): string
{
// ZC address
if ($ao->role === Address::NODE_ZC) {
if (($ao->region_id === 0) && ($ao->host_id === 0) && ($ao->node_id === 0) && is_null($ao->hub_id) && ($ao->point_id === 0))
return 'OK';
else
return 'INVALID ZC address';
}
// RC address
if ($ao->role === Address::NODE_RC) {
if ($ao->region_id && ($ao->region_id === $ao->host_id) && ($ao->node_id === 0) && is_null($ao->hub_id) && ($ao->point_id === 0))
return 'OK';
else
return 'INVALID RC address';
}
// NC address
if ($ao->role === Address::NODE_NC) {
if (($ao->node_id === 0) && is_null($ao->hub_id) && ($ao->point_id === 0))
return 'OK';
else
return 'INVALID NC address';
}
// HUB address
if ($ao->role === Address::NODE_HC) {
if (($ao->node_id !== 0) && is_null($ao->hub_id) && ($ao->point_id === 0))
return 'OK';
else
return 'INVALID HUB address';
}
// POINT address
if ($ao->role === Address::NODE_POINT) {
if ($ao->point_id !== 0)
return 'OK';
else
return 'INVALID POINT address';
}
if ($ao->region_id && ($ao->host_id === 0))
return 'INVALID REGION NODE';
return '';
}
}

View File

@ -27,6 +27,6 @@ class UserCodeSend extends Command
$ao = Address::findFTN($this->argument('ftn'));
$uo = User::where('email',$this->argument('email'))->singleOrFail();
Notification::route('netmail',$ao->parent())->notify(new AddressLink($uo));
Notification::route('netmail',$ao->uplink())->notify(new AddressLink($uo));
}
}

View File

@ -118,7 +118,7 @@ class DomainController extends Controller
if (! $o->public && ! Gate::check('admin',$o))
abort(404);
$o->load(['zones.system','zones.domain']);
$o->load(['zones.system','zones.domain','zones.addresses.nodes_hub']);
return view('domain.view')
->with('o',$o);

View File

@ -76,7 +76,6 @@ class SystemController extends Controller
*/
public function address_add(Request $request,System $o)
{
// @todo a point address is failing validation
// @todo This should be admin of the zone
$this->authorize('admin',$o);
session()->flash('accordion','address');
@ -124,7 +123,6 @@ class SystemController extends Controller
$oo->host_id = $request->region_id_new;
$oo->node_id = 0;
$oo->point_id = 0;
$oo->role = Address::NODE_RC;
$oo->active = TRUE;
$o->addresses()->save($oo);
@ -152,6 +150,7 @@ class SystemController extends Controller
});
})
->where('zone_id',$request->zone_id)
->where('node_id',$request->node_id_new)
->where('point_id',0);
if ($o->count()) {
@ -212,7 +211,6 @@ class SystemController extends Controller
$oo->host_id = $request->host_id_new;
$oo->node_id = $request->node_id_new;
$oo->point_id = 0;
$oo->role = Address::NODE_ACTIVE;
$oo->active = TRUE;
$o->addresses()->save($oo);
@ -276,9 +274,8 @@ class SystemController extends Controller
$oo->host_id = $request->host_id;
$oo->node_id = $request->node_id;
$oo->point_id = $request->point_id;
// @todo Validation should check that the hub is in the right region and net
$oo->hub_id = $request->hub_id > 0 ? $request->hub_id : NULL;
if (is_null($oo->role))
$oo->role = ((! $oo->point_id) && $request->hub) ? Address::NODE_HC : ($request->point_id ? Address::NODE_POINT : Address::NODE_ACTIVE);
$oo->security = $request->security;
$oo->active = TRUE;
@ -327,10 +324,13 @@ class SystemController extends Controller
session()->flash('accordion','address');
// Make sure that no other system has this address active.
if ($o->role === Address::NODE_ACTIVE)
if ($o->role_id === Address::NODE_NN)
return redirect()->back()->withErrors(['address'=>sprintf('%s cannot be demoted any more',$o->ftn3D)]);
$o->role = ($o->role << 1);
$off = $o->role_id;
$o->role &= ~$off;
$o->role |= ($off << 1);
$o->save();
return redirect()->to(sprintf('system/addedit/%d',$o->system_id));
@ -502,10 +502,13 @@ class SystemController extends Controller
session()->flash('accordion','address');
// Make sure that no other system has this address active.
if ($o->role === Address::NODE_NC)
if ($o->role_id === Address::NODE_NC)
return redirect()->back()->withErrors(['address'=>sprintf('%s cannot be promoted any more',$o->ftn3D)]);
$o->role = ($o->role >> 1);
$off = $o->role_id;
$o->role &= ~$off;
$o->role |= ($off >> 1);
$o->save();
return redirect()->to(sprintf('system/addedit/%d',$o->system_id));

View File

@ -50,7 +50,7 @@ class UserController extends Controller
]);
$ao = Address::findOrFail($request->address_id);
if ($ao->check_activation(Auth::user(),$request->code)) {
if ($ao->activation_check(Auth::user(),$request->code)) {
$ao->validated = TRUE;
$ao->save();

View File

@ -69,7 +69,7 @@ class MailSend #implements ShouldQueue
// Return the system we poll
$u = $u->transform(function($item) {
if ($x=$item->parent()) {
if ($x=$item->uplink()) {
$x->uncollected_echomail = $item->uncollected_echomail;
$x->uncollected_netmail = $item->uncollected_netmail;
$x->uncollected_files = $item->uncollected_files;

View File

@ -178,6 +178,7 @@ class NodelistImport implements ShouldQueue
}
$node = 0;
$role = NULL;
switch ($fields[0]) {
case 'Zone':
@ -193,7 +194,6 @@ class NodelistImport implements ShouldQueue
$region = 0;
$host = 0;
$hub_id = NULL;
$role = Address::NODE_ZC;
break;
@ -201,14 +201,12 @@ class NodelistImport implements ShouldQueue
$region = (int)$fields[1];
$host = (int)$fields[1];
$hub_id = NULL;
$role = Address::NODE_RC;
break;
case 'Host':
$host = (int)$fields[1];
$hub_id = NULL;
$role = Address::NODE_NC;
break;
@ -238,7 +236,6 @@ class NodelistImport implements ShouldQueue
case '':
$node = $fields[1];
$role = Address::NODE_ACTIVE;
break;
default:
@ -431,7 +428,7 @@ class NodelistImport implements ShouldQueue
$so->sysop = $sysop;
// We have the same name has changed (except for ZC/RC addresses)
} elseif (($so->name !== $system) && (! ((Address::NODE_ZC|Address::NODE_RC|Address::NODE_NC) & $ao->role))) {
} elseif (($so->name !== $system) && (! ((Address::NODE_ZC|Address::NODE_RC|Address::NODE_NC) & $ao->role_id))) {
Log::alert(sprintf('%s:! System Name changed for BBS [%s:%s] to [%s]',
self::LOGKEY,$so->id,$so->name,$system));
@ -499,6 +496,7 @@ class NodelistImport implements ShouldQueue
throw new \Exception($e->getMessage());
}
// @todo This should be a bit test ($ao->rule & Address::NODE_PVT)?
if ($methods->count() && ($ao->role != Address::NODE_PVT)) {
$methods->transform(function($item) { $item['active'] = Arr::get($item,'active',TRUE); return $item; });
$so->mailers()->sync($methods);
@ -519,7 +517,7 @@ class NodelistImport implements ShouldQueue
try {
$so->addresses()->save($ao);
if ($ao->role === Address::NODE_HC)
if ($ao->role_id === Address::NODE_HC)
$hub_id = $ao->id;
$no->addresses()->attach($ao,['role'=>$ao->role]);

View File

@ -44,7 +44,7 @@ class SystemHeartbeat #implements ShouldQueue
->whereNotNull('pollmode')
->where(function($query) {
return $query
->where('role','<',Address::NODE_ACTIVE)
->where('role','<',Address::NODE_NN)
->orWhereNotNull('heartbeat');
})
->when(! $this->force,function($query) {
@ -62,7 +62,7 @@ class SystemHeartbeat #implements ShouldQueue
if (Job::where('queue','poll')->get()->pluck('command.address.id')->search($oo->id) === FALSE) {
if ((! $oo->system->last_session)
|| ($oo->system->hearbeat && ($oo->system->last_session->addHours($oo->system->heartbeat) < Carbon::now()))
|| ((! $oo->system->hearbeat) && ($oo->role < Address::NODE_ACTIVE) && ($oo->system->last_session->addHours(6) < Carbon::now())))
|| ((! $oo->system->hearbeat) && ($oo->role_id < Address::NODE_NN) && ($oo->system->last_session->addHours(6) < Carbon::now())))
{
Log::info(sprintf('%s:- Polling [%s] (%s) - we havent seen them since [%s], heartbeat [%d]',
self::LOGKEY,

File diff suppressed because it is too large Load Diff

View File

@ -58,8 +58,7 @@ class Echoarea extends Model
public function addresses_active()
{
return $this->belongsToMany(Address::class)
->activeFTN();
return $this->belongsToMany(Address::class);
}
public function domain()

View File

@ -194,7 +194,7 @@ class System extends Model
*/
public function full_name(Address $o): string
{
switch ($o->attributes['role']) {
switch ($o->role_id) {
case Address::NODE_ZC;
return sprintf('ZC-%s-%05d',$o->zone->domain->name,$o->zone->zone_id);
@ -205,7 +205,7 @@ class System extends Model
return sprintf('NC-%s-%05d',$o->zone->domain->name,$o->host_id);
case Address::NODE_HC;
case Address::NODE_ACTIVE;
case Address::NODE_NN;
default:
return $this->name;
}
@ -218,9 +218,8 @@ class System extends Model
* @param Zone $o
* @param int $type
* @return Collection
* @todo This doesnt return sorted addresses, so it is possible that a node address is returned first, before a NC/HC, etc
*/
public function match(Zone $o,int $type=(Address::NODE_NC|Address::NODE_HC|Address::NODE_ACTIVE|Address::NODE_PVT|Address::NODE_POINT)): Collection
public function match(Zone $o,int $type=(Address::NODE_NC|Address::NODE_HC|Address::NODE_NN|Address::NODE_POINT)): Collection
{
$akas = $this->akas
->where(function($item) use($o) {
@ -228,9 +227,7 @@ class System extends Model
});
return ($akas->count() > 1)
? $akas->filter(function($item) use ($type) {
return $item->role & $type;
})
? $akas->filter(function($item) use ($type) { return $item->role_id & $type;})
: $akas;
}
@ -241,7 +238,7 @@ class System extends Model
* @param int $type
* @return Collection
*/
public function inMyZones(Collection $addresses,int $type=(Address::NODE_HC|Address::NODE_ACTIVE|Address::NODE_PVT|Address::NODE_POINT)): Collection
public function inMyZones(Collection $addresses,int $type=(Address::NODE_HC|Address::NODE_NN|Address::NODE_POINT)): Collection
{
$myzones = $this->addresses->pluck('zone_id')->unique();

View File

@ -101,9 +101,8 @@ class User extends Authenticatable implements MustVerifyEmail
}
/**
* Return the zones that this user is ZC for
*
* @return Collection
* @deprecated not used - but if it is, probably could use Address::points()?
*/
public function points(): Collection
{
@ -122,8 +121,8 @@ class User extends Authenticatable implements MustVerifyEmail
*/
public function zc(): Collection
{
$this->load('systems.addresses');
$this->load('systems.addresses.nodes_hub');
return $this->systems->pluck('addresses')->flatten()->where('role',Address::NODE_ZC);
return $this->systems->pluck('addresses')->flatten()->where('role_id',Address::NODE_ZC);
}
}

View File

@ -55,7 +55,7 @@ class AddressLink extends Netmails
$ao->system->sysop,
$ao->ftn3d,
url('/link'),
$ao->set_activation($this->uo)
$ao->activation_set($this->uo)
));
$o->msg = $msg->render();

View File

@ -117,7 +117,7 @@ function our_address(Domain|Address $o=NULL): Collection|Address|NULL
$filter = $our->filter(function($item) use ($o) { return $item->zone->domain_id === $o->zone->domain_id; })->sortBy('role');
// If we are looking for a specific address, and there is only 1 result, return it, otherwise return what we have
if (config('fido.strict') && ($x=$filter->filter(function($item) use ($o) { return $item->role <= $o->role; })->sortBy('role'))->count())
if (config('fido.strict') && ($x=$filter->filter(function($item) use ($o) { return $item->role_id <= $o->role_id; })->sortBy('role'))->count())
$filter = $x;
return $filter->last();

View File

@ -0,0 +1,24 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
DB::update('ALTER TABLE addresses ALTER COLUMN role DROP NOT NULL');
}
/**
* Reverse the migrations.
*/
public function down(): void
{
//
}
};

View File

@ -120,7 +120,7 @@ class TestNodeHierarchy extends Seeder
'node_id'=>$nid,
'point_id'=>0,
'system_id'=>$so->id,
'role'=>Address::NODE_ACTIVE,
'role'=>Address::NODE_NN,
'created_at'=>Carbon::now(),
'updated_at'=>Carbon::now(),
]);
@ -167,7 +167,7 @@ class TestNodeHierarchy extends Seeder
'node_id'=>$nid,
'point_id'=>0,
'system_id'=>$so->id,
'role'=>Address::NODE_ACTIVE,
'role'=>Address::NODE_NN,
'created_at'=>Carbon::now(),
'updated_at'=>Carbon::now(),
]);
@ -214,7 +214,7 @@ class TestNodeHierarchy extends Seeder
'node_id'=>$nid,
'point_id'=>0,
'system_id'=>$so->id,
'role'=>Address::NODE_ACTIVE,
'role'=>Address::NODE_NN,
'created_at'=>Carbon::now(),
'updated_at'=>Carbon::now(),
]);
@ -251,7 +251,7 @@ class TestNodeHierarchy extends Seeder
'point_id'=>0,
'system_id'=>$so->id,
'hub_id'=>$hub->id,
'role'=>Address::NODE_ACTIVE,
'role'=>Address::NODE_NN,
'created_at'=>Carbon::now(),
'updated_at'=>Carbon::now(),
]);

View File

@ -32,14 +32,14 @@
<dd><a href="{{ url('echoarea') }}">Echoareas</a></dd>
<dd><a href="{{ url('filearea') }}">Fileareas</a></dd>
</dl>
@endif
@can('admin')
<dl>
<dt>System Admin</dt>
<dd><a href="{{ url('system/ours') }}">This Host Systems</a></dd>
</dl>
@endif
@can('admin')
<dl>
<dt>Users</dt>
<dd><a href="{{ url('user/addedit') }}">Create</a></dd>

View File

@ -177,7 +177,7 @@
<td>{{ $o->zone->domain->name }}</td>
<td>
<a href="{{ url('system/addedit',$o->system_id) }}">{{ $o->system->name }}</a>
@if (($x=$o->parent()) && ($x->id !== $o->id))
@if (($x=$o->uplink()) && ($x->id !== $o->id))
<br><small>[via <a href="{{ url('system/addedit',$x->system_id) }}">{{ $x->ftn4d }}</a>]</small>
@endif
</td>

View File

@ -1,3 +1,7 @@
@php
use App\Models\Address;
@endphp
<!-- $o=System::class -->
@extends('layouts.app')
@ -135,10 +139,10 @@
<a href="{{ url('system/address/sus',[$oo->id]) }}" title="@if($oo->active)Pause @else Activate @endif Address"><i class="bi @if($oo->active)bi-pause-circle @else bi-play-circle @endif"></i></a>
<a href="{{ url('system/address/mov',[$o->id,$oo->id]) }}" title="Move Address to another System"><i class="bi bi-arrow-right-square"></i></a>
<a href="{{ url('system/address/del',[$oo->id]) }}" title="Delete Address"><i class="bi bi-trash"></i></a>
@if ((\App\Models\Address::NODE_HC|\App\Models\Address::NODE_ACTIVE) & $oo->role)
@if ((Address::NODE_HC|Address::NODE_NN) & $oo->role_id)
<a href="{{ url('system/address/pro',[$oo->id]) }}" title="Promote Address"><i class="bi bi-arrow-up-square"></i></a>
@endif
@if ((\App\Models\Address::NODE_NC|\App\Models\Address::NODE_HC) & $oo->role)
@if ((Address::NODE_NC|Address::NODE_HC) & $oo->role_id)
<a href="{{ url('system/address/dem',[$oo->id]) }}" title="Demote Address"><i class="bi bi-arrow-down-square"></i></a>
@endif
@endif
@ -276,70 +280,7 @@
<div id="collapse_routing" class="accordion-collapse collapse {{ ($flash=='routing') ? 'show' : '' }}" aria-labelledby="routing" data-bs-parent="#accordion_homepage">
<div class="accordion-body">
<div class="row">
<!-- Zone mail sent to -->
<div class="col-6">
@if(! $o->setup && ($x=\App\Models\Zone::active()
->whereIn('id',$o->zones->pluck('id'))
->whereNotIn('id',$o->sessions->pluck('id'))
->get())->count())
<h4>This host's mail is sent to:</h4>
<table class="table monotable">
<thead>
<tr>
<th>AKA</th>
<th>Uplink</th>
</tr>
</thead>
<tbody>
@foreach($x as $zo)
@foreach ($o->match($zo,\App\Models\Address::NODE_ALL) as $oo)
<tr>
<td>{{ $oo->ftn }}</td>
<td>
@if ($x=$oo->parent())
{{ $x->ftn4d }}
@else
None
@endif
</td>
</tr>
@endforeach
@endforeach
</tbody>
</table>
@endif
</div>
<!-- Systems this host collects for -->
<div class="col-6">
@if($o->sessions->count())
<h4>This host collects mail for the following systems:</h4>
<table class="table monotable">
<thead>
<tr>
<th>AKA</th>
<th>Downlink(s)</th>
</tr>
</thead>
<tbody>
@foreach ($o->sessions->sortBy('zone_id') as $zo)
@foreach ($o->match($zo,\App\Models\Address::NODE_ALL) as $oo)
<tr>
<td>{{ $oo->ftn }}</td>
<td>{!! (($x=$oo->children()) && $x->count()) ? $x->pluck('ftn4d')->join('<br>') : 'None' !!}</td>
</tr>
@endforeach
@endforeach
</tbody>
</table>
@endif
</div>
</div>
@include('system.widget.routing')
</div>
</div>
</div>

View File

@ -0,0 +1,68 @@
@php
use App\Models\{Address,Zone};
@endphp
<div class="row">
<!-- Zone mail sent to -->
<div class="col-6">
@if(! $o->setup && ($x=Zone::active()
->whereIn('id',$o->zones->pluck('id'))
->whereNotIn('id',$o->sessions->pluck('id'))
->get())->count())
<h4>This host's mail is sent to:</h4>
<table class="table monotable">
<thead>
<tr>
<th>AKA</th>
<th>Uplink</th>
</tr>
</thead>
<tbody>
@foreach($x as $zo)
@foreach ($o->match($zo,Address::NODE_ALL) as $oo)
<tr>
<td>{{ $oo->ftn }}</td>
<td>
@if ($x=$oo->uplink())
{{ $x->ftn4d }}
@else
None
@endif
</td>
</tr>
@endforeach
@endforeach
</tbody>
</table>
@endif
</div>
<!-- Systems this host collects for -->
<div class="col-6">
@if($o->sessions->count())
<h4>This host collects mail for the following systems:</h4>
<table class="table monotable">
<thead>
<tr>
<th>AKA</th>
<th>For Systems(s)</th>
</tr>
</thead>
<tbody>
@foreach ($o->sessions->sortBy('zone_id') as $zo)
@foreach ($o->match($zo,Address::NODE_ALL) as $oo)
<tr>
<td>{{ $oo->ftn }}</td>
<td>{!! (($x=$oo->downlinks()) && $x->count()) ? $x->pluck('ftn')->join('<br>') : 'None' !!}</td>
</tr>
@endforeach
@endforeach
</tbody>
</table>
@endif
</div>
</div>

View File

@ -1,3 +1,7 @@
@php
use App\Models\{Mailer,User};
@endphp
<!-- $o = System::class -->
<div class="row">
<div class="col-xl-9 col-12">
@ -14,7 +18,7 @@
<span class="input-group-text"><i class="bi bi-people-fill"></i></span>
<select style="width: 80%;" class="form-select @error('users') is-invalid @enderror" id="users" name="users[]">
<option value="">&nbsp;</option>
@foreach (\App\Models\User::orderBy('name')->active()->get() as $uo)
@foreach (User::orderBy('name')->active()->get() as $uo)
<option value="{{ $uo->id }}" @if(in_array($uo->id,old('users',$o->users->pluck('id')->toArray())))selected @endif>{{ $uo->name }} <small>({{ $uo->email }})</small></option>
@endforeach
</select>
@ -145,7 +149,7 @@
<!-- Mailer Ports -->
<div class="row pt-0">
<div class="col-3">
@foreach (\App\Models\Mailer::all() as $mo)
@foreach (Mailer::all() as $mo)
@php($x=$o->mailers->find($mo))
<div class="row pt-0">
<div class="col-12">
@ -282,6 +286,7 @@
</div>
<div class="row">
<!-- @todo This is only relevant for uplinks, so hide it if this system isnt an uplink -->
<div class="col-12 @if((old('pollmode') === "0") || is_null($o->pollmode))d-none @endif" id="heartbeat_option">
@can('admin',$o)
<div class="row p-0">

View File

@ -46,8 +46,8 @@ use App\Models\{Address,Domain,Setup,System};
* + See COMMON
* + Everything else is sent to the HUB or Host or RC (our uplink)
*
* @see Address::parent()
* @see Address::children()
* @see Address::uplink()
* @see Address::downlinks()
*/
class RoutingTest extends TestCase
{
@ -106,9 +106,9 @@ class RoutingTest extends TestCase
// Pick ZC without any session info - we have 0 children
$ao = Address::findFTN('101:0/0@a');
$this->assertEquals($ao->role,Address::NODE_ZC);
$this->assertCount(0,$ao->children());
$this->assertNull($ao->parent());
$this->assertEquals($ao->role_id,Address::NODE_ZC);
$this->assertCount(0,$ao->downstream());
$this->assertNull($ao->uplink());
}
// If we have a ZC, make sure we are routing to all it's children
@ -117,7 +117,7 @@ class RoutingTest extends TestCase
$this->session_zc();
$ao = Address::findFTN('101:0/0@a');
$this->assertCount(935,$ao->children());
$this->assertCount(935,$ao->downstream());
}
// An RC's parent should be the ZC, when we have session details with parent
@ -126,8 +126,8 @@ class RoutingTest extends TestCase
$this->session_zc();
$ao = Address::findFTN('101:1/0@a');
$this->assertEquals($ao->role,Address::NODE_RC);
$this->assertEquals('101:0/0.0@a',$ao->parent()->ftn);
$this->assertEquals($ao->role_id,Address::NODE_RC);
$this->assertEquals('101:0/0.0@a',$ao->uplink()->ftn);
}
// Get a list of active addresses in a Region
@ -136,7 +136,7 @@ class RoutingTest extends TestCase
$this->session_rc();
$ao = Address::findFTN('100:1/0@a');
$this->assertEquals(185,$ao->children()->count());
$this->assertCount(185,$ao->downstream());
}
// An RCs node still collects mail from the RC
@ -146,8 +146,8 @@ class RoutingTest extends TestCase
// An RCs node should still be the RC
$ao = Address::findFTN('100:1/100@a');
$this->assertEquals($ao->role,Address::NODE_ACTIVE);
$this->assertEquals('100:1/0.0@a',$ao->parent()->ftn);
$this->assertEquals($ao->role_id,Address::NODE_NN);
$this->assertEquals('100:1/0.0@a',$ao->uplink()->ftn);
}
// An NC collects mail for its children
@ -157,8 +157,8 @@ class RoutingTest extends TestCase
// A NCs parent should still be the RC
$ao = Address::findFTN('100:10/0@a');
$this->assertEquals($ao->role,Address::NODE_NC);
$this->assertEquals('100:1/0.0@a',$ao->parent()->ftn);
$this->assertEquals($ao->role_id,Address::NODE_NC);
$this->assertEquals('100:1/0.0@a',$ao->uplink()->ftn);
}
// A Hub still collects mail from NC
@ -168,8 +168,8 @@ class RoutingTest extends TestCase
// A Hubs parent should still be the NC
$ao = Address::findFTN('100:10/20.0@a');
$this->assertEquals($ao->role,Address::NODE_HC);
$this->assertEquals('100:1/0.0@a',$ao->parent()->ftn);
$this->assertEquals($ao->role_id,Address::NODE_HC);
$this->assertEquals('100:1/0.0@a',$ao->uplink()->ftn);
}
// A Hub's node still collects mail from Hub
@ -179,8 +179,8 @@ class RoutingTest extends TestCase
// A Hubs node should still be the Hub
$ao = Address::findFTN('100:10/22.0@a');
$this->assertEquals($ao->role,Address::NODE_ACTIVE);
$this->assertEquals('100:1/0.0@a',$ao->parent()->ftn);
$this->assertEquals($ao->role_id,Address::NODE_NN);
$this->assertEquals('100:1/0.0@a',$ao->uplink()->ftn);
}
// An RCs parent is us even if we have session details for another RC
@ -189,7 +189,7 @@ class RoutingTest extends TestCase
$this->session_rc();
$ao = Address::findFTN('100:2/0@a');
$this->assertNull($ao->parent()?->ftn);
$this->assertNull($ao->uplink()?->ftn);
}
// If we also have session details for an NC, then there are less RC nodes
@ -199,7 +199,7 @@ class RoutingTest extends TestCase
$this->session_nc();
$ao = Address::findFTN('100:1/0@a');
$this->assertCount(185-36,$ao->children());
$this->assertCount(185-36,$ao->downstream());
}
// If we also have session details for an Hub, then there are less RC nodes
@ -211,10 +211,10 @@ class RoutingTest extends TestCase
$ao->system->sessions()->attach([$ao->zone_id=>['sespass'=>'ABCD']]);
$ao = Address::findFTN('100:1/0@a');
$this->assertCount(185-6,$ao->children());
$this->assertCount(185,$ao->downstream());
$ao = Address::findFTN('100:10/22@a');
$this->assertEquals('100:10/20.0@a',$ao->parent()->ftn);
$this->assertEquals('100:10/20.0@a',$ao->uplink()->ftn);
}
// If we also have session details for an Hub, then there are less RC nodes
@ -223,7 +223,7 @@ class RoutingTest extends TestCase
$this->session_hub();
$ao = Address::findFTN('100:10/22@a');
$this->assertEquals('100:10/20.0@a',$ao->parent()->ftn);
$this->assertEquals('100:10/20.0@a',$ao->uplink()->ftn);
}
// When we have an RC with session details, we route to all its children
@ -232,7 +232,7 @@ class RoutingTest extends TestCase
$this->session_nc();
$ao = Address::findFTN('100:10/0@a');
$this->assertCount(35,$ao->children());
$this->assertCount(35,$ao->downstream());
}
public function test_complex_rc_nc_hc()
@ -242,29 +242,29 @@ class RoutingTest extends TestCase
$this->session_hub();
$ao = Address::findFTN('100:1/100.0@a');
$this->assertCount(0,$ao->children());
$this->assertEquals('100:1/0.0@a',$ao->parent()->ftn);
$this->assertCount(0,$ao->downstream());
$this->assertEquals('100:1/0.0@a',$ao->uplink()->ftn);
// RC
$ao = Address::findFTN('100:1/0.0@a');
$this->assertCount(186-1-30-6,$ao->children());
$this->assertCount(186-1-30-6,$ao->downstream());
$ao = Address::findFTN('100:11/0.0@a');
$this->assertEquals('100:1/0.0@a',$ao->parent()->ftn);
$this->assertEquals('100:1/0.0@a',$ao->uplink()->ftn);
// NC
$ao = Address::findFTN('100:10/0.0@a');
$this->assertCount(36-1-6,$ao->children());
$this->assertCount(36-1-6,$ao->downstream());
$ao = Address::findFTN('100:10/10.0@a');
$this->assertEquals('100:10/0.0@a',$ao->parent()->ftn);
$this->assertEquals('100:10/0.0@a',$ao->uplink()->ftn);
// HC
$ao = Address::findFTN('100:10/20.0@a');
$this->assertCount(6-1,$ao->children());
$this->assertCount(6-1,$ao->downstream());
$ao = Address::findFTN('100:10/22.0@a');
$this->assertEquals('100:10/20.0@a',$ao->parent()->ftn);
$this->assertEquals('100:10/20.0@a',$ao->uplink()->ftn);
}
public function test_complex_rc_nc_hc_us()
@ -283,29 +283,29 @@ class RoutingTest extends TestCase
$ao->system->sessions()->attach([$ao->zone_id=>['sespass'=>'ABCD']]);
$ao = Address::findFTN('100:1/100.0@a');
$this->assertCount(0,$ao->children());
$this->assertEquals('100:1/0.0@a',$ao->parent()?->ftn);
$this->assertCount(0,$ao->downstream());
$this->assertEquals('100:1/0.0@a',$ao->uplink()?->ftn);
// RC
$ao = Address::findFTN('100:1/0.0@a');
$this->assertCount(186-36-36-1,$ao->children());
$this->assertCount(186-36-36-1,$ao->downstream());
$ao = Address::findFTN('100:11/0.0@a');
$this->assertEquals('100:11/0.0@a',$ao->parent()->ftn);
$this->assertEquals('100:11/0.0@a',$ao->uplink()->ftn);
// NC
$ao = Address::findFTN('100:10/0.0@a');
$this->assertCount(36-6-1,$ao->children());
$this->assertCount(36-6-1,$ao->downstream());
$ao = Address::findFTN('100:10/10.0@a');
$this->assertNull($ao->parent()?->ftn);
$this->assertNull($ao->uplink()?->ftn);
// HC
$ao = Address::findFTN('100:10/20.0@a');
$this->assertCount(6-1,$ao->children());
$this->assertCount(6-1,$ao->downstream());
$ao = Address::findFTN('100:10/22.0@a');
$this->assertEquals('100:10/20.0@a',$ao->parent()->ftn);
$this->assertEquals('100:10/20.0@a',$ao->uplink()->ftn);
Cache::forget('so');
}
@ -330,9 +330,9 @@ class RoutingTest extends TestCase
$ao->system->sessions()->attach([$ao->zone_id=>['sespass'=>'ABCD']]);
$ao = Address::findFTN('100:10/21.2@a');
$this->assertEquals('100:10/21.0@a',$ao->parent()?->ftn);
$this->assertEquals('100:10/21.0@a',$ao->uplink()?->ftn);
$ao = Address::findFTN('100:10/21@a');
$this->assertCount(1,$ao->children());
$this->assertCount(1,$ao->downstream());
}
}