Introduction
asynctelnet is an asynchronous Telnet Client and Server library for python. This project requires python 3.6 and later, using the anyio module.
asynctelnet is a heavily modified anyio-ization of the telnetlib3 module.
Quick Example
Authoring a Telnet Server using Streams interface that offers a basic war game:
import anyio, asynctelnet
async def shell(tcp):
async with asynctelnet.TelnetServer(tcp) as stream:
# this will fail if no charset has been negotiated
await stream.send('\r\nWould you like to play a game? ')
inp = await reader.receive(1)
if inp:
await stream.echo(inp)
await stream.send('\r\nThey say the only way to win '
'is to not play at all.\r\n')
async def main():
listener = await anyio.create_tcp_listener(local_port=56023)
await listener.serve(shell)
anyio.run(main)
Authoring a Telnet Client that plays the war game with this server:
import anyio, asynctelnet
async def shell(tcp):
async with asynctelnet.TelnetClient(tcp, client=True) as stream:
while True:
# read stream until '?' mark is found
outp = await stream.receive(1024)
if not outp:
# End of File
break
elif '?' in outp:
# reply all questions with 'y'.
await stream.send('y')
# display all server output
print(outp, flush=True)
# EOF
print()
async def main():
async with await connect_tcp('localhost', 56023) as client:
await shell(client)
anyio.run(main)
Command Line
Two command line scripts are distributed with this package.
asynctelnet-client
Small terminal telnet client. Some example destinations and options:
asynctelnet-client nethack.alt.org asynctelnet-client --encoding=cp437 --force-binary blackflag.acid.org asynctelnet-client htc.zapto.org
asynctelnet-server
Telnet server providing the default debugging shell. This provides a simple shell server that allows introspection of the session’s values, for example:
tel:sh> help quit, writer, slc, toggle [option|all], reader, proto tel:sh> writer <TelnetWriter server mode:kludge +lineflow -xon_any +slc_sim server-will:BINARY,ECHO,SGA client-will:BINARY,NAWS,NEW_ENVIRON,TTYPE> tel:sh> reader <TelnetReaderUnicode encoding='utf8' limit=65536 buflen=0 eof=False> tel:sh> toggle all wont echo. wont suppress go-ahead. wont outbinary. dont inbinary. xon-any enabled. lineflow disabled. tel:sh> reader <TelnetReaderUnicode encoding='US-ASCII' limit=65536 buflen=1 eof=False> tel:sh> writer <TelnetWriter server mode:local -lineflow +xon_any +slc_sim client-will:NAWS,NEW_ENVIRON,TTYPE>
Both command-line scripts accept argument --shell=my_module.fn_shell describing a python module path to a coroutine of signature shell(reader, writer), just as the above examples.
Features
The following RFC specifications are implemented:
rfc-727, “Telnet Logout Option,” Apr 1977.
rfc-779, “Telnet Send-Location Option”, Apr 1981.
rfc-854, “Telnet Protocol Specification”, May 1983.
rfc-855, “Telnet Option Specifications”, May 1983.
rfc-856, “Telnet Binary Transmission”, May 1983.
rfc-857, “Telnet Echo Option”, May 1983.
rfc-858, “Telnet Suppress Go Ahead Option”, May 1983.
rfc-859, “Telnet Status Option”, May 1983.
rfc-860, “Telnet Timing mark Option”, May 1983.
rfc-885, “Telnet End of Record Option”, Dec 1983.
rfc-1073, “Telnet Window Size Option”, Oct 1988.
rfc-1079, “Telnet Terminal Speed Option”, Dec 1988.
rfc-1091, “Telnet Terminal-Type Option”, Feb 1989.
rfc-1096, “Telnet X Display Location Option”, Mar 1989.
rfc-1123, “Requirements for Internet Hosts”, Oct 1989.
rfc-1184, “Telnet Linemode Option (extended options)”, Oct 1990.
rfc-1372, “Telnet Remote Flow Control Option”, Oct 1992.
rfc-1408, “Telnet Environment Option”, Jan 1993.
rfc-1571, “Telnet Environment Option Interoperability Issues”, Jan 1994.
rfc-1572, “Telnet Environment Option”, Jan 1994.
rfc-2066, “Telnet Charset Option”, Jan 1997.
Further Reading
Further documentation available at https://asynctelnet.readthedocs.org/
Metadata
Release files for asynctelnet 0.2.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| asynctelnet-0.2.5.tar.gz | 100.2 kB | Without provenance | Details for asynctelnet-0.2.5.tar.gz |
Release files / asynctelnet-0.2.5.tar.gz
| Download URL | asynctelnet-0.2.5.tar.gz |
|---|---|
| Size | 100.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b4bb867c2dfca2b1d93a9f684adcc769d2025e46f4080611f119ec2a4089987f
|
|
BLAKE2b-256 checksum How to use checksums |
665a9ceac48f1939c5ff43c3f722a6d0a2600ec6f58f6c2caa2b468e7c1fddb2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.4.2 requests/2.21.0 setuptools/52.0.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.9.1+
|
Security for asynctelnet 0.2.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.