server_base
Module provides class BaseServer.
- class BaseServer(shell=None, _waiter_connected=None, encoding='utf8', encoding_errors='strict', force_binary=False, never_send_ga=False, line_mode=False, connect_maxwait=4.0, limit=None, reader_factory=<class 'telnetlib3.stream_reader.TelnetReader'>, reader_factory_encoding=<class 'telnetlib3.stream_reader.TelnetReaderUnicode'>, writer_factory=<class 'telnetlib3.stream_writer.TelnetWriter'>, writer_factory_encoding=<class 'telnetlib3.stream_writer.TelnetWriterUnicode'>)[source]
Base Telnet Server Protocol.
Class initializer.
- connect_maxwait
maximum duration for
check_negotiation().
- eof_received()[source]
Called when the other end calls write_eof() or equivalent.
This callback may be exercised by the nc(1) client argument
-z.- Return type:
- connection_made(transport)[source]
Called when a connection is made.
Sets attributes
_transport,_when_connected,_last_received,readerandwriter.Ensure
super().connection_made(transport)is called when derived.- Return type:
- data_received(data)[source]
Process bytes received by transport.
Feeds raw bytes through the writer’s IAC interpreter, forwarding in-band data to the reader.
- Return type:
- begin_negotiation()[source]
Begin on-connect negotiation.
A Telnet server is expected to demand preferred session options immediately after connection. Deriving implementations should always call
super().begin_negotiation().- Return type:
- begin_advanced_negotiation()[source]
Begin advanced negotiation.
Callback method further requests advanced telnet options. Called once on receipt of any
DOorWILLacknowledgments received, indicating that the remote end is capable of negotiating further.Only called if sub-classing
begin_negotiation()causes at least one negotiation option to be affirmatively acknowledged.- Return type:
- encoding(outgoing=False, incoming=False)[source]
Encoding that should be used for the direction indicated.
The base implementation always returns the encoding given to class initializer, or, when unset (None),
US-ASCII.
- negotiation_should_advance()[source]
Whether advanced negotiation should commence.
- Return type:
- Returns:
Trueif advanced negotiation should be permitted.
The base implementation returns True if any negotiation options were affirmatively acknowledged by client, more than likely options requested in callback
begin_negotiation().
- check_negotiation(final=False)[source]
Callback, return whether negotiation is complete.
- Parameters:
final (
bool) – Whether this is the final time this callback will be requested to answer regarding protocol negotiation.- Return type:
- Returns:
Whether negotiation is over (server end is satisfied).
Method is called on each new command byte processed until negotiation is considered final, or after
connect_maxwaithas elapsed, setting attribute_waiter_connectedto valueselfwhen complete.Ensure
super().check_negotiation()is called and conditionally combined when derived.