9swampy / Telnet

Published on Nuget at https://www.nuget.org/packages/Telnet

Home Page:http://www.nugetmusthaves.com/Package/Telnet

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

When writing a line to the server \n is used instead of \r\n in PrimS.Telnet.Client

toddaheath opened this issue · comments

When writing a line to the server \n is used instead of \r\n this causes the write to fail for the telnet server that I am connecting to.

From: await this.Write(string.Format("{0}\n", command));
To: await this.Write(string.Format("{0}\r\n", command));

Hi @toddaheath thx for the feedback. It wouldn't be that hard to inject by parameter a default for the current \n allowing you to override in your use case to apply \r\n without changing existing behaviour. I'd welcome a pull request incl tests for incumbent and added behaviour. Alternatively if you're happy to call Write passing in the \r\n you need instead of using the current WriteLine implementation would achieve the same result because as you found the WriteLine's just a shorthand.

Sure, if you want to make me a contributor, I can create a feature branch and PR for a potential fix. For now, I forked the code and made the quick fix.

According to RFC 854, CR+LF should be the default a client sends. The server should accept CR, CR+NUL, or CR+LF. It doesn't make sense to send just LF by itself.

Note that "CR LF" or "CR NUL" is required in both directions (in the default ASCII mode), to preserve the symmetry of the NVT model.

SPEC:
https://tools.ietf.org/html/rfc854

Discussion:
http://www.freesoft.org/CIE/RFC/1123/31.htm

@toddaheath You can submit a PR from your fork. That makes you a contributor. I have 2 open PR from my fork right now.

PR submitted, let me know if you have any comments. I added an optional linefeec parameter that defaults to the old value as suggested. PR Id #39

I see. Due to the RFC I cited I would make the default CR+LF. The only other options would be CR by itself but I don't think we would ever NEED that. Like I said, using LF by itself never makes sense. Even a Macintosh wouldn't make that mistake.

A User Telnet on an ASCII host SHOULD have a user-controllable mode to send either CR LF or CR NUL when the user presses the "end-of-line" key, and CR LF SHOULD be the default.

FROM: https://www.freesoft.org/CIE/RFC/1123/31.htm

I agree but the owner of the repository wanted it to be backward compatible for the people that are currently using the library. If he approves that I’ll update the PR but I don’t have permission to merge the PR, so I’ll have to wait for feedback from him.

Sorry it took so long; merged and published 0.8.2.

Great. Thanks!