telnetlib3 2.2.0
pip install telnetlib3
Released:
Python Telnet server and client CLI and Protocol library
Navigation
Unverified details
These details havenot been verified by PyPIProject links
Meta
- License Expression: ISC
SPDXLicense Expression - Author:Jeff Quast
- Tags api, asyncio, bbs, client, cp437, library, mud, pty, server, telnet, utf8
- Requires: Python >=3.9
- Provides-Extra:
docs,extras
Classifiers
- Development Status
- Intended Audience
- License
- Programming Language
- Topic
- Typing
Project description
Introduction
telnetlib3 is a full-featured Telnet Client and Server library for python3.9 and newer.
Modernasyncio and legacy blocking API’s are provided.
The pythontelnetlib.py module removed by Python 3.13 is also re-distributed as a backport.
Overview
telnetlib3 provides multiple interfaces for working with the Telnet protocol:
Asyncio Protocol
Modern async/await interface for both client and server, supporting concurrentconnections. See theGuidebook for examples and theAPI documentation.
Blocking API
A traditional synchronous interface modeled aftertelnetlib.py (client) andminiboa (server),with various enhancements in protocol negotiation is provided. Blocking API calls for complexarrangements of clients and servers typically require threads.
Seesync API documentation for more.
Command-line Utilities
Two CLI tools are included:telnetlib3-client for connecting to serversandtelnetlib3-server for hosting a server.
Both tools argument--shell=my_module.fn_shell describing a pythonmodule path to a function of signatureasync def shell(reader, writer).The server also provides--pty-exec argument to host a stand-aloneprogram.
telnetlib3-client nethack.alt.orgtelnetlib3-client xibalba.l33t.codes 44510telnetlib3-client --shell bin.client_wargame.shell 1984.ws 666telnetlib3-server 0.0.0.0 1984 --shell=bin.server_wargame.shelltelnetlib3-server --pty-exec /bin/bash -- --login
Fingerprinting Server
A built-in fingerprinting server shell is provided to uniquely identify telnet clients.
Install with optional dependencies for full fingerprinting support (prettytableanducs-detect):
pip install telnetlib3[extras]
Usage:
export TELNETLIB3_DATA_DIR=./datatelnetlib3-server --shell telnetlib3.fingerprinting_server_shell
A public fingerprinting server you can try out yourself:
telnet 1984.ws 555
An optional post-fingerprint hook can process saved files. The hook is run aspython-m <module> <filepath>. The built-in post-script pretty-prints the JSONand integrates withucs-detect for terminal capability probing:
export TELNETLIB3_DATA_DIR=./fingerprintsexport TELNETLIB3_FINGERPRINT_POST_SCRIPT=telnetlib3.fingerprintingtelnetlib3-server --shell telnetlib3.fingerprinting_server_shell
Ifucs-detect is installed and available in PATH, the post-script automaticallyruns it to probe terminal capabilities (colors, sixel, kitty graphics, etc.) andadds the results to the fingerprint data asterminal-fingerprint-data.
Legacy telnetlib
This library contains an unadulterated copy of Python 3.12’stelnetlib.py,from the standard library before it was removed in Python 3.13.
To migrate code, change import statements:
# OLD imports:importtelnetlib# NEW imports:importtelnetlib3telnetlib3 did not provide server support, while this library also providesboth client and server support through a similar Blocking API interface.
Seesync API documentation for details.
Encoding
Often required,--encoding and--force-binary:
telnetlib3-client --encoding=cp437 --force-binary 20forbeers.com 1337
The default encoding is the system locale, usually UTF-8, but all Telnetprotocol textshould be limited to ASCII until BINARY mode is agreed bycompliance of their respective RFCs.
However, many clients and servers that are capable of non-ascii encodings likeUTF-8 or CP437 may not be capable of negotiating about BINARY, NEW_ENVIRON,or CHARSET to negotiate about it.
In this case, use--force-binary and--encoding when the encoding ofthe remote end is known.
Go-Ahead (GA)
When a client does not negotiate Suppress Go-Ahead (SGA), the server sendsIAC GA after output to signal that the client may transmit. This iscorrect behavior for MUD clients like Mudlet that expect prompt detectionvia GA.
If GA causes unwanted output for your use case, disable it:
telnetlib3-server --never-send-ga
For PTY shells, GA is sent after 500ms of output idle time to avoidinjecting GA in the middle of streaming output.
Quick Example
A simple telnet server:
importasyncioimporttelnetlib3asyncdefshell(reader,writer):writer.write('\r\nWould you like to play a game? ')inp=awaitreader.read(1)ifinp:writer.echo(inp)writer.write('\r\nThey say the only way to win ''is to not play at all.\r\n')awaitwriter.drain()writer.close()asyncdefmain():server=awaittelnetlib3.create_server(port=6023,shell=shell)awaitserver.wait_closed()asyncio.run(main())More examples are available in theGuidebook and thebin/ directory of the repository.
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 athttps://telnetlib3.readthedocs.io/
Project details
Unverified details
These details havenot been verified by PyPIProject links
Meta
- License Expression: ISC
SPDXLicense Expression - Author:Jeff Quast
- Tags api, asyncio, bbs, client, cp437, library, mud, pty, server, telnet, utf8
- Requires: Python >=3.9
- Provides-Extra:
docs,extras
Classifiers
- Development Status
- Intended Audience
- License
- Programming Language
- Topic
- Typing
Release historyRelease notifications |RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more aboutinstalling packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more aboutwheel file names.
Copy a direct link to the current filters
File details
Details for the filetelnetlib3-2.2.0.tar.gz.
File metadata
- Download URL:telnetlib3-2.2.0.tar.gz
- Upload date:
- Size: 211.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.15.0a5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 | 85312604c9f52914938fe3697e5bbd219adab446af0df3045f21b07ba5417f73 | |
| MD5 | 9ae4f1d28707da905690715888d2d400 | |
| BLAKE2b-256 | 0d2aa9a7a4cb24626493806d95df0b19740d40a5583836ee070970489ca063b1 |
File details
Details for the filetelnetlib3-2.2.0-py3-none-any.whl.
File metadata
- Download URL:telnetlib3-2.2.0-py3-none-any.whl
- Upload date:
- Size: 219.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.15.0a5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 | 028648619e66d1a746791a3ef3e2a1cc7ffe4b78cf283c8028bef9e493f30554 | |
| MD5 | 439ac9c2a8a25d4c78e4bc09926fcec5 | |
| BLAKE2b-256 | 186251a035c18305402ac5c5eefa88fdaf7e14eba6f09e3a17a218d72fe2c18b |