Compare commits

..

14 Commits

Author SHA1 Message Date
c42340fe60 Telnet Binary Send
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 1m33s
Create Docker Image / Final Docker Image Manifest (push) Successful in 10s
2025-01-31 17:42:21 +11:00
07e42e2f5e Convert IAC IAC to IAC in Telnet Binary Mode
All checks were successful
Create Docker Image / Build Docker Image (x86_64) (push) Successful in 40s
Create Docker Image / Build Docker Image (arm64) (push) Successful in 1m37s
Create Docker Image / Final Docker Image Manifest (push) Successful in 9s
2025-01-31 17:13:12 +11:00
ae9445aa33 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
2025-01-31 16:49:33 +11:00
dd04872c1d IAC binary
All checks were successful
Create Docker Image / Build Docker Image (x86_64) (push) Successful in 36s
Create Docker Image / Build Docker Image (arm64) (push) Successful in 1m33s
Create Docker Image / Final Docker Image Manifest (push) Successful in 10s
2025-01-31 16:33:43 +11:00
3ed4907296 Better support of peek in SocketClient
All checks were successful
Create Docker Image / Build Docker Image (x86_64) (push) Successful in 37s
Create Docker Image / Build Docker Image (arm64) (push) Successful in 1m34s
Create Docker Image / Final Docker Image Manifest (push) Successful in 10s
2025-01-31 16:22:43 +11:00
21519d680b IAC binary
All checks were successful
Create Docker Image / Build Docker Image (x86_64) (push) Successful in 41s
Create Docker Image / Build Docker Image (arm64) (push) Successful in 1m32s
Create Docker Image / Final Docker Image Manifest (push) Successful in 10s
2025-01-31 16:13:32 +11:00
6e7bcc3fe8 IAC binary
All checks were successful
Create Docker Image / Build Docker Image (x86_64) (push) Successful in 42s
Create Docker Image / Build Docker Image (arm64) (push) Successful in 1m35s
Create Docker Image / Final Docker Image Manifest (push) Successful in 10s
2025-01-31 15:54:46 +11:00
e0d2b11b07 IAC binary
All checks were successful
Create Docker Image / Build Docker Image (x86_64) (push) Successful in 36s
Create Docker Image / Build Docker Image (arm64) (push) Successful in 1m33s
Create Docker Image / Final Docker Image Manifest (push) Successful in 10s
2025-01-31 00:16:16 +11:00
5f217291c5 IAC binary
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 1m33s
Create Docker Image / Final Docker Image Manifest (push) Successful in 10s
2025-01-31 00:10:20 +11:00
a281ca9df7 IAC binary
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 1m31s
Create Docker Image / Final Docker Image Manifest (push) Successful in 10s
2025-01-30 23:54:26 +11:00
e8ad0b60dd IAC binary
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 1m33s
Create Docker Image / Final Docker Image Manifest (push) Successful in 9s
2025-01-30 23:48:11 +11:00
0189b091ab IAC binary
All checks were successful
Create Docker Image / Build Docker Image (x86_64) (push) Successful in 40s
Create Docker Image / Build Docker Image (arm64) (push) Successful in 1m32s
Create Docker Image / Final Docker Image Manifest (push) Successful in 10s
2025-01-30 23:40:50 +11:00
34569f476f Begin check for telnet-iac
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 1m38s
Create Docker Image / Final Docker Image Manifest (push) Successful in 10s
2025-01-30 23:18:49 +11:00
52961e2403 Allow admins to reduce the size of pkt_msgs 2025-01-29 21:15:55 +11:00
4 changed files with 166 additions and 8 deletions

View File

@ -936,6 +936,99 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface
if (static::DEBUG) if (static::DEBUG)
Log::debug(sprintf('%s:- Got [%x] (%c)',self::LOGKEY,$ch,$ch)); Log::debug(sprintf('%s:- Got [%x] (%c)',self::LOGKEY,$ch,$ch));
// Look for Telnet IAC, if binary mode we'll need to handle IAC IAC => IAC
if ($ch === 0xff) {
Log::debug(sprintf('%s:- TELNET IAC',self::LOGKEY));
$iaccmd = NULL;
// Peek for the next 2 chars
do {
try {
$iac = $this->client->read(1,1,MSG_PEEK);
Log::debug(sprintf('%s: - IAC LOOP',self::LOGKEY),['iac'=>ord($iac),'cmd'=>$iaccmd]);
switch (ord($iac)) {
// Binary Mode
case 0x00:
if ($iaccmd === 0xfb) {
Log::debug(sprintf('%s: - IAC WILL BINARY [%02x]',self::LOGKEY,ord($iac)));
// Config with DO
//$this->client->send(chr(0xff).chr(0xfd).$iac,10);
} elseif ($iaccmd === 0xfd) {
Log::debug(sprintf('%s: - IAC DO BINARY [%02x]',self::LOGKEY,ord($iac)));
// Config with WILL
if (! $this->client->iac_bin) {
$this->client->send(chr(0xff).chr(0xfb).$iac,10);
$this->client->iac_bin = true;
}
}
$iaccmd = NULL;
break;
// Suppress Go Ahead
case 0x03:
if ($iaccmd === 0xfb) {
Log::debug(sprintf('%s: - IAC WILL SUPPRESS-GO-AHEAD [%02x]',self::LOGKEY,ord($iac)));
// Config with DO
//$this->client->send(chr(0xff).chr(0xfd).$iac,10);
} elseif ($iaccmd === 0xfd) {
Log::debug(sprintf('%s: - IAC DO SUPPRESS-GO-AHEAD [%02x]',self::LOGKEY,ord($iac)));
// Config with WILL
$this->client->send(chr(0xff).chr(0xfb).$iac,10);
}
$iaccmd = NULL;
break;
// Will
case 0xfb:
Log::debug(sprintf('%s: - IAC WILL [%02x]',self::LOGKEY,ord($iac)));
$iaccmd = ord($iac);
break;
// Do
case 0xfd:
Log::debug(sprintf('%s: - IAC DO [%02x]',self::LOGKEY,ord($iac)));
$iaccmd = ord($iac);
break;
// IAC
case 0xff:
Log::debug(sprintf('%s: - IAC [%02x]',self::LOGKEY,ord($iac)));
$iaccmd = ord($iac);
break;
default:
Log::debug(sprintf('%s: - IAC Unhandled [%02x]',self::LOGKEY,ord($iac)),['iac'=>$iac,'iaccmd'=>$iaccmd,'ch'=>ord($iac)]);
$ch = ord($iac);
$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;
}
} while (! is_null($iac));
Log::debug(sprintf('%s:- Leaving IAC with [%02x]',self::LOGKEY,$ch),['ch'=>serialize($ch)]);
}
if (($ch != self::TIMEOUT) && ($ch < 0)) if (($ch != self::TIMEOUT) && ($ch < 0))
return $ch; return $ch;

View File

@ -665,6 +665,8 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
if (($c=$this->ls_readcanned($timeout)) < 0) if (($c=$this->ls_readcanned($timeout)) < 0)
return $c; return $c;
Log::debug(sprintf('%s: ls_readzdle [%02x]',self::LOGKEY,$c));
/* Check for unescaped XON/XOFF */ /* Check for unescaped XON/XOFF */
if (! ($this->ls_Protocol&self::LSZ_OPTDIRZAP)) { if (! ($this->ls_Protocol&self::LSZ_OPTDIRZAP)) {
switch ($c) { switch ($c) {
@ -1147,7 +1149,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
private function ls_zrecvdata32(string &$data,int &$len,int $timeout): int private function ls_zrecvdata32(string &$data,int &$len,int $timeout): int
{ {
if (static::DEBUG) if (static::DEBUG)
Log::debug(sprintf('%s:+ ls_zrecvdata32',self::LOGKEY),['d'=>$data]); Log::debug(sprintf('%s:+ ls_zrecvdata32',self::LOGKEY),['d'=>$data,'len'=>$len,'timeout'=>$timeout]);
$got = 0; /* Bytes total got */ $got = 0; /* Bytes total got */
$crc = 0; /* Received CRC */ $crc = 0; /* Received CRC */
@ -1165,6 +1167,9 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
return self::LSZ_BADCRC; return self::LSZ_BADCRC;
} else { } else {
if (static::DEBUG)
Log::debug(sprintf('%s:- ls_zrecvdata32 c>32 [%x] (%c)',self::LOGKEY,$c,($c<31 ? 32 : $c)),['c'=>serialize($c)]);
switch ($c) { switch ($c) {
case self::LSZ_CRCE: case self::LSZ_CRCE:
case self::LSZ_CRCG: case self::LSZ_CRCG:
@ -1277,6 +1282,8 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
break; break;
case self::LSZ_BADCRC: case self::LSZ_BADCRC:
$this->rxbuf = '';
case self::TIMEOUT: case self::TIMEOUT:
if ($this->ls_rxAttnStr) { if ($this->ls_rxAttnStr) {
$this->client->buffer_add($this->ls_rxAttnStr); $this->client->buffer_add($this->ls_rxAttnStr);
@ -1305,6 +1312,8 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
$needzdata = 1; $needzdata = 1;
} }
Log::debug(sprintf('%s:- ls_zrecvfile RC [%s]',self::LOGKEY,$rc),['needzdata'=>$needzdata]);
/* We need new position -- ZDATA (and may be ZEOF) */ /* We need new position -- ZDATA (and may be ZEOF) */
} else { } else {
Log::debug(sprintf('%s:- ls_zrecvfile Want ZDATA/ZEOF at [%d]',self::LOGKEY,$rxpos)); Log::debug(sprintf('%s:- ls_zrecvfile Want ZDATA/ZEOF at [%d]',self::LOGKEY,$rxpos));
@ -1335,7 +1344,7 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
return self::OK; return self::OK;
} }
Log::debug(sprintf('%s:- ls_zrecvfile ZDATA',self::LOGKEY)); Log::debug(sprintf('%s:- ls_zrecvfile ZDATA',self::LOGKEY),['newpos'=>$newpos]);
$needzdata = 0; $needzdata = 0;
} }
} }
@ -1928,6 +1937,9 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
$this->ls_zsendhhdr(self::ZNAK,$this->ls_storelong(0)); $this->ls_zsendhhdr(self::ZNAK,$this->ls_storelong(0));
} }
// sleep between tries
sleep(5);
} while (++$trys < 10); } while (++$trys < 10);
Log::error(sprintf('%s:? ls_zrecvnewpos Something strange or timeout [%d]',self::LOGKEY,$rc)); Log::error(sprintf('%s:? ls_zrecvnewpos Something strange or timeout [%d]',self::LOGKEY,$rc));
@ -2061,6 +2073,8 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
$crc = $this->LSZ_INIT_CRC(); $crc = $this->LSZ_INIT_CRC();
Log::debug(sprintf('%s:*** ',self::LOGKEY),['header'=>self::HEADER_TYPE]);
/* First, calculate packet header byte */ /* First, calculate packet header byte */
if (($type = self::HEADER_TYPE if (($type = self::HEADER_TYPE
[($this->ls_Protocol&self::LSZ_OPTCRC32)==self::LSZ_OPTCRC32] [($this->ls_Protocol&self::LSZ_OPTCRC32)==self::LSZ_OPTCRC32]

View File

@ -197,6 +197,7 @@ final class SocketClient {
return match ($key) { return match ($key) {
'address_remote', 'port_remote' => $this->{$key}, 'address_remote', 'port_remote' => $this->{$key},
'cps', 'speed' => Arr::get($this->session,$key), 'cps', 'speed' => Arr::get($this->session,$key),
'iac_bin' => Arr::get($this->session,$key),
'rx_free' => self::RX_BUF_SIZE-$this->rx_left, 'rx_free' => self::RX_BUF_SIZE-$this->rx_left,
'rx_left' => strlen($this->rx_buf), 'rx_left' => strlen($this->rx_buf),
'tx_free' => self::TX_BUF_SIZE-strlen($this->tx_buf), 'tx_free' => self::TX_BUF_SIZE-strlen($this->tx_buf),
@ -210,6 +211,7 @@ final class SocketClient {
switch ($key) { switch ($key) {
case 'cps': case 'cps':
case 'speed': case 'speed':
case 'iac_bin':
$this->session[$key] = $value; $this->session[$key] = $value;
break; break;
@ -428,11 +430,46 @@ final class SocketClient {
Log::debug(sprintf('%s:- Returning [%d] chars from the RX buffer',self::LOGKEY,$len)); Log::debug(sprintf('%s:- Returning [%d] chars from the RX buffer',self::LOGKEY,$len));
$result = substr($this->rx_buf,0,$len); $result = substr($this->rx_buf,0,$len);
if ($flags !== MSG_PEEK)
$this->rx_buf = substr($this->rx_buf,strlen($result)); $this->rx_buf = substr($this->rx_buf,strlen($result));
Log::debug(sprintf('%s:*** ',self::LOGKEY),['iac_bin'=>$this->iac_bin]);
// In case we are in Telnet Binary Mode
if ($this->iac_bin) {
if (self::DEBUG)
Log::debug(sprintf('%s:- Telnet IAC Binary Mode, looking for ff ff',self::LOGKEY),['result'=>hex_dump($result)]);
// if the last char is ff, we need to get the next char
if (str_ends_with($result,"\xff")) {
Log::debug(sprintf('%s: - We have a hit',self::LOGKEY));
// If we have it in our buffer, just get it
if ($this->rx_left) {
$result .= substr($this->rx_buf,0,1);
$this->rx_buf = substr($this->rx_buf,1);
// Else put everything back into rx_buf, and increase len by 1
} else {
$this->rx_buf = $result;
$len++;
$result = '';
}
}
if (strlen($result) > 1)
$result = str_replace("\xff\xff","\xff",$result);
if (strlen($result))
return $result;
} else
return $result; return $result;
} }
if (self::DEBUG)
Log::debug(sprintf('%s:- Buffer doesnt have [%d] chars, it only has [%d], or it ends with 0xff',self::LOGKEY,$len,strlen($this->rx_buf)),['rx_buf'=>hex_dump($this->rx_buf)]);
if ($timeout && (! $this->hasData($timeout))) if ($timeout && (! $this->hasData($timeout)))
throw new SocketException(SocketException::SOCKET_TIMEOUT,$timeout); throw new SocketException(SocketException::SOCKET_TIMEOUT,$timeout);
@ -486,13 +523,19 @@ final class SocketClient {
} }
} }
if ($flags === MSG_PEEK) {
Log::debug(sprintf('%s:- Returning [%d] chars as a result of a PEEK operation, buffer would have [%d], but still has [%d]',self::LOGKEY,$len,strlen($this->rx_buf.$buf),strlen($this->rx_buf)),['rx_buf'=>hex_dump($this->rx_buf),'buf'=>hex_dump($buf)]);
return substr($this->rx_buf.$buf,0,$len);
}
$this->rx_buf .= $buf; $this->rx_buf .= $buf;
if (self::DEBUG) if (self::DEBUG)
Log::debug(sprintf('%s:- Added [%d] chars to the RX buffer',self::LOGKEY,strlen($buf)),['rx_buf'=>hex_dump($this->rx_buf)]); Log::debug(sprintf('%s:- Added [%d] chars to the RX buffer',self::LOGKEY,strlen($buf)),['rx_buf'=>hex_dump($this->rx_buf)]);
// Loop again and return the data, now that it is in the RX buffer // Loop again and return the data, now that it is in the RX buffer
return $this->read($timeout,$len); return $this->read($timeout,$len,$flags);
} }
/** /**
@ -511,6 +554,9 @@ final class SocketClient {
else else
throw new SocketException(SocketException::SOCKET_TIMEOUT,$timeout); throw new SocketException(SocketException::SOCKET_TIMEOUT,$timeout);
if (self::DEBUG)
Log::debug(sprintf('%s:+ read_ch [%c] (%x)',self::LOGKEY,$ch,ord($ch)));
return ord($ch); return ord($ch);
} }
@ -549,6 +595,11 @@ final class SocketClient {
if (self::DEBUG) if (self::DEBUG)
Log::debug(sprintf('%s:- Sending [%d] chars [%s]',self::LOGKEY,strlen($message),Str::limit($message,15))); Log::debug(sprintf('%s:- Sending [%d] chars [%s]',self::LOGKEY,strlen($message),Str::limit($message,15)));
if ($this->iac_bin) {
Log::debug(sprintf('%s:- IAC_BIN mode, looking for 0xff',self::LOGKEY));
$message = str_replace("\xff","\xff\xff",$message);
}
switch ($this->type) { switch ($this->type) {
case SOCK_STREAM: case SOCK_STREAM:
return socket_write($this->connection,$message,strlen($message)); return socket_write($this->connection,$message,strlen($message));

View File

@ -37,7 +37,7 @@ class SystemRegisterRequest extends FormRequest
'heartbeat' => 'Sorry, only an admin can set this below 12', 'heartbeat' => 'Sorry, only an admin can set this below 12',
'hold' => 'Must be Yes or No', 'hold' => 'Must be Yes or No',
'pollmode' => 'Must be Hold, Normal or Crash', 'pollmode' => 'Must be Hold, Normal or Crash',
'pkt_msgs' => 'Sorry, only an admin can increase this above 100', 'pkt_msgs' => 'Sorry, only an admin can increase this above 100 or below 5',
]; ];
} }
@ -95,10 +95,10 @@ class SystemRegisterRequest extends FormRequest
'nullable', 'nullable',
'integer', 'integer',
function ($attribute,$value,$fail) { function ($attribute,$value,$fail) {
if (($value > 100) && (! Gate::allows('admin'))) if ((($value > 100) || ($value < 5)) && (! Gate::allows('admin')))
$fail(true); $fail(true);
}, },
'min:5', 'min:1',
'max:65535', 'max:65535',
], ],
] : [])); ] : []));