diff --git a/app/Classes/FTN/Packet.php b/app/Classes/FTN/Packet.php index c98a6a6..f76f7fa 100644 --- a/app/Classes/FTN/Packet.php +++ b/app/Classes/FTN/Packet.php @@ -372,7 +372,7 @@ abstract class Packet extends FTNBase implements \Iterator, \Countable 'H' => $date->format('H'), // Hour 'M' => $date->format('i'), // Minute 'S' => $date->format('s'), // Second - 'password' => strtoupper((! is_null($passwd)) ? $passwd : $o->session('pktpass')), // Packet Password + 'password' => strtoupper((! is_null($passwd)) ? $passwd : $o->pass_packet), // Packet Password ]; } @@ -505,7 +505,7 @@ abstract class Packet extends FTNBase implements \Iterator, \Countable public function password(string $password=NULL): self { if ($password && (strlen($password) < 9)) - $this->pass_p = $password; + $this->pass_p = strtoupper($password); return $this; } diff --git a/app/Classes/FTN/Packet/FSC39.php b/app/Classes/FTN/Packet/FSC39.php index f7014b8..f1bd77e 100644 --- a/app/Classes/FTN/Packet/FSC39.php +++ b/app/Classes/FTN/Packet/FSC39.php @@ -82,7 +82,7 @@ final class FSC39 extends Packet $this->tftn_p->host_id, // Dest Net (Setup::PRODUCT_ID & 0xff), // Product Code Lo Setup::PRODUCT_VERSION_MAJ, // Product Version Major - $this->pass_p ?: $this->tftn_p->session('pktpass'), // Packet Password + $this->pass_p ?: $this->tftn_p->pass_packet, // Packet Password $this->fftn_p->zone->zone_id, // Orig Zone $this->tftn_p->zone->zone_id, // Dest Zone '', // Reserved diff --git a/app/Classes/FTN/Packet/FSC45.php b/app/Classes/FTN/Packet/FSC45.php index 7aabe07..5560704 100644 --- a/app/Classes/FTN/Packet/FSC45.php +++ b/app/Classes/FTN/Packet/FSC45.php @@ -69,7 +69,7 @@ final class FSC45 extends Packet $this->tftn_p->host_id, // Dest Net (Setup::PRODUCT_ID & 0xff), // Product Code Setup::PRODUCT_VERSION_MAJ, // Product Version - $this->pass_p ?: $this->tftn_p->session('pktpass'), // Packet Password + $this->pass_p ?: $this->tftn_p->pass_packet, // Packet Password $this->fftn_p->zone->zone_id, // Orig Zone $this->tftn_p->zone->zone_id, // Dest Zone $this->fftn_p->zone->domain->name, // Orig Domain diff --git a/app/Classes/FTN/Packet/FSC48.php b/app/Classes/FTN/Packet/FSC48.php index d13f23b..6fa1b94 100644 --- a/app/Classes/FTN/Packet/FSC48.php +++ b/app/Classes/FTN/Packet/FSC48.php @@ -82,7 +82,7 @@ final class FSC48 extends Packet $this->tftn_p->host_id, // Dest Net (Setup::PRODUCT_ID & 0xff), // Product Code Lo Setup::PRODUCT_VERSION_MAJ, // Product Version Major - $this->pass_p ?: $this->tftn_p->session('pktpass'), // Packet Password + $this->pass_p ?: $this->tftn_p->pass_packet, // Packet Password $this->fftn_p->zone->zone_id, // Orig Zone $this->tftn_p->zone->zone_id, // Dest Zone $this->fftn_p->point_id ? $this->fftn_p->host_id : 0x00, // Aux Net diff --git a/app/Classes/FTN/Packet/FTS1.php b/app/Classes/FTN/Packet/FTS1.php index c94bf28..6264ae2 100644 --- a/app/Classes/FTN/Packet/FTS1.php +++ b/app/Classes/FTN/Packet/FTS1.php @@ -75,7 +75,7 @@ final class FTS1 extends Packet $this->tftn_p->host_id, // Dest Net (Setup::PRODUCT_ID & 0xff), // Product Code Lo Setup::PRODUCT_VERSION_MAJ, // Product Version Major - $this->pass_p ?: $this->tftn_p->session('pktpass'), // Packet Password + $this->pass_p ?: $this->tftn_p->pass_packet, // Packet Password $this->fftn_p->zone->zone_id, // Orig Zone $this->tftn_p->zone->zone_id, // Dest Zone '', // Reserved diff --git a/app/Classes/FTN/Tic.php b/app/Classes/FTN/Tic.php index abd56c7..6d8eedd 100644 --- a/app/Classes/FTN/Tic.php +++ b/app/Classes/FTN/Tic.php @@ -106,7 +106,7 @@ class Tic extends FTNBase $result->put('REPLACES',$this->file->replaces); $result->put('AREA',$this->file->filearea->name); $result->put('AREADESC',$this->file->filearea->description); - if ($x=strtoupper($this->to->session('ticpass'))) + if ($x=$this->to->pass_tic) $result->put('PW',$x); $result->put('CRC',sprintf("%X",$this->file->crc)); @@ -351,7 +351,7 @@ class Tic extends FTNBase throw new SizeMismatchException(sprintf('TIC file size [%d] doesnt match file [%s] (%d)',$this->file->size,$fs->path($rel_path_name),$y)); // Validate Password - if (strtoupper($pw) !== ($y=strtoupper($this->file->fftn->session('ticpass')))) + if (strtoupper($pw) !== ($y=$this->file->fftn->pass_tic)) throw new InvalidPasswordException(sprintf('TIC file PASSWORD [%s] doesnt match system [%s] (%s)',$pw,$this->file->fftn->ftn,$y)); // Validate Sender is linked diff --git a/app/Classes/Node.php b/app/Classes/Node.php index 7da5407..3cd5ee8 100644 --- a/app/Classes/Node.php +++ b/app/Classes/Node.php @@ -86,9 +86,9 @@ class Node case 'password': // If we have already authed, we'll use that password. if ($this->ftns_authed->count()) - return $this->ftns_authed->first()->session('sespass'); + return $this->ftns_authed->first()->pass_session; else - return ($this->ftns->count() && ($x=$this->ftns->first()->session('sespass'))) ? $x : '-'; + return ($this->ftns->count() && ($x=$this->ftns->first()->pass_session)) ? $x : '-'; // Return how long our session has been connected case 'session_time': @@ -194,7 +194,7 @@ class Node throw new Exception('Already authed'); foreach ($this->ftns as $o) { - if (! $sespass=$o->session('sespass')) + if (! $sespass=$o->pass_session) continue; // If we have challenge, then we are doing MD5 diff --git a/app/Http/Controllers/SystemController.php b/app/Http/Controllers/SystemController.php index 45e557e..eb1557c 100644 --- a/app/Http/Controllers/SystemController.php +++ b/app/Http/Controllers/SystemController.php @@ -575,7 +575,7 @@ class SystemController extends Controller session()->flash('accordion','filearea'); // Ensure we have session details for this address. - if (! $ao->session('sespass')) + if (! $ao->pass_session) return redirect()->back()->withErrors('System doesnt belong to this network'); $ao->fileareas()->syncWithPivotValues($request->get('id',[]),['subscribed'=>Carbon::now()]); diff --git a/app/Jobs/PacketProcess.php b/app/Jobs/PacketProcess.php index bff445c..b1ddc1a 100644 --- a/app/Jobs/PacketProcess.php +++ b/app/Jobs/PacketProcess.php @@ -95,7 +95,7 @@ class PacketProcess implements ShouldQueue } // Check the packet password - if (strtoupper($pkt->fftn->session('pktpass')) !== strtoupper($pkt->password)) { + if ($pkt->fftn->pass_packet !== strtoupper($pkt->password)) { Log::error(sprintf('%s:! Packet from [%s] with password [%s] is invalid.',self::LOGKEY,$pkt->fftn->ftn,$pkt->password)); Notification::route('netmail',$pkt->fftn)->notify(new PacketPasswordInvalid($pkt->password,$f->pktName())); diff --git a/app/Models/Address.php b/app/Models/Address.php index 1733db6..a34b0ee 100644 --- a/app/Models/Address.php +++ b/app/Models/Address.php @@ -40,7 +40,6 @@ use App\Traits\{QueryCacheableConfig,ScopeActive}; class Address extends Model { use QueryCacheableConfig,ScopeActive,SoftDeletes; - const CACHE_KEY = 0; private const LOGKEY = 'MA-'; @@ -358,12 +357,12 @@ class Address extends Model } return [ - 'z'=>(int)$zone_id ?: $matches[1], - 'r'=>(int)$region_id, - 'n'=>(int)$matches[2], - 'f'=>(int)$matches[3], - 'p'=>empty($matches[4]) ? 0 : (int)$matches[4], - 'd'=>$matches[5] ?? NULL + 'z' => (int)$zone_id ?: $matches[1], + 'r' => (int)$region_id, + 'n' => (int)$matches[2], + 'f' => (int)$matches[3], + 'p' => empty($matches[4]) ? 0 : (int)$matches[4], + 'd' => $matches[5] ?? NULL ]; } @@ -386,6 +385,18 @@ class Address extends Model ->FTNorder(); } + /** + * Select to support returning FTN address + * + * @param $query + * @return void + */ + public function scopeFTN($query) + { + return $query->select(['zone_id','host_id','node_id','point_id']) + ->with('zone.domain'); + } + public function scopeFTNOrder($query) { return $query @@ -744,11 +755,21 @@ class Address extends Model return sprintf('%s.%d',$this->getFTN3DAttribute(),$this->point_id); } + public function getIsDefaultRouteAttribute(): bool + { + return ! is_null($this->session('default')); + } + public function getIsDownAttribute(): bool { return $this->role & self::NODE_DOWN; } + public function getIsHostedAttribute(): bool + { + return ! is_null($this->getPassSessionAttribute()); + } + public function getIsHoldAttribute(): bool { return $this->role & self::NODE_HOLD; @@ -816,6 +837,26 @@ class Address extends Model } } + public function getPassFixAttribute(): ?string + { + return strtoupper($this->session('fixpass')); + } + + public function getPassPacketAttribute(): ?string + { + return strtoupper($this->session('pktpass')); + } + + public function getPassSessionAttribute(): ?string + { + return $this->session('sesspass'); + } + + public function getPassTicAttribute(): ?string + { + return strtoupper($this->session('ticpass')); + } + /* METHODS */ /** @@ -902,11 +943,11 @@ class Address extends Model public function downlinks(): Collection { // We have no session data for this address, by definition it has no children - if (! $this->session('sespass') && (! our_address()->pluck('id')->contains($this->id))) + if (! $this->is_hosted && (! our_address()->pluck('id')->contains($this->id))) return new Collection; // If this system is not marked to default route for this address - if (! $this->session('default')) { + if (! $this->is_default_route) { $children = $this->children(); // We route everything for this domain @@ -1284,7 +1325,7 @@ class Address extends Model * @param string $type * @return string|null */ - public function session(string $type): ?string + private function session(string $type): ?string { return ($this->exists && ($x=$this->system->sessions->where('id',$this->zone_id)->first())) ? ($x->pivot->{$type} ?: '') : NULL; } @@ -1302,7 +1343,7 @@ class Address extends Model return NULL; // If we have session password, then we are the parent - if ($x=$this->session('sespass')) + if ($this->is_hosted) return $this; if ($x=$this->parent()?->uplink()) { diff --git a/resources/views/domain/view.blade.php b/resources/views/domain/view.blade.php index 2bbd196..bcd10da 100644 --- a/resources/views/domain/view.blade.php +++ b/resources/views/domain/view.blade.php @@ -134,7 +134,7 @@ @foreach ($o->zones->sortBy('zone_id') as $oz) @foreach ($oz->addresses as $ao)