ziutek / telnet

Package to handle a telnet connection
Other
141 stars 60 forks source link

How to disable echo? #10

Closed vinllen closed 6 years ago

vinllen commented 6 years ago

The code SetEcho(false) doesn't work in your code, but when I use telnet command in Linux shell, the echo mode is disabled.

vinllen commented 6 years ago

I've been tried send "IAC WON'T ECHO": 255 252 1 and "IAC DONT ECHO": 255 254 1 according to the RFC857 but all failed. Do you have any idea how to disable the echo?

ziutek commented 6 years ago

The description of SetEcho method clearly says: "SetEcho tries to enable/disable echo on server side. Typically telnet servers doesn't support this."

The echo can be probably only disabled by a process that runs on the server side (eg: the Unix login program does this when you type password).

vinllen commented 6 years ago

Hi, Ziutek.I think there must be a way to disable echo on the client side so that every command won't be echo anymore. telnet command is a client in Linux shell, but there is no echo in this client.

ziutek commented 6 years ago

Yes. You can simply stop print anything you receive from server.

vinllen commented 6 years ago

But how to judge whether it's an echo packet or not in an easy way? It's easy when I start only one goroutine that sends a message after receiving, however, I use two goroutines that one for reading while the other for writing.

ziutek commented 6 years ago

It seems that you still don't understand the problem with echo.

I don't known your specific case, but the problem insist in (99% probability) that in your case, the echo isn't produced by telnet server but by your remote operating system/application (I don't known any server that supports echo option). If this OS/application doesn't support option to disable echo, its output will be mixed with your input.

If the remote system is Unix/Linux and you have access to the shell, you can disable echo using:

stty -echo

command.

ziutek commented 6 years ago

There is a LINEMODE (currently not supported by this package) that when supported by both sides can probably do echo locally for line editing. See https://tools.ietf.org/html/rfc1184

vinllen commented 6 years ago

Hi, Ziutek. Thanks for your detailed explanation, it helps me a lot.