Dont accept connections when application down
All checks were successful
Create Docker Image / Build Docker Image (x86_64) (push) Successful in 39s
Create Docker Image / Build Docker Image (arm64) (push) Successful in 1m46s
Create Docker Image / Final Docker Image Manifest (push) Successful in 10s

This commit is contained in:
Deon George 2024-06-07 18:07:34 +10:00
parent b23d9351b5
commit 829fe1d7a9
4 changed files with 240 additions and 207 deletions

View File

@ -124,6 +124,8 @@ abstract class Protocol
protected bool $originate;
/** Our comms details */
protected bool $down = FALSE;
private array $comms;
protected bool $force_queue = FALSE;
@ -366,6 +368,9 @@ abstract class Protocol
// We are an IP node
$this->optionSet(self::O_TCP);
$this->client = $client;
// @todo This appears to be a bug in laravel? Need to call app()->isDownForMaintenance() twice?
app()->isDownForMaintenance();
$this->down = app()->isDownForMaintenance();
switch ($mo->name) {
case 'EMSI':

View File

@ -168,10 +168,21 @@ final class Binkp extends BaseProtocol
*
* @throws \Exception
*/
private function binkp_hs(): void
private function binkp_hs(): bool
{
Log::debug(sprintf('%s:+ Starting BINKP handshake',self::LOGKEY));
if (! $this->originate && $this->down) {
Log::info(sprintf('%s:! System down for maintenance',self::LOGKEY));
$this->msgs(self::BPM_BSY,'RETRY 0600: Down for maintenance, back soon...');
while ($this->tx_left || $this->mqueue->count())
$this->binkp_send();
return FALSE;
}
if (! $this->originate && $this->capGet(self::F_MD,self::O_WANT)) {
$random_key = random_bytes(8);
$this->md_challenge = md5($random_key,TRUE);
@ -206,6 +217,8 @@ final class Binkp extends BaseProtocol
$this->msgs(self::BPM_ADR,$addresses->pluck('ftn')->join(' '));
}
return TRUE;
}
/**
@ -1341,7 +1354,8 @@ final class Binkp extends BaseProtocol
return self::S_FAILURE;
$this->force_queue = $force_queue;
$this->binkp_hs();
if (! $this->binkp_hs())
return self::S_FAILURE;
while (TRUE) {
if ((! $this->sessionGet(self::SE_INIT))

View File

@ -930,6 +930,14 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface
$this->client->rx_purge();
$this->client->tx_purge();
if ($this->down) {
Log::info(sprintf('%s:! System down for maintenance',self::LOGKEY));
$this->client->buffer_add(self::EMSI_NAK.'Sorry down for maintenance, call back again after a few minutes'.self::CR.self::CR);
$this->client->buffer_flush(5);
return -1;
}
$this->emsi_banner();
$t1 = $this->client->timer_set(self::EMSI_HSTIMEOUT);

View File

@ -42,6 +42,12 @@ return [
'debug' => (bool) env('APP_DEBUG', false),
// Where the maintenance mode file is stored when calling down
'maintenance' => [
'driver' => 'cache',
//'store' => 'memcached',
],
/*
|--------------------------------------------------------------------------
| Application URL