import time
import error
+try:
+ from twisted.internet import ssl
+except ImportError:
+ log.msg("SSL ERROR: You do not have ssl support this may cause problems with tls client connections.")
+
class XMPPClientConnector(SRVConnector):
s.authenticator.useTls = 1
else:
s.authenticator.useTls = 0
- # reactor.connectTCP(s.hostname, s.port, s)
+
if pint.v:
- log.msg('================================== %s connect ==================================' % (str(time.time()),))
+ log.msg('================================== %s connect to %s:%s ==================================' % (str(time.time()),s.hostname,s.port))
+
connect_srv = True
if attrs.has_key('route'):
connect_srv = False
if s.hostname in ['localhost', '127.0.0.1']:
connect_srv = False
if not connect_srv:
- reactor.connectTCP(s.hostname, s.port, s)
+ reactor.connectTCP(s.hostname, s.port, s, bindAddress=pint.bindAddress)
else:
connector = XMPPClientConnector(reactor, s.hostname, s)
connector.connect()
self.cache_data = {}
self.verbose = self.pint.v
+ self.noisy = self.verbose
self.version = attrs.get('version', 0.0)
""" Log incoming data on the xmlstream """
if self.pint.v:
try:
- log.msg("SID: %s => RECV: %s" % (self.sid, unicode(buf, 'utf-8').encode('ascii', 'replace')))
+ log.msg("SID: %s => RECV: %r" % (self.sid, buf,))
except:
log.err()
if self.use_raw and self.authid:
def rawDataOut(self, buf):
""" Log outgoing data on the xmlstream """
try:
- log.msg("SID: %s => SEND: %s" % (self.sid, unicode(buf, 'utf-8').encode('ascii', 'replace')))
+ log.msg("SID: %s => SEND: %r" % (self.sid, buf,))
except:
log.err()
if self.verbose and not getattr(self, 'terminated', False):
log.msg(self.sid)
log.msg(self.rid)
+ log.msg(self.waiting_requests)
log.msg('SESSION -> We have expired')
self.disconnect()
request by returning a deferred which will get called back
when there is data or when the wait timeout expires.
"""
-
# queue this request
if d is None:
d = defer.Deferred()
if not rid:
rid = self.rid - 1
self.appendWaitingRequest(d, rid)
-
# check if there is any data to send back to a request
self.returnWaitingRequests()
-
+
# make sure we aren't queueing too many requests
self.clearWaitingRequests(self.hold)
return d
# If we get tls, then we should start tls, wait and then return
# Here we wait, the tls initializer will start it
if starttls and self.secure:
+ if self.verbose:
+ log.msg("Wait until starttls is completed.")
+ log.msg(initializers)
return
self.elems.append(f)
if len(self.waiting_requests) > 0:
def streamError(self, streamerror):
"""called when we get a stream:error stanza"""
- try: # a workaround for a bug in twisted.words.protocols.jabber.error
- err_elem = streamerror.value.getElement()
- err_elem.toXml()
- except: # no matter what the exception we just return None
- err_elem = None
+ err_elem = getattr(streamerror.value, "element")
e = self.buildRemoteError(err_elem)
do_expire = True