Compare commits

...

2 Commits

Author SHA1 Message Date
b5f22bea86 Downgrade DNS query errors, since they are handled
All checks were successful
Create Docker Image / Build Docker Image (x86_64) (push) Successful in 38s
Create Docker Image / Build Docker Image (arm64) (push) Successful in 1m48s
Create Docker Image / Final Docker Image Manifest (push) Successful in 10s
2024-06-01 12:55:44 +10:00
aa50580c13 Move HAproxy exceptions into their own class, and downgrade HAproxy errors since they are handled 2024-06-01 12:55:27 +10:00
13 changed files with 42 additions and 37 deletions

View File

@ -7,8 +7,8 @@ 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\EMSI;
use App\Classes\Sock\Exception\SocketException;
use App\Classes\Sock\SocketClient; use App\Classes\Sock\SocketClient;
use App\Classes\Sock\SocketException;
use App\Models\{Address,Mailer,Setup,System,SystemLog}; use App\Models\{Address,Mailer,Setup,System,SystemLog};
// @todo after receiving a mail packet/file, dont acknowledge it until we can validate that we can read it properly. // @todo after receiving a mail packet/file, dont acknowledge it until we can validate that we can read it properly.

View File

@ -11,8 +11,8 @@ use League\Flysystem\UnreadableFileEncountered;
use App\Classes\Crypt; 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\SocketClient; use App\Classes\Sock\SocketClient;
use App\Classes\Sock\SocketException;
use App\Exceptions\{FileGrewException,InvalidFTNException}; use App\Exceptions\{FileGrewException,InvalidFTNException};
use App\Models\{Address,Mailer}; use App\Models\{Address,Mailer};

View File

@ -110,7 +110,7 @@ final class DNS extends BaseProtocol
$this->query = new BaseProtocol\DNS\Query($this->client->read(0,512)); $this->query = new BaseProtocol\DNS\Query($this->client->read(0,512));
} catch (\Exception $e) { } catch (\Exception $e) {
Log::error(sprintf('%s:! Ignoring bad DNS query (%s)',self::LOGKEY,$e->getMessage())); Log::notice(sprintf('%s:! Ignoring bad DNS query (%s)',self::LOGKEY,$e->getMessage()));
return FALSE; return FALSE;
} }
@ -119,7 +119,7 @@ final class DNS extends BaseProtocol
// If the wrong class // If the wrong class
if ($this->query->class !== self::DNS_QUERY_IN) { if ($this->query->class !== self::DNS_QUERY_IN) {
Log::error(sprintf('%s:! We only service Internet queries [%d]',self::LOGKEY,$this->query->class)); Log::notice(sprintf('%s:! We only service Internet queries [%d]',self::LOGKEY,$this->query->class));
return $this->reply(self::DNS_NOTIMPLEMENTED,[],$this->soa()); return $this->reply(self::DNS_NOTIMPLEMENTED,[],$this->soa());
} }
@ -272,7 +272,7 @@ final class DNS extends BaseProtocol
// Other attributes return NOTIMPL // Other attributes return NOTIMPL
default: default:
Log::error(sprintf('%s:! We dont support DNS query types [%d]',self::LOGKEY,$this->query->type)); Log::notice(sprintf('%s:! We dont support DNS query types [%d]',self::LOGKEY,$this->query->type));
return $this->reply(self::DNS_NOTIMPLEMENTED,[],$this->soa()); return $this->reply(self::DNS_NOTIMPLEMENTED,[],$this->soa());
} }
@ -309,14 +309,14 @@ final class DNS extends BaseProtocol
private function nameerr(): int private function nameerr(): int
{ {
Log::error(sprintf('%s:! DNS query for a resource we dont manage [%s]',self::LOGKEY,$this->query->domain)); Log::notice(sprintf('%s:! DNS query for a resource we dont manage [%s]',self::LOGKEY,$this->query->domain));
return $this->reply(self::DNS_NAMEERR,[],$this->soa()); return $this->reply(self::DNS_NAMEERR,[],$this->soa());
} }
private function nodata(): int private function nodata(): int
{ {
Log::error(sprintf('%s:! DNS query for a resource we dont manage [%s] in our zone(s)',self::LOGKEY,$this->query->domain)); Log::notice(sprintf('%s:! DNS query for a resource we dont manage [%s] in our zone(s)',self::LOGKEY,$this->query->domain));
return $this->reply(self::DNS_NOERROR,[],$this->soa()); return $this->reply(self::DNS_NOERROR,[],$this->soa());
} }

View File

@ -6,12 +6,12 @@ use Carbon\Carbon;
use Illuminate\Support\Facades\Log; 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\SocketClient; use App\Classes\Sock\SocketClient;
use App\Classes\Sock\SocketException;
use App\Exceptions\InvalidFTNException; use App\Exceptions\InvalidFTNException;
use App\Models\{Address,Mailer,Setup};
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\Traits\CRC as CRCTrait; use App\Traits\CRC as CRCTrait;
// http://ftsc.org/docs/fsc-0056.001 // http://ftsc.org/docs/fsc-0056.001

View File

@ -5,9 +5,9 @@ namespace App\Classes\Protocol;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use App\Classes\{Node,Protocol}; use App\Classes\{Node,Protocol};
use App\Classes\Protocol\Zmodem as ZmodemClass;
use App\Classes\File\{Receive,Send}; use App\Classes\File\{Receive,Send};
use App\Classes\Sock\{SocketClient,SocketException}; use App\Classes\Sock\Exception\SocketException;
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,Mailer};

View File

@ -0,0 +1,6 @@
<?php
namespace App\Classes\Sock\Exception;
final class HAproxyException extends \Exception {
}

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Classes\Sock; namespace App\Classes\Sock\Exception;
// @todo Can we change this to use socket_strerr() && socket_last_error() // @todo Can we change this to use socket_strerr() && socket_last_error()
final class SocketException extends \Exception { final class SocketException extends \Exception {

View File

@ -6,6 +6,8 @@ use Illuminate\Support\Arr;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use Illuminate\Support\Str; use Illuminate\Support\Str;
use App\Classes\Sock\Exception\{HAproxyException,SocketException};
/** /**
* Class SocketClient * Class SocketClient
* *
@ -57,34 +59,26 @@ final class SocketClient {
if (config('fido.haproxy')) { if (config('fido.haproxy')) {
Log::debug(sprintf('%s:+ HAPROXY connection host [%s] on port [%d] (%s)',self::LOGKEY,$this->address_remote,$this->port_remote,$this->type)); Log::debug(sprintf('%s:+ HAPROXY connection host [%s] on port [%d] (%s)',self::LOGKEY,$this->address_remote,$this->port_remote,$this->type));
if ($this->read(5,12) !== "\x0d\x0a\x0d\x0a\x00\x0d\x0aQUIT\x0a") { if ($this->read(5,12) !== "\x0d\x0a\x0d\x0a\x00\x0d\x0aQUIT\x0a")
Log::error(sprintf('%s:! Failed to initialise HAPROXY connection',self::LOGKEY)); throw new HAproxyException('Failed to initialise HAPROXY connection');
throw new SocketException(SocketException::CANT_CONNECT,'Failed to initialise HAPROXY connection');
}
// Version/Command // Version/Command
$vc = $this->read_ch(5); $vc = $this->read_ch(5);
if (($x=($vc>>4)&0x7) !== 2) { if (($x=($vc>>4)&0x7) !== 2)
Log::error(sprintf('%s:! HAPROXY version [%d] is not handled',self::LOGKEY,$x)); throw new HAproxyException(sprintf('Unknown HAPROXY version [%d]',$x));
throw new SocketException(SocketException::CANT_CONNECT,'Unknown HAPROXY version');
}
switch ($x=($vc&0x7)) { switch ($x=($vc&0x7)) {
// HAPROXY internal // HAPROXY internal
case 0: case 0:
Log::debug(sprintf('%s:! HAPROXY internal health-check',self::LOGKEY)); throw new HAproxyException('HAPROXY internal health-check');
throw new SocketException(SocketException::CANT_CONNECT,'Healthcheck');
// PROXY connection // PROXY connection
case 1: case 1:
break; break;
default: default:
Log::error(sprintf('%s:! HAPROXY command [%d] is not handled',self::LOGKEY,$x)); throw new HAproxyException(sprintf('HAPROXY command [%d] is not handled',$x));
throw new SocketException(SocketException::CANT_CONNECT,'Unknown HAPROXY command');
} }
// Protocol/Address Family // Protocol/Address Family
@ -101,8 +95,7 @@ final class SocketClient {
break; break;
default: default:
Log::error(sprintf('%s:! HAPROXY protocol [%d] is not handled',self::LOGKEY,$x)); throw new HAproxyException(sprintf('HAPROXY protocol [%d] is not handled',$x));
throw new SocketException(SocketException::CANT_CONNECT,'Unknown HAPROXY protocol');
} }
switch ($x=($pa&0x7)) { switch ($x=($pa&0x7)) {
@ -110,8 +103,7 @@ final class SocketClient {
break; break;
default: default:
Log::error(sprintf('%s:! HAPROXY address family [%d] is not handled',self::LOGKEY,$x)); throw new HAproxyException(sprintf('HAPROXY address family [%d] is not handled',$x));
throw new SocketException(SocketException::CANT_CONNECT,'Unknown HAPROXY address family');
} }
$len = Arr::get(unpack('n',$this->read(5,2)),1); $len = Arr::get(unpack('n',$this->read(5,2)),1);
@ -126,8 +118,7 @@ final class SocketClient {
$dst = inet_ntop($this->read(5,16)); $dst = inet_ntop($this->read(5,16));
} else { } else {
Log::error(sprintf('%s:! HAPROXY address len [%d:%d] is not handled',self::LOGKEY,$p,$len)); throw new HAproxyException(sprintf('HAPROXY address len [%d:%d] is not handled',$p,$len));
throw new SocketException(SocketException::CANT_CONNECT,'Unknown HAPROXY address length');
} }
$src_port = unpack('n',$this->read(5,2)); $src_port = unpack('n',$this->read(5,2));

View File

@ -4,6 +4,8 @@ namespace App\Classes\Sock;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use App\Classes\Sock\Exception\{HAproxyException,SocketException};
final class SocketServer { final class SocketServer {
private const LOGKEY = 'SS-'; private const LOGKEY = 'SS-';
@ -128,8 +130,13 @@ final class SocketServer {
try { try {
$r = new SocketClient($accept); $r = new SocketClient($accept);
} catch (HAproxyException $e) {
Log::notice(sprintf('%s:! HAPROXY Exception [%s]',self::LOGKEY,$e->getMessage()));
socket_close($accept);
continue;
} catch (\Exception $e) { } catch (\Exception $e) {
Log::error(sprintf('%s:! Creating Socket client failed? [%s]',self::LOGKEY,$e->getMessage())); Log::notice(sprintf('%s:! Creating Socket client failed? [%s]',self::LOGKEY,$e->getMessage()));
socket_close($accept); socket_close($accept);
continue; continue;
} }

View File

@ -6,7 +6,7 @@ use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use App\Classes\Protocol\Binkp; use App\Classes\Protocol\Binkp;
use App\Classes\Sock\SocketException; use App\Classes\Sock\Exception\SocketException;
use App\Classes\Sock\SocketServer; use App\Classes\Sock\SocketServer;
use App\Models\Setup; use App\Models\Setup;

View File

@ -6,7 +6,7 @@ use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use App\Classes\Protocol\EMSI; use App\Classes\Protocol\EMSI;
use App\Classes\Sock\SocketException; use App\Classes\Sock\Exception\SocketException;
use App\Classes\Sock\SocketServer; use App\Classes\Sock\SocketServer;
use App\Models\Setup; use App\Models\Setup;

View File

@ -6,7 +6,8 @@ use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use App\Classes\Protocol\{Binkp,DNS,EMSI}; use App\Classes\Protocol\{Binkp,DNS,EMSI};
use App\Classes\Sock\{SocketException,SocketServer}; use App\Classes\Sock\Exception\SocketException;
use App\Classes\Sock\SocketServer;
use App\Models\Setup; use App\Models\Setup;
class ServerStart extends Command class ServerStart extends Command

View File

@ -15,8 +15,8 @@ use Illuminate\Support\Facades\Notification;
use App\Classes\Protocol; use App\Classes\Protocol;
use App\Classes\Protocol\{Binkp,EMSI}; use App\Classes\Protocol\{Binkp,EMSI};
use App\Classes\Sock\Exception\SocketException;
use App\Classes\Sock\SocketClient; use App\Classes\Sock\SocketClient;
use App\Classes\Sock\SocketException;
use App\Models\{Address,Mailer,Setup}; use App\Models\{Address,Mailer,Setup};
use App\Notifications\Netmails\PollingFailed; use App\Notifications\Netmails\PollingFailed;
use App\Traits\ObjectIssetFix; use App\Traits\ObjectIssetFix;