On 2/7/2023 8:47 AM, Peter Corlett via cctalk wrote:
On Tue, Feb 07, 2023 at 12:27:33PM +0100, Cedric Amand via cctalk wrote:
I've looked at the problem a bit, there are two issues to solve at first
glance ; (A) there doesn't seem to be a telnet server library in python,
so whatever you do you have to write your own telnet server, which is a
bit more than just handling the sockets and newlines
You're overthinking this. Go old-school and write it as a regular REPL
command which is spawned from inetd. You don't actually need to implement
TELNET protocol for this as any sane telnet(1) client has sensible defaults in the absence of a protocol negotiation, which is just as well as a lot of modern software gets confused if you send the TELNET escape code even though
the protocol requires it. (FTP clients are particularly shoddy in this
regard, as most of them think it's a weird kind of HTTP and get the framing wrong on edge cases such as strings containing NUL and CR characters, and if
they were really phoning it in, SP and/or '+'.)

Only heavyweight and/or high-performance daemons need to roll everything by hand. I did a funky whois server in Perl many moons ago for fun, but it was
quite unnecessary to do so and inetd would have been quite up to the load.

and of course (B) this has to be linked to someone's API key, although we
could simply release the code and have everyone run their own little
gateway.
The latter would seem to be the best approach, and of course if you're using
inetd, tcpwrappers deals with the access-control issues.

So, it's both simple and not simple. Maybe another language ( perl comes
to mind - NetServer:Generic ) would be better suited to run a telnet
server.
And I see NetServer::Generic was written by Charles Stross! However, what
with him having been distracted by a writing career resulting in dozens of
rather good books, it's not been maintained since 2000, and I see no
indication that it actually speaks TELNET protocol either. From what I
vaguely recall of Charlie's work in the 1990s dotcom boom, the thing he
would have written this for was machine-to-machine communication which
didn't involve TELNET.

These days, Perl users would probably reach for the more modern Net::Server
or one of its subclasses, or just glom a REPL onto inetd.

If you can get it telnet accessible, tcpser (shameless plug) can be used to expose it as a "Hayes(tm)" modem-reachable service.

Jim


--
Jim Brain
br...@jbrain.com
www.jbrain.com

Reply via email to