Update and display last seen for systems

This commit is contained in:
Deon George 2021-07-04 23:24:38 +10:00
parent acfde97e79
commit c8447d8573
5 changed files with 19 additions and 15 deletions

View File

@ -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;
}

View File

@ -1027,6 +1027,8 @@ final class Binkp extends BaseProtocol
}
/**
* Remote accepted our password
*
* @throws Exception
*/
private function M_ok(string $buf): int

View File

@ -12,6 +12,8 @@ class System extends Model
{
use HasFactory,ScopeActive;
protected $dates = ['last_session'];
/* RELATIONS */
public function addresses()

View File

@ -74,7 +74,7 @@
<td>{{ $oz->system->sysop }}</td>
<td>{{ $oz->system->location }}</td>
<td>{{ $oz->zone_id }}:0/0</td>
<td>-</td>
<td>{{ $oz->system->last_session ? $oz->system->last_session->format('Y-m-d H:i') : '-' }}</td>
</tr>
@foreach ($oz->addresses()->active()->FTNorder()->where('point_id',0)->whereNull('hub_id')->with(['system','zone.domain'])->get() as $ao)
@ -84,7 +84,7 @@
<td>{{ $ao->system->sysop }}</td>
<td>{{ $ao->system->location }}</td>
<td>{{ $oz->zone_id }}:{{ $ao->host_id }}/0</td>
<td>-</td>
<td>{{ $ao->system->last_session ? $ao->system->last_session->format('Y-m-d H:i') : '-' }}</td>
</tr>
@endif
@ -93,7 +93,7 @@
<td>{{ $ao->system->sysop }}</td>
<td>{{ $ao->system->location }}</td>
<td>{{ $ao->ftn_3d }}</td>
<td>-</td>
<td>{{ $ao->system->last_session ? $ao->system->last_session->format('Y-m-d H:i') : '-' }}</td>
</tr>
<!-- If this node is a hub -->
@ -104,7 +104,7 @@
<td>{{ $aoo->system->sysop }}</td>
<td>{{ $aoo->system->location }}</td>
<td>{{ $aoo->ftn_3d }}</td>
<td>-</td>
<td>{{ $aoo->system->last_session ? $aoo->system->last_session->format('Y-m-d H:i') : '-' }}</td>
</tr>
@endforeach
@endif

View File

@ -21,7 +21,7 @@
<th>System</th>
<th>Sysop</th>
<th>Location</th>
<th>Connect</th>
<th>Last Seen</th>
<th>Address</th>
<th>ZeroTier ID</th>
</tr>
@ -35,14 +35,7 @@
<td>{{ $oo->system->name }}</td>
<td>{{ $oo->system->sysop }}</td>
<td>{{ $oo->system->location }}</td>
<td>
@switch($oo->system->method)
@case(23)<a href="telnet://{{ $oo->system->address }}:{{ $oo->system->port }}">Telnet</a>@break
@case(22)<a href="ssh://{{ $oo->system->address }}:{{ $oo->system->port }}">SSH</a>@break
@case(519)<a href="rlogin://{{ $oo->system->address }}:{{ $oo->system->port }}">SSH</a>@break
@default No details
@endswitch
</td>
<td>{{ $oo->system->last_session ? $oo->system->last_session->format('Y-m-d H:i') : '-' }}</td>
<td>{{ join(',',$oo->system->addresses->where('zone_id',$oo->zone_id)->pluck('ftn')->toArray()) }}</td>
<td>{{ $oo->system->zt_id }}</td>
</tr>