Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions | Static Private Attributes
test.test_ftplib.SSLConnection Class Reference
Inheritance diagram for test.test_ftplib.SSLConnection:
Inheritance graph
[legend]
Collaboration diagram for test.test_ftplib.SSLConnection:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def secure_connection
def handle_read_event
def handle_write_event
def send
def recv
def handle_error
def close
def __repr__
def add_channel
def del_channel
def create_socket
def set_socket

Public Attributes

 socket
 family_and_type

Static Public Attributes

 debug = False
 connected = False
 accepting = False
 closing = False
 addr = None
tuple ignore_log_types = frozenset(['warning'])

Private Member Functions

def _do_ssl_handshake
def _do_ssl_shutdown

Static Private Attributes

 _ssl_accepting = False
 _ssl_closing = False

Detailed Description

An asyncore.dispatcher subclass supporting TLS/SSL.

Definition at line 270 of file test_ftplib.py.


Member Function Documentation

def asyncore.dispatcher.__repr__ (   self) [inherited]

Definition at line 264 of file asyncore.py.

00264 
00265     def __repr__(self):
00266         status = [self.__class__.__module__+"."+self.__class__.__name__]
00267         if self.accepting and self.addr:
00268             status.append('listening')
00269         elif self.connected:
00270             status.append('connected')
00271         if self.addr is not None:
00272             try:
00273                 status.append('%s:%d' % self.addr)
00274             except TypeError:
00275                 status.append(repr(self.addr))
00276         return '<%s at %#x>' % (' '.join(status), id(self))

Definition at line 285 of file test_ftplib.py.

00285 
00286         def _do_ssl_handshake(self):
00287             try:
00288                 self.socket.do_handshake()
00289             except ssl.SSLError as err:
00290                 if err.args[0] in (ssl.SSL_ERROR_WANT_READ,
00291                                    ssl.SSL_ERROR_WANT_WRITE):
00292                     return
00293                 elif err.args[0] == ssl.SSL_ERROR_EOF:
00294                     return self.handle_close()
00295                 raise
00296             except socket.error as err:
00297                 if err.args[0] == errno.ECONNABORTED:
00298                     return self.handle_close()
00299             else:
00300                 self._ssl_accepting = False

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 301 of file test_ftplib.py.

00301 
00302         def _do_ssl_shutdown(self):
00303             self._ssl_closing = True
00304             try:
00305                 self.socket = self.socket.unwrap()
00306             except ssl.SSLError as err:
00307                 if err.args[0] in (ssl.SSL_ERROR_WANT_READ,
00308                                    ssl.SSL_ERROR_WANT_WRITE):
00309                     return
00310             except socket.error as err:
00311                 # Any "socket error" corresponds to a SSL_ERROR_SYSCALL return
00312                 # from OpenSSL's SSL_shutdown(), corresponding to a
00313                 # closed socket condition. See also:
00314                 # http://www.mail-archive.com/openssl-users@openssl.org/msg60710.html
00315                 pass
00316             self._ssl_closing = False
00317             super(SSLConnection, self).close()

Here is the caller graph for this function:

def asyncore.dispatcher.add_channel (   self,
  map = None 
) [inherited]

Definition at line 279 of file asyncore.py.

00279 
00280     def add_channel(self, map=None):
00281         #self.log_info('adding channel %s' % self)
00282         if map is None:
00283             map = self._map
00284         map[self._fileno] = self

Here is the caller graph for this function:

Definition at line 359 of file test_ftplib.py.

00359 
00360         def close(self):
00361             if (isinstance(self.socket, ssl.SSLSocket) and
00362                 self.socket._sslobj is not None):
00363                 self._do_ssl_shutdown()
00364             else:
00365                 super(SSLConnection, self).close()
00366 
00367 
    class DummyTLS_DTPHandler(SSLConnection, DummyDTPHandler):

Here is the call graph for this function:

Here is the caller graph for this function:

def asyncore.dispatcher.create_socket (   self,
  family,
  type 
) [inherited]

Definition at line 294 of file asyncore.py.

00294 
00295     def create_socket(self, family, type):
00296         self.family_and_type = family, type
00297         sock = socket.socket(family, type)
00298         sock.setblocking(0)
00299         self.set_socket(sock)

Here is the caller graph for this function:

def asyncore.dispatcher.del_channel (   self,
  map = None 
) [inherited]

Definition at line 285 of file asyncore.py.

00285 
00286     def del_channel(self, map=None):
00287         fd = self._fileno
00288         if map is None:
00289             map = self._map
00290         if fd in map:
00291             #self.log_info('closing channel %d:%s' % (fd, self))
00292             del map[fd]
00293         self._fileno = None

Here is the caller graph for this function:

Definition at line 356 of file test_ftplib.py.

00356 
00357         def handle_error(self):
00358             raise

Here is the caller graph for this function:

Definition at line 318 of file test_ftplib.py.

00318 
00319         def handle_read_event(self):
00320             if self._ssl_accepting:
00321                 self._do_ssl_handshake()
00322             elif self._ssl_closing:
00323                 self._do_ssl_shutdown()
00324             else:
00325                 super(SSLConnection, self).handle_read_event()

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 326 of file test_ftplib.py.

00326 
00327         def handle_write_event(self):
00328             if self._ssl_accepting:
00329                 self._do_ssl_handshake()
00330             elif self._ssl_closing:
00331                 self._do_ssl_shutdown()
00332             else:
00333                 super(SSLConnection, self).handle_write_event()

Here is the call graph for this function:

def test.test_ftplib.SSLConnection.recv (   self,
  buffer_size 
)

Definition at line 344 of file test_ftplib.py.

00344 
00345         def recv(self, buffer_size):
00346             try:
00347                 return super(SSLConnection, self).recv(buffer_size)
00348             except ssl.SSLError as err:
00349                 if err.args[0] in (ssl.SSL_ERROR_WANT_READ,
00350                                    ssl.SSL_ERROR_WANT_WRITE):
00351                     return b''
00352                 if err.args[0] in (ssl.SSL_ERROR_EOF, ssl.SSL_ERROR_ZERO_RETURN):
00353                     self.handle_close()
00354                     return b''
00355                 raise

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 276 of file test_ftplib.py.

00276 
00277         def secure_connection(self):
00278             self.del_channel()
00279             socket = ssl.wrap_socket(self.socket, suppress_ragged_eofs=False,
00280                                      certfile=CERTFILE, server_side=True,
00281                                      do_handshake_on_connect=False,
00282                                      ssl_version=ssl.PROTOCOL_SSLv23)
00283             self.set_socket(socket)
00284             self._ssl_accepting = True

Here is the call graph for this function:

Here is the caller graph for this function:

def test.test_ftplib.SSLConnection.send (   self,
  data 
)

Definition at line 334 of file test_ftplib.py.

00334 
00335         def send(self, data):
00336             try:
00337                 return super(SSLConnection, self).send(data)
00338             except ssl.SSLError as err:
00339                 if err.args[0] in (ssl.SSL_ERROR_EOF, ssl.SSL_ERROR_ZERO_RETURN,
00340                                    ssl.SSL_ERROR_WANT_READ,
00341                                    ssl.SSL_ERROR_WANT_WRITE):
00342                     return 0
00343                 raise

Here is the caller graph for this function:

def asyncore.dispatcher.set_socket (   self,
  sock,
  map = None 
) [inherited]

Definition at line 300 of file asyncore.py.

00300 
00301     def set_socket(self, sock, map=None):
        self.socket = sock

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 273 of file test_ftplib.py.

Definition at line 274 of file test_ftplib.py.

asyncore.dispatcher.accepting = False [static, inherited]

Definition at line 227 of file asyncore.py.

asyncore.dispatcher.addr = None [static, inherited]

Reimplemented in smtpd.SMTPChannel.

Definition at line 229 of file asyncore.py.

asyncore.dispatcher.closing = False [static, inherited]

Definition at line 228 of file asyncore.py.

asyncore.dispatcher.connected = False [static, inherited]

Reimplemented in asyncore.file_dispatcher.

Definition at line 226 of file asyncore.py.

asyncore.dispatcher.debug = False [static, inherited]

Definition at line 225 of file asyncore.py.

Definition at line 295 of file asyncore.py.

tuple asyncore.dispatcher.ignore_log_types = frozenset(['warning']) [static, inherited]

Definition at line 230 of file asyncore.py.

Reimplemented from asyncore.dispatcher.

Definition at line 304 of file test_ftplib.py.


The documentation for this class was generated from the following file: