Getting out of IAC mode
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 1m31s
Create Docker Image / Final Docker Image Manifest (push) Successful in 10s

This commit is contained in:
Deon George 2025-01-31 16:49:33 +11:00
parent dd04872c1d
commit ae9445aa33

View File

@ -943,82 +943,87 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface
$iaccmd = NULL; $iaccmd = NULL;
// Peek for the next 2 chars // Peek for the next 2 chars
do { do {
$iac = $this->client->read(10,1,MSG_PEEK); try {
Log::debug(sprintf('%s: - IAC LOOP',self::LOGKEY),['iac'=>ord($iac),'cmd'=>$iaccmd]); $iac = $this->client->read(1,1,MSG_PEEK);
Log::debug(sprintf('%s: - IAC LOOP',self::LOGKEY),['iac'=>ord($iac),'cmd'=>$iaccmd]);
switch (ord($iac)) { switch (ord($iac)) {
// Binary Mode // Binary Mode
case 0x00: case 0x00:
if ($iaccmd === 0xfb) { if ($iaccmd === 0xfb) {
Log::debug(sprintf('%s: - IAC WILL BINARY [%02x]',self::LOGKEY,ord($iac))); Log::debug(sprintf('%s: - IAC WILL BINARY [%02x]',self::LOGKEY,ord($iac)));
// Config with DO // Config with DO
//$this->client->send(chr(0xff).chr(0xfd).$iac,10); //$this->client->send(chr(0xff).chr(0xfd).$iac,10);
} elseif ($iaccmd === 0xfd) { } elseif ($iaccmd === 0xfd) {
Log::debug(sprintf('%s: - IAC DO BINARY [%02x]',self::LOGKEY,ord($iac))); Log::debug(sprintf('%s: - IAC DO BINARY [%02x]',self::LOGKEY,ord($iac)));
// Config with WILL // Config with WILL
if ($this->client->iac_bin) { if ($this->client->iac_bin) {
$this->client->send(chr(0xff).chr(0xfb).$iac,10); $this->client->send(chr(0xff).chr(0xfb).$iac,10);
$this->client->iac_bin = true; $this->client->iac_bin = true;
}
} }
}
$iaccmd = NULL; $iaccmd = NULL;
break; break;
// Suppress Go Ahead // Suppress Go Ahead
case 0x03: case 0x03:
if ($iaccmd === 0xfb) { if ($iaccmd === 0xfb) {
Log::debug(sprintf('%s: - IAC WILL SUPPRESS-GO-AHEAD [%02x]',self::LOGKEY,ord($iac))); Log::debug(sprintf('%s: - IAC WILL SUPPRESS-GO-AHEAD [%02x]',self::LOGKEY,ord($iac)));
// Config with DO // Config with DO
//$this->client->send(chr(0xff).chr(0xfd).$iac,10); //$this->client->send(chr(0xff).chr(0xfd).$iac,10);
} elseif ($iaccmd === 0xfd) { } elseif ($iaccmd === 0xfd) {
Log::debug(sprintf('%s: - IAC DO SUPPRESS-GO-AHEAD [%02x]',self::LOGKEY,ord($iac))); Log::debug(sprintf('%s: - IAC DO SUPPRESS-GO-AHEAD [%02x]',self::LOGKEY,ord($iac)));
// Config with WILL // Config with WILL
$this->client->send(chr(0xff).chr(0xfb).$iac,10); $this->client->send(chr(0xff).chr(0xfb).$iac,10);
} }
$iaccmd = NULL; $iaccmd = NULL;
break; break;
// Will // Will
case 0xfb: case 0xfb:
Log::debug(sprintf('%s: - IAC WILL [%02x]',self::LOGKEY,ord($iac))); Log::debug(sprintf('%s: - IAC WILL [%02x]',self::LOGKEY,ord($iac)));
$iaccmd = ord($iac); $iaccmd = ord($iac);
break; break;
// Do // Do
case 0xfd: case 0xfd:
Log::debug(sprintf('%s: - IAC DO [%02x]',self::LOGKEY,ord($iac))); Log::debug(sprintf('%s: - IAC DO [%02x]',self::LOGKEY,ord($iac)));
$iaccmd = ord($iac); $iaccmd = ord($iac);
break; break;
// IAC // IAC
case 0xff: case 0xff:
Log::debug(sprintf('%s: - IAC [%02x]',self::LOGKEY,ord($iac))); Log::debug(sprintf('%s: - IAC [%02x]',self::LOGKEY,ord($iac)));
$iaccmd = ord($iac); $iaccmd = ord($iac);
break; break;
default: default:
Log::debug(sprintf('%s: - IAC Unhandled [%02x]',self::LOGKEY,ord($iac)),['iac'=>$iac,'iaccmd'=>$iaccmd,'ch'=>ord($iac)]); Log::debug(sprintf('%s: - IAC Unhandled [%02x]',self::LOGKEY,ord($iac)),['iac'=>$iac,'iaccmd'=>$iaccmd,'ch'=>ord($iac)]);
$ch = ord($iac); $ch = ord($iac);
$iac = NULL; $iac = NULL;
}
if ($iaccmd) {
$iac = ord($this->client->read_ch(10));
$ch = NULL;
} elseif (is_null($ch)) {
$ch = ord($this->client->read_ch(10));
}
} catch (SocketException $e) {
Log::debug(sprintf('%s:! SocketException: %s',self::LOGKEY,$e->getMessage()),['class'=>get_class($e),'code'=>$e->getCode()]);
$iac = NULL;
} }
if ($iaccmd) {
$iac = ord($this->client->read_ch(10));
$ch = NULL;
} elseif (is_null($ch)) {
$ch = ord($this->client->read_ch(10));
}
} while (! is_null($iac)); } while (! is_null($iac));
Log::debug(sprintf('%s:- Leaving IAC with [%02x]',self::LOGKEY,$ch),['ch'=>serialize($ch)]); Log::debug(sprintf('%s:- Leaving IAC with [%02x]',self::LOGKEY,$ch),['ch'=>serialize($ch)]);