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.Split Table into Classes Show Methods in One Table
| Line # | Kind | Name | Docs |
|---|---|---|---|
| 173 | Method | write | Send the given data over my transport. |
| 178 | Method | connectionMade | I will write a welcomeMessage and loginPrompt to the client. |
| 182 | Method | welcomeMessage | Override me to return a string which will be sent to the client |
| 190 | Method | loginPrompt | Override me to return a 'login:'-type prompt. |
| 194 | Method | iacSBchunk | Undocumented |
| 197 | Method | iac_DO | Undocumented |
| 200 | Method | iac_DONT | Undocumented |
| 203 | Method | iac_WILL | Undocumented |
| 206 | Method | iac_WONT | Undocumented |
| 209 | Method | iac_IP | Undocumented |
| 212 | Method | processLine | I call a method that looks like 'telnet_*' where '*' is filled |
| 221 | Method | telnet_User | I take a username, set it to the 'self.username' attribute, |
| 230 | Method | telnet_Password | I accept a password as an argument, and check it with the |
| 244 | Method | telnet_Command | The default 'command processing' mode. You probably want to |
| 249 | Method | processChunk | I take a chunk of data and delegate out to telnet_* methods |
| 272 | Method | dataReceived | Called whenever data is received. |
| 320 | Method | loggedIn | Called after the user succesfully logged in. |
Inherited from Protocol:
| Line # | Kind | Name | Docs |
|---|---|---|---|
| 384 | Method | connectionLost | Called when the connection is shut down. |
Inherited from BaseProtocol (via Protocol):
| Line # | Kind | Name | Docs |
|---|---|---|---|
| 341 | Method | makeConnection | Make a connection to a transport and a server. |
| Line # | Kind | Name | Docs |
|---|---|---|---|
| 384 | Method | connectionLost | Called when the connection is shut down. |
| 178 | Method | connectionMade | I will write a welcomeMessage and loginPrompt to the client. |
| 272 | Method | dataReceived | Called whenever data is received. |
| 197 | Method | iac_DO | Undocumented |
| 200 | Method | iac_DONT | Undocumented |
| 209 | Method | iac_IP | Undocumented |
| 203 | Method | iac_WILL | Undocumented |
| 206 | Method | iac_WONT | Undocumented |
| 194 | Method | iacSBchunk | Undocumented |
| 320 | Method | loggedIn | Called after the user succesfully logged in. |
| 190 | Method | loginPrompt | Override me to return a 'login:'-type prompt. |
| 341 | Method | makeConnection | Make a connection to a transport and a server. |
| 249 | Method | processChunk | I take a chunk of data and delegate out to telnet_* methods |
| 212 | Method | processLine | I call a method that looks like 'telnet_*' where '*' is filled |
| 244 | Method | telnet_Command | The default 'command processing' mode. You probably want to |
| 230 | Method | telnet_Password | I accept a password as an argument, and check it with the |
| 221 | Method | telnet_User | I take a username, set it to the 'self.username' attribute, |
| 182 | Method | welcomeMessage | Override me to return a string which will be sent to the client |
| 173 | Method | write | Send the given data over my transport. |
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.| Parameters | data | a 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. |
Called after the user succesfully logged in.
Override in subclasses.