Compare commits
10 Commits
5312bee9bc
...
b322a3f0b0
Author | SHA1 | Date | |
---|---|---|---|
b322a3f0b0 | |||
0bbff33fdd | |||
67cbfa4c64 | |||
cf95b2dab4 | |||
95969a857b | |||
58fe142f7c | |||
43c4f1511d | |||
b2b519a2c4 | |||
7352a74a12 | |||
5874b2aef1 |
@ -160,7 +160,7 @@ abstract class Packet extends FTNBase implements \Iterator, \Countable
|
|||||||
try {
|
try {
|
||||||
$o->zone = Zone::where('zone_id',$o->fz)
|
$o->zone = Zone::where('zone_id',$o->fz)
|
||||||
->where('default',TRUE)
|
->where('default',TRUE)
|
||||||
->singleOrFail();
|
->sole();
|
||||||
|
|
||||||
} catch (ModelNotFoundException $e) {
|
} catch (ModelNotFoundException $e) {
|
||||||
throw new InvalidPacketException(sprintf('%s:! We couldnt work out the packet zone, and there isnt a default for[%d]',self::LOGKEY,$o->fz));
|
throw new InvalidPacketException(sprintf('%s:! We couldnt work out the packet zone, and there isnt a default for[%d]',self::LOGKEY,$o->fz));
|
||||||
@ -263,7 +263,7 @@ abstract class Packet extends FTNBase implements \Iterator, \Countable
|
|||||||
|
|
||||||
case 'software':
|
case 'software':
|
||||||
Software::unguard();
|
Software::unguard();
|
||||||
$o = Software::singleOrNew(['code'=>$this->product,'type'=>Software::SOFTWARE_TOSSER]);
|
$o = Software::firstOrNew(['code'=>$this->product,'type'=>Software::SOFTWARE_TOSSER]);
|
||||||
Software::reguard();
|
Software::reguard();
|
||||||
|
|
||||||
return $o;
|
return $o;
|
||||||
|
50
app/Classes/FTN/Process/Netmail/Robot.php
Normal file
50
app/Classes/FTN/Process/Netmail/Robot.php
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Classes\FTN\Process\Netmail;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Notification;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
|
use App\Classes\FTN\Process;
|
||||||
|
use App\Models\{Echomail,Netmail};
|
||||||
|
use App\Notifications\Netmails\Areafix\{InvalidPassword,NotConfiguredHere};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Process messages to Ping
|
||||||
|
*
|
||||||
|
* @package App\Classes\FTN\Process
|
||||||
|
*/
|
||||||
|
abstract class Robot extends Process
|
||||||
|
{
|
||||||
|
private const LOGKEY = 'RPR';
|
||||||
|
|
||||||
|
public static function handle(Echomail|Netmail $mo): bool
|
||||||
|
{
|
||||||
|
if (((strtolower($mo->to) !== 'areafix') && (strtolower($mo->to) !== 'filefix')) || (! ($mo instanceof Netmail)))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
Log::info(sprintf('%s:- Processing *FIX [%s] message from (%s) [%s]',self::LOGKEY,$mo->to,$mo->from,$mo->fftn->ftn));
|
||||||
|
|
||||||
|
// If this is not a node we manage, then respond with a sorry can help you
|
||||||
|
if (! $mo->fftn->system->sessions->count()) {
|
||||||
|
Notification::route('netmail',$mo->fftn)->notify(new NotConfiguredHere($mo));
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If this nodes password is not correct
|
||||||
|
if ($mo->fftn->pass_fix !== strtoupper($mo->subject)) {
|
||||||
|
Notification::route('netmail',$mo->fftn)->notify(new InvalidPassword($mo));
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((strtolower($mo->to) === 'areafix'))
|
||||||
|
return static::areafix($mo);
|
||||||
|
|
||||||
|
if ((strtolower($mo->to) === 'filefix'))
|
||||||
|
return static::filefix($mo);
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
93
app/Classes/FTN/Process/Netmail/Robot/Areafix.php
Normal file
93
app/Classes/FTN/Process/Netmail/Robot/Areafix.php
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Classes\FTN\Process\Netmail\Robot;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Notification;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
|
use App\Classes\FTN\Process\Netmail\Robot;
|
||||||
|
use App\Models\{Echomail,Netmail};
|
||||||
|
use App\Notifications\Netmails\Areafix\CommandsProcessed;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Process messages to Ping
|
||||||
|
*
|
||||||
|
* @package App\Classes\FTN\Process
|
||||||
|
*/
|
||||||
|
final class Areafix extends Robot
|
||||||
|
{
|
||||||
|
private const LOGKEY = 'RPA';
|
||||||
|
|
||||||
|
public const commands = 'App\\Classes\\FTN\\Process\\Netmail\\Robot\\Areafix\\';
|
||||||
|
|
||||||
|
public static function handle(Echomail|Netmail $mo): bool
|
||||||
|
{
|
||||||
|
if ((strtolower($mo->to) !== 'areafix') || (! ($mo instanceof Netmail)))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
Log::info(sprintf('%s:- Processing AREAFIX [%s] message from (%s) [%s]', self::LOGKEY, $mo->to, $mo->from, $mo->fftn->ftn));
|
||||||
|
|
||||||
|
return parent::handle($mo);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function areafix(Netmail $mo): bool
|
||||||
|
{
|
||||||
|
$result = collect();
|
||||||
|
$result->push('--> BEGIN <--');
|
||||||
|
|
||||||
|
foreach ($mo->body_lines as $command) {
|
||||||
|
// Skip empty lines
|
||||||
|
if (! $command)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
$command = explode(' ',strtoupper(trim($command)));
|
||||||
|
|
||||||
|
// If command starts with '...' or '---', its a tear/tag line, and we have reached the end
|
||||||
|
if (str_starts_with($command[0],'...') || str_starts_with($command[0],'---')) {
|
||||||
|
Log::debug(sprintf('%s:= We got a tearline/tagline, end of processing',self::LOGKEY));
|
||||||
|
|
||||||
|
$result->push('--> END OF PROCESSING <--');
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
// If command doesnt start with %, its an area
|
||||||
|
} elseif (! str_starts_with($command[0],'%')) {
|
||||||
|
Log::info(sprintf('%s:= Assuming command [%s] is an AREA command',self::LOGKEY,$command[0]));
|
||||||
|
|
||||||
|
array_unshift($command,'%AREA');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Some commands are reserved words
|
||||||
|
switch ($x=strtolower(substr($command[0],1))) {
|
||||||
|
case 'list':
|
||||||
|
$class = self::commands.'AreaList';
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
// Parse the message body and pluck out the commands on each line
|
||||||
|
$class = self::commands.ucfirst($x);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! class_exists($class)) {
|
||||||
|
$result->push(sprintf('%-25s <-- **COMMAND UNKNOWN**',join(' ',$command)));
|
||||||
|
Log::info(sprintf('%s:! Command UNKNOWN [%s] ',self::LOGKEY,join('|',$command)),['class'=>$class]);
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Drop the command from the array, the rest are arguments
|
||||||
|
array_shift($command);
|
||||||
|
|
||||||
|
// Refresh our echoareas
|
||||||
|
$mo->fftn->load('echoareas');
|
||||||
|
|
||||||
|
$o = new $class($mo,$command);
|
||||||
|
$result->push($o->process());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reply with a confirmation of what commands were processed
|
||||||
|
Notification::route('netmail',$mo->fftn)->notify(new CommandsProcessed($mo,$result));
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
}
|
@ -5,7 +5,7 @@ namespace App\Classes\FTN\Process\Netmail\Robot\Areafix;
|
|||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
use Illuminate\Support\Facades\Notification;
|
use Illuminate\Support\Facades\Notification;
|
||||||
|
|
||||||
use App\Classes\FTN\Process\Netmail\Areafix;
|
use App\Classes\FTN\Process\Netmail\Robot\Areafix;
|
||||||
use App\Notifications\Netmails\Areafix\Help as HelpNotification;
|
use App\Notifications\Netmails\Areafix\Help as HelpNotification;
|
||||||
|
|
||||||
// A Help Index Command
|
// A Help Index Command
|
||||||
@ -33,7 +33,7 @@ class Help extends Base
|
|||||||
if (($file === 'Base.php') || (! str_ends_with(strtolower($file),'.php')))
|
if (($file === 'Base.php') || (! str_ends_with(strtolower($file),'.php')))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
$class = Areafix::areafix_commands.preg_replace('/\.php$/','',$file);
|
$class = Areafix::commands.preg_replace('/\.php$/','',$file);
|
||||||
if ($result->count())
|
if ($result->count())
|
||||||
$result->push('');
|
$result->push('');
|
||||||
|
|
||||||
|
@ -1,58 +1,36 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Classes\FTN\Process\Netmail;
|
namespace App\Classes\FTN\Process\Netmail\Robot;
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Notification;
|
use Illuminate\Support\Facades\Notification;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
use App\Classes\FTN\Process;
|
use App\Classes\FTN\Process\Netmail\Robot;
|
||||||
use App\Classes\FTN\Process\Netmail\Robot\Unknown;
|
|
||||||
use App\Models\{Echomail,Netmail};
|
use App\Models\{Echomail,Netmail};
|
||||||
use App\Notifications\Netmails\FixCantHandle;
|
use App\Notifications\Netmails\Areafix\CommandsProcessed;
|
||||||
use App\Notifications\Netmails\Areafix\{CommandsProcessed,InvalidPassword,NotConfiguredHere};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Process messages to Ping
|
* Process messages to Ping
|
||||||
*
|
*
|
||||||
* @package App\Classes\FTN\Process
|
* @package App\Classes\FTN\Process
|
||||||
*/
|
*/
|
||||||
final class Areafix extends Process
|
final class Filefix extends Robot
|
||||||
{
|
{
|
||||||
private const LOGKEY = 'RP-';
|
private const LOGKEY = 'RPF';
|
||||||
|
|
||||||
public const areafix_commands = 'App\\Classes\\FTN\\Process\\Netmail\\Robot\\Areafix\\';
|
public const commands = 'App\\Classes\\FTN\\Process\\Netmail\\Robot\\Filefix\\';
|
||||||
|
|
||||||
public static function handle(Echomail|Netmail $mo): bool
|
public static function handle(Echomail|Netmail $mo): bool
|
||||||
{
|
{
|
||||||
if (((strtolower($mo->to) !== 'areafix') && (strtolower($mo->to) !== 'filefix')) || (! ($mo instanceof Netmail)))
|
if ((strtolower($mo->to) !== 'filefix') || (! ($mo instanceof Netmail)))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
Log::info(sprintf('%s:- Processing *FIX [%s] message from (%s) [%s]',self::LOGKEY,$mo->to,$mo->from,$mo->fftn->ftn));
|
Log::info(sprintf('%s:- Processing FILEFIX [%s] message from (%s) [%s]', self::LOGKEY, $mo->to, $mo->from, $mo->fftn->ftn));
|
||||||
|
|
||||||
// If this is not a node we manage, then respond with a sorry can help you
|
return parent::handle($mo);
|
||||||
if (! $mo->fftn->system->sessions->count()) {
|
|
||||||
Notification::route('netmail',$mo->fftn)->notify(new NotConfiguredHere($mo));
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If this nodes password is not correct
|
|
||||||
if ($mo->fftn->pass_fix !== strtoupper($mo->subject)) {
|
|
||||||
Notification::route('netmail',$mo->fftn)->notify(new InvalidPassword($mo));
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((strtolower($mo->to) === 'areafix'))
|
|
||||||
return self::areafix($mo);
|
|
||||||
|
|
||||||
if ((strtolower($mo->to) === 'filefix'))
|
|
||||||
return self::filefix($mo);
|
|
||||||
|
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function areafix(Netmail $mo): bool
|
public static function filefix(Netmail $mo): bool
|
||||||
{
|
{
|
||||||
$result = collect();
|
$result = collect();
|
||||||
$result->push('--> BEGIN <--');
|
$result->push('--> BEGIN <--');
|
||||||
@ -82,12 +60,12 @@ final class Areafix extends Process
|
|||||||
// Some commands are reserved words
|
// Some commands are reserved words
|
||||||
switch ($x=strtolower(substr($command[0],1))) {
|
switch ($x=strtolower(substr($command[0],1))) {
|
||||||
case 'list':
|
case 'list':
|
||||||
$class = self::areafix_commands.'AreaList';
|
$class = self::commands.'AreaList';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// Parse the message body and pluck out the commands on each line
|
// Parse the message body and pluck out the commands on each line
|
||||||
$class = self::areafix_commands.ucfirst($x);
|
$class = self::commands.ucfirst($x);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! class_exists($class)) {
|
if (! class_exists($class)) {
|
||||||
@ -101,7 +79,7 @@ final class Areafix extends Process
|
|||||||
array_shift($command);
|
array_shift($command);
|
||||||
|
|
||||||
// Refresh our echoareas
|
// Refresh our echoareas
|
||||||
$mo->fftn->load('echoareas');
|
$mo->fftn->load('fileareas');
|
||||||
|
|
||||||
$o = new $class($mo,$command);
|
$o = new $class($mo,$command);
|
||||||
$result->push($o->process());
|
$result->push($o->process());
|
||||||
@ -112,11 +90,4 @@ final class Areafix extends Process
|
|||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function filefix(Netmail $mo): bool
|
|
||||||
{
|
|
||||||
Notification::route('netmail',$mo->fftn)->notify(new FixCantHandle($mo));
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
}
|
}
|
39
app/Classes/FTN/Process/Netmail/Robot/Filefix/AreaList.php
Normal file
39
app/Classes/FTN/Process/Netmail/Robot/Filefix/AreaList.php
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Classes\FTN\Process\Netmail\Robot\Filefix;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
use Illuminate\Support\Facades\Notification;
|
||||||
|
|
||||||
|
use App\Classes\FTN\Process\Netmail\Robot\Areafix\Base;
|
||||||
|
use App\Notifications\Netmails\Filefix\AreaList as AreaListNotification;
|
||||||
|
|
||||||
|
// LIST - List echoareas in a domain
|
||||||
|
class AreaList extends Base
|
||||||
|
{
|
||||||
|
private const LOGKEY = 'AFS';
|
||||||
|
private const command = '%LIST';
|
||||||
|
|
||||||
|
public static function help(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
self::command,
|
||||||
|
' List the available fileareas in this network',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function process(): string
|
||||||
|
{
|
||||||
|
Log::debug(sprintf('%s:- Filefix [%s] for [%s] for [%s]',self::LOGKEY,self::command,$this->mo->fftn->ftn,join('|',$this->arguments)));
|
||||||
|
|
||||||
|
if (count($this->arguments) > 1)
|
||||||
|
return sprintf('%-25s <-- INVALID COMMAND',self::command);
|
||||||
|
|
||||||
|
else {
|
||||||
|
Notification::route('netmail',$this->mo->fftn)
|
||||||
|
->notify(new AreaListNotification($this->mo));
|
||||||
|
|
||||||
|
return sprintf('%-25s <-- COMMAND PROCESSED',self::command);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
50
app/Classes/FTN/Process/Netmail/Robot/Filefix/Help.php
Normal file
50
app/Classes/FTN/Process/Netmail/Robot/Filefix/Help.php
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Classes\FTN\Process\Netmail\Robot\Filefix;
|
||||||
|
|
||||||
|
use App\Classes\FTN\Process\Netmail\Robot\Areafix\Base;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
use Illuminate\Support\Facades\Notification;
|
||||||
|
|
||||||
|
use App\Classes\FTN\Process\Netmail\Robot\Filefix;
|
||||||
|
use App\Notifications\Netmails\Filefix\Help as HelpNotification;
|
||||||
|
|
||||||
|
// A Help Index Command
|
||||||
|
class Help extends Base
|
||||||
|
{
|
||||||
|
private const LOGKEY = 'FFH';
|
||||||
|
|
||||||
|
private const filefix_classes = 'app/Classes/FTN/Process/Netmail/Robot/Filefix';
|
||||||
|
private const command = '%HELP';
|
||||||
|
|
||||||
|
public static function help(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
self::command,
|
||||||
|
' This message!',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function process(): string
|
||||||
|
{
|
||||||
|
Log::debug(sprintf('%s:- Processing [%s] for [%s]',self::LOGKEY,self::command,$this->mo->fftn->ftn));
|
||||||
|
|
||||||
|
$result = collect();
|
||||||
|
|
||||||
|
foreach (preg_grep('/^([^.])/',scandir(self::filefix_classes)) as $file) {
|
||||||
|
if (($file === 'Base.php') || (! str_ends_with(strtolower($file),'.php')))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
$class = Filefix::commands.preg_replace('/\.php$/','',$file);
|
||||||
|
if ($result->count())
|
||||||
|
$result->push('');
|
||||||
|
|
||||||
|
$result = $result
|
||||||
|
->merge($class::help());
|
||||||
|
}
|
||||||
|
|
||||||
|
Notification::route('netmail',$this->mo->fftn)->notify(new HelpNotification($this->mo,$result));
|
||||||
|
|
||||||
|
return sprintf('%-25s <-- COMMAND PROCESSED',self::command);
|
||||||
|
}
|
||||||
|
}
|
201
app/Classes/Fonts/Ansitex.php
Normal file
201
app/Classes/Fonts/Ansitex.php
Normal file
@ -0,0 +1,201 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Classes\Fonts;
|
||||||
|
|
||||||
|
use App\Classes\Font;
|
||||||
|
|
||||||
|
final class Ansitex extends Font
|
||||||
|
{
|
||||||
|
protected const FONT = [
|
||||||
|
'a' => [
|
||||||
|
[0xda,0xc4,0xdc],
|
||||||
|
[0xb3,0xdf,0xdb],
|
||||||
|
[0x20,0x20,0x20],
|
||||||
|
],
|
||||||
|
'b' => [
|
||||||
|
[0xb3,0xc4,0xdc],
|
||||||
|
[0xb3,0x5f,0xdb],
|
||||||
|
[0x20,0x20,0x20],
|
||||||
|
],
|
||||||
|
'c' => [
|
||||||
|
[0xda,0xc4,0xdc],
|
||||||
|
[0xb3,0x5f,0xdc],
|
||||||
|
[0x20,0x20,0x20],
|
||||||
|
],
|
||||||
|
'd' => [
|
||||||
|
[0xda,0xc4,0xdb],
|
||||||
|
[0xb3,0x5f,0xdb],
|
||||||
|
[0x20,0x20,0x20],
|
||||||
|
],
|
||||||
|
'e' => [
|
||||||
|
[0xda,0xc4,0xdc],
|
||||||
|
[0xc3,0x5f,0xdc],
|
||||||
|
[0x20,0x20,0x20],
|
||||||
|
],
|
||||||
|
'f' => [
|
||||||
|
[0xda,0xc4,0xdc],
|
||||||
|
[0xc3,0x20,0x20],
|
||||||
|
[0x20,0x20,0x20],
|
||||||
|
],
|
||||||
|
'g' => [
|
||||||
|
[0xda,0xc4,0xdc],
|
||||||
|
[0xb3,0x5f,0xdb],
|
||||||
|
[0x20,0xc4,0xdf],
|
||||||
|
],
|
||||||
|
'h' => [
|
||||||
|
[0xde,0xc4,0xdc],
|
||||||
|
[0xde,0x20,0xdb],
|
||||||
|
[0x20,0x20,0x20],
|
||||||
|
],
|
||||||
|
'i' => [
|
||||||
|
[0x20,0xdf],
|
||||||
|
[0xde,0xdb],
|
||||||
|
[0x20,0x20],
|
||||||
|
],
|
||||||
|
'j' => [
|
||||||
|
[0x20,0xdf],
|
||||||
|
[0xde,0xdb],
|
||||||
|
[0xc4,0xdf],
|
||||||
|
],
|
||||||
|
'k' => [
|
||||||
|
[0xb3,0x20,0xdc],
|
||||||
|
[0xb3,0x60,0xdc],
|
||||||
|
[0x20,0x20,0x20],
|
||||||
|
],
|
||||||
|
'l' => [
|
||||||
|
[0xb3,0x20],
|
||||||
|
[0xb3,0xdc],
|
||||||
|
[0x20,0x20],
|
||||||
|
],
|
||||||
|
'm' => [
|
||||||
|
[0xda,0xda,0xdc],
|
||||||
|
[0xb3,0xb3,0xdb],
|
||||||
|
[0x20,0x20,0x20],
|
||||||
|
],
|
||||||
|
'n' => [
|
||||||
|
[0xda,0xc4,0xdc],
|
||||||
|
[0xb3,0x20,0xdb],
|
||||||
|
[0x20,0x20,0x20],
|
||||||
|
],
|
||||||
|
'o' => [
|
||||||
|
[0xda,0xc4,0xdc],
|
||||||
|
[0xb3,0x5f,0xdb],
|
||||||
|
[0x20,0x20,0x20],
|
||||||
|
],
|
||||||
|
'p' => [
|
||||||
|
[0xda,0xc4,0xdc],
|
||||||
|
[0xb3,0x5f,0xdb],
|
||||||
|
[0xc0,0x20,0x20],
|
||||||
|
],
|
||||||
|
'q' => [
|
||||||
|
[0xda,0xc4,0xdc],
|
||||||
|
[0xb3,0x5f,0xdb],
|
||||||
|
[0x20,0x20,0xdf],
|
||||||
|
],
|
||||||
|
'r' => [
|
||||||
|
[0xda,0xc4,0xdc],
|
||||||
|
[0xb3,0xc1,0x5c],
|
||||||
|
[0x20,0x20,0x20],
|
||||||
|
],
|
||||||
|
's' => [
|
||||||
|
[0xda,0xc4,0xdc],
|
||||||
|
[0x2e,0x5c,0xdc],
|
||||||
|
[0x20,0x20,0x20],
|
||||||
|
],
|
||||||
|
't' => [
|
||||||
|
[0xda,0xc2,0xdc],
|
||||||
|
[0x20,0xb3,0x20],
|
||||||
|
[0x20,0x20,0x20],
|
||||||
|
],
|
||||||
|
'u' => [
|
||||||
|
[0xda,0x20,0xdc],
|
||||||
|
[0xb3,0x5f,0xdb],
|
||||||
|
[0x20,0x20,0x20],
|
||||||
|
],
|
||||||
|
'v' => [
|
||||||
|
[0xda,0x20,0xdc],
|
||||||
|
[0x60,0x5c,0xdb],
|
||||||
|
[0x20,0x20,0x20],
|
||||||
|
],
|
||||||
|
'w' => [
|
||||||
|
[0xda,0xda,0xdb],
|
||||||
|
[0x60,0x5c,0xdb],
|
||||||
|
[0x20,0x20,0x20],
|
||||||
|
],
|
||||||
|
'x' => [
|
||||||
|
[0xda,0x20,0xdc],
|
||||||
|
[0xda,0xdf,0xdc],
|
||||||
|
[0x20,0x20,0x20],
|
||||||
|
],
|
||||||
|
'y' => [
|
||||||
|
[0xda,0x20,0xdc],
|
||||||
|
[0xb3,0x5f,0xdb],
|
||||||
|
[0x20,0xc4,0xdf],
|
||||||
|
],
|
||||||
|
'z' => [
|
||||||
|
[0xda,0xc4,0xdc],
|
||||||
|
[0x2e,0x2f,0xdc],
|
||||||
|
[0x20,0x20,0x20],
|
||||||
|
],
|
||||||
|
'1' => [
|
||||||
|
[0xc4,0xdc],
|
||||||
|
[0x20,0xdb],
|
||||||
|
[0x20,0x20],
|
||||||
|
],
|
||||||
|
'2' => [
|
||||||
|
[0xfe,0xc4,0xdc],
|
||||||
|
[0xda,0x2f,0xdc],
|
||||||
|
[0x20,0x20,0x20],
|
||||||
|
],
|
||||||
|
'3' => [
|
||||||
|
[0xda,0xc4,0xdc],
|
||||||
|
[0xda,0xf0,0xdb],
|
||||||
|
[0x20,0x20,0x20],
|
||||||
|
],
|
||||||
|
'4' => [
|
||||||
|
[0xde,0x20,0xdc],
|
||||||
|
[0xc0,0xc4,0xdb],
|
||||||
|
[0x20,0x20,0x20],
|
||||||
|
],
|
||||||
|
'5' => [
|
||||||
|
[0xda,0xc4,0xdc],
|
||||||
|
[0x2e,0x2d,0xdc],
|
||||||
|
[0x20,0x20,0x20],
|
||||||
|
],
|
||||||
|
'6' => [
|
||||||
|
[0xde,0xc4,0xbf],
|
||||||
|
[0xb3,0x5f,0xdb],
|
||||||
|
[0x20,0x20,0x20],
|
||||||
|
],
|
||||||
|
'7' => [
|
||||||
|
[0xfe,0x2d,0xbf],
|
||||||
|
[0x20,0xde,0x20],
|
||||||
|
[0x20,0x20,0x20],
|
||||||
|
],
|
||||||
|
'8' => [
|
||||||
|
[0xda,0xc4,0xdc],
|
||||||
|
[0xc3,0xf0,0xdb],
|
||||||
|
[0x20,0x20,0x20],
|
||||||
|
],
|
||||||
|
'9' => [
|
||||||
|
[0xda,0xc4,0xdc],
|
||||||
|
[0xd4,0xc4,0xdb],
|
||||||
|
[0x20,0x20,0x20],
|
||||||
|
],
|
||||||
|
'0' => [
|
||||||
|
[0xda,0xc4,0xdc],
|
||||||
|
[0xb3,0x5f,0xdb],
|
||||||
|
[0x20,0x20,0x20],
|
||||||
|
],
|
||||||
|
'#' => [
|
||||||
|
[0xdc,0xba,0xdc],
|
||||||
|
[0xfe,0xba,0xfe],
|
||||||
|
[0x20,0x20,0x20],
|
||||||
|
],
|
||||||
|
'!' => [
|
||||||
|
[0xdb],
|
||||||
|
[0xfe],
|
||||||
|
[0x20],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
@ -3,11 +3,10 @@
|
|||||||
namespace App\Classes;
|
namespace App\Classes;
|
||||||
|
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Illuminate\Support\Facades\Config;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
use App\Classes\File\{Receive,Send};
|
use App\Classes\File\{Receive,Send};
|
||||||
use App\Classes\Protocol\EMSI;
|
use App\Classes\Protocol\{Binkp,DNS,EMSI,Zmodem};
|
||||||
use App\Classes\Sock\Exception\SocketException;
|
use App\Classes\Sock\Exception\SocketException;
|
||||||
use App\Classes\Sock\SocketClient;
|
use App\Classes\Sock\SocketClient;
|
||||||
use App\Models\{Address,Mailer,Setup,System,SystemLog};
|
use App\Models\{Address,Mailer,Setup,System,SystemLog};
|
||||||
@ -98,10 +97,10 @@ abstract class Protocol
|
|||||||
|
|
||||||
// File transfer status
|
// File transfer status
|
||||||
|
|
||||||
public const FOP_OK = 0;
|
public const FOP_OK = 0;
|
||||||
public const FOP_CONT = 1;
|
public const FOP_CONT = 1;
|
||||||
public const FOP_SKIP = 2;
|
public const FOP_SKIP = 2;
|
||||||
public const FOP_ERROR = 3;
|
public const FOP_ERROR = 3;
|
||||||
public const FOP_SUSPEND = 4;
|
public const FOP_SUSPEND = 4;
|
||||||
public const FOP_GOT = 5;
|
public const FOP_GOT = 5;
|
||||||
|
|
||||||
@ -123,10 +122,13 @@ abstract class Protocol
|
|||||||
protected array $capability; // @todo make private
|
protected array $capability; // @todo make private
|
||||||
/** @var bool Are we originating a connection */
|
/** @var bool Are we originating a connection */
|
||||||
protected bool $originate;
|
protected bool $originate;
|
||||||
/** Our comms details */
|
|
||||||
|
|
||||||
|
/** @var bool Is the application down for maintenance */
|
||||||
protected bool $down = FALSE;
|
protected bool $down = FALSE;
|
||||||
|
|
||||||
|
/** @var int Our mailer ID for logging purposes */
|
||||||
|
private int $mailer_id;
|
||||||
|
|
||||||
private array $comms;
|
private array $comms;
|
||||||
|
|
||||||
protected bool $force_queue = FALSE;
|
protected bool $force_queue = FALSE;
|
||||||
@ -135,9 +137,31 @@ abstract class Protocol
|
|||||||
|
|
||||||
abstract protected function protocol_session(bool $force_queue=FALSE): int;
|
abstract protected function protocol_session(bool $force_queue=FALSE): int;
|
||||||
|
|
||||||
public function __construct()
|
/**
|
||||||
|
* @param Setup $setup
|
||||||
|
* @throws \Exception
|
||||||
|
*/
|
||||||
|
public function __construct(Setup $setup)
|
||||||
{
|
{
|
||||||
$this->setup = Config::get('setup',Setup::findOrFail(config('app.id')));
|
$this->setup = $setup;
|
||||||
|
|
||||||
|
// Some initialisation details
|
||||||
|
switch (get_class($this)) {
|
||||||
|
case Binkp::class:
|
||||||
|
$this->mailer_id = Mailer::where('name','BINKP')->sole()->id;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DNS::class:
|
||||||
|
case Zmodem::class:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EMSI::class:
|
||||||
|
$this->mailer_id = Mailer::where('name','EMSI')->sole()->id;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw new \Exception('not handled'.get_class($this));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -246,20 +270,27 @@ abstract class Protocol
|
|||||||
* Incoming Protocol session
|
* Incoming Protocol session
|
||||||
*
|
*
|
||||||
* @param SocketClient $client
|
* @param SocketClient $client
|
||||||
* @return int|null
|
* @return int
|
||||||
* @throws SocketException
|
* @throws SocketException
|
||||||
*/
|
*/
|
||||||
public function onConnect(SocketClient $client): ?int
|
public function onConnect(SocketClient $client): int
|
||||||
{
|
{
|
||||||
$pid = pcntl_fork();
|
$pid = pcntl_fork();
|
||||||
|
|
||||||
if ($pid === -1)
|
if ($pid === -1)
|
||||||
throw new SocketException(SocketException::CANT_ACCEPT,'Could not fork process');
|
throw new SocketException(SocketException::CANT_ACCEPT,'Could not fork process');
|
||||||
|
|
||||||
|
// If our parent returns a PID, we've forked
|
||||||
if ($pid)
|
if ($pid)
|
||||||
Log::info(sprintf('%s:+ New connection from [%s], thread [%d] created',self::LOGKEY,$client->address_remote,$pid));
|
Log::info(sprintf('%s:+ New connection from [%s], thread [%d] created',self::LOGKEY,$client->address_remote,$pid));
|
||||||
|
|
||||||
// Parent return ready for next connection
|
// This is the new thread
|
||||||
|
else {
|
||||||
|
Log::withContext(['pid'=>getmypid()]);
|
||||||
|
|
||||||
|
$this->session($client,(new Address));
|
||||||
|
}
|
||||||
|
|
||||||
return $pid;
|
return $pid;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -302,6 +333,7 @@ abstract class Protocol
|
|||||||
* Our addresses to send to the remote
|
* Our addresses to send to the remote
|
||||||
*
|
*
|
||||||
* @return Collection
|
* @return Collection
|
||||||
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
protected function our_addresses(): Collection
|
protected function our_addresses(): Collection
|
||||||
{
|
{
|
||||||
@ -325,15 +357,14 @@ abstract class Protocol
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialise our Session
|
* Setup a session with a remote client
|
||||||
*
|
*
|
||||||
* @param Mailer $mo
|
* @param SocketClient $client Socket details of session
|
||||||
* @param SocketClient $client
|
* @param Address|null $o If we have an address, we originated a session to this Address
|
||||||
* @param Address|null $o
|
|
||||||
* @return int
|
* @return int
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public function session(Mailer $mo,SocketClient $client,Address $o=NULL): int
|
public function session(SocketClient $client,Address $o=NULL): int
|
||||||
{
|
{
|
||||||
if ($o->exists)
|
if ($o->exists)
|
||||||
Log::withContext(['ftn'=>$o->ftn]);
|
Log::withContext(['ftn'=>$o->ftn]);
|
||||||
@ -366,12 +397,10 @@ abstract class Protocol
|
|||||||
// We are an IP node
|
// We are an IP node
|
||||||
$this->optionSet(self::O_TCP);
|
$this->optionSet(self::O_TCP);
|
||||||
$this->client = $client;
|
$this->client = $client;
|
||||||
// @todo This appears to be a bug in laravel? Need to call app()->isDownForMaintenance() twice?
|
|
||||||
app()->isDownForMaintenance();
|
|
||||||
$this->down = app()->isDownForMaintenance();
|
$this->down = app()->isDownForMaintenance();
|
||||||
|
|
||||||
switch ($mo->name) {
|
switch (get_class($this)) {
|
||||||
case 'EMSI':
|
case EMSI::class:
|
||||||
Log::debug(sprintf('%s:- Starting EMSI',self::LOGKEY));
|
Log::debug(sprintf('%s:- Starting EMSI',self::LOGKEY));
|
||||||
|
|
||||||
$rc = $this->protocol_init();
|
$rc = $this->protocol_init();
|
||||||
@ -385,7 +414,7 @@ abstract class Protocol
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'BINKP':
|
case Binkp::class:
|
||||||
Log::debug(sprintf('%s:- Starting BINKP',self::LOGKEY));
|
Log::debug(sprintf('%s:- Starting BINKP',self::LOGKEY));
|
||||||
|
|
||||||
$rc = $this->protocol_session($this->originate);
|
$rc = $this->protocol_session($this->originate);
|
||||||
@ -393,13 +422,11 @@ abstract class Protocol
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
Log::error(sprintf('%s:! Unsupported session type [%d]',self::LOGKEY,$mo->id));
|
Log::error(sprintf('%s:! Unsupported session type [%s]',self::LOGKEY,get_class($this)));
|
||||||
|
|
||||||
return self::S_FAILURE;
|
return self::S_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// @todo Unlock outbounds
|
|
||||||
|
|
||||||
// @todo These flags determine when we connect to the remote.
|
// @todo These flags determine when we connect to the remote.
|
||||||
// If the remote indicated that they dont support file requests (NRQ) or temporarily hold them (HRQ)
|
// If the remote indicated that they dont support file requests (NRQ) or temporarily hold them (HRQ)
|
||||||
if (($this->node->optionGet(self::O_NRQ) && (! $this->setup->optionGet(EMSI::F_IGNORE_NRQ,'emsi_options'))) || $this->node->optionGet(self::O_HRQ))
|
if (($this->node->optionGet(self::O_NRQ) && (! $this->setup->optionGet(EMSI::F_IGNORE_NRQ,'emsi_options'))) || $this->node->optionGet(self::O_HRQ))
|
||||||
@ -430,6 +457,7 @@ abstract class Protocol
|
|||||||
if ($so && $so->exists) {
|
if ($so && $so->exists) {
|
||||||
foreach ($this->node->aka_other as $aka)
|
foreach ($this->node->aka_other as $aka)
|
||||||
// @todo For disabled zones, we shouldnt refuse to record the address
|
// @todo For disabled zones, we shouldnt refuse to record the address
|
||||||
|
// @todo If the system hasnt presented an address for a configured period (eg: 30 days) assume it no longer carries it
|
||||||
if ((! Address::findFTN($aka)) && ($oo=Address::createFTN($aka,$so))) {
|
if ((! Address::findFTN($aka)) && ($oo=Address::createFTN($aka,$so))) {
|
||||||
$oo->validated = TRUE;
|
$oo->validated = TRUE;
|
||||||
$oo->save();
|
$oo->save();
|
||||||
@ -441,7 +469,7 @@ abstract class Protocol
|
|||||||
$slo->items_sent_size = $this->send->total_sent_bytes;
|
$slo->items_sent_size = $this->send->total_sent_bytes;
|
||||||
$slo->items_recv = $this->recv->total_recv;
|
$slo->items_recv = $this->recv->total_recv;
|
||||||
$slo->items_recv_size = $this->recv->total_recv_bytes;
|
$slo->items_recv_size = $this->recv->total_recv_bytes;
|
||||||
$slo->mailer_id = $mo->id;
|
$slo->mailer_id = $this->mailer_id;
|
||||||
$slo->sessiontime = $this->node->session_time;
|
$slo->sessiontime = $this->node->session_time;
|
||||||
$slo->result = ($rc & self::S_MASK);
|
$slo->result = ($rc & self::S_MASK);
|
||||||
$slo->originate = $this->originate;
|
$slo->originate = $this->originate;
|
||||||
@ -455,12 +483,6 @@ abstract class Protocol
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// @todo Optional after session execution event
|
|
||||||
// if ($this->node->start_time && $this->setup->cfg('CFG_AFTERSESSION')) {}
|
|
||||||
|
|
||||||
// @todo Optional after session includes mail event
|
|
||||||
// if ($this->node->start_time && $this->setup->cfg('CFG_AFTERMAIL')) {}
|
|
||||||
|
|
||||||
return $rc;
|
return $rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,9 +12,8 @@ use App\Classes\Crypt;
|
|||||||
use App\Classes\Node;
|
use App\Classes\Node;
|
||||||
use App\Classes\Protocol as BaseProtocol;
|
use App\Classes\Protocol as BaseProtocol;
|
||||||
use App\Classes\Sock\Exception\SocketException;
|
use App\Classes\Sock\Exception\SocketException;
|
||||||
use App\Classes\Sock\SocketClient;
|
|
||||||
use App\Exceptions\{FileGrewException,InvalidFTNException};
|
use App\Exceptions\{FileGrewException,InvalidFTNException};
|
||||||
use App\Models\{Address,Mailer,Setup};
|
use App\Models\{Address,Setup};
|
||||||
|
|
||||||
final class Binkp extends BaseProtocol
|
final class Binkp extends BaseProtocol
|
||||||
{
|
{
|
||||||
@ -142,27 +141,6 @@ final class Binkp extends BaseProtocol
|
|||||||
*/
|
*/
|
||||||
private Crypt $crypt_out;
|
private Crypt $crypt_out;
|
||||||
|
|
||||||
/**
|
|
||||||
* Incoming BINKP session
|
|
||||||
*
|
|
||||||
* @param SocketClient $client
|
|
||||||
* @return int|null
|
|
||||||
* @throws SocketException
|
|
||||||
*/
|
|
||||||
public function onConnect(SocketClient $client): ?int
|
|
||||||
{
|
|
||||||
// If our parent returns a PID, we've forked
|
|
||||||
if (! parent::onConnect($client)) {
|
|
||||||
Log::withContext(['pid'=>getmypid()]);
|
|
||||||
|
|
||||||
$this->session(Mailer::where('name','BINKP')->singleOrFail(),$client,(new Address));
|
|
||||||
$this->client->close();
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BINKD handshake
|
* BINKD handshake
|
||||||
*
|
*
|
||||||
|
@ -6,7 +6,6 @@ use Illuminate\Support\Facades\Log;
|
|||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
use App\Classes\Protocol as BaseProtocol;
|
use App\Classes\Protocol as BaseProtocol;
|
||||||
use App\Classes\Sock\SocketClient;
|
|
||||||
use App\Models\{Address,Domain,Mailer};
|
use App\Models\{Address,Domain,Mailer};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -64,22 +63,6 @@ final class DNS extends BaseProtocol
|
|||||||
public const DNS_TYPE_OPT = 41; // OPT Records
|
public const DNS_TYPE_OPT = 41; // OPT Records
|
||||||
public const DNS_TYPE_DS = 43; // DS Records (Delegation signer RFC 4034)
|
public const DNS_TYPE_DS = 43; // DS Records (Delegation signer RFC 4034)
|
||||||
|
|
||||||
public function onConnect(SocketClient $client): ?int
|
|
||||||
{
|
|
||||||
// If our parent returns a PID, we've forked
|
|
||||||
if (! parent::onConnect($client)) {
|
|
||||||
Log::withContext(['pid'=>getmypid()]);
|
|
||||||
|
|
||||||
$this->client = $client;
|
|
||||||
$this->protocol_session();
|
|
||||||
|
|
||||||
Log::debug(sprintf('%s:= onConnect - Connection closed [%s]',self::LOGKEY,$client->address_remote));
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function protocol_init(): int
|
protected function protocol_init(): int
|
||||||
{
|
{
|
||||||
// N/A
|
// N/A
|
||||||
@ -179,11 +162,11 @@ final class DNS extends BaseProtocol
|
|||||||
|
|
||||||
switch ($labels->first()) {
|
switch ($labels->first()) {
|
||||||
case '_binkp':
|
case '_binkp':
|
||||||
$mailer = Mailer::where('name','BINKP')->singleOrFail();
|
$mailer = Mailer::where('name','BINKP')->sole();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '_ifcico':
|
case '_ifcico':
|
||||||
$mailer = Mailer::where('name','EMSI')->singleOrFail();
|
$mailer = Mailer::where('name','EMSI')->sole();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -7,11 +7,10 @@ use Illuminate\Support\Facades\Log;
|
|||||||
|
|
||||||
use App\Classes\Protocol as BaseProtocol;
|
use App\Classes\Protocol as BaseProtocol;
|
||||||
use App\Classes\Sock\Exception\SocketException;
|
use App\Classes\Sock\Exception\SocketException;
|
||||||
use App\Classes\Sock\SocketClient;
|
|
||||||
use App\Exceptions\InvalidFTNException;
|
use App\Exceptions\InvalidFTNException;
|
||||||
use App\Interfaces\CRC as CRCInterface;
|
use App\Interfaces\CRC as CRCInterface;
|
||||||
use App\Interfaces\Zmodem as ZmodemInterface;
|
use App\Interfaces\Zmodem as ZmodemInterface;
|
||||||
use App\Models\{Address,Mailer,Setup};
|
use App\Models\{Address,Setup};
|
||||||
use App\Traits\CRC as CRCTrait;
|
use App\Traits\CRC as CRCTrait;
|
||||||
|
|
||||||
// http://ftsc.org/docs/fsc-0056.001
|
// http://ftsc.org/docs/fsc-0056.001
|
||||||
@ -82,27 +81,6 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface
|
|||||||
'1'=>self::P_ZMODEM,
|
'1'=>self::P_ZMODEM,
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
|
||||||
* Incoming EMSI session
|
|
||||||
*
|
|
||||||
* @param SocketClient $client
|
|
||||||
* @return int|null
|
|
||||||
* @throws SocketException
|
|
||||||
*/
|
|
||||||
public function onConnect(SocketClient $client): ?int
|
|
||||||
{
|
|
||||||
// If our parent returns a PID, we've forked
|
|
||||||
if (! parent::onConnect($client)) {
|
|
||||||
Log::withContext(['pid'=>getmypid()]);
|
|
||||||
|
|
||||||
$this->session(Mailer::where('name','EMSI')->singleOrFail(),$client,(new Address));
|
|
||||||
$this->client->close();
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send our welcome banner
|
* Send our welcome banner
|
||||||
*
|
*
|
||||||
|
@ -10,7 +10,7 @@ use App\Classes\Sock\Exception\SocketException;
|
|||||||
use App\Classes\Sock\SocketClient;
|
use App\Classes\Sock\SocketClient;
|
||||||
use App\Interfaces\CRC as CRCInterface;
|
use App\Interfaces\CRC as CRCInterface;
|
||||||
use App\Interfaces\Zmodem as ZmodemInterface;
|
use App\Interfaces\Zmodem as ZmodemInterface;
|
||||||
use App\Models\{Address,Mailer};
|
use App\Models\Address;
|
||||||
use App\Traits\CRC as CRCTrait;
|
use App\Traits\CRC as CRCTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -202,27 +202,6 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
|
|||||||
private string $rxbuf = '';
|
private string $rxbuf = '';
|
||||||
private string $txbuf = '';
|
private string $txbuf = '';
|
||||||
|
|
||||||
/**
|
|
||||||
* @param SocketClient $client
|
|
||||||
* @return null
|
|
||||||
* @throws SocketException
|
|
||||||
*/
|
|
||||||
public function onConnect(SocketClient $client): ?int
|
|
||||||
{
|
|
||||||
// If our parent returns a PID, we've forked
|
|
||||||
if (! parent::onConnect($client)) {
|
|
||||||
Log::withContext(['pid'=>getmypid()]);
|
|
||||||
|
|
||||||
$this->session(Mailer::where('name','ZMODEM')->singleOrFail(),$client);
|
|
||||||
$this->client->close();
|
|
||||||
|
|
||||||
Log::info(sprintf('%s:= onConnect - Connection closed [%s]',self::LOGKEY,$client->address_remote));
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialise our session
|
* Initialise our session
|
||||||
*/
|
*/
|
||||||
|
@ -141,7 +141,11 @@ final class SocketServer {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->handler[0]->{$this->handler[1]}($r);
|
// If the handler returns a value, then that is the main thread
|
||||||
|
if (! $this->handler[0]->{$this->handler[1]}($r)) {
|
||||||
|
$r->close();
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ class AddressIdle extends Command
|
|||||||
*/
|
*/
|
||||||
public function handle(): int
|
public function handle(): int
|
||||||
{
|
{
|
||||||
$do = Domain::where('name',$this->argument('domain'))->singleOrFail();
|
$do = Domain::where('name',$this->argument('domain'))->sole();
|
||||||
|
|
||||||
return Job::dispatchSync($do,$this->option('ftn') ? Address::findFTN($this->option('ftn')) : NULL);
|
return Job::dispatchSync($do,$this->option('ftn') ? Address::findFTN($this->option('ftn')) : NULL);
|
||||||
}
|
}
|
||||||
|
@ -1,53 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Console\Commands;
|
|
||||||
|
|
||||||
use Illuminate\Console\Command;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
use App\Classes\Protocol\Binkp;
|
|
||||||
use App\Classes\Sock\Exception\SocketException;
|
|
||||||
use App\Classes\Sock\SocketServer;
|
|
||||||
use App\Models\Setup;
|
|
||||||
|
|
||||||
class CommBinkpReceive extends Command
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* The name and signature of the console command.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $signature = 'comm:binkp:receive';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The console command description.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $description = 'BINKP receive';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Execute the console command.
|
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
* @throws SocketException
|
|
||||||
*/
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
Log::info('Listening for BINKP connections...');
|
|
||||||
$o = Setup::findOrFail(config('app.id'));
|
|
||||||
|
|
||||||
$server = new SocketServer($o->binkp_port,$o->binkp_bind);
|
|
||||||
$server->handler = [new Binkp,'onConnect'];
|
|
||||||
|
|
||||||
try {
|
|
||||||
$server->listen();
|
|
||||||
|
|
||||||
} catch (SocketException $e) {
|
|
||||||
if ($e->getMessage() === 'Can\'t accept connections: "Success"')
|
|
||||||
Log::debug('Server Terminated');
|
|
||||||
else
|
|
||||||
Log::emergency('Uncaught Message: '.$e->getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -27,8 +27,6 @@ class CommBinkpSend extends Command
|
|||||||
*/
|
*/
|
||||||
protected $description = 'BINKP send';
|
protected $description = 'BINKP send';
|
||||||
|
|
||||||
private const ID = 'BINKP';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute the console command.
|
* Execute the console command.
|
||||||
*
|
*
|
||||||
@ -42,7 +40,7 @@ class CommBinkpSend extends Command
|
|||||||
|
|
||||||
Log::info(sprintf('CBS:- Call BINKP send for %s',$ao->ftn));
|
Log::info(sprintf('CBS:- Call BINKP send for %s',$ao->ftn));
|
||||||
|
|
||||||
$mo = Mailer::where('name',self::ID)->singleOrFail();
|
$mo = Mailer::where('name','BINKP')->sole();
|
||||||
|
|
||||||
if ($this->option('now'))
|
if ($this->option('now'))
|
||||||
Job::dispatchSync($ao,$mo);
|
Job::dispatchSync($ao,$mo);
|
||||||
|
@ -1,53 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Console\Commands;
|
|
||||||
|
|
||||||
use Illuminate\Console\Command;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
use App\Classes\Protocol\EMSI;
|
|
||||||
use App\Classes\Sock\Exception\SocketException;
|
|
||||||
use App\Classes\Sock\SocketServer;
|
|
||||||
use App\Models\Setup;
|
|
||||||
|
|
||||||
class CommEMSIReceive extends Command
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* The name and signature of the console command.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $signature = 'comm:emsi:receive';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The console command description.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $description = 'EMSI receive';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Execute the console command.
|
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
* @throws \Exception
|
|
||||||
*/
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
Log::info('Listening for EMSI connections...');
|
|
||||||
$o = Setup::findOrFail(config('app.id'));
|
|
||||||
|
|
||||||
$server = new SocketServer($o->emsi_port,$o->emsi_bind);
|
|
||||||
$server->handler = [new EMSI,'onConnect'];
|
|
||||||
|
|
||||||
try {
|
|
||||||
$server->listen();
|
|
||||||
|
|
||||||
} catch (SocketException $e) {
|
|
||||||
if ($e->getMessage() === 'Can\'t accept connections: "Success"')
|
|
||||||
Log::debug('Server Terminated');
|
|
||||||
else
|
|
||||||
Log::emergency('Uncaught Message: '.$e->getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -27,8 +27,6 @@ class CommEMSISend extends Command
|
|||||||
*/
|
*/
|
||||||
protected $description = 'EMSI send';
|
protected $description = 'EMSI send';
|
||||||
|
|
||||||
private const ID = 'EMSI';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute the console command.
|
* Execute the console command.
|
||||||
*
|
*
|
||||||
@ -42,7 +40,7 @@ class CommEMSISend extends Command
|
|||||||
|
|
||||||
Log::info(sprintf('CES:- Call EMSI send for %s',$ao->ftn));
|
Log::info(sprintf('CES:- Call EMSI send for %s',$ao->ftn));
|
||||||
|
|
||||||
$mo = Mailer::where('name',self::ID)->singleOrFail();
|
$mo = Mailer::where('name','EMSI')->sole();
|
||||||
|
|
||||||
if ($this->option('now'))
|
if ($this->option('now'))
|
||||||
Job::dispatchSync($ao,$mo);
|
Job::dispatchSync($ao,$mo);
|
||||||
|
@ -16,7 +16,7 @@ class ZoneCheck extends Command
|
|||||||
|
|
||||||
public function handle(): int
|
public function handle(): int
|
||||||
{
|
{
|
||||||
$do = Domain::where('name',$this->argument('domain'))->singleOrFail();
|
$do = Domain::where('name',$this->argument('domain'))->sole();
|
||||||
|
|
||||||
foreach ($do->zones->sortby('zone_id') as $zo) {
|
foreach ($do->zones->sortby('zone_id') as $zo) {
|
||||||
if ($this->option('zone') && ($this->option('zone') != $zo->zone_id))
|
if ($this->option('zone') && ($this->option('zone') != $zo->zone_id))
|
||||||
|
@ -34,7 +34,8 @@ class EchoareaImport extends Command
|
|||||||
*/
|
*/
|
||||||
public function handle(): int
|
public function handle(): int
|
||||||
{
|
{
|
||||||
$do = Domain::where('name',strtolower($this->argument('domain')))->singleOrFail();
|
$do = Domain::where('name',strtolower($this->argument('domain')))->single();
|
||||||
|
|
||||||
return Job::dispatchSync($this->argument('file'),$do,$this->option('prefix') ?: '',$this->option('unlink'));
|
return Job::dispatchSync($this->argument('file'),$do,$this->option('prefix') ?: '',$this->option('unlink'));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -34,7 +34,8 @@ class FileareaImport extends Command
|
|||||||
*/
|
*/
|
||||||
public function handle(): int
|
public function handle(): int
|
||||||
{
|
{
|
||||||
$do = Domain::where('name',strtolower($this->argument('domain')))->singleOrFail();
|
$do = Domain::where('name',strtolower($this->argument('domain')))->sole();
|
||||||
|
|
||||||
return Job::dispatchSync($this->argument('file'),$do,$this->option('prefix') ?: '',$this->option('unlink'));
|
return Job::dispatchSync($this->argument('file'),$do,$this->option('prefix') ?: '',$this->option('unlink'));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -40,7 +40,7 @@ class Rescan extends Command
|
|||||||
if (! $this->argument('area'))
|
if (! $this->argument('area'))
|
||||||
throw new \Exception('Areaname is required');
|
throw new \Exception('Areaname is required');
|
||||||
|
|
||||||
$fao = Filearea::where('name',$this->argument('area'))->singleOrFail();
|
$fao = Filearea::where('name',$this->argument('area'))->sole();
|
||||||
if ($fao->domain_id !== $ao->zone->domain_id)
|
if ($fao->domain_id !== $ao->zone->domain_id)
|
||||||
throw new \Exception(sprintf('File area [%s] is not in domain [%s] for FTN [%s]',$fao->name,$ao->zone->domain->name,$ao->ftn));
|
throw new \Exception(sprintf('File area [%s] is not in domain [%s] for FTN [%s]',$fao->name,$ao->zone->domain->name,$ao->ftn));
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ class NodesNew extends Command
|
|||||||
*/
|
*/
|
||||||
public function handle(): int
|
public function handle(): int
|
||||||
{
|
{
|
||||||
$do = Domain::where('name',$this->argument('domain'))->singleOrFail();
|
$do = Domain::where('name',$this->argument('domain'))->sole();
|
||||||
$ao = NULL;
|
$ao = NULL;
|
||||||
|
|
||||||
if ($this->option('netmail')) {
|
if ($this->option('netmail')) {
|
||||||
|
@ -50,7 +50,7 @@ class ServerStart extends Command
|
|||||||
'address'=>$o->binkp_bind,
|
'address'=>$o->binkp_bind,
|
||||||
'port'=>$o->binkp_port,
|
'port'=>$o->binkp_port,
|
||||||
'proto'=>SOCK_STREAM,
|
'proto'=>SOCK_STREAM,
|
||||||
'class'=>new Binkp,
|
'class'=>new Binkp($o),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if ($o->emsi_active)
|
if ($o->emsi_active)
|
||||||
@ -58,7 +58,7 @@ class ServerStart extends Command
|
|||||||
'address'=>$o->emsi_bind,
|
'address'=>$o->emsi_bind,
|
||||||
'port'=>$o->emsi_port,
|
'port'=>$o->emsi_port,
|
||||||
'proto'=>SOCK_STREAM,
|
'proto'=>SOCK_STREAM,
|
||||||
'class'=>new EMSI,
|
'class'=>new EMSI($o),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if ($o->dns_active)
|
if ($o->dns_active)
|
||||||
@ -66,7 +66,7 @@ class ServerStart extends Command
|
|||||||
'address'=>$o->dns_bind,
|
'address'=>$o->dns_bind,
|
||||||
'port'=>$o->dns_port,
|
'port'=>$o->dns_port,
|
||||||
'proto'=>SOCK_DGRAM,
|
'proto'=>SOCK_DGRAM,
|
||||||
'class'=>new DNS,
|
'class'=>new DNS($o),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$children = collect();
|
$children = collect();
|
||||||
|
@ -25,7 +25,7 @@ class UserCodeSend extends Command
|
|||||||
public function handle(): int
|
public function handle(): int
|
||||||
{
|
{
|
||||||
$ao = Address::findFTN($this->argument('ftn'));
|
$ao = Address::findFTN($this->argument('ftn'));
|
||||||
$uo = User::where('email',$this->argument('email'))->singleOrFail();
|
$uo = User::where('email',$this->argument('email'))->sole();
|
||||||
|
|
||||||
Notification::route('netmail',$ao->uplink())->notify(new AddressLink($uo));
|
Notification::route('netmail',$ao->uplink())->notify(new AddressLink($uo));
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ class ZoneController extends Controller
|
|||||||
$o->save();
|
$o->save();
|
||||||
$zo = Zone::where('zone_id',$request->zone_id)
|
$zo = Zone::where('zone_id',$request->zone_id)
|
||||||
->where('domain_id',$request->domain_id)
|
->where('domain_id',$request->domain_id)
|
||||||
->singleOrFail();
|
->sole();
|
||||||
|
|
||||||
// Find the zones 0/0 address, and assign it to this host.
|
// Find the zones 0/0 address, and assign it to this host.
|
||||||
$ao = Address::where('zone_id',$zo->id)
|
$ao = Address::where('zone_id',$zo->id)
|
||||||
|
@ -10,6 +10,7 @@ use Illuminate\Queue\InteractsWithQueue;
|
|||||||
use Illuminate\Queue\ManuallyFailedException;
|
use Illuminate\Queue\ManuallyFailedException;
|
||||||
use Illuminate\Queue\MaxAttemptsExceededException;
|
use Illuminate\Queue\MaxAttemptsExceededException;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
use Illuminate\Support\Facades\Config;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
use Illuminate\Support\Facades\Notification;
|
use Illuminate\Support\Facades\Notification;
|
||||||
|
|
||||||
@ -85,6 +86,7 @@ class AddressPoll implements ShouldQueue, ShouldBeUnique
|
|||||||
}
|
}
|
||||||
|
|
||||||
Log::info(sprintf('%s:- Polling [%s] - attempt [%d]',self::LOGKEY,$this->ao->ftn,$this->attempts()));
|
Log::info(sprintf('%s:- Polling [%s] - attempt [%d]',self::LOGKEY,$this->ao->ftn,$this->attempts()));
|
||||||
|
$setup = Config::get('setup',Setup::findOrFail(config('app.id')));
|
||||||
|
|
||||||
foreach ($this->ao->system->mailer_preferred as $o) {
|
foreach ($this->ao->system->mailer_preferred as $o) {
|
||||||
// If we chose a protocol, skip to find the mailer details for it
|
// If we chose a protocol, skip to find the mailer details for it
|
||||||
@ -93,14 +95,12 @@ class AddressPoll implements ShouldQueue, ShouldBeUnique
|
|||||||
|
|
||||||
switch ($o->name) {
|
switch ($o->name) {
|
||||||
case 'BINKP':
|
case 'BINKP':
|
||||||
$s = new Binkp;
|
$s = new Binkp($setup);
|
||||||
$mo = Mailer::where('name','BINKP')->singleOrFail();
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'EMSI':
|
case 'EMSI':
|
||||||
$s = new EMSI;
|
$s = new EMSI($setup);
|
||||||
$mo = Mailer::where('name','EMSI')->singleOrFail();
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -116,7 +116,7 @@ class AddressPoll implements ShouldQueue, ShouldBeUnique
|
|||||||
try {
|
try {
|
||||||
$client = SocketClient::create($this->ao->system->address,$o->pivot->port);
|
$client = SocketClient::create($this->ao->system->address,$o->pivot->port);
|
||||||
|
|
||||||
if (($s->session($mo,$client,$this->ao) & Protocol::S_MASK) === Protocol::S_OK) {
|
if (($s->session($client,$this->ao) & Protocol::S_MASK) === Protocol::S_OK) {
|
||||||
Log::info(sprintf('%s:= Connection ended successfully with [%s] (%s)',self::LOGKEY,$client->address_remote,$this->ao->ftn));
|
Log::info(sprintf('%s:= Connection ended successfully with [%s] (%s)',self::LOGKEY,$client->address_remote,$this->ao->ftn));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -62,7 +62,9 @@ class NodelistImport implements ShouldQueue
|
|||||||
{
|
{
|
||||||
switch ($key) {
|
switch ($key) {
|
||||||
case 'jobname':
|
case 'jobname':
|
||||||
return sprintf('%s-%s',$this->domain?->name,is_object($this->file) ? $this->file->name : $this->file);
|
return ($this->domain)
|
||||||
|
? sprintf('%s-%s',$this->domain?->name,(is_object($this->file) ? $this->file->name : $this->file))
|
||||||
|
: (is_object($this->file) ? $this->file->name : $this->file);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -144,8 +146,8 @@ class NodelistImport implements ShouldQueue
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$mailer_binkp = Mailer::where('name','BINKP')->singleOrFail();
|
$mailer_binkp = Mailer::where('name','BINKP')->sole();
|
||||||
$mailer_emsi = Mailer::where('name','EMSI')->singleOrFail();
|
$mailer_emsi = Mailer::where('name','EMSI')->sole();
|
||||||
|
|
||||||
$p = $c = 0;
|
$p = $c = 0;
|
||||||
|
|
||||||
@ -557,7 +559,9 @@ class NodelistImport implements ShouldQueue
|
|||||||
$no->load('addresses');
|
$no->load('addresses');
|
||||||
|
|
||||||
$remove = $zo
|
$remove = $zo
|
||||||
->addresses->pluck('id')
|
->addresses
|
||||||
|
->filter(fn($item)=>(! $item->point_id))
|
||||||
|
->pluck('id')
|
||||||
->diff($no->addresses->pluck('id'))
|
->diff($no->addresses->pluck('id'))
|
||||||
->diff(our_address($do)->pluck('id'))
|
->diff(our_address($do)->pluck('id'))
|
||||||
->diff(our_nodes($do)->pluck('id'));
|
->diff(our_nodes($do)->pluck('id'));
|
||||||
|
@ -34,7 +34,7 @@ class TicProcess implements ShouldQueue
|
|||||||
*/
|
*/
|
||||||
public function __construct(private string $file,private ?string $domain=NULL)
|
public function __construct(private string $file,private ?string $domain=NULL)
|
||||||
{
|
{
|
||||||
$this->do = $domain ? Domain::where('name',$domain)->singleOrFail() : NULL;
|
$this->do = $domain ? Domain::where('name',$domain)->sole() : NULL;
|
||||||
|
|
||||||
$this->onQueue(self::QUEUE);
|
$this->onQueue(self::QUEUE);
|
||||||
}
|
}
|
||||||
|
@ -120,7 +120,7 @@ class Address extends Model
|
|||||||
|
|
||||||
// Check Domain exists
|
// Check Domain exists
|
||||||
Domain::unguard();
|
Domain::unguard();
|
||||||
$do = Domain::singleOrNew(['name'=>$ftn['d']]);
|
$do = Domain::firstOrNew(['name'=>$ftn['d']]);
|
||||||
Domain::reguard();
|
Domain::reguard();
|
||||||
|
|
||||||
if (! $do->exists) {
|
if (! $do->exists) {
|
||||||
@ -143,7 +143,7 @@ class Address extends Model
|
|||||||
|
|
||||||
// Create zone
|
// Create zone
|
||||||
Zone::unguard();
|
Zone::unguard();
|
||||||
$zo = Zone::singleOrNew(['domain_id'=>$do->id,'zone_id'=>$ftn['z']]);
|
$zo = Zone::firstOrNew(['domain_id'=>$do->id,'zone_id'=>$ftn['z']]);
|
||||||
Zone::reguard();
|
Zone::reguard();
|
||||||
|
|
||||||
if (! $zo->exists) {
|
if (! $zo->exists) {
|
||||||
|
@ -12,12 +12,12 @@ class AreaList extends Netmails
|
|||||||
{
|
{
|
||||||
use MessagePath,PageTemplate;
|
use MessagePath,PageTemplate;
|
||||||
|
|
||||||
private const LOGKEY = 'ACH';
|
private const LOGKEY = 'ACL';
|
||||||
|
|
||||||
private Netmail $mo;
|
private Netmail $mo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reply to a areafix, commands unknown.
|
* Reply to a areafix AREALIST commands.
|
||||||
*
|
*
|
||||||
* @param Netmail $mo
|
* @param Netmail $mo
|
||||||
*/
|
*/
|
||||||
|
@ -16,7 +16,7 @@ class Help extends Netmails
|
|||||||
private const LOGKEY = 'ACH';
|
private const LOGKEY = 'ACH';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reply to a areafix, commands unknown.
|
* Reply to an areafix HELP commands.
|
||||||
*
|
*
|
||||||
* @param Netmail $mo
|
* @param Netmail $mo
|
||||||
* @param Collection $commands
|
* @param Collection $commands
|
||||||
|
103
app/Notifications/Netmails/Filefix/AreaList.php
Normal file
103
app/Notifications/Netmails/Filefix/AreaList.php
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Notifications\Netmails\Filefix;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
|
use App\Notifications\Netmails;
|
||||||
|
use App\Models\Netmail;
|
||||||
|
use App\Traits\{MessagePath,PageTemplate};
|
||||||
|
|
||||||
|
class AreaList extends Netmails
|
||||||
|
{
|
||||||
|
use MessagePath,PageTemplate;
|
||||||
|
|
||||||
|
private const LOGKEY = 'FCL';
|
||||||
|
|
||||||
|
private Netmail $mo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reply to a filefix AREALIST commands.
|
||||||
|
*
|
||||||
|
* @param Netmail $mo
|
||||||
|
*/
|
||||||
|
public function __construct(Netmail $mo)
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
|
||||||
|
$this->mo = $mo->withoutRelations();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the mail representation of the notification.
|
||||||
|
*
|
||||||
|
* @param mixed $notifiable
|
||||||
|
* @return Netmail
|
||||||
|
* @throws \Exception
|
||||||
|
*/
|
||||||
|
public function toNetmail(object $notifiable): Netmail
|
||||||
|
{
|
||||||
|
$o = $this->setupNetmail($notifiable);
|
||||||
|
$ao = $notifiable->routeNotificationFor(static::via);
|
||||||
|
|
||||||
|
Log::info(sprintf('%s:+ Responding to filefix for a node [%s] LIST processed',self::LOGKEY,$ao->ftn));
|
||||||
|
|
||||||
|
$o->to = $this->mo->from;
|
||||||
|
$o->replyid = $this->mo->msgid;
|
||||||
|
$o->subject = 'Filefix - List';
|
||||||
|
|
||||||
|
// Message
|
||||||
|
$msg = $this->page(FALSE,'Filefix');
|
||||||
|
|
||||||
|
$msg->addText("Here are the list of available filereas:\r\r\r\r");
|
||||||
|
|
||||||
|
$areas = $ao->domain
|
||||||
|
->fileareas
|
||||||
|
->filter(fn($item)=>$item->active && ($item->can_read($ao->security) || $item->can_write($ao->security)));
|
||||||
|
|
||||||
|
if ($areas->count()) {
|
||||||
|
$msg->addText(sprintf(":---:-%s-:-%s-:-%s-:\r",
|
||||||
|
str_repeat('-',10),
|
||||||
|
str_repeat('-',48),
|
||||||
|
str_repeat('-',5),
|
||||||
|
));
|
||||||
|
$msg->addText(sprintf(": : %-10s : %-48s : %-5s :\r",'AREA','DESCRIPTION','FILES'));
|
||||||
|
$msg->addText(sprintf(":---:-%s-:-%s-:-%s-:\r",
|
||||||
|
str_repeat('-',10),
|
||||||
|
str_repeat('-',48),
|
||||||
|
str_repeat('-',5),
|
||||||
|
));
|
||||||
|
|
||||||
|
foreach ($areas as $eao) {
|
||||||
|
$msg->addText(sprintf(":%s%s%s: %-10s : %-48s : %5d :\r",
|
||||||
|
($x=$ao->echoareas->contains($eao)) ? '*' : ' ',
|
||||||
|
(! $x ? '+' : ' '),
|
||||||
|
($eao->can_read($ao->security) && (! $eao->can_write($ao->security)))
|
||||||
|
? 'R'
|
||||||
|
: (((! $eao->can_read($ao->security)) && $eao->can_write($ao->security)) ? 'W' : ' '),
|
||||||
|
$eao->name,
|
||||||
|
$eao->description,
|
||||||
|
$eao->files()->count(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
$msg->addText(sprintf(":---:-%s-:-%s-:-%s-:\r",
|
||||||
|
str_repeat('-',10),
|
||||||
|
str_repeat('-',48),
|
||||||
|
str_repeat('-',5),
|
||||||
|
));
|
||||||
|
|
||||||
|
$msg->addText("\r'*' = Subscribed, '+' = available, 'R' = read only, 'W' = write only\r");
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$msg->addText(sprintf('No areas available to you from domain [%s]',$ao->domain->name));
|
||||||
|
}
|
||||||
|
|
||||||
|
$o->msg = $msg->render();
|
||||||
|
$o->set_tagline = 'Why did the chicken cross the road? The robot programmed it.';
|
||||||
|
|
||||||
|
$o->save();
|
||||||
|
|
||||||
|
return $o;
|
||||||
|
}
|
||||||
|
}
|
63
app/Notifications/Netmails/Filefix/Help.php
Normal file
63
app/Notifications/Netmails/Filefix/Help.php
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Notifications\Netmails\Filefix;
|
||||||
|
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
|
use App\Notifications\Netmails;
|
||||||
|
use App\Models\Netmail;
|
||||||
|
use App\Traits\{MessagePath,PageTemplate};
|
||||||
|
|
||||||
|
class Help extends Netmails
|
||||||
|
{
|
||||||
|
use MessagePath,PageTemplate;
|
||||||
|
|
||||||
|
private const LOGKEY = 'FCH';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reply to a filefix HELP commands.
|
||||||
|
*
|
||||||
|
* @param Netmail $mo
|
||||||
|
* @param Collection $commands
|
||||||
|
*/
|
||||||
|
public function __construct(private Netmail $mo,private Collection $commands)
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the mail representation of the notification.
|
||||||
|
*
|
||||||
|
* @param mixed $notifiable
|
||||||
|
* @return Netmail
|
||||||
|
* @throws \Exception
|
||||||
|
*/
|
||||||
|
public function toNetmail(object $notifiable): Netmail
|
||||||
|
{
|
||||||
|
$o = $this->setupNetmail($notifiable);
|
||||||
|
$ao = $notifiable->routeNotificationFor(static::via);
|
||||||
|
|
||||||
|
Log::info(sprintf('%s:+ Responding to filefix for a node [%s] HELP processed',self::LOGKEY,$ao->ftn));
|
||||||
|
|
||||||
|
$o->to = $this->mo->from;
|
||||||
|
$o->replyid = $this->mo->msgid;
|
||||||
|
$o->subject = 'Filefix - Help';
|
||||||
|
|
||||||
|
// Message
|
||||||
|
$msg = $this->page(FALSE,'Filefix');
|
||||||
|
|
||||||
|
$msg->addText("Here are the list of commands available to you:\r\r\r\r");
|
||||||
|
|
||||||
|
foreach ($this->commands as $command) {
|
||||||
|
$msg->addText("$command\r");
|
||||||
|
}
|
||||||
|
|
||||||
|
$o->msg = $msg->render();
|
||||||
|
$o->set_tagline = 'Why did the chicken cross the road? The robot programmed it.';
|
||||||
|
|
||||||
|
$o->save();
|
||||||
|
|
||||||
|
return $o;
|
||||||
|
}
|
||||||
|
}
|
@ -17,11 +17,11 @@ use App\Listeners\EchomailListener;
|
|||||||
use App\Listeners\Matrix\MessageListener;
|
use App\Listeners\Matrix\MessageListener;
|
||||||
use App\Notifications\Channels\{EchomailChannel,MatrixChannel,NetmailChannel};
|
use App\Notifications\Channels\{EchomailChannel,MatrixChannel,NetmailChannel};
|
||||||
use App\Models\{Echomail,Netmail,User};
|
use App\Models\{Echomail,Netmail,User};
|
||||||
use App\Traits\SingleOrFail;
|
use App\Traits\Single;
|
||||||
|
|
||||||
class AppServiceProvider extends ServiceProvider
|
class AppServiceProvider extends ServiceProvider
|
||||||
{
|
{
|
||||||
use SingleOrFail;
|
use Single;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register any application services.
|
* Register any application services.
|
||||||
@ -52,7 +52,7 @@ class AppServiceProvider extends ServiceProvider
|
|||||||
*/
|
*/
|
||||||
public function boot()
|
public function boot()
|
||||||
{
|
{
|
||||||
static::bootSingleOrFail();
|
static::bootSingle();
|
||||||
|
|
||||||
// Add our page assets
|
// Add our page assets
|
||||||
Blade::directive('pa',function($expression) {
|
Blade::directive('pa',function($expression) {
|
||||||
|
25
app/Traits/Single.php
Normal file
25
app/Traits/Single.php
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add eloquent queries single(), singleOrNew()
|
||||||
|
*/
|
||||||
|
namespace App\Traits;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||||
|
|
||||||
|
trait Single
|
||||||
|
{
|
||||||
|
private static function bootSingle(): void
|
||||||
|
{
|
||||||
|
// When a query should return 1 object, or NULL if it doesnt
|
||||||
|
Builder::macro('single',function () {
|
||||||
|
$result = $this->get();
|
||||||
|
|
||||||
|
if ($result->count() === 1)
|
||||||
|
return $result->first();
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -1,49 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add eloquent queries single(), singleOrFail(), singleOrNew()
|
|
||||||
*/
|
|
||||||
namespace App\Traits;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
|
||||||
|
|
||||||
trait SingleOrFail
|
|
||||||
{
|
|
||||||
private static function bootSingleOrFail(): void
|
|
||||||
{
|
|
||||||
// When a query should return 1 object, or FAIL if it doesnt
|
|
||||||
// @deprecated use sole()
|
|
||||||
Builder::macro('singleOrFail',function () {
|
|
||||||
$result = $this->get();
|
|
||||||
|
|
||||||
if (($x=$result->count()) === 1)
|
|
||||||
return $result->first();
|
|
||||||
|
|
||||||
if ($x === 0)
|
|
||||||
throw new ModelNotFoundException('Query brings back 0 record(s) called for singleOrFail()');
|
|
||||||
else
|
|
||||||
throw new \Exception(sprintf('Query brings back %d record(s) called for singleOrFail()',$x));
|
|
||||||
});
|
|
||||||
|
|
||||||
// When a query should return 1 object, or NULL if it doesnt
|
|
||||||
Builder::macro('single',function () {
|
|
||||||
$result = $this->get();
|
|
||||||
|
|
||||||
if ($result->count() === 1)
|
|
||||||
return $result->first();
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
});
|
|
||||||
|
|
||||||
// When a query should return 1 object, or NULL if it doesnt
|
|
||||||
Builder::macro('singleOrNew',function ($args) {
|
|
||||||
$result = $this->where($args)->get();
|
|
||||||
|
|
||||||
if ($result->count() === 1)
|
|
||||||
return $result->first();
|
|
||||||
|
|
||||||
return $this->newModelInstance($args);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
@ -9,6 +9,7 @@ return [
|
|||||||
// Netmail
|
// Netmail
|
||||||
'robots' => [
|
'robots' => [
|
||||||
\App\Classes\FTN\Process\Netmail\Ping::class,
|
\App\Classes\FTN\Process\Netmail\Ping::class,
|
||||||
\App\Classes\FTN\Process\Netmail\Areafix::class,
|
\App\Classes\FTN\Process\Netmail\Robot\Areafix::class,
|
||||||
|
\App\Classes\FTN\Process\Netmail\Robot\Filefix::class,
|
||||||
],
|
],
|
||||||
];
|
];
|
@ -38,7 +38,7 @@ class TestNodeHierarchy extends Seeder
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
foreach (['a','b'] as $domain) {
|
foreach (['a','b'] as $domain) {
|
||||||
$do = Domain::where('name',$domain)->singleOrFail();
|
$do = Domain::where('name',$domain)->sole();
|
||||||
$this->hierarchy($do,100);
|
$this->hierarchy($do,100);
|
||||||
$this->hierarchy($do,101);
|
$this->hierarchy($do,101);
|
||||||
}
|
}
|
||||||
@ -84,7 +84,7 @@ class TestNodeHierarchy extends Seeder
|
|||||||
'updated_at'=>Carbon::now(),
|
'updated_at'=>Carbon::now(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$zo = Zone::where('zone_id',$zoneid)->where('domain_id',$domain->id)->singleOrFail();
|
$zo = Zone::where('zone_id',$zoneid)->where('domain_id',$domain->id)->sole();
|
||||||
if (self::DEBUG)
|
if (self::DEBUG)
|
||||||
dump(['zo'=>$zo->zone_id,'rid'=>0,'hid'=>0,'nid'=>0]);
|
dump(['zo'=>$zo->zone_id,'rid'=>0,'hid'=>0,'nid'=>0]);
|
||||||
|
|
||||||
|
@ -1,16 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
| Broadcast Channels
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
|
|
|
||||||
| Here you may register all of the event broadcasting channels that your
|
|
||||||
| application supports. The given channel authorization callbacks are
|
|
||||||
| used to check if an authenticated user can listen to the channel.
|
|
||||||
|
|
|
||||||
*/
|
|
||||||
|
|
||||||
Broadcast::channel('App.User.{id}', function ($user, $id) {
|
|
||||||
return (int) $user->id === (int) $id;
|
|
||||||
});
|
|
@ -57,7 +57,7 @@ class RoutingTest extends TestCase
|
|||||||
{
|
{
|
||||||
//$this->seed(TestNodeHierarchy::class);
|
//$this->seed(TestNodeHierarchy::class);
|
||||||
|
|
||||||
$do = Domain::where('name','a')->singleOrFail();
|
$do = Domain::where('name','a')->sole();
|
||||||
$zo = $do->zones->where('zone_id',100)->pop();
|
$zo = $do->zones->where('zone_id',100)->pop();
|
||||||
return $zo->addresses;
|
return $zo->addresses;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user