Fix binkp remote closing connection, add/delete session details, menu item this system, minor CSS fixes, move system form editing to individual files
This commit is contained in:
@@ -107,6 +107,7 @@ abstract class Protocol
|
||||
switch ($key) {
|
||||
case 'ls_SkipGuard': /* double-skip protection on/off */
|
||||
case 'rxOptions': /* Options from ZRINIT header */
|
||||
case 'socket_error':
|
||||
return $this->comms[$key] ?? 0;
|
||||
|
||||
case 'ls_rxAttnStr':
|
||||
@@ -126,6 +127,7 @@ abstract class Protocol
|
||||
case 'ls_rxAttnStr':
|
||||
case 'ls_SkipGuard':
|
||||
case 'rxOptions':
|
||||
case 'socket_error':
|
||||
$this->comms[$key] = $value;
|
||||
break;
|
||||
|
||||
|
@@ -300,8 +300,15 @@ final class SocketClient {
|
||||
throw new SocketException($x=socket_last_error($this->connection),socket_strerror($x));
|
||||
|
||||
// If our buffer is null, see if we have any out of band data.
|
||||
if (($rc == 0) && is_nulL($buf) && ($this->hasData(0) > 0))
|
||||
socket_recv($this->connection,$buf, $len,MSG_OOB);
|
||||
// @todo We throw an errorexception when the socket is closed by the remote I think.
|
||||
if (($rc == 0) && is_nulL($buf) && ($this->hasData(0) > 0)) {
|
||||
try {
|
||||
socket_recv($this->connection,$buf, $len,MSG_OOB);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
throw new SocketException($x=socket_last_error($this->connection),socket_strerror($x));
|
||||
}
|
||||
}
|
||||
|
||||
return is_null($buf) ? '' : $buf;
|
||||
}
|
||||
|
@@ -10,6 +10,7 @@ final class SocketException extends \Exception {
|
||||
public const CANT_CONNECT = 5;
|
||||
public const SOCKET_ERROR = 6;
|
||||
public const SOCKET_EAGAIN = 11;
|
||||
public const SOCKET_READ = 22;
|
||||
|
||||
private array $messages = [
|
||||
self::CANT_CREATE_SOCKET => 'Can\'t create socket: "%s"',
|
||||
@@ -19,6 +20,7 @@ final class SocketException extends \Exception {
|
||||
self::CANT_CONNECT => 'Can\'t connect: "%s"',
|
||||
self::SOCKET_ERROR => 'Socket Error: "%s"',
|
||||
self::SOCKET_EAGAIN => 'Socket Resource Temporarily Unavailable - Try again',
|
||||
self::SOCKET_READ => 'Unable to read from socket',
|
||||
];
|
||||
|
||||
public function __construct(int $code,string $params=NULL) {
|
||||
|
@@ -4,7 +4,7 @@ namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
use App\Models\{Address,System};
|
||||
use App\Models\{Address,System,Zone};
|
||||
use App\Rules\{FidoInteger,TwoByteInteger};
|
||||
|
||||
class SystemController extends Controller
|
||||
@@ -24,6 +24,7 @@ class SystemController extends Controller
|
||||
*/
|
||||
public function add_address(Request $request,System $o)
|
||||
{
|
||||
// @todo This should be admin of the zone
|
||||
$this->authorize('admin',$o);
|
||||
session()->flash('add_address',TRUE);
|
||||
|
||||
@@ -182,6 +183,35 @@ class SystemController extends Controller
|
||||
return redirect()->to(sprintf('ftn/system/addedit/%d',$o->id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add Session details
|
||||
*
|
||||
* @param Request $request
|
||||
* @param System $o
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
* @throws \Illuminate\Auth\Access\AuthorizationException
|
||||
*/
|
||||
public function add_session(Request $request,System $o)
|
||||
{
|
||||
// @todo This should be admin of the zone
|
||||
$this->authorize('admin',$o);
|
||||
session()->flash('add_session',TRUE);
|
||||
|
||||
$validate = $request->validate([
|
||||
'zone_id' => 'required|exists:zones,id',
|
||||
'sespass' => 'required|string|min:4',
|
||||
'pktpass' => 'required|string|min:4|max:8',
|
||||
'ticpass' => 'required|string|min:4',
|
||||
'fixpass' => 'required|string|min:4',
|
||||
]);
|
||||
|
||||
$zo = Zone::findOrFail($validate['zone_id']);
|
||||
|
||||
$o->sessions()->attach($zo,$validate);
|
||||
|
||||
return redirect()->to(sprintf('ftn/system/addedit/%d',$o->id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add or edit a node
|
||||
*/
|
||||
@@ -225,6 +255,7 @@ class SystemController extends Controller
|
||||
*/
|
||||
public function del_address(Address $o)
|
||||
{
|
||||
// @todo This should be admin of the zone
|
||||
$this->authorize('admin',$o);
|
||||
session()->flash('add_address',TRUE);
|
||||
|
||||
@@ -236,6 +267,28 @@ class SystemController extends Controller
|
||||
return redirect()->to(sprintf('ftn/system/addedit/%d',$sid));
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete address assigned to a host
|
||||
*
|
||||
* @param Address $o
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
* @throws \Illuminate\Auth\Access\AuthorizationException
|
||||
*/
|
||||
public function del_session(System $o,Zone $zo)
|
||||
{
|
||||
$this->authorize('admin',$zo);
|
||||
session()->flash('add_session',TRUE);
|
||||
|
||||
$o->sessions()->detach($zo);
|
||||
|
||||
return redirect()->to(sprintf('ftn/system/addedit/%d',$o->id));
|
||||
}
|
||||
|
||||
public function ours()
|
||||
{
|
||||
return view('system.ours');
|
||||
}
|
||||
|
||||
/**
|
||||
* Suspend address assigned to a host
|
||||
*
|
||||
@@ -245,6 +298,7 @@ class SystemController extends Controller
|
||||
*/
|
||||
public function sus_address(Address $o)
|
||||
{
|
||||
// @todo This should be admin of the zone
|
||||
$this->authorize('admin',$o);
|
||||
session()->flash('add_address',TRUE);
|
||||
|
||||
|
@@ -8,20 +8,20 @@ use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class ActiveUser
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle(Request $request, Closure $next)
|
||||
{
|
||||
if (Auth::user()->exists && ! Auth::user()->active) {
|
||||
Auth::logout();
|
||||
abort(403,'Your account is not active');
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle(Request $request, Closure $next)
|
||||
{
|
||||
if (Auth::user()->exists && ! Auth::user()->active) {
|
||||
Auth::logout();
|
||||
abort(403,'Your account is not active');
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
|
@@ -26,6 +26,12 @@ class Address extends Model
|
||||
|
||||
/* RELATIONS */
|
||||
|
||||
/**
|
||||
* Find children dependant on this record
|
||||
*
|
||||
* @todo While this is finding children of hubs, we are not currently finding children of Hosts or Regions.
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function children()
|
||||
{
|
||||
return $this->belongsTo(self::class,'id','hub_id');
|
||||
@@ -162,7 +168,7 @@ class Address extends Model
|
||||
static $session = NULL;
|
||||
|
||||
if (is_null($session)) {
|
||||
$session = (new AddressZone)
|
||||
$session = (new SystemZone)
|
||||
->where('zone_id',$this->zone_id)
|
||||
->where('system_id',$this->system_id)
|
||||
->single();
|
||||
|
@@ -1,10 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class AddressZone extends Model
|
||||
{
|
||||
protected $table = 'address_zone';
|
||||
}
|
@@ -23,6 +23,37 @@ class System extends Model
|
||||
->orderBy('point_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Session Passwords for system
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
*/
|
||||
public function sessions()
|
||||
{
|
||||
return $this->belongsToMany(Zone::class)
|
||||
->withPivot(['sespass','pktpass','ticpass','fixpass','zt_ipv4','zt_ipv6']);
|
||||
}
|
||||
|
||||
/**
|
||||
* If this system is configured as this host
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasOne
|
||||
*/
|
||||
public function setup()
|
||||
{
|
||||
return $this->hasOne(Setup::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Zones a system has addresses for
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasManyThrough
|
||||
*/
|
||||
public function zones()
|
||||
{
|
||||
return $this->hasManyThrough(Zone::class,Address::class,'system_id','id','id','zone_id');
|
||||
}
|
||||
|
||||
/* GENERAL METHODS */
|
||||
|
||||
/**
|
||||
|
20
app/Models/SystemZone.php
Normal file
20
app/Models/SystemZone.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class SystemZone extends Model
|
||||
{
|
||||
protected $table = 'system_zone';
|
||||
|
||||
public function system()
|
||||
{
|
||||
return $this->belongsTo(System::class);
|
||||
}
|
||||
|
||||
public function zone()
|
||||
{
|
||||
return $this->belongsTo(Zone::class);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user