Package twisted :: Package protocols :: Module ftp :: Class FTP
[frames | no frames]

Class FTP

     Factory --+        
               |        
   ClientFactory --+    
                   |    
          DTPFactory --+
                       |
BaseProtocol --+       |
               |       |
        Protocol --+   |
                   |   |
        LineReceiver --+
                       |
                      FTP


An FTP server.

This class is unstable (it will be heavily refactored to support dynamic content, etc).
Method Summary
  buildFullpath(self, rpath)
Build a new path, from a relative path based on the current wd This routine is not fully tested, and I fear that it can be exploited by building clever paths
  checkauth(self)
Will return None if the user has been authorized This must be run in front of all commands except USER, PASS and QUIT
  connectionMade(self)
Called when a connection is made.
  ftp_Abor(self, params)
  ftp_Cdup(self, params)
  ftp_Cwd(self, params)
  ftp_Dele(self, params)
  ftp_Epsv(self, params)
Request for a Extended Passive connection
  ftp_List(self, params)
  ftp_Mkd(self, params)
  ftp_Nlst(self, params)
  ftp_Noop(self, params)
Do nothing, and reply an OK-message Sometimes used by clients to avoid a time-out.
  ftp_Pass(self, params)
Authorize the USER and the submitted password
  ftp_Pasv(self, params)
Request for a passive connection
  ftp_Port(self, params)
Request for an active connection This command may be potentially abused, and the only countermeasure so far is that no port below 1024 may be targeted.
  ftp_Pwd(self, params)
  ftp_Quit(self, params)
  ftp_Retr(self, params)
  ftp_Rmd(self, params)
  ftp_Size(self, params)
  ftp_Stor(self, params)
  ftp_Syst(self, params)
Return the running operating system to the client However, due to security-measures, it will return a standard 'L8' reply
  ftp_Type(self, params)
  ftp_User(self, params)
Get the login name, and reset the session PASS is expected to follow
  getListing(self, params, action)
  lineReceived(self, line)
Process the input from the client
  reply(self, key, s)
  setAction(self, action)
Alias for DTP.setAction Since there's no guarantee an instance of dtp exists
    Inherited from LineReceiver
  clearLineBuffer(self)
Clear buffered data.
  dataReceived(self, data)
Protocol.dataReceived.
  lineLengthExceeded(self, line)
Called when the maximum line length has been reached.
  rawDataReceived(self, data)
Override this for when raw data is received.
  sendLine(self, line)
Sends a line to the other end of the connection.
  setLineMode(self, extra)
Sets the line-mode of this receiver.
  setRawMode(self)
Sets the raw mode of this receiver.
    Inherited from Protocol
  connectionFailed(self)
(Deprecated)
  connectionLost(self, reason)
Called when the connection is shut down.
    Inherited from BaseProtocol
  makeConnection(self, transport)
Make a connection to a transport and a server.
    Inherited from DTPFactory
  buildProtocol(self, addr)
Create an instance of a subclass of Protocol.
  createActiveServer(self)
  createPassiveServer(self)
    Inherited from ClientFactory
  clientConnectionFailed(self, connector, reason)
Called when a connection has failed.
  clientConnectionLost(self, connector, reason)
Called when a connection is lost.
  startedConnecting(self, connector)
Called when a connection has been started.
    Inherited from Factory
  doStart(self)
Make sure startFactory is called.
  doStop(self)
Make sure stopFactory is called.
  startFactory(self)
This will be called before I begin listening on a Port or Connector.
  stopFactory(self)
This will be called before I stop listening on all Ports/Connectors.

Class Variable Summary
int debug = 0                                                                     
NoneType passwd = None                                                                  
NoneType peerhost = None                                                                  
NoneType peerport = None                                                                  
NoneType queuedfile = None                                                                  
NoneType root = None                                                                  
NoneType type = None                                                                  
NoneType user = None                                                                  
NoneType wd = None                                                                  
    Inherited from LineReceiver
str _LineReceiver__buffer = ''
str delimiter: The line-ending delimiter to use.
int line_mode = 1                                                                     
int MAX_LENGTH: The maximum length of a line to allow (If a sent line is longer than this, the connection is dropped).
    Inherited from Protocol
tuple __implements__ = (<class twisted.internet.interfaces.IPr...
    Inherited from BaseProtocol
int connected = 0                                                                     
NoneType transport = None                                                                  
    Inherited from DTPFactory
NoneType action = None                                                                  
NoneType dtp = None                                                                  
NoneType dtpPort = None                                                                  
    Inherited from Factory
str noisy = 'sure, why not'
int numPorts = 0                                                                     
NoneType protocol = None                                                                  

Method Details

buildFullpath(self, rpath)

Build a new path, from a relative path based on the current wd This routine is not fully tested, and I fear that it can be exploited by building clever paths

checkauth(self)

Will return None if the user has been authorized This must be run in front of all commands except USER, PASS and QUIT

connectionMade(self)

Called when a connection is made.

This may be considered the initializer of the protocol, because it is called when the connection is completed. For clients, this is called once the connection to the server has been established; for servers, this is called after an accept() call stops blocking and a socket has been received. If you need to send any greeting or initial message, do it here.
Overrides:
twisted.internet.protocol.BaseProtocol.connectionMade (inherited documentation)

ftp_Epsv(self, params)

Request for a Extended Passive connection

ftp_Noop(self, params)

Do nothing, and reply an OK-message Sometimes used by clients to avoid a time-out. TODO: Add time-out, let Noop extend this time-out. Add a No-Transfer-Time-out as well to get rid of idlers.

ftp_Pass(self, params)

Authorize the USER and the submitted password

ftp_Pasv(self, params)

Request for a passive connection

ftp_Port(self, params)

Request for an active connection This command may be potentially abused, and the only countermeasure so far is that no port below 1024 may be targeted. An extra approach is to disable port'ing to a third-party ip, which is optional through ALLOW_THIRDPARTY. Note that this disables 'Cross-ftp'

ftp_Syst(self, params)

Return the running operating system to the client However, due to security-measures, it will return a standard 'L8' reply

ftp_User(self, params)

Get the login name, and reset the session PASS is expected to follow

lineReceived(self, line)

Process the input from the client
Overrides:
twisted.protocols.basic.LineReceiver.lineReceived

setAction(self, action)

Alias for DTP.setAction Since there's no guarantee an instance of dtp exists

Class Variable Details

debug

Type:
int
Value:
0                                                                     

passwd

Type:
NoneType
Value:
None                                                                  

peerhost

Type:
NoneType
Value:
None                                                                  

peerport

Type:
NoneType
Value:
None                                                                  

queuedfile

Type:
NoneType
Value:
None                                                                  

root

Type:
NoneType
Value:
None                                                                  

type

Type:
NoneType
Value:
None                                                                  

user

Type:
NoneType
Value:
None                                                                  

wd

Type:
NoneType
Value:
None                                                                  

Generated by Epydoc 2.0 on Sat Oct 25 00:55:07 2003 http://epydoc.sf.net