2021-06-20 13:03:20 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
2021-07-18 12:10:21 +00:00
|
|
|
use Carbon\Carbon;
|
2021-06-24 10:16:37 +00:00
|
|
|
use Exception;
|
2021-07-30 14:35:52 +00:00
|
|
|
use Illuminate\Database\Eloquent\Collection;
|
2021-06-20 13:03:20 +00:00
|
|
|
use Illuminate\Database\Eloquent\Model;
|
2021-06-25 06:42:12 +00:00
|
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
2021-09-06 13:39:32 +00:00
|
|
|
use Illuminate\Support\Facades\DB;
|
2021-06-20 13:03:20 +00:00
|
|
|
|
2021-07-15 14:54:23 +00:00
|
|
|
use App\Classes\FTN\Packet;
|
2021-06-20 13:03:20 +00:00
|
|
|
use App\Http\Controllers\DomainController;
|
2021-09-06 13:39:32 +00:00
|
|
|
use App\Traits\{ScopeActive,UsePostgres};
|
2021-06-20 13:03:20 +00:00
|
|
|
|
2021-11-20 00:11:17 +00:00
|
|
|
/**
|
|
|
|
* @todo Need to stop this from happening:
|
|
|
|
* In this example nn:3/1 can be defined 3 different ways.
|
|
|
|
* + id | zone_id | region_id | host_id | node_id | point_id | status | role | system_id | hub_id
|
|
|
|
* + ----+---------+-----------+---------+---------+----------+--------+------+-----------+--------
|
|
|
|
* + 533 | 6 | 3 | 0 | 1 | 0 | | 4 | 1 |
|
|
|
|
* + 534 | 6 | 3 | 3 | 1 | 0 | | 2 | 1 |
|
|
|
|
* + 535 | 6 | 0 | 3 | 1 | 0 | | 2 | 1 |
|
|
|
|
*/
|
2021-06-20 13:03:20 +00:00
|
|
|
class Address extends Model
|
|
|
|
{
|
2021-09-06 13:39:32 +00:00
|
|
|
use ScopeActive,SoftDeletes,UsePostgres;
|
2021-06-24 10:16:37 +00:00
|
|
|
|
2021-06-24 13:09:09 +00:00
|
|
|
/* SCOPES */
|
|
|
|
|
|
|
|
public function scopeFTNOrder($query)
|
|
|
|
{
|
|
|
|
return $query
|
|
|
|
->orderBy('region_id')
|
2021-06-25 06:42:12 +00:00
|
|
|
->orderBy('host_id')
|
2021-06-24 13:09:09 +00:00
|
|
|
->orderBy('node_id')
|
|
|
|
->orderBy('point_id');
|
|
|
|
}
|
|
|
|
|
2021-06-20 13:03:20 +00:00
|
|
|
/* RELATIONS */
|
|
|
|
|
2021-07-04 11:47:23 +00:00
|
|
|
/**
|
2021-07-26 11:21:58 +00:00
|
|
|
* Find children dependent on this record
|
2021-07-04 11:47:23 +00:00
|
|
|
*/
|
2021-07-02 13:19:50 +00:00
|
|
|
public function children()
|
|
|
|
{
|
2021-07-26 11:21:58 +00:00
|
|
|
// We have no session data for this address, by definition it has no children
|
|
|
|
if (! $this->session('sespass'))
|
|
|
|
return $this->hasMany(self::class,'id','void');
|
|
|
|
|
2021-08-09 13:35:22 +00:00
|
|
|
if (! $this->session('default')) {
|
|
|
|
switch ($this->role) {
|
|
|
|
case DomainController::NODE_ZC:
|
|
|
|
$children = self::select('addresses.*')
|
|
|
|
->where('zone_id',$this->zone_id);
|
2021-07-26 11:21:58 +00:00
|
|
|
|
2021-08-09 13:35:22 +00:00
|
|
|
break;
|
2021-07-26 11:21:58 +00:00
|
|
|
|
2021-08-09 13:35:22 +00:00
|
|
|
case DomainController::NODE_RC:
|
|
|
|
$children = self::select('addresses.*')
|
|
|
|
->where('zone_id',$this->zone_id)
|
|
|
|
->where('region_id',$this->region_id);
|
2021-07-26 11:21:58 +00:00
|
|
|
|
2021-08-09 13:35:22 +00:00
|
|
|
break;
|
2021-07-26 11:21:58 +00:00
|
|
|
|
2021-08-09 13:35:22 +00:00
|
|
|
case DomainController::NODE_NC:
|
|
|
|
$children = self::select('addresses.*')
|
|
|
|
->where('zone_id',$this->zone_id)
|
|
|
|
->where('region_id',$this->region_id)
|
|
|
|
->where('host_id',$this->host_id);
|
2021-07-26 11:21:58 +00:00
|
|
|
|
2021-08-09 13:35:22 +00:00
|
|
|
break;
|
2021-07-15 14:54:23 +00:00
|
|
|
|
2021-08-09 13:35:22 +00:00
|
|
|
case DomainController::NODE_HC:
|
|
|
|
// Identify our children.
|
|
|
|
$children = self::select('addresses.*')
|
|
|
|
->where('hub_id',$this->id);
|
2021-07-15 14:54:23 +00:00
|
|
|
|
2021-08-09 13:35:22 +00:00
|
|
|
break;
|
|
|
|
|
2021-09-11 13:32:10 +00:00
|
|
|
case DomainController::NODE_UNKNOWN:
|
2021-08-09 13:35:22 +00:00
|
|
|
case DomainController::NODE_ACTIVE:
|
|
|
|
case DomainController::NODE_POINT:
|
|
|
|
// Nodes dont have children, but must return a relationship instance
|
|
|
|
return $this->hasOne(self::class,NULL,'void');
|
2021-07-26 11:21:58 +00:00
|
|
|
|
2021-08-09 13:35:22 +00:00
|
|
|
default:
|
|
|
|
throw new Exception('Unknown role: '.serialize($this->role));
|
|
|
|
}
|
2021-07-15 14:54:23 +00:00
|
|
|
|
2021-08-09 13:35:22 +00:00
|
|
|
} else {
|
|
|
|
$children = self::select('addresses.*')
|
|
|
|
->where('zone_id',$this->zone_id);
|
2021-07-26 11:21:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Remove any children that we have session details for (SAME AS HC)
|
|
|
|
$sessions = self::select('hubnodes.*')
|
|
|
|
->join('system_zone',['system_zone.system_id'=>'addresses.system_id','system_zone.zone_id'=>'addresses.zone_id'])
|
|
|
|
->join('addresses as hubnodes',['hubnodes.zone_id'=>'addresses.zone_id','hubnodes.id'=>'addresses.id'])
|
|
|
|
->where('addresses.zone_id',$this->zone_id)
|
|
|
|
->where('addresses.system_id','<>',$this->system_id)
|
|
|
|
->whereIN('addresses.system_id',$children->get()->pluck('system_id'));
|
|
|
|
|
|
|
|
// For each of the session, identify their children
|
|
|
|
$session_kids = collect();
|
|
|
|
foreach ($sessions->get() as $so)
|
|
|
|
$session_kids = $session_kids->merge(($x=$so->children) ? $x->pluck('id') : []);
|
|
|
|
|
|
|
|
// ZC's receive all mail, except for defined nodes, and defined hubs/hosts/rcs
|
|
|
|
return $this->hasMany(self::class,'zone_id','zone_id')
|
|
|
|
->whereIn('id',$children->get()->pluck('id')->toArray())
|
|
|
|
->whereNotIn('id',$sessions->get()->pluck('id')->toArray())
|
|
|
|
->whereNotIn('id',$session_kids->toArray())
|
|
|
|
->where('system_id','<>',$this->system_id)
|
|
|
|
->select('addresses.*')
|
|
|
|
->orderBy('region_id')
|
|
|
|
->orderBy('host_id')
|
|
|
|
->orderBy('node_id')
|
|
|
|
->orderBy('point_id')
|
|
|
|
->with(['zone.domain']);
|
|
|
|
}
|
|
|
|
|
2021-08-25 12:13:49 +00:00
|
|
|
public function echoareas()
|
|
|
|
{
|
|
|
|
return $this->belongsToMany(Echoarea::class)
|
|
|
|
->withPivot(['subscribed']);
|
|
|
|
}
|
|
|
|
|
2021-07-26 11:21:58 +00:00
|
|
|
/**
|
|
|
|
* Who we send this systems mail to.
|
|
|
|
*
|
|
|
|
* @return Address|null
|
|
|
|
* @throws Exception
|
|
|
|
*/
|
|
|
|
public function parent(): ?Address
|
|
|
|
{
|
|
|
|
// If we are have session password, then we dont have a parent
|
|
|
|
if ($this->session('sespass'))
|
|
|
|
return $this;
|
|
|
|
|
|
|
|
switch ($this->role) {
|
2021-08-09 13:35:22 +00:00
|
|
|
// ZCs dont have parents, but we may have a default
|
2021-07-26 11:21:58 +00:00
|
|
|
case DomainController::NODE_ZC:
|
2021-08-09 13:35:22 +00:00
|
|
|
if (($x=$this->zone->systems->where('pivot.default',TRUE))->count())
|
|
|
|
return $x->first()->match($this->zone)->first();
|
|
|
|
else
|
|
|
|
return NULL;
|
2021-07-26 11:21:58 +00:00
|
|
|
|
|
|
|
// RC
|
|
|
|
case DomainController::NODE_RC:
|
|
|
|
$parent = self::where('zone_id',$this->zone_id)
|
|
|
|
->where('region_id',0)
|
|
|
|
->where('host_id',0)
|
|
|
|
->where('node_id',0)
|
|
|
|
->single();
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
// Hosts
|
|
|
|
case DomainController::NODE_NC:
|
|
|
|
// See if we have a RC
|
|
|
|
$parent = self::where('zone_id',$this->zone_id)
|
|
|
|
->where('region_id',$this->region_id)
|
|
|
|
->where('host_id',0)
|
|
|
|
->where('node_id',0)
|
|
|
|
->single();
|
|
|
|
|
|
|
|
if (! $parent) {
|
|
|
|
// See if we have a RC
|
|
|
|
$parent = self::where('zone_id',$this->zone_id)
|
|
|
|
->where('region_id',0)
|
|
|
|
->where('host_id',0)
|
|
|
|
->where('node_id',0)
|
|
|
|
->single();
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
// Hubs
|
|
|
|
case DomainController::NODE_HC:
|
|
|
|
// Normal Nodes
|
|
|
|
case DomainController::NODE_ACTIVE:
|
|
|
|
// If we are a child of a hub, then check our hub
|
|
|
|
$parent = (($this->hub_id)
|
|
|
|
? self::where('id',$this->hub_id)
|
|
|
|
: self::where('zone_id',$this->zone_id)
|
|
|
|
->where('region_id',$this->region_id)
|
|
|
|
->where('host_id',$this->host_id)
|
|
|
|
->where('node_id',0))
|
|
|
|
->single();
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
2021-09-11 13:32:10 +00:00
|
|
|
case DomainController::NODE_UNKNOWN:
|
2021-07-26 11:21:58 +00:00
|
|
|
case DomainController::NODE_POINT:
|
2021-11-20 00:11:17 +00:00
|
|
|
case DomainController::NODE_DOWN:
|
2021-07-26 11:21:58 +00:00
|
|
|
// @todo Points - if the boss is defined, we should return it.
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
default:
|
|
|
|
throw new Exception('Unknown role: '.serialize($this->role));
|
2021-07-15 14:54:23 +00:00
|
|
|
}
|
2021-07-26 11:21:58 +00:00
|
|
|
|
|
|
|
return $parent?->parent();
|
2021-07-02 13:19:50 +00:00
|
|
|
}
|
|
|
|
|
2021-06-20 13:03:20 +00:00
|
|
|
public function system()
|
|
|
|
{
|
|
|
|
return $this->belongsTo(System::class);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function zone()
|
|
|
|
{
|
|
|
|
return $this->belongsTo(Zone::class);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ATTRIBUTES */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Render the node name in full 5D
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
2021-07-15 14:54:23 +00:00
|
|
|
public function getFTNAttribute(): string
|
2021-06-20 13:03:20 +00:00
|
|
|
{
|
2021-06-26 01:48:55 +00:00
|
|
|
return sprintf('%s@%s',$this->getFTN4DAttribute(),$this->zone->domain->name);
|
|
|
|
}
|
|
|
|
|
2021-08-29 01:48:27 +00:00
|
|
|
public function getFTN2DAttribute(): string
|
|
|
|
{
|
|
|
|
return sprintf('%d/%d',$this->host_id ?: $this->region_id,$this->node_id);
|
|
|
|
}
|
|
|
|
|
2021-07-15 14:54:23 +00:00
|
|
|
public function getFTN3DAttribute(): string
|
2021-06-26 01:48:55 +00:00
|
|
|
{
|
|
|
|
return sprintf('%d:%d/%d',$this->zone->zone_id,$this->host_id ?: $this->region_id,$this->node_id);
|
|
|
|
}
|
|
|
|
|
2021-07-15 14:54:23 +00:00
|
|
|
public function getFTN4DAttribute(): string
|
2021-06-26 01:48:55 +00:00
|
|
|
{
|
|
|
|
return sprintf('%s.%d',$this->getFTN3DAttribute(),$this->point_id);
|
2021-06-20 13:03:20 +00:00
|
|
|
}
|
|
|
|
|
2021-07-26 11:21:58 +00:00
|
|
|
public function getRoleNameAttribute(): string
|
2021-06-20 13:03:20 +00:00
|
|
|
{
|
2021-07-26 11:21:58 +00:00
|
|
|
switch ($this->role) {
|
|
|
|
case DomainController::NODE_ACTIVE:
|
|
|
|
return 'NODE';
|
|
|
|
case DomainController::NODE_ZC:
|
|
|
|
return 'ZC';
|
|
|
|
case DomainController::NODE_RC:
|
|
|
|
return 'RC';
|
|
|
|
case DomainController::NODE_NC:
|
|
|
|
return 'NC';
|
|
|
|
case DomainController::NODE_HC:
|
|
|
|
return 'HUB';
|
|
|
|
case DomainController::NODE_POINT:
|
|
|
|
return 'POINT';
|
2021-06-20 13:03:20 +00:00
|
|
|
default:
|
|
|
|
return '?';
|
|
|
|
}
|
|
|
|
}
|
2021-06-24 10:16:37 +00:00
|
|
|
|
2021-07-15 14:54:23 +00:00
|
|
|
/* METHODS */
|
2021-06-24 10:16:37 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Find a record in the DB for a node string, eg: 10:1/1.0
|
|
|
|
*
|
|
|
|
* @param string $ftn
|
2021-06-29 10:43:29 +00:00
|
|
|
* @return Address|null
|
2021-06-24 10:16:37 +00:00
|
|
|
* @throws Exception
|
|
|
|
*/
|
|
|
|
public static function findFTN(string $ftn): ?self
|
|
|
|
{
|
2021-06-29 10:43:29 +00:00
|
|
|
$ftn = self::parseFTN($ftn);
|
2021-06-24 10:16:37 +00:00
|
|
|
|
2021-07-26 11:21:58 +00:00
|
|
|
// Are we looking for a region address
|
|
|
|
if (($ftn['f'] === 0) && $ftn['p'] === 0) {
|
|
|
|
$o = (new self)->active()
|
|
|
|
->select('addresses.*')
|
|
|
|
->where('zones.zone_id',$ftn['z'])
|
|
|
|
->where(function($q) use ($ftn) {
|
|
|
|
return $q
|
|
|
|
->where(function($q) use ($ftn) {
|
|
|
|
return $q->where('region_id',$ftn['n'])
|
|
|
|
->where('host_id',0);
|
|
|
|
});
|
|
|
|
})
|
|
|
|
->where('node_id',$ftn['f'])
|
|
|
|
->where('point_id',$ftn['p'])
|
|
|
|
->join('zones',['zones.id'=>'addresses.zone_id'])
|
|
|
|
->join('domains',['domains.id'=>'zones.domain_id'])
|
|
|
|
->where('zones.active',TRUE)
|
|
|
|
->where('domains.active',TRUE)
|
|
|
|
->where('addresses.active',TRUE)
|
|
|
|
->when($ftn['d'],function($query,$domain) {
|
|
|
|
$query->where('domains.name',$domain);
|
|
|
|
})
|
|
|
|
->when((! $ftn['d']),function($query) {
|
2021-08-16 12:26:33 +00:00
|
|
|
$query->where('zones.default',TRUE);
|
2021-07-26 11:21:58 +00:00
|
|
|
})
|
|
|
|
->single();
|
|
|
|
|
|
|
|
if ($o && $o->system->active)
|
|
|
|
return $o;
|
|
|
|
}
|
|
|
|
|
2021-06-24 10:16:37 +00:00
|
|
|
$o = (new self)->active()
|
|
|
|
->select('addresses.*')
|
2021-06-29 10:43:29 +00:00
|
|
|
->where('zones.zone_id',$ftn['z'])
|
2021-11-20 00:11:17 +00:00
|
|
|
->where(function($q) use ($ftn) {
|
|
|
|
return $q->where(function($qq) use ($ftn) {
|
|
|
|
return $qq
|
|
|
|
->where('region_id',0)
|
|
|
|
->where('host_id',$ftn['n']);
|
|
|
|
})
|
|
|
|
->orWhere(function($qq) use ($ftn) {
|
|
|
|
return $qq
|
|
|
|
->where('region_id',$ftn['n'])
|
|
|
|
->where('host_id',0);
|
|
|
|
});
|
|
|
|
})
|
2021-07-26 11:21:58 +00:00
|
|
|
->where('node_id',$ftn['f'])
|
|
|
|
->where('point_id',$ftn['p'])
|
2021-06-24 10:16:37 +00:00
|
|
|
->join('zones',['zones.id'=>'addresses.zone_id'])
|
|
|
|
->join('domains',['domains.id'=>'zones.domain_id'])
|
|
|
|
->where('zones.active',TRUE)
|
|
|
|
->where('domains.active',TRUE)
|
|
|
|
->where('addresses.active',TRUE)
|
2021-06-29 10:43:29 +00:00
|
|
|
->when($ftn['d'],function($query,$domain) {
|
|
|
|
$query->where('domains.name',$domain);
|
2021-06-24 10:16:37 +00:00
|
|
|
})
|
2021-06-29 10:43:29 +00:00
|
|
|
->when((! $ftn['d']),function($query) {
|
2021-08-16 12:26:33 +00:00
|
|
|
$query->where('zones.default',TRUE);
|
2021-06-24 10:16:37 +00:00
|
|
|
})
|
|
|
|
->single();
|
|
|
|
|
|
|
|
return ($o && $o->system->active) ? $o : NULL;
|
|
|
|
}
|
|
|
|
|
2021-07-30 14:35:52 +00:00
|
|
|
/**
|
|
|
|
* Get echomail for this node
|
|
|
|
*
|
|
|
|
* @return Packet|null
|
|
|
|
*/
|
|
|
|
public function getEchomail(): ?Packet
|
|
|
|
{
|
2021-09-06 13:39:32 +00:00
|
|
|
$pkt = NULL;
|
|
|
|
|
|
|
|
$echomail = DB::table('address_echomail')
|
|
|
|
->select('echomail_id')
|
|
|
|
->where('address_id',$this->id)
|
|
|
|
->whereNull('sent_date')
|
|
|
|
->get();
|
|
|
|
|
|
|
|
if (($x=Echomail::select('*')
|
|
|
|
->whereIn('_id',$echomail->pluck('echomail_id')))
|
2021-07-30 14:35:52 +00:00
|
|
|
->count())
|
|
|
|
{
|
2021-09-06 13:39:32 +00:00
|
|
|
$pkt = $this->getPacket($x->get());
|
|
|
|
|
|
|
|
DB::table('address_echomail')
|
|
|
|
->whereIn('echomail_id',$echomail->pluck('echomail_id'))
|
|
|
|
->where('address_id',$this->id)
|
|
|
|
->whereNull('sent_date')
|
|
|
|
->update(['sent_date'=>Carbon::now()]);
|
2021-07-30 14:35:52 +00:00
|
|
|
}
|
|
|
|
|
2021-09-06 13:39:32 +00:00
|
|
|
return $pkt;
|
2021-07-30 14:35:52 +00:00
|
|
|
}
|
|
|
|
|
2021-07-15 14:54:23 +00:00
|
|
|
/**
|
|
|
|
* Get netmail for this node (including it's children)
|
2021-07-17 05:48:07 +00:00
|
|
|
*
|
|
|
|
* @return Packet|null
|
2021-07-15 14:54:23 +00:00
|
|
|
*/
|
2021-07-17 05:48:07 +00:00
|
|
|
public function getNetmail(): ?Packet
|
2021-07-15 14:54:23 +00:00
|
|
|
{
|
2021-08-08 11:49:58 +00:00
|
|
|
if (($x=Netmail::whereIn('tftn_id',(($x=$this->children) ? $x->pluck('id') : collect())->push($this->id))
|
2021-07-18 12:10:21 +00:00
|
|
|
->where(function($q) {
|
|
|
|
return $q->whereNull('sent')
|
|
|
|
->orWhere('sent',FALSE);
|
|
|
|
}))
|
2021-08-14 14:21:04 +00:00
|
|
|
->whereNull('local')
|
2021-07-18 12:10:21 +00:00
|
|
|
->count())
|
|
|
|
{
|
2021-07-30 14:35:52 +00:00
|
|
|
return $this->getPacket($x->get());
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
2021-07-17 05:48:07 +00:00
|
|
|
|
2021-07-30 14:35:52 +00:00
|
|
|
/**
|
|
|
|
* Return a packet of mail
|
|
|
|
*
|
|
|
|
* @param Collection $c
|
|
|
|
* @return Packet
|
|
|
|
*/
|
|
|
|
private function getPacket(Collection $c): Packet
|
|
|
|
{
|
|
|
|
$o = new Packet($this);
|
2021-07-15 14:54:23 +00:00
|
|
|
|
2021-07-30 14:35:52 +00:00
|
|
|
foreach ($c as $oo) {
|
|
|
|
$o->addMail($oo->packet($this));
|
2021-07-15 14:54:23 +00:00
|
|
|
|
2021-07-30 14:35:52 +00:00
|
|
|
$oo->packet = $o->name;
|
|
|
|
$oo->sent = TRUE;
|
|
|
|
$oo->sent_at = Carbon::now();
|
|
|
|
$oo->save();
|
2021-07-15 14:54:23 +00:00
|
|
|
}
|
|
|
|
|
2021-07-30 14:35:52 +00:00
|
|
|
return $o;
|
2021-07-15 14:54:23 +00:00
|
|
|
}
|
|
|
|
|
2021-06-29 10:43:29 +00:00
|
|
|
/**
|
|
|
|
* Parse a string and split it out as an FTN array
|
|
|
|
*
|
|
|
|
* @param string $ftn
|
|
|
|
* @return array
|
|
|
|
* @throws Exception
|
|
|
|
*/
|
|
|
|
public static function parseFTN(string $ftn): array
|
|
|
|
{
|
|
|
|
// http://ftsc.org/docs/frl-1028.002
|
|
|
|
if (! preg_match('#^([0-9]+):([0-9]+)/([0-9]+)(.([0-9]+))?(@([a-z0-9\-_~]{0,8}))?$#',strtolower($ftn),$matches))
|
|
|
|
throw new Exception('Invalid FTN: '.$ftn);
|
|
|
|
|
|
|
|
// Check our numbers are correct.
|
|
|
|
foreach ([1,2,3] as $i) {
|
2021-07-01 11:56:55 +00:00
|
|
|
if ((! is_numeric($matches[$i])) || ($matches[$i] > DomainController::NUMBER_MAX))
|
2021-06-29 10:43:29 +00:00
|
|
|
throw new Exception('Invalid FTN: '.$ftn);
|
|
|
|
}
|
|
|
|
|
2021-07-01 11:56:55 +00:00
|
|
|
if (isset($matches[5]) AND ((! is_numeric($matches[$i])) || ($matches[5] > DomainController::NUMBER_MAX)))
|
2021-06-29 10:43:29 +00:00
|
|
|
throw new Exception('Invalid FTN: '.$ftn);
|
|
|
|
|
|
|
|
return [
|
|
|
|
'z'=>(int)$matches[1],
|
|
|
|
'n'=>(int)$matches[2],
|
|
|
|
'f'=>(int)$matches[3],
|
|
|
|
'p'=>isset($matches[5]) && $matches[5] ? (int)$matches[5] : 0,
|
|
|
|
'd'=>$matches[7] ?? NULL
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2021-06-24 13:09:09 +00:00
|
|
|
/**
|
|
|
|
* Retrieve the address session details/passwords
|
|
|
|
*
|
|
|
|
* @param string $type
|
|
|
|
* @return string|null
|
|
|
|
*/
|
2021-06-24 10:16:37 +00:00
|
|
|
public function session(string $type): ?string
|
|
|
|
{
|
2021-07-31 07:43:58 +00:00
|
|
|
return ($x=$this->system->sessions->where('id',$this->zone_id)->first()) ? $x->pivot->{$type} : NULL;
|
2021-06-24 10:16:37 +00:00
|
|
|
}
|
2021-06-20 13:03:20 +00:00
|
|
|
}
|