jnorell / net_telnet Goto Github PK
View Code? Open in Web Editor NEWNet_Telnet provides a PHP implementation of the TELNET protocol.
License: Other
Net_Telnet provides a PHP implementation of the TELNET protocol.
License: Other
While sorting out WNPP at Debian I found yours: https://bugs.debian.org/706404
I am not sure if I should close it or not. Are you using this software or should you archive it ?
On PHP 7.2 it performs without any issues, but on PHP 8 I get warnings
PHP Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /tmp/Net_Telnet-master/Net/Telnet.php on line 1535
On certain devices (Fortinet) I experienced telnet auto negation failures for the telnet session.
Sample from this script:
attempting connection to 127.0.0.1:12123
connected to 127.0.0.1:12123
DO ECHO
DO SUPPRESS GO AHEAD
login: waiting for login prompt: login:
expect: watching for login:
< DO TERMINAL TYPE
WONT TERMINAL TYPE
< DO TSPEED
WONT TSPEED
< DO XDISPLOC
WONT XDISPLOC
< DO NEW-ENVIRON
WONT NEW-ENVIRON
< WILL ECHO
Enabling Remote Echo
< WILL SUPPRESS GO AHEAD
Enabling Suppress Go Ahead (SGA) on Receive
Enabling Suppress Go Ahead (SGA) on Transmit
WILL SUPPRESS GO AHEAD
< DO SUPPRESS GO AHEAD
< DO ECHO
Disabling Remote Echo to prevent Echo loop
DONT ECHO
Enabling Local Network Echo
WILL ECHO
< DO NAWS
WONT NAWS
< WILL STATUS
< DO LFLOW
WONT LFLOW
Sample from PuttyTel which works properly:
2016-03-09 14:02:35 Looking up host "127.0.0.1"
2016-03-09 14:02:35 Connecting to 127.0.0.1 port 12123
2016-03-09 14:02:35 client: WILL NAWS
2016-03-09 14:02:35 client: WILL TSPEED
2016-03-09 14:02:35 client: WILL TTYPE
2016-03-09 14:02:35 client: WILL NEW_ENVIRON
2016-03-09 14:02:35 client: DO ECHO
2016-03-09 14:02:35 client: WILL SGA
2016-03-09 14:02:35 client: DO SGA
2016-03-09 14:02:36 server: DO TTYPE
2016-03-09 14:02:36 server: DO TSPEED
2016-03-09 14:02:36 server: DO XDISPLOC
2016-03-09 14:02:36 client: WONT XDISPLOC
2016-03-09 14:02:36 server: DO NEW_ENVIRON
2016-03-09 14:02:36 server: DO NAWS
2016-03-09 14:02:36 client: SB NAWS 80,24
2016-03-09 14:02:36 server: WILL ECHO
2016-03-09 14:02:36 server: DO SGA
2016-03-09 14:02:36 server: WILL SGA
2016-03-09 14:02:36 server: SB TSPEED SEND
2016-03-09 14:02:36 client: SB TSPEED IS 38400,38400
2016-03-09 14:02:36 server: SB NEW_ENVIRON SEND
2016-03-09 14:02:36 client: SB NEW_ENVIRON IS
2016-03-09 14:02:36 server: SB TTYPE SEND
2016-03-09 14:02:36 client: SB TTYPE IS XTERM
2016-03-09 14:02:36 server: DO ECHO
2016-03-09 14:02:36 client: WONT ECHO
2016-03-09 14:02:36 server: WILL STATUS
2016-03-09 14:02:36 client: DONT STATUS
2016-03-09 14:02:36 server: DO LFLOW
2016-03-09 14:02:36 client: WONT LFLOW
The workaround that @jnorell came up with is as follows:
Edit Net/Telnet.php, line 983
right now has this:
if ($this->mode['echo_remote']) {
$this->debug("Disabling Remote Echo to prevent Echo loop");
$this->mode['echo_remote'] = false;
$this->send_telcmd(TEL_DONT, $opt);
}
Change that to:
if ($this->mode['echo_remote']) {
$this->debug("Refusing to Echo");
$this->send_telcmd(TEL_WONT, $opt);
break;
$this->debug("Disabling Remote Echo to prevent Echo loop");
$this->mode['echo_remote'] = false;
$this->send_telcmd(TEL_DONT, $opt);
}
Which essentially sends a "TEL_WONT" instead of a "TEL_DONT" on in response to the DO ECHO.
After you change the code above, valid debug output looks as follows and the code worked properly:
attempting connection to 127.0.0.1:12123
connected to 127.0.0.1:12123
DO ECHO
DO SUPPRESS GO AHEAD
login: waiting for login prompt: login:
expect: watching for login:
< DO TERMINAL TYPE
WONT TERMINAL TYPE
< DO TSPEED
WONT TSPEED
< DO XDISPLOC
WONT XDISPLOC
< DO NEW-ENVIRON
WONT NEW-ENVIRON
< WILL ECHO
Enabling Remote Echo
< WILL SUPPRESS GO AHEAD
Enabling Suppress Go Ahead (SGA) on Receive
Enabling Suppress Go Ahead (SGA) on Transmit
WILL SUPPRESS GO AHEAD
< DO SUPPRESS GO AHEAD
< DO ECHO
Refusing to Echo
WONT ECHO
< DO NAWS
WONT NAWS
< WILL STATUS
< DO LFLOW
WONT LFLOW
Opening a bug just to track it should anyone else encounter a similar issue.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.