When we have multiple addresses, add we want a specific address, return the lowest role, or if strict mode enable, return the lowest role that is higher than the target
This commit is contained in:
parent
301fc33d2f
commit
27c050dc38
@ -48,6 +48,7 @@ MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
|
|||||||
|
|
||||||
FIDO_DIR=fido
|
FIDO_DIR=fido
|
||||||
FIDO_PACKET_KEEP=
|
FIDO_PACKET_KEEP=
|
||||||
|
FIDO_STRICT=FALSE
|
||||||
|
|
||||||
FILESYSTEM_DISK=s3
|
FILESYSTEM_DISK=s3
|
||||||
AWS_ACCESS_KEY_ID=
|
AWS_ACCESS_KEY_ID=
|
||||||
|
@ -70,7 +70,7 @@ class HubStats extends Dynamic
|
|||||||
|
|
||||||
$header = "| %-12s | %4d | %3d | %3d | %16s | %5s | %5s |\r\n";
|
$header = "| %-12s | %4d | %3d | %3d | %16s | %5s | %5s |\r\n";
|
||||||
|
|
||||||
$output = sprintf("Hub Status for [%s] as at [%s]\r\n",our_address($this->ao->zone->domain)->where('active',TRUE)->first()->ftn,$date);
|
$output = sprintf("Hub Status for [%s] as at [%s]\r\n",our_address($this->ao->zone->domain,$this->ao)->ftn,$date);
|
||||||
$output .= "\r";
|
$output .= "\r";
|
||||||
$output .= "+--------------+------+-----+-----+------------------+-------+-------+\r\n";
|
$output .= "+--------------+------+-----+-----+------------------+-------+-------+\r\n";
|
||||||
$output .= "| FTN | ECHO | NET |FILES| LAST SESSION | MODE |AUTOHLD|\r\n";
|
$output .= "| FTN | ECHO | NET |FILES| LAST SESSION | MODE |AUTOHLD|\r\n";
|
||||||
|
@ -714,6 +714,7 @@ class Address extends Model
|
|||||||
*
|
*
|
||||||
* @param bool $update
|
* @param bool $update
|
||||||
* @return Packet|null
|
* @return Packet|null
|
||||||
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public function getNetmail(bool $update=FALSE): ?Packet
|
public function getNetmail(bool $update=FALSE): ?Packet
|
||||||
{
|
{
|
||||||
@ -769,7 +770,7 @@ class Address extends Model
|
|||||||
public function getPacket(Collection $msgs,string $passwd=NULL): ?Packet
|
public function getPacket(Collection $msgs,string $passwd=NULL): ?Packet
|
||||||
{
|
{
|
||||||
$s = Setup::findOrFail(config('app.id'));
|
$s = Setup::findOrFail(config('app.id'));
|
||||||
$ao = $s->system->match($this->zone)->first();
|
$ao = our_address($this->zone->domain,$this);
|
||||||
|
|
||||||
// If we dont match on the address, we cannot pack mail for that system
|
// If we dont match on the address, we cannot pack mail for that system
|
||||||
if (! $ao) {
|
if (! $ao) {
|
||||||
|
@ -65,7 +65,9 @@ class System extends Model
|
|||||||
public function akas()
|
public function akas()
|
||||||
{
|
{
|
||||||
return $this->hasMany(Address::class)
|
return $this->hasMany(Address::class)
|
||||||
->active();
|
->active()
|
||||||
|
->FTNorder()
|
||||||
|
->orderBy('role','ASC');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function mailers()
|
public function mailers()
|
||||||
|
@ -85,16 +85,24 @@ if (! function_exists('hexstr')) {
|
|||||||
* Return our addresses.
|
* Return our addresses.
|
||||||
* If zone provided, limit the list to those within the zone
|
* If zone provided, limit the list to those within the zone
|
||||||
*
|
*
|
||||||
* @param Domain|NULL $do
|
* @param Domain|NULL $do Limit the addresses for the specific domain
|
||||||
* @return Collection
|
* @param Address|null $ao If address is presented, show the address we use when talking to that address
|
||||||
|
* @return Collection|Address|NULL
|
||||||
*/
|
*/
|
||||||
function our_address(Domain $do=NULL): Collection
|
function our_address(Domain $do=NULL,Address $ao=NULL): Collection|Address|NULL
|
||||||
{
|
{
|
||||||
$our = Setup::findOrFail(config('app.id'))->system->addresses;
|
$our = Setup::findOrFail(config('app.id'))
|
||||||
|
->system
|
||||||
|
->akas;
|
||||||
|
|
||||||
return $do
|
if ($do)
|
||||||
? $our->filter(function($item) use ($do) { return $item->zone->domain_id === $do->id; })
|
$our = $our->filter(function($item) use ($do) { return $item->zone->domain_id === $do->id; });
|
||||||
: $our;
|
|
||||||
|
// If we are looking for a specific address, and there is only 1 result, return it, otherwise return what we have
|
||||||
|
if ($ao && config('fido.strict') && ($x=$our->filter(function($item) use ($ao) { return $item->role <= $ao->role; }))->count())
|
||||||
|
$our = $x;
|
||||||
|
|
||||||
|
return $ao ? $our->last() : $our;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -34,4 +34,6 @@ return [
|
|||||||
// Number of messages in a packet that will result in them being queued for processing
|
// Number of messages in a packet that will result in them being queued for processing
|
||||||
'queue_msgs' => env('FIDO_QUEUE_MSGS', 50),
|
'queue_msgs' => env('FIDO_QUEUE_MSGS', 50),
|
||||||
|
|
||||||
|
// Strict mode enforces what address we present to uplinks, when we carry more than 1 address with different roles
|
||||||
|
'strict' => env('FIDO_STRICT',FALSE),
|
||||||
];
|
];
|
Loading…
Reference in New Issue
Block a user