125 lines
2.6 KiB
PHP
125 lines
2.6 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Exception;
|
|
use Illuminate\Database\Eloquent\Collection;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Support\Facades\File;
|
|
|
|
/**
|
|
* Class Setup
|
|
*
|
|
* @package App\Models
|
|
* @property Collection nodes
|
|
* @property array binkp_options
|
|
*/
|
|
class Setup extends Model
|
|
{
|
|
// Our non model attributes and values
|
|
private array $internal = [];
|
|
|
|
public function __construct(array $attributes = [])
|
|
{
|
|
parent::__construct($attributes);
|
|
|
|
// @todo This should go in a config file in the config dir
|
|
$this->opt_cht = 0; /* CHAT mode - not implemented*/
|
|
$this->opt_cr = 0; /* Crypt mode - not implemented*/
|
|
$this->opt_mb = 1; /* Multi-Batch mode */
|
|
$this->opt_md = 0; /* CRAM-MD5 mode */
|
|
$this->opt_nd = 0; /* http://ftsc.org/docs/fsp-1027.001: No-dupes mode */
|
|
$this->opt_nda = 1; /* http://ftsc.org/docs/fsp-1027.001: Asymmetric ND mode */
|
|
$this->opt_mpwd = 0; /* Multi-Password mode - not implemented */
|
|
$this->opt_nr = 1; /* http://ftsc.org/docs/fsp-1027.001: Non-Reliable mode */
|
|
$this->binkp_options = ['m','d','r','b'];
|
|
|
|
/* EMSI SETTINGS */
|
|
$this->do_prevent = 1; /* EMSI - send an immediate EMSI_INQ on connect */
|
|
$this->ignore_nrq = 0;
|
|
$this->options = 0; /* EMSI - our capabilities */
|
|
|
|
/* EMSI - the order of protocols we are able to accept */
|
|
$this->inbound = '/tmp';
|
|
}
|
|
|
|
/* RELATIONS */
|
|
|
|
public function nodes()
|
|
{
|
|
return $this->belongsToMany(Node::class);
|
|
}
|
|
|
|
/* ATTRIBUTES */
|
|
|
|
public function getLocationAttribute()
|
|
{
|
|
return $this->nodes->first()->location;
|
|
}
|
|
|
|
public function getSysopAttribute()
|
|
{
|
|
return $this->nodes->first()->sysop;
|
|
}
|
|
|
|
public function getSystemNameAttribute()
|
|
{
|
|
return $this->nodes->first()->system;
|
|
}
|
|
|
|
/* METHODS */
|
|
|
|
/**
|
|
* @throws Exception
|
|
*/
|
|
public function __get($key)
|
|
{
|
|
switch ($key) {
|
|
case 'binkp_options':
|
|
case 'ignore_nrq':
|
|
case 'inbound':
|
|
case 'opt_nr':
|
|
case 'opt_nd':
|
|
case 'opt_nda':
|
|
case 'opt_md':
|
|
case 'opt_cr':
|
|
case 'opt_mb':
|
|
case 'opt_cht':
|
|
case 'do_prevent':
|
|
case 'options':
|
|
return $this->internal[$key] ?? FALSE;
|
|
|
|
case 'version':
|
|
return File::exists('VERSION') ? chop(File::get('VERSION')) : 'dev';
|
|
|
|
default:
|
|
return parent::__get($key);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @throws Exception
|
|
*/
|
|
public function __set($key,$value)
|
|
{
|
|
switch ($key) {
|
|
case 'binkp_options':
|
|
case 'ignore_nrq':
|
|
case 'inbound':
|
|
case 'opt_nr':
|
|
case 'opt_nd':
|
|
case 'opt_nda':
|
|
case 'opt_md':
|
|
case 'opt_cr':
|
|
case 'opt_mb':
|
|
case 'opt_cht':
|
|
case 'do_prevent':
|
|
case 'options':
|
|
$this->internal[$key] = $value;
|
|
break;
|
|
|
|
default:
|
|
parent::__get($key);
|
|
}
|
|
}
|
|
} |