Closed vinllen closed 6 years ago
I added checking to avoid optEcho loop. Try the modified code and report does it help.
It doesn't work. Is it the problem that different switch uses different telnet protocol version?
Does no response
mean accept in telnet protocol?
When I set the echo option to false in the (func (c *Conn) SetEcho(echo bool)
), the optEcho loop still exists. However, this loop disappears when setting the option to true. This phenomenon is very strange. Setting echo option true receive:
received cmd: 251 1
received cmd: 251 1
received cmd: 251 1
received cmd: 251 3
received cmd: 253 24
received cmd: 253 31
received cmd: 254 24
About the first problem, it looks like some switches need character \r after \n
Hi, Dear Ziutek,
Sorry to bother you again. I have two questions about the telnet option recently. I used your library to telnet different switch and router. Some of them are OK, while some are not.
The "Password:" string didn't show After login into the switch using telnet, the
Username:
characters show normally. Some switches don't show thepassword:
characters after typing the username. Actually, no response occurred whatever I type.In my experiments, some switches can display the
password:
character but some aren't. I can't find any help in the google results and (rfc854)[https://tools.ietf.org/html/rfc854]. Do you know it's telnet option problem or switch configuration problem? Supplement: thepassword:
string can all be displayed normally when using (Linux telnet client)[https://linux.die.net/man/1/telnet]."echo option" negotiate loop I didn't modify your code so that for every
IAC WILL ECHO/255 251 1
replyIAC DO ECHO/255 253 2
; for everyIAC WON'T ECHO/255 252 1
replyIAC DON'T ECHO/255 254 1
. This strategy should work OK according to the (rfc854)[https://tools.ietf.org/html/rfc854]. But some switches go into dead loop, here comes the print from debug:I don't know whether it's problem of switch telnet version. What I want is accept any echo configuration. Here comes the description of option response in
rfc854
:If a party receives what appears to be a request to enter some mode it is already in, the request should not be acknowledged. This non-response is essential to prevent endless loops in the negotiation. It is required that a response be sent to requests for a change of mode -- even if the mode is not changed.
In my understanding, no response means enable. So I modify your code in
func (c *Conn) cmd(cmd byte)
that doesn't reply anydo
anddon't
when receivewill
andwon't
:It looks like the switch enable echo option which is what I want. Do you think it's a right way to erase these two line code to enable echo option?