Hello community, here is the log from the commit of package python-nbxmpp for openSUSE:Factory checked in at 2018-03-20 22:00:33 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-nbxmpp (Old) and /work/SRC/openSUSE:Factory/.python-nbxmpp.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-nbxmpp" Tue Mar 20 22:00:33 2018 rev:17 rq:588742 version:0.6.4 Changes: -------- --- /work/SRC/openSUSE:Factory/python-nbxmpp/python-nbxmpp.changes 2017-12-14 11:02:13.589876162 +0100 +++ /work/SRC/openSUSE:Factory/.python-nbxmpp.new/python-nbxmpp.changes 2018-03-20 22:01:02.492209841 +0100 @@ -1,0 +2,11 @@ +Mon Mar 17 19:32:02 UTC 2018 - [email protected] + +- Update to version 0.6.4 (changes since 0.6.1): + * Correctly load client certs. + * Warn on any error in the certificate chain. + * Fixed a traceback loop. + * Add ALPN and SNI support for when using DirectTLS. + * Fix SOCKS5 usage. + * Bugfixes. + +------------------------------------------------------------------- Old: ---- nbxmpp-0.6.1.tar.gz New: ---- nbxmpp-0.6.4.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-nbxmpp.spec ++++++ --- /var/tmp/diff_new_pack.JvvR8O/_old 2018-03-20 22:01:03.648168222 +0100 +++ /var/tmp/diff_new_pack.JvvR8O/_new 2018-03-20 22:01:03.648168222 +0100 @@ -1,7 +1,7 @@ # # spec file for package python-nbxmpp # -# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -19,10 +19,10 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} %define _name nbxmpp Name: python-nbxmpp -Version: 0.6.1 +Version: 0.6.4 Release: 0 Summary: XMPP library by Gajim team -License: GPL-3.0+ +License: GPL-3.0-or-later Group: Development/Languages/Python Url: https://python-nbxmpp.gajim.org/ Source: https://files.pythonhosted.org/packages/source/n/%{_name}/%{_name}-%{version}.tar.gz @@ -56,13 +56,15 @@ %python_expand %fdupes %{buildroot}%{$python_sitelib}/ %files %{python_files} -%defattr(-,root,root) +%if 0%{?suse_version} >= 1500 +%license COPYING +%else %doc COPYING +%endif %{python_sitelib}/%{_name}/ %{python_sitelib}/%{_name}-* %files %{python_files doc} -%defattr(-,root,root) %doc ChangeLog README %doc doc/apidocs/ doc/examples/ ++++++ nbxmpp-0.6.1.tar.gz -> nbxmpp-0.6.4.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nbxmpp-0.6.1/ChangeLog new/nbxmpp-0.6.4/ChangeLog --- old/nbxmpp-0.6.1/ChangeLog 2017-11-29 21:25:08.000000000 +0100 +++ new/nbxmpp-0.6.4/ChangeLog 2018-03-17 17:37:47.000000000 +0100 @@ -1,3 +1,18 @@ +python-nbxmpp 0.6.4 (17 March 2018) + + * Fix SOCKS5 usage + +python-nbxmpp 0.6.3 (26 January 2018) + + * Add ALPN and SNI support for when using DirectTLS + * Bugfixes + +python-nbxmpp 0.6.2 (27 December 2017) + + * Correctly load client certs + * Warn on any error in the certificate chain + * Fixed a traceback loop + python-nbxmpp 0.6.1 (29 November 2017) * Add new getStanzaIDAttrs method diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nbxmpp-0.6.1/PKG-INFO new/nbxmpp-0.6.4/PKG-INFO --- old/nbxmpp-0.6.1/PKG-INFO 2017-11-29 21:26:28.000000000 +0100 +++ new/nbxmpp-0.6.4/PKG-INFO 2018-03-17 17:38:21.000000000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 1.0 Name: nbxmpp -Version: 0.6.1 +Version: 0.6.4 Summary: Non blocking Jabber/XMPP module Home-page: http://dev.gajim.org/gajim/python-nbxmpp Author: Yann Leboulanger diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nbxmpp-0.6.1/nbxmpp/__init__.py new/nbxmpp-0.6.4/nbxmpp/__init__.py --- old/nbxmpp-0.6.1/nbxmpp/__init__.py 2017-11-29 21:25:08.000000000 +0100 +++ new/nbxmpp-0.6.4/nbxmpp/__init__.py 2018-03-17 17:37:47.000000000 +0100 @@ -17,4 +17,4 @@ from .plugin import PlugIn from .smacks import Smacks -__version__ = "0.6.1" +__version__ = "0.6.4" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nbxmpp-0.6.1/nbxmpp/auth_nb.py new/nbxmpp-0.6.4/nbxmpp/auth_nb.py --- old/nbxmpp-0.6.1/nbxmpp/auth_nb.py 2017-11-29 21:25:08.000000000 +0100 +++ new/nbxmpp-0.6.4/nbxmpp/auth_nb.py 2018-03-17 17:37:47.000000000 +0100 @@ -693,10 +693,13 @@ #self.bound='failure' self.bound = [] return - if feats.getTag('session', namespace=NS_SESSION): - self.session = 1 - else: - self.session = -1 + + self.session = -1 + session = feats.getTag('session', namespace=NS_SESSION) + if session is not None: + if session.getTag('optional') is None: + self.session = 1 + self.bound = [] def plugout(self): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nbxmpp-0.6.1/nbxmpp/client_nb.py new/nbxmpp-0.6.4/nbxmpp/client_nb.py --- old/nbxmpp-0.6.1/nbxmpp/client_nb.py 2017-01-01 23:13:23.000000000 +0100 +++ new/nbxmpp-0.6.4/nbxmpp/client_nb.py 2018-03-17 17:37:47.000000000 +0100 @@ -72,6 +72,7 @@ self.stream_started = False self.disconnecting = False self.protocol_type = 'XMPP' + self.alpn = False def disconnect(self, message=''): """ @@ -150,7 +151,7 @@ def connect(self, on_connect, on_connect_failure, hostname=None, port=5222, on_proxy_failure=None, on_stream_error_cb=None, proxy=None, - secure_tuple=('tls', None, None, None, None)): + secure_tuple=('tls', None, None, None, None, False)): """ Open XMPP connection (open XML streams in both directions) @@ -165,19 +166,22 @@ values for keys 'host' and 'port' - connection details for proxy serve and optionally keys 'user' and 'pass' as proxy credentials :param secure_tuple: tuple of (desired connection type, cacerts, - mycerts, tls_version, cipher_list) + mycerts, tls_version, cipher_list, alpn) connection type can be 'ssl' - TLS established after TCP connection, 'tls' - TLS established after negotiation with starttls, or 'plain'. - cacerts, mycerts, tls_version, cipher_list - see tls_nb.NonBlockingTLS - constructor for more details + cacerts, mycerts, tls_version, cipher_list, alpn + see tls_nb.NonBlockingTLS constructor for more details """ self.on_connect = on_connect self.on_connect_failure=on_connect_failure self.on_proxy_failure = on_proxy_failure self.on_stream_error_cb = on_stream_error_cb self.desired_security, self.cacerts, self.mycerts, self.tls_version, \ - self.cipher_list = secure_tuple + self.cipher_list = secure_tuple[:5] + if len(secure_tuple) == 6: + # ALPN support was added in version 0.6.3 + self.alpn = secure_tuple[5] self.Connection = None self.Port = port self.proxy = proxy @@ -239,6 +243,7 @@ certs=certs, tls_version = self.tls_version, cipher_list = self.cipher_list, + alpn=self.alpn, proxy_dict=proxy_dict) # plug transport into client as self.Connection @@ -465,7 +470,10 @@ Raise event to connection instance. DATA_SENT and DATA_RECIVED events are used in XML console to show XMPP traffic """ - log.info('raising event from transport: :::::%s::::\n_____________\n%s\n_____________\n' % (event_type, data)) + e_t = event_type + if type(event_type) != str: + e_t = event_type.encode('utf-8') + log.info('raising event from transport: :::::%s::::\n_____________\n%s\n_____________\n' % (e_t, data)) if hasattr(self, 'Dispatcher'): self.Dispatcher.Event('', event_type, data) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nbxmpp-0.6.1/nbxmpp/dispatcher_nb.py new/nbxmpp-0.6.4/nbxmpp/dispatcher_nb.py --- old/nbxmpp-0.6.1/nbxmpp/dispatcher_nb.py 2017-06-04 14:17:22.000000000 +0200 +++ new/nbxmpp-0.6.4/nbxmpp/dispatcher_nb.py 2018-01-27 21:32:42.000000000 +0100 @@ -589,6 +589,8 @@ if len(self.sm.uqueue) > self.sm.max_queue: self.sm.request_ack() + if (self.sm.in_h - self.sm.last_sent_in_h) > 100: + self.sm.send_ack() return ID diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nbxmpp-0.6.1/nbxmpp/idlequeue.py new/nbxmpp-0.6.4/nbxmpp/idlequeue.py --- old/nbxmpp-0.6.1/nbxmpp/idlequeue.py 2017-01-01 23:13:23.000000000 +0100 +++ new/nbxmpp-0.6.4/nbxmpp/idlequeue.py 2018-01-27 21:32:42.000000000 +0100 @@ -21,6 +21,7 @@ from __future__ import unicode_literals import os +import errno import sys import select import logging @@ -43,22 +44,23 @@ import fcntl if sys.version_info[0] == 2 or not HAVE_GLIB: - FLAG_WRITE = 20 # write only - FLAG_READ = 19 # read only - FLAG_READ_WRITE = 23 # read and write - FLAG_CLOSE = 16 # wait for close + FLAG_WRITE = 20 # write only 10100 + FLAG_READ = 19 # read only 10011 + FLAG_READ_WRITE = 23 # read and write 10111 + FLAG_CLOSE = 16 # wait for close 10000 + PENDING_READ = 3 # waiting read event 11 + PENDING_WRITE = 4 # waiting write event 100 + IS_CLOSED = 16 # channel closed 10000 else: FLAG_WRITE = GLib.IOCondition.OUT | GLib.IOCondition.HUP - FLAG_READ = GLib.IOCondition.IN | GLib.IOCondition.PRI | \ - GLib.IOCondition.HUP + FLAG_READ = GLib.IOCondition.IN | GLib.IOCondition.PRI | \ + GLib.IOCondition.HUP FLAG_READ_WRITE = GLib.IOCondition.OUT | GLib.IOCondition.IN | \ - GLib.IOCondition.PRI | GLib.IOCondition.HUP - FLAG_CLOSE = GLib.IOCondition.HUP - -PENDING_READ = 3 # waiting read event -PENDING_WRITE = 4 # waiting write event -IS_CLOSED = 16 # channel closed - + GLib.IOCondition.PRI | GLib.IOCondition.HUP + FLAG_CLOSE = GLib.IOCondition.HUP + PENDING_READ = GLib.IOCondition.IN # There is data to read. + PENDING_WRITE = GLib.IOCondition.OUT # Data CAN be written without blocking. + IS_CLOSED = GLib.IOCondition.HUP # Hung up (connection broken) def get_idlequeue(): """ @@ -353,7 +355,7 @@ :param obj: the IdleObject :param writable: True if obj has data to sent - :param readable: True if obj expects data to be reiceived + :param readable: True if obj expects data to be received """ if obj.fd == -1: return @@ -426,27 +428,15 @@ def process(self): """ + This function must be overridden by an implementation of the IdleQueue. + Process idlequeue. Check for any pending timeout or alarm events. Call IdleObjects on possible and requested read, write and error events on their file descriptors Call this in regular intervals. """ - if not self.queue: - # check for timeouts/alert also when there are no active fds - self._check_time_events() - return True - try: - waiting_descriptors = self.selector.poll(0) - except select.error as e: - waiting_descriptors = [] - if e[0] != 4: # interrupt - raise - for fd, flags in waiting_descriptors: - self._process_events(fd, flags) - self._check_time_events() - return True - + raise NotImplementedError("You need to define a process() method.") class SelectIdleQueue(IdleQueue): """ @@ -456,6 +446,29 @@ support io_add_watch properly (yet) """ + def checkQueue(self): + """ + Iterates through all known file descriptors and uses os.stat to check if they're valid. + Greatly improves performance if the caller hands us and expects notification on an invalid file handle. + """ + bad_fds=[] + union={} + union.update(self.write_fds) + union.update(self.read_fds) + union.update(self.error_fds) + for fd in (union.keys()): + try: + status = os.stat(fd) + except OSError as e: + # This file descriptor is invalid. Add to list for closure. + bad_fds.append(fd) + + for fd in (bad_fds): + obj = self.queue.get(fd) + if obj is not None: + self.remove_timeout(fd) + self.unplug_idle(fd) + def _init_idle(self): """ Create a dict, which maps file/pipe/sock descriptor to glib event id @@ -466,7 +479,7 @@ def _add_idle(self, fd, flags): """ - This method is called when we plug a new idle object. Remove descriptor + This method is called when we plug a new idle object. Add descriptor to read/write/error lists, according flags """ if flags & 3: @@ -494,9 +507,10 @@ try: waiting_descriptors = select.select(list(self.read_fds.keys()), list(self.write_fds.keys()), list(self.error_fds.keys()), 0) - except select.error as e: + except OSError as e: waiting_descriptors = ((), (), ()) - if e[0] != 4: # interrupt + if e.errno != errno.EINTR: + self.checkQueue() raise for fd in waiting_descriptors[0]: q = self.queue.get(fd) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nbxmpp-0.6.1/nbxmpp/protocol.py new/nbxmpp-0.6.4/nbxmpp/protocol.py --- old/nbxmpp-0.6.1/nbxmpp/protocol.py 2017-11-29 21:25:08.000000000 +0100 +++ new/nbxmpp-0.6.4/nbxmpp/protocol.py 2018-01-14 20:31:53.000000000 +0100 @@ -1400,6 +1400,10 @@ hash_ = hl.hexdigest() return hash_ + def addHash(self, hash_, algo): + self.setAttr('algo', algo) + self.setData(hash_) + class Hashes2(Node): """ Hash elements for various XEPs as defined in XEP-300 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nbxmpp-0.6.1/nbxmpp/proxy_connectors.py new/nbxmpp-0.6.4/nbxmpp/proxy_connectors.py --- old/nbxmpp-0.6.1/nbxmpp/proxy_connectors.py 2017-01-01 23:13:23.000000000 +0100 +++ new/nbxmpp-0.6.4/nbxmpp/proxy_connectors.py 2018-03-17 17:37:47.000000000 +0100 @@ -135,25 +135,30 @@ self.onreceive(self._on_greeting_sent) self.send(to_send) + def _to_int(self, c): + if type(c) == str: # py2 + return ord(c) + return c # py3 + def _on_greeting_sent(self, reply): if reply is None: return if len(reply) != 2: self.on_failure('Invalid proxy reply') return - if reply[0] != '\x05': + if self._to_int(reply[0]) != 5: log.info('Invalid proxy reply') self.on_failure('Invalid proxy reply') return - if reply[1] == '\x00': + if self._to_int(reply[1]) == 0: return self._on_proxy_auth('\x01\x00') - elif reply[1] == '\x02': + elif self._to_int(reply[1]) == 2: to_send = '\x01' + chr(len(self.proxy_user)) + self.proxy_user +\ chr(len(self.proxy_pass)) + self.proxy_pass self.onreceive(self._on_proxy_auth) self.send(to_send) else: - if reply[1] == '\xff': + if self._to_int(reply[1]) == 255: log.error('Authentification to proxy impossible: no acceptable ' 'auth method') self.on_failure('Authentification to proxy impossible: no ' @@ -208,13 +213,13 @@ log.error('Invalid proxy reply') self.on_failure('Invalid proxy reply') return - if reply[0] != '\x05': + if self._to_int(reply[0]) != 5: log.error('Invalid proxy reply') self.on_failure('Invalid proxy reply') return - if reply[1] != '\x00': + if self._to_int(reply[1]) != 0: # Connection failed - if ord(reply[1])<9: + if self._to_int(reply[1]) < 9: errors = ['general SOCKS server failure', 'connection not allowed by ruleset', 'Network unreachable', @@ -224,17 +229,19 @@ 'Command not supported', 'Address type not supported' ] - txt = errors[ord(reply[1])-1] + txt = errors[self._to_int(reply[1])-1] else: txt = 'Invalid proxy reply' log.error(txt) self.on_failure(txt) return # Get the bound address/port - elif reply[3] == '\x01': + elif self._to_int(reply[3]) == 1: begin, end = 3, 7 - elif reply[3] == '\x03': - begin, end = 4, 4 + reply[4] + elif self._to_int(reply[3]) == 3: + begin, end = 4, 4 + self._to_int(reply[4]) + elif self._to_int(reply[3]) == 4: + begin, end = 3, 19 else: log.error('Invalid proxy reply') self.on_failure('Invalid proxy reply') diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nbxmpp-0.6.1/nbxmpp/smacks.py new/nbxmpp-0.6.4/nbxmpp/smacks.py --- old/nbxmpp-0.6.1/nbxmpp/smacks.py 2017-06-04 14:17:22.000000000 +0200 +++ new/nbxmpp-0.6.4/nbxmpp/smacks.py 2018-01-27 21:32:42.000000000 +0100 @@ -18,6 +18,7 @@ self.con = con # Connection object self.out_h = 0 # Outgoing stanzas handled self.in_h = 0 # Incoming stanzas handled + self.last_sent_in_h = 0 # Last acked stanza. self.uqueue = [] # Unhandled stanzas queue self.old_uqueue = [] # Unhandled stanzas queue of the last session self.session_id = None @@ -68,6 +69,7 @@ log.debug("Clearing smacks uqueue") self.uqueue = [] self.in_h = 0 + self.last_sent_in_h = 0 self.out_h = 0 self.session_id = None self.enabled = True @@ -99,11 +101,13 @@ self.uqueue = [] resume = Acks() resume.buildResume(self.in_h, self.session_id) + self.last_sent_in_h = self.in_h self._owner.Connection.send(resume, False) - def send_ack(self, disp, stanza): + def send_ack(self, disp=None, stanza=None): ack = Acks() ack.buildAnswer(self.in_h) + self.last_sent_in_h = self.in_h self._owner.Connection.send(ack, False) def send_closing_ack(self): @@ -112,6 +116,7 @@ return ack = Acks() ack.buildAnswer(self.in_h) + self.last_sent_in_h = self.in_h self._owner.Connection.send(ack, True) def request_ack(self): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nbxmpp-0.6.1/nbxmpp/tls_nb.py new/nbxmpp-0.6.4/nbxmpp/tls_nb.py --- old/nbxmpp-0.6.1/nbxmpp/tls_nb.py 2017-01-01 23:13:23.000000000 +0100 +++ new/nbxmpp-0.6.4/nbxmpp/tls_nb.py 2018-01-27 21:32:42.000000000 +0100 @@ -253,7 +253,7 @@ PyOpenSSLWrapper. """ - def __init__(self, cacerts, mycerts, tls_version, cipher_list): + def __init__(self, cacerts, mycerts, tls_version, cipher_list, alpn): """ :param cacerts: path to pem file with certificates of known XMPP servers :param mycerts: path to pem file with certificates of user trusted @@ -275,6 +275,7 @@ self.tls_version = '1.0' else: self.tls_version = tls_version + self.alpn = alpn def plugin(self, owner): """ @@ -376,7 +377,11 @@ except AttributeError as e: # py-OpenSSL < 0.9 or old OpenSSL flags |= 16384 - + + if self.alpn: + # XEP-0368 set ALPN Protocol + tcpsock._sslContext.set_alpn_protos([b'xmpp-client']) + try: # OpenSSL 1.0.1d supports TLS 1.1 and TLS 1.2 and # fixes renegotiation in TLS 1.1, 1.2 by using the correct TLS version. @@ -407,7 +412,7 @@ conn = tcpsock._owner._caller log.debug('Using client cert and key from %s' % conn.client_cert) try: - p12 = OpenSSL.crypto.load_pkcs12(open(conn.client_cert).read(), + p12 = OpenSSL.crypto.load_pkcs12(open(conn.client_cert, 'rb').read(), conn.client_cert_passphrase) except OpenSSL.crypto.Error as exception_obj: log.warning('Unable to load client pkcs12 certificate from ' @@ -448,6 +453,11 @@ tcpsock._sslObj = OpenSSL.SSL.Connection(tcpsock._sslContext, tcpsock._sock) tcpsock._sslObj.set_connect_state() # set to client mode + + if self.alpn: + # Set SNI EXT on the SSL Connection object, see XEP-0368 + tcpsock._sslObj.set_tlsext_host_name(tcpsock._owner.Server.encode()) + wrapper = PyOpenSSLWrapper(tcpsock._sslObj) tcpsock._recv = wrapper.recv tcpsock._send = wrapper.send @@ -494,13 +504,13 @@ def _ssl_verify_callback(self, sslconn, cert, errnum, depth, ok): # Exceptions can't propagate up through this callback, so print them here. try: + if not self._owner.ssl_errnum: + self._owner.ssl_errnum = errnum if depth == 0: self._owner.ssl_certificate = cert - if not ok: - self._owner.ssl_errnum = errnum return True - except: - log.error("Exception caught in _ssl_info_callback:", exc_info=True) + except Exception: + log.exception("Exception caught in _ssl_info_callback:") # Make sure something is printed, even if log is disabled. traceback.print_exc() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nbxmpp-0.6.1/nbxmpp/transports_nb.py new/nbxmpp-0.6.4/nbxmpp/transports_nb.py --- old/nbxmpp-0.6.1/nbxmpp/transports_nb.py 2017-11-29 21:25:08.000000000 +0100 +++ new/nbxmpp-0.6.4/nbxmpp/transports_nb.py 2018-03-17 17:37:47.000000000 +0100 @@ -316,7 +316,7 @@ estabilish TLS connection. """ def __init__(self, raise_event, on_disconnect, idlequeue, estabilish_tls, - certs, tls_version, cipher_list, proxy_dict=None): + certs, tls_version, cipher_list, alpn, proxy_dict=None): """ :param proxy_dict: dictionary with proxy data as loaded from config file """ @@ -341,6 +341,8 @@ self.ssl_certificate = None self.ssl_errnum = 0 + self.alpn = alpn + # FIXME: transport should not be aware xmpp def start_disconnect(self): NonBlockingTransport.start_disconnect(self) @@ -432,7 +434,7 @@ """ cacerts, mycerts = self.certs result = tls_nb.NonBlockingTLS.get_instance(cacerts, mycerts, - self.tls_version, self.cipher_list).PlugIn(self) + self.tls_version, self.cipher_list, self.alpn).PlugIn(self) if result: on_succ() else: @@ -609,13 +611,13 @@ try: # get as many bites, as possible, but not more than RECV_BUFSIZE received = self._recv(RECV_BUFSIZE) - except socket.error as e: - log.info("_do_receive: got %s:" % received, exc_info=True) except tls_nb.SSLWrapper.Error as e: log.info("_do_receive, caught SSL error, got %s:" % received, exc_info=True) errnum, errstr = e.errno,\ decode_py2(e.strerror, locale.getpreferredencoding()) + except socket.error as e: + log.info("_do_receive: got %s:" % received, exc_info=True) if received == '': errstr = 'zero bytes on recv' @@ -649,19 +651,21 @@ received = self.received_bytes_buff + received self.received_bytes_buff = b'' - # try to decode data - try: - received = decode_py2(received, 'utf-8') - except UnicodeDecodeError: - for i in range(-1, -4, -1): - char = received[i] - if sys.version_info[0] < 3: # with py2 we get a str - char = ord(char) - if char & 0xc0 == 0xc0: - self.received_bytes_buff = received[i:] - received = received[:i] - break - received = decode_py2(received, 'utf-8') + if self.state != PROXY_CONNECTING or self.proxy_dict['type'] != \ + 'socks5': + # try to decode data + try: + received = decode_py2(received, 'utf-8') + except UnicodeDecodeError: + for i in range(-1, -4, -1): + char = received[i] + if sys.version_info[0] < 3: # with py2 we get a str + char = ord(char) + if char & 0xc0 == 0xc0: + self.received_bytes_buff = received[i:] + received = received[:i] + break + received = decode_py2(received, 'utf-8') # pass received data to owner if self.on_receive: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nbxmpp-0.6.1/setup.py new/nbxmpp-0.6.4/setup.py --- old/nbxmpp-0.6.1/setup.py 2017-11-29 21:25:08.000000000 +0100 +++ new/nbxmpp-0.6.4/setup.py 2018-03-17 17:37:47.000000000 +0100 @@ -3,7 +3,7 @@ from distutils.core import setup setup(name='nbxmpp', - version='0.6.1', + version='0.6.4', description='Non blocking Jabber/XMPP module', author='Yann Leboulanger', author_email='[email protected]',
