summaryrefslogtreecommitdiff
path: root/sleekxmpp/xmlstream/xmlstream.py
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2010-10-27 19:25:02 -0400
committerLance Stout <lancestout@gmail.com>2010-10-27 19:27:47 -0400
commit9c08e56ed04ff38422dfadcbf8cc18da03c3c399 (patch)
treeff960c0a245db7039951792261998e3929329a18 /sleekxmpp/xmlstream/xmlstream.py
parentb888610525a441dce622bf6132a4b3cab76a26b2 (diff)
downloadslixmpp-9c08e56ed04ff38422dfadcbf8cc18da03c3c399.tar.gz
slixmpp-9c08e56ed04ff38422dfadcbf8cc18da03c3c399.tar.bz2
slixmpp-9c08e56ed04ff38422dfadcbf8cc18da03c3c399.tar.xz
slixmpp-9c08e56ed04ff38422dfadcbf8cc18da03c3c399.zip
SSL and signal fixes.
Made setting the SIG* handlers conditional on if the signal defined for the OS. Added the attribute ssl_version to XMLStream to set the version of SSL used during connection. It defaults to ssl.PROTOCOL_TLSv1, but OpenFire tends to require ssl.PROTOCOL_SSLv23.
Diffstat (limited to 'sleekxmpp/xmlstream/xmlstream.py')
-rw-r--r--sleekxmpp/xmlstream/xmlstream.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/sleekxmpp/xmlstream/xmlstream.py b/sleekxmpp/xmlstream/xmlstream.py
index ace93cc3..630e68bf 100644
--- a/sleekxmpp/xmlstream/xmlstream.py
+++ b/sleekxmpp/xmlstream/xmlstream.py
@@ -87,6 +87,8 @@ class XMLStream(object):
send_queue -- A queue of stanzas to be sent on the stream.
socket -- The connection to the server.
ssl_support -- Indicates if a SSL library is available for use.
+ ssl_version -- The version of the SSL protocol to use.
+ Defaults to ssl.PROTOCOL_TLSv1.
state -- A state machine for managing the stream's
connection state.
stream_footer -- The start tag and any attributes for the stream's
@@ -155,6 +157,7 @@ class XMLStream(object):
self.sendXML = self.send_xml
self.ssl_support = SSL_SUPPORT
+ self.ssl_version = ssl.PROTOCOL_TLSv1
self.state = StateMachine(('disconnected', 'connected'))
self.state._set_state('disconnected')
@@ -196,8 +199,11 @@ class XMLStream(object):
self.auto_reconnect = True
self.is_client = False
- signal.signal(signal.SIGHUP, self._handle_kill)
- signal.signal(signal.SIGTERM, self._handle_kill) # used in Windows
+ if hasattr(signal, 'SIGHUP'):
+ signal.signal(signal.SIGHUP, self._handle_kill)
+ if hasattr(signal, 'SIGTERM'):
+ # Used in Windows
+ signal.signal(signal.SIGTERM, self._handle_kill)
def _handle_kill(self, signum, frame):
"""
@@ -370,7 +376,7 @@ class XMLStream(object):
if self.ssl_support:
logging.info("Negotiating TLS")
ssl_socket = ssl.wrap_socket(self.socket,
- ssl_version=ssl.PROTOCOL_TLSv1,
+ ssl_version=self.ssl_version,
do_handshake_on_connect=False)
if hasattr(self.socket, 'socket'):
# We are using a testing socket, so preserve the top
@@ -788,7 +794,7 @@ class XMLStream(object):
def _threaded_event_wrapper(self, func, args):
"""
- Capture exceptions for event handlers that run
+ Capture exceptions for event handlers that run
in individual threads.
Arguments: