Package twisted :: Package conch :: Package ssh :: Module connection :: Class SSHConnection
[show private | hide private]
[frames | no frames]

Class SSHConnection

Logger --+    
         |    
SSHService --+
             |
            SSHConnection

Known Subclasses:
SshConnection

Method Summary
  __init__(self)
  adjustWindow(self, channel, bytesToAdd)
Tell the other side that we will receive more data.
  channelClosed(self, channel)
Called when a channel is closed.
subclass of SSHChannel/tuple getChannel(self, channelType, windowSize, maxPacket, data)
The other side requested a channel of some sort.
int/tuple gotGlobalRequest(self, requestType, data)
We got a global request.
  openChannel(self, channel, extra)
Open a new channel on this connection.
  sendClose(self, channel)
Close a channel.
  sendData(self, channel, data)
Send data to a channel.
  sendEOF(self, channel)
Send an EOF (End of File) for a channel.
  sendExtendedData(self, channel, dataType, data)
Send extended data to a channel.
  sendGlobalRequest(self, request, data, wantReply)
Send a global request for this connection.
  sendRequest(self, channel, requestType, data, wantReply)
Send a request to a channel.
  serviceStarted(self)
called when the service is active on the transport.
  serviceStopped(self)
called when the service is stopped, either by the connection ending or by another service being started
  ssh_CHANNEL_CLOSE(self, packet)
  ssh_CHANNEL_DATA(self, packet)
  ssh_CHANNEL_EOF(self, packet)
  ssh_CHANNEL_EXTENDED_DATA(self, packet)
  ssh_CHANNEL_FAILURE(self, packet)
  ssh_CHANNEL_OPEN(self, packet)
  ssh_CHANNEL_OPEN_CONFIRMATION(self, packet)
  ssh_CHANNEL_OPEN_FAILURE(self, packet)
  ssh_CHANNEL_REQUEST(self, packet)
  ssh_CHANNEL_SUCCESS(self, packet)
  ssh_CHANNEL_WINDOW_ADJUST(self, packet)
  ssh_GLOBAL_REQUEST(self, packet)
  ssh_REQUEST_FAILURE(self, packet)
  ssh_REQUEST_SUCCESS(self, packet)
Inherited from SSHService: logPrefix, packetReceived

Class Variable Summary
str name = 'ssh-connection'
dict protocolMessages = {96: 'MSG_CHANNEL_EOF', 97: 'MSG_CHAN...
Inherited from SSHService: transport
Inherited from Logger: __implemented__, __providedBy__, __provides__

Method Details

adjustWindow(self, channel, bytesToAdd)

Tell the other side that we will receive more data. This should not normally need to be called as it is managed automatically.
Parameters:
channel
           (type=subclass of SSHChannel)
bytesToAdd
           (type=int)

channelClosed(self, channel)

Called when a channel is closed. It clears the local state related to the channel, and calls channel.closed(). MAKE SURE YOU CALL THIS METHOD, even if you subclass SSHConnection. If you don't, things will break mysteriously.

getChannel(self, channelType, windowSize, maxPacket, data)

The other side requested a channel of some sort. channelType is the type of channel being requested, windowSize is the initial size of the remote window, maxPacket is the largest packet we should send, data is any other packet data (often nothing).

We return a subclass of SSHChannel.

By default, this dispatches to a method 'channel_channelType' with any non-alphanumerics in the channelType replace with _'s. If it cannot find a suitable method, it returns an OPEN_UNKNOWN_CHANNEL_TYPE error. The method is called with arguments of windowSize, maxPacket, data.
Parameters:
channelType
           (type=str)
windowSize
           (type=int)
maxPacket
           (type=int)
data
           (type=str)
Returns:
subclass of SSHChannel/tuple

gotGlobalRequest(self, requestType, data)

We got a global request. pretty much, this is just used by the client to request that we forward a port from the server to the client. Returns either:
  • 1: request accepted
  • 1, <data>: request accepted with request specific data
  • 0: request denied
By default, this dispatches to a method 'global_requestType' with -'s in requestType replaced with _'s. The found method is passed data. If this method cannot be found, this method returns 0. Otherwise, it returns the return value of that method.
Parameters:
requestType
           (type=str)
data
           (type=str)
Returns:
int/tuple

openChannel(self, channel, extra='')

Open a new channel on this connection.
Parameters:
channel
           (type=subclass of SSHChannel)
extra
           (type=str)

sendClose(self, channel)

Close a channel.
Parameters:
channel
           (type=subclass of SSHChannel)

sendData(self, channel, data)

Send data to a channel. This should not normally be used: instead use channel.write(data) as it manages the window automatically.
Parameters:
channel
           (type=subclass of SSHChannel)
data
           (type=str)

sendEOF(self, channel)

Send an EOF (End of File) for a channel.
Parameters:
channel
           (type=subclass of SSHChannel)

sendExtendedData(self, channel, dataType, data)

Send extended data to a channel. This should not normally be used: instead use channel.writeExtendedData(data, dataType) as it manages the window automatically.
Parameters:
channel
           (type=subclass of SSHChannel)
dataType
           (type=int)
data
           (type=str)

sendGlobalRequest(self, request, data, wantReply=0)

Send a global request for this connection. Current this is only used for remote->local TCP forwarding.
Parameters:
request
           (type=str)
data
           (type=str)
wantReply
           (type=bool @rtype Deferred/None)

sendRequest(self, channel, requestType, data, wantReply=0)

Send a request to a channel.
Parameters:
channel
           (type=subclass of SSHChannel)
requestType
           (type=str)
data
           (type=str)
wantReply
           (type=bool @rtype Deferred/None)

serviceStarted(self)

called when the service is active on the transport.
Overrides:
twisted.conch.ssh.service.SSHService.serviceStarted (inherited documentation)

serviceStopped(self)

called when the service is stopped, either by the connection ending or by another service being started
Overrides:
twisted.conch.ssh.service.SSHService.serviceStopped (inherited documentation)

Class Variable Details

name

Type:
str
Value:
'ssh-connection'                                                       

protocolMessages

Type:
dict
Value:
{80: 'MSG_GLOBAL_REQUEST',
 81: 'MSG_REQUEST_SUCCESS',
 82: 'MSG_REQUEST_FAILURE',
 90: 'MSG_CHANNEL_OPEN',
 91: 'MSG_CHANNEL_OPEN_CONFIRMATION',
 92: 'MSG_CHANNEL_OPEN_FAILURE',
 93: 'MSG_CHANNEL_WINDOW_ADJUST',
 94: 'MSG_CHANNEL_DATA',
...                                                                    

Generated by Epydoc 2.1 on Thu Aug 16 09:55:12 2007 http://epydoc.sf.net