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

This commit is contained in:
Deon George 2025-01-31 17:13:12 +11:00
parent ae9445aa33
commit 07e42e2f5e

View File

@ -433,6 +433,33 @@ 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));
// 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));
// if the last char is ff, we need to get the next char
if (str_ends_with($result,"\xff")) {
// 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 = NULL;
}
}
if (strlen($result) > 1)
$result = str_replace("\xff\xff","\xff",$result);
if ($result)
return $result;
} else
return $result; return $result;
} }