Telnet Binary Send
This commit is contained in:
parent
07e42e2f5e
commit
c42340fe60
@ -960,7 +960,7 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface
|
|||||||
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;
|
||||||
}
|
}
|
||||||
|
@ -433,13 +433,17 @@ final class SocketClient {
|
|||||||
if ($flags !== MSG_PEEK)
|
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
|
// In case we are in Telnet Binary Mode
|
||||||
if ($this->iac_bin) {
|
if ($this->iac_bin) {
|
||||||
if (self::DEBUG)
|
if (self::DEBUG)
|
||||||
Log::debug(sprintf('%s:- Telnet IAC Binary Mode, looking for ff ff',self::LOGKEY));
|
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 the last char is ff, we need to get the next char
|
||||||
if (str_ends_with($result,"\xff")) {
|
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 we have it in our buffer, just get it
|
||||||
if ($this->rx_left) {
|
if ($this->rx_left) {
|
||||||
$result .= substr($this->rx_buf,0,1);
|
$result .= substr($this->rx_buf,0,1);
|
||||||
@ -449,14 +453,14 @@ final class SocketClient {
|
|||||||
} else {
|
} else {
|
||||||
$this->rx_buf = $result;
|
$this->rx_buf = $result;
|
||||||
$len++;
|
$len++;
|
||||||
$result = NULL;
|
$result = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strlen($result) > 1)
|
if (strlen($result) > 1)
|
||||||
$result = str_replace("\xff\xff","\xff",$result);
|
$result = str_replace("\xff\xff","\xff",$result);
|
||||||
|
|
||||||
if ($result)
|
if (strlen($result))
|
||||||
return $result;
|
return $result;
|
||||||
|
|
||||||
} else
|
} else
|
||||||
@ -464,7 +468,7 @@ final class SocketClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (self::DEBUG)
|
if (self::DEBUG)
|
||||||
Log::debug(sprintf('%s:- Buffer doesnt have [%d] chars, it only has [%d]',self::LOGKEY,$len,strlen($this->rx_buf)));
|
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);
|
||||||
@ -591,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));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user