Dont abort a session when there is an invalid FTN presented

This commit is contained in:
2023-09-18 21:22:21 +10:00
parent eb40f94e37
commit 4343774079
4 changed files with 36 additions and 16 deletions

View File

@@ -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
{