Merge branch 'develop' of github.com:fritzy/SleekXMPP into develop
This commit is contained in:
commit
d9db1b84fe
@ -151,7 +151,7 @@ if __name__ == '__main__':
|
|||||||
#
|
#
|
||||||
# if xmpp.connect(('talk.google.com', 5222)):
|
# if xmpp.connect(('talk.google.com', 5222)):
|
||||||
# ...
|
# ...
|
||||||
xmpp.process(block=False)
|
xmpp.process(block=True)
|
||||||
print("Done")
|
print("Done")
|
||||||
else:
|
else:
|
||||||
print("Unable to connect.")
|
print("Unable to connect.")
|
||||||
|
@ -37,7 +37,7 @@ class PingTest(sleekxmpp.ClientXMPP):
|
|||||||
def __init__(self, jid, password, pingjid):
|
def __init__(self, jid, password, pingjid):
|
||||||
sleekxmpp.ClientXMPP.__init__(self, jid, password)
|
sleekxmpp.ClientXMPP.__init__(self, jid, password)
|
||||||
if pingjid is None:
|
if pingjid is None:
|
||||||
pingjid = self.jid
|
pingjid = self.boundjid.bare
|
||||||
self.pingjid = pingjid
|
self.pingjid = pingjid
|
||||||
|
|
||||||
# The session_start event will be triggered when
|
# The session_start event will be triggered when
|
||||||
|
@ -88,8 +88,9 @@ class XEP_0065(base_plugin):
|
|||||||
|
|
||||||
# Request that the proxy activate the session with the target.
|
# Request that the proxy activate the session with the target.
|
||||||
self.activate(proxy, sid, to, timeout=timeout)
|
self.activate(proxy, sid, to, timeout=timeout)
|
||||||
self.xmpp.event('stream:%s:%s' % (sid, conn.peer_jid), conn)
|
socket = self.get_socket(sid)
|
||||||
return self.get_socket(sid)
|
self.xmpp.event('stream:%s:%s' % (sid, to), socket)
|
||||||
|
return socket
|
||||||
|
|
||||||
def request_stream(self, to, sid=None, ifrom=None, block=True, timeout=None, callback=None):
|
def request_stream(self, to, sid=None, ifrom=None, block=True, timeout=None, callback=None):
|
||||||
if sid is None:
|
if sid is None:
|
||||||
@ -198,11 +199,16 @@ class XEP_0065(base_plugin):
|
|||||||
sock = self._sessions.get(sid)
|
sock = self._sessions.get(sid)
|
||||||
if sock:
|
if sock:
|
||||||
try:
|
try:
|
||||||
|
# sock.close() will also delete sid from self._sessions (see _connect_proxy)
|
||||||
sock.close()
|
sock.close()
|
||||||
except socket.error:
|
except socket.error:
|
||||||
pass
|
pass
|
||||||
|
# Though this should not be neccessary remove the closed session anyway
|
||||||
with self._sessions_lock:
|
with self._sessions_lock:
|
||||||
del self._sessions[sid]
|
if sid in self._sessions:
|
||||||
|
log.warn(('SOCKS5 session with sid = "%s" was not ' +
|
||||||
|
'removed from _sessions by sock.close()') % sid)
|
||||||
|
del self._sessions[sid]
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
"""Closes all proxy sockets."""
|
"""Closes all proxy sockets."""
|
||||||
@ -250,6 +256,7 @@ class XEP_0065(base_plugin):
|
|||||||
if sid in self._sessions:
|
if sid in self._sessions:
|
||||||
del self._sessions[sid]
|
del self._sessions[sid]
|
||||||
_close()
|
_close()
|
||||||
|
log.info('Socket closed.')
|
||||||
sock.close = close
|
sock.close = close
|
||||||
|
|
||||||
sock.peer_jid = peer
|
sock.peer_jid = peer
|
||||||
|
@ -1343,12 +1343,12 @@ class XMLStream(object):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
def _start_thread(self, name, target, track=True):
|
def _start_thread(self, name, target, track=True):
|
||||||
self.__active_threads.add(name)
|
|
||||||
self.__thread[name] = threading.Thread(name=name, target=target)
|
self.__thread[name] = threading.Thread(name=name, target=target)
|
||||||
self.__thread[name].daemon = self._use_daemons
|
self.__thread[name].daemon = self._use_daemons
|
||||||
self.__thread[name].start()
|
self.__thread[name].start()
|
||||||
|
|
||||||
if track:
|
if track:
|
||||||
|
self.__active_threads.add(name)
|
||||||
with self.__thread_cond:
|
with self.__thread_cond:
|
||||||
self.__thread_count += 1
|
self.__thread_count += 1
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user