Begin check for telnet-iac
This commit is contained in:
parent
52961e2403
commit
34569f476f
@ -936,6 +936,24 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface
|
||||
if (static::DEBUG)
|
||||
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));
|
||||
|
||||
// Peek for the next 2 chars
|
||||
do {
|
||||
$iac = $this->client->read(10,1,MSG_PEEK);
|
||||
|
||||
switch ($iac) {
|
||||
default:
|
||||
Log::debug(sprintf('%s: - IAC [%02x]',self::LOGKEY,$iac));
|
||||
|
||||
$iac = NULL;
|
||||
}
|
||||
|
||||
} while (! is_null($iac));
|
||||
}
|
||||
|
||||
if (($ch != self::TIMEOUT) && ($ch < 0))
|
||||
return $ch;
|
||||
|
||||
|
@ -665,6 +665,8 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
|
||||
if (($c=$this->ls_readcanned($timeout)) < 0)
|
||||
return $c;
|
||||
|
||||
Log::debug(sprintf('%s: ls_readzdle [%02x]',self::LOGKEY,$c));
|
||||
|
||||
/* Check for unescaped XON/XOFF */
|
||||
if (! ($this->ls_Protocol&self::LSZ_OPTDIRZAP)) {
|
||||
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
|
||||
{
|
||||
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 */
|
||||
$crc = 0; /* Received CRC */
|
||||
@ -1165,6 +1167,9 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
|
||||
return self::LSZ_BADCRC;
|
||||
|
||||
} 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) {
|
||||
case self::LSZ_CRCE:
|
||||
case self::LSZ_CRCG:
|
||||
@ -1277,6 +1282,8 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
|
||||
break;
|
||||
|
||||
case self::LSZ_BADCRC:
|
||||
$this->rxbuf = '';
|
||||
|
||||
case self::TIMEOUT:
|
||||
if ($this->ls_rxAttnStr) {
|
||||
$this->client->buffer_add($this->ls_rxAttnStr);
|
||||
@ -1305,6 +1312,8 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
|
||||
$needzdata = 1;
|
||||
}
|
||||
|
||||
Log::debug(sprintf('%s:- ls_zrecvfile RC [%s]',self::LOGKEY,$rc),['needzdata'=>$needzdata]);
|
||||
|
||||
/* We need new position -- ZDATA (and may be ZEOF) */
|
||||
} else {
|
||||
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;
|
||||
}
|
||||
|
||||
Log::debug(sprintf('%s:- ls_zrecvfile ZDATA',self::LOGKEY));
|
||||
Log::debug(sprintf('%s:- ls_zrecvfile ZDATA',self::LOGKEY),['newpos'=>$newpos]);
|
||||
$needzdata = 0;
|
||||
}
|
||||
}
|
||||
@ -1928,6 +1937,9 @@ final class Zmodem extends Protocol implements CRCInterface,ZmodemInterface
|
||||
$this->ls_zsendhhdr(self::ZNAK,$this->ls_storelong(0));
|
||||
}
|
||||
|
||||
// sleep between tries
|
||||
sleep(5);
|
||||
|
||||
} while (++$trys < 10);
|
||||
|
||||
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();
|
||||
|
||||
Log::debug(sprintf('%s:*** ',self::LOGKEY),['header'=>self::HEADER_TYPE]);
|
||||
|
||||
/* First, calculate packet header byte */
|
||||
if (($type = self::HEADER_TYPE
|
||||
[($this->ls_Protocol&self::LSZ_OPTCRC32)==self::LSZ_OPTCRC32]
|
||||
|
@ -428,6 +428,7 @@ final class SocketClient {
|
||||
Log::debug(sprintf('%s:- Returning [%d] chars from the RX buffer',self::LOGKEY,$len));
|
||||
|
||||
$result = substr($this->rx_buf,0,$len);
|
||||
if ($flags !== MSG_PEEK)
|
||||
$this->rx_buf = substr($this->rx_buf,strlen($result));
|
||||
|
||||
return $result;
|
||||
@ -492,7 +493,7 @@ final class SocketClient {
|
||||
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
|
||||
return $this->read($timeout,$len);
|
||||
return $this->read($timeout,$len,$flags);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -511,6 +512,9 @@ final class SocketClient {
|
||||
else
|
||||
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);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user