Added tool to list node addresses and the address we use,
Fix address edit which reactivated the address, Fix correct icons when using address merge, We only advertise validated addresses and use validated addresses for routing, Show our address on known AKA screen
This commit is contained in:
@@ -84,14 +84,27 @@ if (! function_exists('hexstr')) {
|
||||
|
||||
/**
|
||||
* Return our addresses.
|
||||
*
|
||||
* We have two address types:
|
||||
* + a) address that we advertise to receive mail and use to package up mail (Public)
|
||||
* + b) address that we accept and process mail
|
||||
*
|
||||
* a is a subset of b, where b might have addresses we used in the past but no longer (but mail still comes in, and we
|
||||
* dont want to send out mail with those addresses anymore)
|
||||
*
|
||||
* Public addresses are when validated is set to true
|
||||
* When determining our public addresses for a specific Address (when Address::class is passed), we only return addresses
|
||||
* when security is not null
|
||||
*
|
||||
* If domain provided, limit the list to those within the domain - returning a Collection::class
|
||||
* If address provided, return our address that would be used for the provided address - return Address::class
|
||||
*
|
||||
* @param Domain|Address|null $o - Domain or Address
|
||||
* @param Domain|Address|null $o Domain or Address
|
||||
* @param bool $public Return only public addresses
|
||||
* @return Collection|Address|NULL
|
||||
* @throws Exception
|
||||
*/
|
||||
function our_address(Domain|Address $o=NULL): Collection|Address|NULL
|
||||
function our_address(Domain|Address $o=NULL,bool $public=TRUE): Collection|Address|NULL
|
||||
{
|
||||
if (! Config::has('setup'))
|
||||
Config::set('setup',Setup::findOrFail(config('app.id')));
|
||||
@@ -99,7 +112,7 @@ function our_address(Domain|Address $o=NULL): Collection|Address|NULL
|
||||
$so = Config::get('setup');
|
||||
$so->loadMissing([
|
||||
'system:id,name,sysop,location',
|
||||
'system.akas:addresses.id,addresses.zone_id,region_id,host_id,node_id,point_id,addresses.system_id,addresses.active,role',
|
||||
'system.akas:addresses.id,addresses.zone_id,region_id,host_id,node_id,point_id,addresses.system_id,addresses.active,role,validated,security',
|
||||
'system.akas.zone:id,domain_id,zone_id',
|
||||
'system.akas.zone.domain:id,name',
|
||||
]);
|
||||
@@ -117,20 +130,22 @@ function our_address(Domain|Address $o=NULL): Collection|Address|NULL
|
||||
// Looking for addresses in the same domain, and if fido.strict, addresses that have a higher role (ie: uplink)
|
||||
case Address::class:
|
||||
$filter = $so->system->akas
|
||||
->filter(fn($item)=>$item->zone->domain_id === $o->zone->domain_id)
|
||||
->filter(fn($item)=>((! $public) || ($public && $item->validated)) && ($item->zone->domain_id === $o->zone->domain_id))
|
||||
->sortBy('role_id');
|
||||
|
||||
// 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(fn($item)=>$item->role_id <= $o->role_id)->sortBy('role_id'))->count())
|
||||
$filter = $x;
|
||||
|
||||
return $filter->count() ? $filter->last()->unsetRelation('nodes_hub') : NULL;
|
||||
return $filter->count()
|
||||
? ($filter->filter(fn($item)=>$item->region_id === $o->region_id)->count()
|
||||
? $filter->last()
|
||||
: $filter->first())->unsetRelation('nodes_hub')
|
||||
: NULL;
|
||||
|
||||
// Addresses in this domain
|
||||
case Domain::class:
|
||||
return $so->system->akas
|
||||
->filter(fn($item)=>$item->zone->domain_id === $o->id)
|
||||
->sortBy('role_id');
|
||||
->filter(fn($item)=>((! $public) || ($public && $item->validated)) && ($item->zone->domain_id === $o->id));
|
||||
|
||||
// We shouldnt get here
|
||||
default:
|
||||
|
Reference in New Issue
Block a user