t.p.t.Telnet(protocol.Protocol) : class documentation

Part of twisted.protocols.telnet View Source View In Hierarchy

Known subclasses: twisted.manhole.telnet.Shell

I am a Protocol for handling Telnet connections. I have two sets of special methods, telnet_* and iac_*.

telnet_* methods get called on every line sent to me. The method to call is decided by the current mode. The initial mode is 'User'; this means that telnet_User is the first telnet_* method to be called. All telnet_* methods should return a string which specifies the mode to go into next; thus dictating which telnet_* method to call next. For example, the default telnet_User method returns 'Password' to go into Password mode, and the default telnet_Password method returns 'Command' to go into Command mode.

The iac_* methods are less-used; they are called when an IAC telnet byte is received. You can define iac_DO, iac_DONT, iac_WILL, iac_WONT, and iac_IP methods to do what you want when one of these bytes is received.

Method write Send the given data over my transport.
Method connectionMade I will write a welcomeMessage and loginPrompt to the client.
Method welcomeMessage Override me to return a string which will be sent to the client before login.
Method loginPrompt Override me to return a 'login:'-type prompt.
Method iacSBchunk Undocumented
Method iac_DO Undocumented
Method iac_DONT Undocumented
Method iac_WILL Undocumented
Method iac_WONT Undocumented
Method iac_IP Undocumented
Method processLine I call a method that looks like 'telnet_*' where '*' is filled in by the current mode. telnet_* methods should return a string which will become the new mode. If None is returned, the mode will not change.
Method telnet_User No summary
Method telnet_Password I accept a password as an argument, and check it with the checkUserAndPass method. If the login is successful, I call loggedIn().
Method telnet_Command The default 'command processing' mode. You probably want to override me.
Method processChunk I take a chunk of data and delegate out to telnet_* methods by way of processLine. If the current mode is 'Done', I'll close the connection.
Method dataReceived Called whenever data is received.
Method loggedIn Called after the user succesfully logged in.

Inherited from Protocol:

Method logPrefix Return a prefix matching the class name, to identify log messages related to this protocol instance.
Method connectionLost Called when the connection is shut down.

Inherited from BaseProtocol (via Protocol):

Method makeConnection Make a connection to a transport and a server.
def write(self, data): (source)
Send the given data over my transport.
def connectionMade(self): (source)
I will write a welcomeMessage and loginPrompt to the client.
def welcomeMessage(self): (source)
Override me to return a string which will be sent to the client before login.
def loginPrompt(self): (source)
Override me to return a 'login:'-type prompt.
def iacSBchunk(self, chunk): (source)
Undocumented
def iac_DO(self, feature): (source)
Undocumented
def iac_DONT(self, feature): (source)
Undocumented
def iac_WILL(self, feature): (source)
Undocumented
def iac_WONT(self, feature): (source)
Undocumented
def iac_IP(self, feature): (source)
Undocumented
def processLine(self, line): (source)
I call a method that looks like 'telnet_*' where '*' is filled in by the current mode. telnet_* methods should return a string which will become the new mode. If None is returned, the mode will not change.
def telnet_User(self, user): (source)
I take a username, set it to the 'self.username' attribute, print out a password prompt, and switch to 'Password' mode. If you want to do something else when the username is received (ie, create a new user if the user doesn't exist), override me.
def telnet_Password(self, paswd): (source)
I accept a password as an argument, and check it with the checkUserAndPass method. If the login is successful, I call loggedIn().
def telnet_Command(self, cmd): (source)
The default 'command processing' mode. You probably want to override me.
def processChunk(self, chunk): (source)
I take a chunk of data and delegate out to telnet_* methods by way of processLine. If the current mode is 'Done', I'll close the connection.
def dataReceived(self, data): (source)
Called whenever data is received.

Use this method to translate to a higher-level message. Usually, some callback will be made upon the receipt of each complete protocol message.

Parametersdataa string of indeterminate length. Please keep in mind that you will probably need to buffer some data, as partial (or multiple) protocol messages may be received! I recommend that unit tests for protocols call through to this method with differing chunk sizes, down to one byte at a time.
def loggedIn(self): (source)
Called after the user succesfully logged in.

Override in subclasses.

API Documentation for Twisted, generated by pydoctor at 2012-09-01 11:44:56.