[Toybox] [PATCH] telnet: various fixes.
enh
enh at google.com
Thu Apr 22 19:38:51 PDT 2021
This got a bit out of hand. All I wanted to fix was the CR conversion to
get this part of https://tools.ietf.org/html/rfc854 right:
Therefore, the sequence "CR LF" must be treated as a single "new
line" character and used whenever their combined action is
intended; the sequence "CR NUL" must be used where a carriage
return alone is actually desired; and the CR character must be
avoided in other contexts. This rule gives assurance to systems
which must decide whether to perform a "new line" function or a
multiple-backspace that the TELNET stream contains a character
following a CR that will allow a rational decision.
But to understand the code well enough to do that, and to fix it so that
it works when IAC or CR sequences are split across multiple reads, I
ended up rewriting a lot:
* Add punctuation in help.
* Remove duplicated #include.
* Remove some unnecessary globals, enlarge the global buffers, and keep
state for correct IAC sequence processing across reads.
* Reduce code duplication and rewrite bits that made no sense.
* Handle entering/exiting raw mode more uniformly.
* Fix the prompt (the character count was wrong).
* Allow ^]^D (like BSD telnet) as well as ^]e to exit, and look less
like we crashed when doing so.
* Simplify the IAC sequence handling, but more importantly work
correctly when a sequence is split across multiple reads.
* Use more of the existing "x" functions from lib. (And remove code that
was duplicating what the "x" functions they'd just called had already
done.)
* Show "Connected to".
* Better signal handling.
I'm still not happy with TELOPT_ECHO and TELOPT_SGA in handle_wwdd(),
but don't (yet) understand them well enough to simplify them further. On
the bright side, I think TELOPT_NAWS is a lot clearer now.
It also occurs to me now I'm looking at the diff that although the IAC
output code is now better than it was, it probably still isn't pulling
its weight and might better be replaced by printf().
...but this patch has already gotten way out of hand!
---
toys/pending/telnet.c | 416 +++++++++++++++++++-----------------------
1 file changed, 187 insertions(+), 229 deletions(-)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20210422/20b564bf/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-telnet-various-fixes.patch
Type: text/x-patch
Size: 16620 bytes
Desc: not available
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20210422/20b564bf/attachment-0002.bin>
More information about the Toybox
mailing list