Table of contents Index
class FtpDataConnect - Helper class for FtpProxy to build data connections.
Declared in module Ftp
Synopsis
class FtpDataConnect:
def Ftp.FtpDataConnect.__del__(self) # Deinitializes an FtpDataConnect class
def Ftp.FtpDataConnect.__init__(self, session, ftp_proxy) # Initializes an FtpDataConnect instance.
def Ftp.FtpDataConnect.acceptedCallback(self, client, fd) # Callback called when a connection was accepted on either side.
def Ftp.FtpDataConnect.connectedCallback(self, fd) # Callback called when a connection was established.
def Ftp.FtpDataConnect.prepare(self, side, mode) # Prepares the data channel on `side' side using `mode' mode.
def Ftp.FtpDataConnect.processState(self) # Do the processing as required by the current state.
def Ftp.FtpDataConnect.resetState(self) # Reset data connection state.
def Ftp.FtpDataConnect.start(self, side1, side2, way) # Start the data connection procedure as prepared by earlier prepare calls.
def Ftp.FtpDataConnect.stopDataConnection(self) # Callback called by the data proxy to indicate the end of the data connection.
Description
FtpDataConnect is a helper class for the Ftp proxy, it builds
the data-connection.
Attributes:
-
ftp_proxy
- FtpProxy instance we belong to
-
state
- connection state 0 is initial, 1 one of the connections
were established, 2 both connections established ready to start data
proxy.
-
modes
- array indexed by side,
L
for Listen or C
for connect
-
listens
- listen objects created by us, array indexed by side
-
connects
- connect objects created by us, array indexed by side
-
sides
- determines the order in which sides must be processed
(first listen/connect on sides[0] then on sides[1])
-
fds
- array indexed by side, containing the side specific fd
-
localsa
- x
-
localsesa
- y
-
localclsa
- z
Ftp.FtpDataConnect.__del__(self)
Deinitializes an FtpDataConnect class
- self
- this instance
Calls resetState() to destroy bound listeners and
connectors. It destroys running data connection.
Initializes an FtpDataConnect instance.
- self
- this instance
- session
- the session
- ftp_proxy
- the proxy instance we belong to. It is used
to fetch settings from (portrange etc.).
Initializes an FtpDataConnect instance.
Ftp.FtpDataConnect.acceptedCallback(self, client, fd)
Callback called when a connection was accepted on either side.
- self
- this instance
- client
- the client address which has connected
- fd
- the file descriptor for the connection
This callback is called if any of the sides was in L
mode,
and a connection was accepted on the listening socket.
Notes:
stores the parameters, increases the state and continues with the state machine
Ftp.FtpDataConnect.connectedCallback(self, fd)
Callback called when a connection was established.
This function is similar to acceptedCallback, but used
if we were in C
(connect) mode.
Ftp.FtpDataConnect.prepare(self, side, mode)
Prepares the data channel on `side' side using `mode' mode.
- self
- this instance
- side
- FTP_SIDE_CLIENT or FTP_SIDE_SERVER representing
either the client or the server
- mode
- 'L' or 'C' for Listen or Connect
This function prepares the given side of the data
connection. This means either to listen for connections
(like passive mode on the client side) or to start
establishing a connection (passive mode on the server side).
Ftp.FtpDataConnect.processState(self)
Do the processing as required by the current state.
- self
- this instance
This function is called each time after processing the
current state finishes. This means that if the data
connection on the server side is established we are
ready to step one further and start accepting connections
on the client side.
Notes:
If state == 2, stacks in the proxy and starts it with a session
stacked out from self.session In state 0 and 1 it either listens or connects, based on the type field
of parms[state]
Ftp.FtpDataConnect.resetState(self)
Reset data connection state.
- self
- this instance
Sets the initial state of everything, and destroy pending
listeners.
Ftp.FtpDataConnect.start(self, side1, side2, way)
Start the data connection procedure as prepared by earlier prepare calls.
- side1
- connect/listen on this side first
- side2
- connect/listen on this side after the first one succeeded
- way
- direction
Previous calls to prepare determines how the data connection
should be built. This function starts the state machine
whose final state is to start a proxy on the established
data connection.
Ftp.FtpDataConnect.stopDataConnection(self)
Callback called by the data proxy to indicate the end of the data connection.
This callback is registered with the data proxy
([FtpDataProxy], see below), and is called when
the data connection was terminated. It's task is
to signal this condition to the Ftp proxy core.
Copyright © 2000 BalaBit IT Ltd.
Written by: Balázs Scheidler