Changed to using new Address Model, Implemented Setup, Some minor CSS changes

This commit is contained in:
Deon George
2021-06-24 20:16:37 +10:00
parent ec6594b701
commit d1ca78d372
33 changed files with 766 additions and 172 deletions

View File

@@ -3,12 +3,11 @@
namespace App\Classes;
use Carbon\Carbon;
use Exception;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Log;
use App\Models\Node as NodeModel;
use App\Models\Address;
/**
* Object representing the node we are communicating with
@@ -64,7 +63,7 @@ class Node
// The nodes password
case 'password':
return ($this->ftns_authed->count() && $x=$this->ftns_authed->first()->sespass) ? $x : '-';
return ($this->ftns_authed->count() && ($x=$this->ftns_authed->first()->session('sespass'))) ? $x : '-';
// Return how long our session has been connected
case 'session_time':
@@ -102,8 +101,8 @@ class Node
{
switch ($key) {
case 'ftn':
if (! is_object($value) OR ! $value instanceof NodeModel)
throw new Exception('Not a node object: '.(is_object($value) ? get_class($value) : serialize($value)));
if (! is_object($value) OR ! $value instanceof Address)
throw new Exception('Not an Address object: '.(is_object($value) ? get_class($value) : serialize($value)));
// Ignore any duplicate FTNs that we get
if ($this->ftns->search(function($item) use ($value) { return $item->id === $value->id; }) !== FALSE) {
@@ -154,11 +153,11 @@ class Node
throw new Exception('Already authed');
foreach ($this->ftns as $o) {
if (! $o->sespass)
if (! $o->session('sespass'))
continue;
// If we have challenge, then we are doing MD5
$exp_pwd = $challenge ? $this->md5_challenge($o->sespass,$challenge) : $o->sespass;
$exp_pwd = $challenge ? $this->md5_challenge($o->session('sespass'),$challenge) : $o->session('sespass');
if ($exp_pwd === $password)
$this->ftns_authed->push($o);
@@ -208,11 +207,10 @@ class Node
* When we originate a call to a node, we need to store the node we are connecting with in the ftns_authed, so
* authentication proceeds when we send our M_pwd
*
* @param NodeModel $o
* @param Address $o
*/
public function originate(NodeModel $o): void
public function originate(Address $o): void
{
$this->ftns->push($o);
$this->ftns_authed->push($o);
}