diff --git a/app/Classes/Protocol/Binkp.php b/app/Classes/Protocol/Binkp.php index 680f74d..14183d3 100644 --- a/app/Classes/Protocol/Binkp.php +++ b/app/Classes/Protocol/Binkp.php @@ -12,7 +12,7 @@ use App\Classes\Crypt; use App\Classes\Protocol as BaseProtocol; use App\Classes\Sock\SocketClient; use App\Classes\Sock\SocketException; -use App\Exceptions\FileGrewException; +use App\Exceptions\{FileGrewException,InvalidFTNException}; use App\Models\Address; final class Binkp extends BaseProtocol @@ -700,6 +700,11 @@ final class Binkp extends BaseProtocol Log::info(sprintf('%s:- Got AKA [%s]',self::LOGKEY,$rem_aka)); } + } catch (InvalidFTNException $e) { + Log::error(sprintf('%s:! AKA is INVALID [%s] (%s), ignoring',self::LOGKEY,$rem_aka,$e->getMessage())); + + continue; + } catch (\Exception $e) { Log::error(sprintf('%s:! AKA is INVALID [%s] (%d:%s-%s)',self::LOGKEY,$rem_aka,$e->getLine(),$e->getFile(),$e->getMessage())); diff --git a/app/Classes/Protocol/EMSI.php b/app/Classes/Protocol/EMSI.php index 4e45f4e..44955a7 100644 --- a/app/Classes/Protocol/EMSI.php +++ b/app/Classes/Protocol/EMSI.php @@ -3,12 +3,12 @@ namespace App\Classes\Protocol; use Carbon\Carbon; -use Exception; use Illuminate\Support\Facades\Log; use App\Classes\Protocol as BaseProtocol; use App\Classes\Sock\SocketClient; use App\Classes\Sock\SocketException; +use App\Exceptions\InvalidFTNException; use App\Models\{Address,Setup}; use App\Interfaces\CRC as CRCInterface; use App\Interfaces\Zmodem as ZmodemInterface; @@ -88,7 +88,7 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface * @param SocketClient $client * @return int|null * @throws SocketException - * @throws Exception + * @throws \Exception */ public function onConnect(SocketClient $client): ?int { @@ -108,7 +108,7 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface /** * Send our welcome banner * - * @throws Exception + * @throws \Exception */ private function emsi_banner(): void { @@ -123,7 +123,7 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface * Create the EMSI_DAT * * @return string - * @throws Exception + * @throws \Exception */ private function emsi_makedat(): string { @@ -273,7 +273,7 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface * * @param string $str * @return int - * @throws Exception + * @throws \Exception */ private function emsi_parsedat(string $str): int { @@ -328,10 +328,15 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface continue; } - } catch (Exception) { - Log::error(sprintf('%s: ! AKA is INVALID [%s]',self::LOGKEY,$rem_aka)); + } catch (InvalidFTNException $e) { + Log::error(sprintf('%s:! AKA is INVALID [%s] (%s), ignoring',self::LOGKEY,$rem_aka,$e->getMessage())); continue; + + } catch (\Exception) { + Log::error(sprintf('%s: ! AKA is INVALID [%s]',self::LOGKEY,$rem_aka)); + + return self::S_FAILURE|self::S_ADDTRY; } // Check if the remote has our AKA @@ -504,7 +509,7 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface * STEP 2A, RECEIVE EMSI HANDSHAKE * * @throws SocketException - * @throws Exception + * @throws \Exception */ private function emsi_recv(int $mode): int { @@ -683,7 +688,7 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface * STEP 2B, TRANSMIT EMSI HANDSHAKE * * @throws SocketException - * @throws Exception + * @throws \Exception */ private function emsi_send(): int { @@ -822,7 +827,7 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface * STEP 1, EMSI INIT * * @throws SocketException - * @throws Exception + * @throws \Exception */ protected function protocol_init(): int { @@ -969,7 +974,7 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface * Setup our EMSI session * * @return int - * @throws Exception + * @throws \Exception */ protected function protocol_session(): int { @@ -1194,7 +1199,7 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface * * @param int $zap * @return bool - * @throws Exception + * @throws \Exception */ private function wazoosend(int $zap): bool { diff --git a/app/Exceptions/InvalidFTNException.php b/app/Exceptions/InvalidFTNException.php new file mode 100644 index 0000000..5e4abaf --- /dev/null +++ b/app/Exceptions/InvalidFTNException.php @@ -0,0 +1,9 @@ + DomainController::NUMBER_MAX)) - throw new \Exception('Invalid FTN: '.$ftn); + throw new InvalidFTNException(sprintf('Invalid FTN: %s - zone, host or node address invalid',$ftn)); } if (isset($matches[5]) AND ((! is_numeric($matches[$i])) || ($matches[5] > DomainController::NUMBER_MAX))) - throw new \Exception('Invalid FTN: '.$ftn); + throw new InvalidFTNException(sprintf('Invalid FTN: %s - point address invalid',$ftn)); return [ 'z'=>(int)$matches[1],