Yann Leboulanger pushed to branch master at gajim / python-nbxmpp

Commits:

9 changed files:

Changes:

  • nbxmpp/auth_nb.py
    ... ... @@ -461,18 +461,18 @@ class SASL(PlugIn):
    461 461
                 self.realm = chal['realm']
    
    462 462
             if 'qop' in chal and ((chal['qop'] =='auth') or \
    
    463 463
             (isinstance(chal['qop'], list) and 'auth' in chal['qop'])):
    
    464
                 self.resp = {}
    
    465
                 self.resp['username'] = self.username
    
    464
                 self.resp = {'username': self.username,
    
    465
                     'nonce': chal['nonce'],
    
    466
                     'cnonce': '%x' % rndg.getrandbits(196),
    
    467
                     'nc': ('00000001'),  # ToDo: Is this a tupel or only a string?
    
    468
                     'qop': 'auth',
    
    469
                     'digest-uri': 'xmpp/' + self._owner.Server,
    
    470
                     'charset': 'utf-8'
    
    471
                 }
    
    466 472
                 if self.realm:
    
    467 473
                     self.resp['realm'] = self.realm
    
    468 474
                 else:
    
    469 475
                     self.resp['realm'] = self._owner.Server
    
    470
                 self.resp['nonce'] = chal['nonce']
    
    471
                 self.resp['cnonce'] = '%x' % rndg.getrandbits(196)
    
    472
                 self.resp['nc'] = ('00000001')
    
    473
                 self.resp['qop'] = 'auth'
    
    474
                 self.resp['digest-uri'] = 'xmpp/' + self._owner.Server
    
    475
                 self.resp['charset'] = 'utf-8'
    
    476 476
                 # Password is now required
    
    477 477
                 self._owner._caller.get_password(self.set_password, self.mechanism)
    
    478 478
             elif 'rspauth' in chal:
    

  • nbxmpp/bosh.py
    ... ... @@ -101,7 +101,7 @@ class NonBlockingBOSH(NonBlockingTransport):
    101 101
             NonBlockingTransport.connect(self, conn_5tuple, on_connect, on_connect_failure)
    
    102 102
     
    
    103 103
             global FAKE_DESCRIPTOR
    
    104
             FAKE_DESCRIPTOR = FAKE_DESCRIPTOR - 1
    
    104
             FAKE_DESCRIPTOR -= 1
    
    105 105
             self.fd = FAKE_DESCRIPTOR
    
    106 106
     
    
    107 107
             self.stanza_buffer = []
    

  • nbxmpp/c14n.py
    ... ... @@ -28,7 +28,7 @@ def c14n(node, is_buggy):
    28 28
         s = "<" + node.name
    
    29 29
         if node.namespace:
    
    30 30
             if not node.parent or node.parent.namespace != node.namespace:
    
    31
                 s = s + ' xmlns="%s"' % node.namespace
    
    31
                 s += ' xmlns="%s"' % node.namespace
    
    32 32
     
    
    33 33
         sorted_attrs = sorted(node.attrs.keys())
    
    34 34
         for key in sorted_attrs:
    
    ... ... @@ -36,15 +36,15 @@ def c14n(node, is_buggy):
    36 36
                 continue
    
    37 37
             val = ustr(node.attrs[key])
    
    38 38
             # like XMLescape() but with whitespace and without &gt;
    
    39
             s = s + ' %s="%s"' % ( key, normalise_attr(val) )
    
    40
         s = s + ">"
    
    39
             s += ' %s="%s"' % (key, normalise_attr(val))
    
    40
         s += ">"
    
    41 41
         cnt = 0
    
    42 42
         if node.kids:
    
    43 43
             for a in node.kids:
    
    44 44
                 if (len(node.data)-1) >= cnt:
    
    45 45
                     s = s + normalise_text(node.data[cnt])
    
    46 46
                 s = s + c14n(a, is_buggy)
    
    47
                 cnt=cnt+1
    
    47
                 cnt += 1
    
    48 48
         if (len(node.data)-1) >= cnt: s = s + normalise_text(node.data[cnt])
    
    49 49
         if not node.kids and s.endswith('>'):
    
    50 50
             s=s[:-1]+' />'
    

  • nbxmpp/client_nb.py
    ... ... @@ -273,9 +273,9 @@ class NonBlockingClient:
    273 273
             """
    
    274 274
             if err_message:
    
    275 275
                 log.debug('While looping over DNS A records: %s' % err_message)
    
    276
             if self.ip_addresses == []:
    
    276
             if not self.ip_addresses:
    
    277 277
                 msg = 'Run out of hosts for name %s:%s.' % (self.Server, self.Port)
    
    278
                 msg = msg + ' Error for last IP: %s' % err_message
    
    278
                 msg += ' Error for last IP: %s' % err_message
    
    279 279
                 self.disconnect(msg)
    
    280 280
             else:
    
    281 281
                 self.current_ip = self.ip_addresses.pop(0)
    

  • nbxmpp/dispatcher_nb.py
    ... ... @@ -104,7 +104,7 @@ class XMPPDispatcher(PlugIn):
    104 104
             # \ufddo -> \ufdef range
    
    105 105
             c = '\ufdd0'
    
    106 106
             r = c
    
    107
             while (c < '\ufdef'):
    
    107
             while c < '\ufdef':
    
    108 108
                 c = chr(ord(c) + 1)
    
    109 109
                 r += '|' + c
    
    110 110
     
    
    ... ... @@ -112,7 +112,7 @@ class XMPPDispatcher(PlugIn):
    112 112
             c = '\ufffe'
    
    113 113
             r += '|' + c
    
    114 114
             r += '|' + chr(ord(c) + 1)
    
    115
             while (c < '\U0010fffe'):
    
    115
             while c < '\U0010fffe':
    
    116 116
                 c = chr(ord(c) + 0x10000)
    
    117 117
                 r += '|' + c
    
    118 118
                 r += '|' + chr(ord(c) + 1)
    
    ... ... @@ -458,7 +458,7 @@ class XMPPDispatcher(PlugIn):
    458 458
             stanza.getName() != 'a' and stanza.getName() != 'enabled' and
    
    459 459
             stanza.getName() != 'resumed'):
    
    460 460
                 # increments the number of stanzas that has been handled
    
    461
                 self.sm.in_h = self.sm.in_h + 1
    
    461
                 self.sm.in_h += 1
    
    462 462
             list_ = ['default'] # we will use all handlers:
    
    463 463
             if typ in self.handlers[xmlns][name]:
    
    464 464
                 list_.append(typ) # from very common...
    
    ... ... @@ -571,7 +571,7 @@ class XMPPDispatcher(PlugIn):
    571 571
             # If no ID then it is a whitespace
    
    572 572
             if self.sm and self.sm.enabled and ID:
    
    573 573
                 self.sm.uqueue.append(stanza)
    
    574
                 self.sm.out_h = self.sm.out_h + 1
    
    574
                 self.sm.out_h += 1
    
    575 575
                 if len(self.sm.uqueue) > self.sm.max_queue:
    
    576 576
                     self.sm.request_ack()
    
    577 577
     
    

  • nbxmpp/proxy_connectors.py
    ... ... @@ -195,7 +195,8 @@ class SOCKS5Connector(ProxyConnector):
    195 195
     #                               # Resolve locally
    
    196 196
     #                               self.ipaddr = socket.inet_aton(socket.gethostbyname(self.xmpp_server[0]))
    
    197 197
     #                               req = req + "\x01" + ipaddr
    
    198
             req = req + struct.pack(">H", self.xmpp_server[1])
    
    198
     
    
    199
             req += struct.pack(">H", self.xmpp_server[1])
    
    199 200
             self.onreceive(self._on_req_sent)
    
    200 201
             self.send(req)
    
    201 202
     
    

  • nbxmpp/smacks.py
    ... ... @@ -143,7 +143,7 @@ class Smacks():
    143 143
             self.enabled = True
    
    144 144
             self.resuming = True
    
    145 145
             self.con.set_oldst()
    
    146
             if self.old_uqueue != []:
    
    146
             if self.old_uqueue:
    
    147 147
                 log.info('Session resumed, replaying %s stanzas...' % len(self.old_uqueue))
    
    148 148
                 for i in self.old_uqueue:
    
    149 149
                     self._owner.Connection.send(i, False)
    

  • nbxmpp/tls_nb.py
    ... ... @@ -120,7 +120,8 @@ class SSLWrapper:
    120 120
                     if self.exc_str:
    
    121 121
                         if self.strerror:
    
    122 122
                             s += "(%s)" % self.exc_str
    
    123
                         else: s += "(%s)" % str(self.exc_args)
    
    123
                         else:
    
    124
                             s += "(%s)" % str(self.exc_args)
    
    124 125
                 return s
    
    125 126
     
    
    126 127
         def __init__(self, sslobj, sock=None):
    

  • nbxmpp/transports_nb.py
    ... ... @@ -583,7 +583,7 @@ class NonBlockingTCP(NonBlockingTransport, IdleObject):
    583 583
                     except UnicodeDecodeError:
    
    584 584
                         for i in range(-1, -4, -1):
    
    585 585
                             char = sent_data[i]
    
    586
                             if char & 0xc0 == 0xc0:
    
    586
                             if ord(char) & 0xc0 == 0xc0:
    
    587 587
                                 self.sent_bytes_buff = sent_data[i:]
    
    588 588
                                 sent_data = sent_data[:i]
    
    589 589
                                 break
    
    ... ... @@ -794,7 +794,7 @@ class NonBlockingHTTP(NonBlockingTCP):
    794 794
                 headers.append('Connection: Keep-Alive')
    
    795 795
             headers.append('\r\n')
    
    796 796
             headers = '\r\n'.join(headers)
    
    797
             return('%s%s' % (headers, httpbody))
    
    797
             return '%s%s' % (headers, httpbody)
    
    798 798
     
    
    799 799
         def parse_http_message(self, message):
    
    800 800
             """