2021-07-15 14:54:23 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
|
|
|
|
use Illuminate\Console\Command;
|
|
|
|
|
|
|
|
use App\Classes\FTN\Packet;
|
2024-05-17 12:10:54 +00:00
|
|
|
use App\Jobs\PacketProcess as Job;
|
2022-11-11 11:57:40 +00:00
|
|
|
use App\Models\Address;
|
2021-07-15 14:54:23 +00:00
|
|
|
|
2024-05-19 13:28:45 +00:00
|
|
|
/**
|
|
|
|
* Things to test
|
|
|
|
* + Packet
|
|
|
|
* - Sender doesnt exist (try and send a bounce message in the same session)
|
|
|
|
* - Sender defined in DB by not ours
|
|
|
|
* - Sender has wrong password
|
|
|
|
* - Packet too old
|
|
|
|
*
|
|
|
|
* + Echomail
|
|
|
|
* - Area doesnt exist (to uplink)
|
|
|
|
* - Sender not subscribed (to uplink)
|
|
|
|
* - Sender cannot post (to uplink)
|
|
|
|
* - Sender has wrong address for echorea domain (to uplink)
|
|
|
|
* - Test message in echoarea
|
|
|
|
* - Echomail from address doesnt match packet envelope (to uplink)
|
|
|
|
* - Echomail too old (to uplink)
|
|
|
|
* - Rescanned dont generate notifications
|
|
|
|
* - Rescanned dont trigger bots
|
|
|
|
* - Some Notifications to an uplink should go to the admin instead?
|
|
|
|
*
|
|
|
|
* + Netmail
|
|
|
|
* - To hub, and user not defined (reject)
|
|
|
|
* - To hub, but user redirect (redirected)
|
|
|
|
* - To areafix (processed)
|
|
|
|
* - To ping (respond)
|
|
|
|
* - With trace turned on (respond)
|
|
|
|
*/
|
2021-08-29 14:24:40 +00:00
|
|
|
class PacketProcess extends Command
|
2021-07-15 14:54:23 +00:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* The name and signature of the console command.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
2021-09-10 14:38:11 +00:00
|
|
|
protected $signature = 'packet:process'
|
2022-11-13 13:29:55 +00:00
|
|
|
.' {file : Packet to process}'
|
2021-09-10 14:38:11 +00:00
|
|
|
.' {--N|nobot : Dont process bots}'
|
2023-11-22 01:15:48 +00:00
|
|
|
.' {ftn? : System the packet is from}'
|
|
|
|
.' {--Q|dontqueue : Dont queue the message}';
|
2021-07-15 14:54:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The console command description.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $description = 'Process Packet';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Execute the console command.
|
|
|
|
*
|
2024-05-21 11:41:23 +00:00
|
|
|
* @return int|void
|
|
|
|
* @throws \Exception
|
2021-07-15 14:54:23 +00:00
|
|
|
*/
|
|
|
|
public function handle()
|
|
|
|
{
|
2023-10-26 00:02:36 +00:00
|
|
|
$rel_name = sprintf('%s/%s',config('fido.dir'),$this->argument('file'));
|
|
|
|
|
2023-11-22 01:15:48 +00:00
|
|
|
$m = [];
|
2023-10-26 00:02:36 +00:00
|
|
|
if ($this->argument('ftn')) {
|
2024-05-19 13:28:45 +00:00
|
|
|
$ao = Address::findFTN($this->argument('ftn'));
|
2023-10-26 00:02:36 +00:00
|
|
|
|
2023-11-24 22:48:37 +00:00
|
|
|
} elseif (preg_match(sprintf('/^%s\.(.{3})$/',Packet::regex),$this->argument('file'),$m)) {
|
2024-05-19 13:28:45 +00:00
|
|
|
$ao = Address::findOrFail(hexdec($m[1]));
|
2023-10-26 00:02:36 +00:00
|
|
|
|
|
|
|
} else {
|
|
|
|
$this->error('Unable to determine sender FTN address');
|
|
|
|
exit(1);
|
|
|
|
}
|
2021-07-15 14:54:23 +00:00
|
|
|
|
2024-05-19 13:28:45 +00:00
|
|
|
Job::dispatchSync($rel_name,$ao->zone->domain,$this->option('dontqueue'));
|
2021-09-12 13:06:17 +00:00
|
|
|
|
2024-05-21 11:41:23 +00:00
|
|
|
return self::SUCCESS;
|
2021-07-15 14:54:23 +00:00
|
|
|
}
|
2023-07-15 00:46:19 +00:00
|
|
|
}
|