From c8447d8573acbdb08ad2c727fc7eab7724b5594a Mon Sep 17 00:00:00 2001 From: Deon George Date: Sun, 4 Jul 2021 23:24:38 +1000 Subject: [PATCH] Update and display last seen for systems --- app/Classes/Node.php | 11 +++++++++-- app/Classes/Protocol/Binkp.php | 2 ++ app/Models/System.php | 2 ++ resources/views/domain/view.blade.php | 8 ++++---- resources/views/system/ours.blade.php | 11 ++--------- 5 files changed, 19 insertions(+), 15 deletions(-) diff --git a/app/Classes/Node.php b/app/Classes/Node.php index be9669e..e8adaab 100644 --- a/app/Classes/Node.php +++ b/app/Classes/Node.php @@ -159,8 +159,11 @@ class Node // If we have challenge, then we are doing MD5 $exp_pwd = $challenge ? $this->md5_challenge($o->session('sespass'),$challenge) : $o->session('sespass'); - if ($exp_pwd === $password) + if ($exp_pwd === $password) { + $o->system->last_session = Carbon::now(); + $o->system->save(); $this->ftns_authed->push($o); + } } Log::debug(sprintf('%s: = End [%d]',__METHOD__,$this->ftns_authed->count())); @@ -227,7 +230,11 @@ class Node $ftn = $this->ftns_authed->first()->ftn; return $this->ftns->search(function($item) use ($ftn) { - return $item->ftn == $ftn; + if ($item->ftn == $ftn) { + $item->system->last_session = Carbon::now(); + $item->system->save(); + return TRUE; + } }) !== FALSE; } diff --git a/app/Classes/Protocol/Binkp.php b/app/Classes/Protocol/Binkp.php index ffcfc86..c6c7984 100644 --- a/app/Classes/Protocol/Binkp.php +++ b/app/Classes/Protocol/Binkp.php @@ -1027,6 +1027,8 @@ final class Binkp extends BaseProtocol } /** + * Remote accepted our password + * * @throws Exception */ private function M_ok(string $buf): int diff --git a/app/Models/System.php b/app/Models/System.php index a8b5b1d..8a3debf 100644 --- a/app/Models/System.php +++ b/app/Models/System.php @@ -12,6 +12,8 @@ class System extends Model { use HasFactory,ScopeActive; + protected $dates = ['last_session']; + /* RELATIONS */ public function addresses() diff --git a/resources/views/domain/view.blade.php b/resources/views/domain/view.blade.php index 8fa90c7..1e53b11 100644 --- a/resources/views/domain/view.blade.php +++ b/resources/views/domain/view.blade.php @@ -74,7 +74,7 @@ {{ $oz->system->sysop }} {{ $oz->system->location }} {{ $oz->zone_id }}:0/0 - - + {{ $oz->system->last_session ? $oz->system->last_session->format('Y-m-d H:i') : '-' }} @foreach ($oz->addresses()->active()->FTNorder()->where('point_id',0)->whereNull('hub_id')->with(['system','zone.domain'])->get() as $ao) @@ -84,7 +84,7 @@ {{ $ao->system->sysop }} {{ $ao->system->location }} {{ $oz->zone_id }}:{{ $ao->host_id }}/0 - - + {{ $ao->system->last_session ? $ao->system->last_session->format('Y-m-d H:i') : '-' }} @endif @@ -93,7 +93,7 @@ {{ $ao->system->sysop }} {{ $ao->system->location }} {{ $ao->ftn_3d }} - - + {{ $ao->system->last_session ? $ao->system->last_session->format('Y-m-d H:i') : '-' }} @@ -104,7 +104,7 @@ {{ $aoo->system->sysop }} {{ $aoo->system->location }} {{ $aoo->ftn_3d }} - - + {{ $aoo->system->last_session ? $aoo->system->last_session->format('Y-m-d H:i') : '-' }} @endforeach @endif diff --git a/resources/views/system/ours.blade.php b/resources/views/system/ours.blade.php index 371ea0d..b3bffb4 100644 --- a/resources/views/system/ours.blade.php +++ b/resources/views/system/ours.blade.php @@ -21,7 +21,7 @@ System Sysop Location - Connect + Last Seen Address ZeroTier ID @@ -35,14 +35,7 @@ {{ $oo->system->name }} {{ $oo->system->sysop }} {{ $oo->system->location }} - - @switch($oo->system->method) - @case(23)Telnet@break - @case(22)SSH@break - @case(519)SSH@break - @default No details - @endswitch - + {{ $oo->system->last_session ? $oo->system->last_session->format('Y-m-d H:i') : '-' }} {{ join(',',$oo->system->addresses->where('zone_id',$oo->zone_id)->pluck('ftn')->toArray()) }} {{ $oo->system->zt_id }}