Some BINKP optimisation, implemented crypt, implemented receiving compressed transfers
This commit is contained in:
@@ -2,11 +2,13 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Exception;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Facades\File;
|
||||
|
||||
use App\Classes\Protocol\{Binkp,DNS,EMSI};
|
||||
|
||||
/**
|
||||
* This class represents our configuration.
|
||||
*
|
||||
@@ -14,26 +16,17 @@ use Illuminate\Support\Facades\File;
|
||||
*
|
||||
* @package App\Models
|
||||
* @property Collection nodes
|
||||
* @property array binkp_options
|
||||
*/
|
||||
class Setup extends Model
|
||||
{
|
||||
public const S_DOMAIN = 1<<1; // Users can create Domains
|
||||
public const S_SYSTEM = 1<<2; // Users can create Systems
|
||||
public const PRODUCT_NAME = 'Clearing Houz';
|
||||
public const PRODUCT_ID = 0xAB8D;
|
||||
public const PRODUCT_VERSION_MAJ = 0;
|
||||
public const PRODUCT_VERSION_MIN = 0;
|
||||
|
||||
public const BINKP_OPT_CHT = 1<<1; /* CHAT mode - not implemented */
|
||||
public const BINKP_OPT_CR = 1<<2; /* Crypt mode - not implemented */
|
||||
public const BINKP_OPT_MB = 1<<3; /* Multi-Batch mode */
|
||||
public const BINKP_OPT_MD = 1<<4; /* CRAM-MD5 mode */
|
||||
public const BINKP_OPT_ND = 1<<5; /* http://ftsc.org/docs/fsp-1027.001: No-dupes mode */
|
||||
public const BINKP_OPT_NDA = 1<<6; /* http://ftsc.org/docs/fsp-1027.001: Asymmetric ND mode */
|
||||
public const BINKP_OPT_NR = 1<<7; /* http://ftsc.org/docs/fsp-1027.001: Non-Reliable mode */
|
||||
public const BINKP_OPT_MPWD = 1<<8; /* Multi-Password mode - not implemented */
|
||||
|
||||
public const BINKP_PORT = 24554;
|
||||
public const BINKP_BIND = '::';
|
||||
public const BIND = '::';
|
||||
public const EMSI_PORT = 60179;
|
||||
public const EMSI_BIND = self::BINKP_BIND;
|
||||
public const EMSI_BIND = self::BIND;
|
||||
public const DNS_PORT = 53;
|
||||
public const DNS_BIND = '::';
|
||||
|
||||
@@ -42,25 +35,19 @@ class Setup extends Model
|
||||
public const O_DNS = 1<<3; /* List for DNS */
|
||||
public const O_HIDEAKA = 1<<4; /* Hide AKAs to different Zones */
|
||||
|
||||
public const PRODUCT_NAME = 'Clearing Houz';
|
||||
public const PRODUCT_ID = 0xAB8D;
|
||||
public const PRODUCT_VERSION_MAJ = 0;
|
||||
public const PRODUCT_VERSION_MIN = 0;
|
||||
|
||||
public const MAX_MSGS_PKT = 50;
|
||||
|
||||
public const hexdigitslower = '0123456789abcdef';
|
||||
|
||||
// Our non model attributes and values
|
||||
private array $internal = [];
|
||||
|
||||
protected $casts = [
|
||||
'servers' => 'array',
|
||||
];
|
||||
|
||||
public function __construct(array $attributes = [])
|
||||
{
|
||||
parent::__construct($attributes);
|
||||
|
||||
// @todo These option should be in setup?
|
||||
$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;
|
||||
@@ -68,21 +55,30 @@ class Setup extends Model
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function __get($key)
|
||||
{
|
||||
switch ($key) {
|
||||
case 'binkp_bind':
|
||||
case 'dns_bind':
|
||||
case 'emsi_bind':
|
||||
return Arr::get($this->servers,str_replace('_','.',$key),self::BIND);
|
||||
|
||||
case 'binkp_port':
|
||||
return Arr::get($this->servers,str_replace('_','.',$key),Binkp::PORT);
|
||||
case 'dns_port':
|
||||
return Arr::get($this->servers,str_replace('_','.',$key),EMSI::PORT);
|
||||
case 'emsi_port':
|
||||
return Arr::get($this->servers,str_replace('_','.',$key),DNS::PORT);
|
||||
|
||||
case 'binkp_options':
|
||||
case 'dns_options':
|
||||
case 'emsi_options':
|
||||
return Arr::get($this->servers,'binkp.options');
|
||||
|
||||
case 'binkp_settings':
|
||||
case 'ignore_nrq':
|
||||
case 'opt_nr': // @todo - this keys are now in #binkp as bits
|
||||
case 'opt_nd':
|
||||
case 'opt_nda':
|
||||
case 'opt_md':
|
||||
case 'opt_cr':
|
||||
case 'opt_mb':
|
||||
case 'opt_cht':
|
||||
case 'opt_mpwd':
|
||||
case 'do_prevent':
|
||||
return $this->internal[$key] ?? FALSE;
|
||||
|
||||
@@ -98,12 +94,23 @@ class Setup extends Model
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function __set($key,$value)
|
||||
{
|
||||
switch ($key) {
|
||||
case 'binkp_bind':
|
||||
case 'binkp_port':
|
||||
case 'binkp_options':
|
||||
case 'dns_bind':
|
||||
case 'dns_port':
|
||||
case 'dns_options':
|
||||
case 'emsi_bind':
|
||||
case 'emsi_port':
|
||||
case 'emsi_options':
|
||||
return Arr::set($this->servers,str_replace('_','.',$key),$value);
|
||||
|
||||
case 'binkp_settings':
|
||||
case 'ignore_nrq':
|
||||
case 'opt_nr':
|
||||
case 'opt_nd':
|
||||
@@ -127,7 +134,7 @@ class Setup extends Model
|
||||
*
|
||||
* @param int $c
|
||||
* @return string
|
||||
* @throws Exception
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function product_id(int $c=self::PRODUCT_ID): string
|
||||
{
|
||||
@@ -165,37 +172,18 @@ class Setup extends Model
|
||||
|
||||
/* METHODS */
|
||||
|
||||
/* BINKP OPTIONS: BINKP_OPT_* */
|
||||
|
||||
public function binkpOptionClear(int $key): void
|
||||
public function optionClear(int $key,$index='options'): void
|
||||
{
|
||||
$this->binkp &= ~$key;
|
||||
$this->{$index} &= ~$key;
|
||||
}
|
||||
|
||||
public function binkpOptionGet(int $key): int
|
||||
public function optionGet(int $key,$index='options'): int
|
||||
{
|
||||
return ($this->binkp & $key);
|
||||
return ($this->{$index} & $key);
|
||||
}
|
||||
|
||||
public function binkpOptionSet(int $key): void
|
||||
public function optionSet(int $key,$index='options'): void
|
||||
{
|
||||
$this->binkp |= $key;
|
||||
}
|
||||
|
||||
/* GENERAL OPTIONS: O_* */
|
||||
|
||||
public function optionClear(int $key): void
|
||||
{
|
||||
$this->options &= ~$key;
|
||||
}
|
||||
|
||||
public function optionGet(int $key): int
|
||||
{
|
||||
return ($this->options & $key);
|
||||
}
|
||||
|
||||
public function optionSet(int $key): void
|
||||
{
|
||||
$this->options |= $key;
|
||||
$this->{$index} |= $key;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user