Philipp Hörist pushed to branch nbxmpp_1.0 at gajim / python-nbxmpp
Commits: 28601b51 by lovetox at 2020-08-15T08:42:45+02:00 Perform UTS46 mapping on domain names
http://unicode.org/reports/tr46/
- - - - - 10c5f7f0 by lovetox at 2020-08-15T08:42:45+02:00 Add method to disable stream management
- - - - - c14f3e5b by lovetox at 2020-08-15T08:42:45+02:00 Add namespace
- - - - - 40c09048 by lovetox at 2020-08-15T08:42:45+02:00 Client: set_ignore_tls_errors() allow to pass None
- - - - - a545dce9 by André Apitzsch at 2020-08-15T08:42:45+02:00 Add namespace of XEP-393
- - - - - c74c2eaf by Philipp Hörist at 2020-08-15T08:42:45+02:00 Revert "Client: set_ignore_tls_errors() allow to pass None"
This reverts commit 3bf7d2eaab6b12bd18045c2907e78224fc23e58d - - - - - 4e9438b6 by lovetox at 2020-08-15T08:42:45+02:00 Client: set_ignored_tls_errors() allow to pass None
- - - - - 29d4261e by lovetox at 2020-08-15T08:42:45+02:00 Client: Expose more information about the connection
- - - - - c0b512fe by lovetox at 2020-08-15T08:42:45+02:00 TCP: Catch Runtime error
Fixes #101
- - - - - 80f36a84 by lovetox at 2020-08-15T08:42:45+02:00 TCP: Set input/output closed on finalize()
Hopefully Fixes #108
- - - - - 2a370f80 by lovetox at 2020-08-15T08:42:45+02:00 Update ChangeLog
- - - - - f72eeeb0 by lovetox at 2020-08-15T08:42:45+02:00 1.0.2
- - - - -
10 changed files:
- ChangeLog - nbxmpp/__init__.py - nbxmpp/client.py - nbxmpp/connection.py - nbxmpp/namespaces.py - nbxmpp/protocol.py - nbxmpp/smacks.py - nbxmpp/tcp.py - nbxmpp/websocket.py - setup.cfg
Changes:
===================================== ChangeLog ===================================== @@ -1,3 +1,17 @@ +python-nbxmpp 1.0.2 (14 August 2020) + + New + + * Client: Expose more information about the connection + * Client: set_ignored_tls_errors() allow to pass None + * Add method to disable stream management + + Bugfixes + + * TCP: Set input/output closed on finalize() + * TCP: Catch Runtime error + * Perform UTS46 mapping on domain names + python-nbxmpp 1.0.1 (07 July 2020)
New
===================================== nbxmpp/__init__.py ===================================== @@ -4,4 +4,4 @@ from .protocol import *
gi.require_version('Soup', '2.4')
-__version__ = "1.0.1" +__version__ = "1.0.2"
===================================== nbxmpp/client.py ===================================== @@ -95,6 +95,8 @@ class Client(Observable): self._allowed_protocols = None self._allowed_mechs = None
+ self._sm_disabled = False + self._stream_id = None self._stream_secure = False self._stream_authenticated = False @@ -105,7 +107,7 @@ class Client(Observable): self._ping_id = None self._error = None, None, None
- self._ignored_tls_errors = [] + self._ignored_tls_errors = set() self._ignore_tls_errors = False self._accepted_certificates = [] self._peer_certificate = None @@ -113,6 +115,7 @@ class Client(Observable):
self._con = None self._local_address = None + self._remote_address = None self._mode = Mode.CLIENT
self._ping_source_id = None @@ -184,6 +187,8 @@ class Client(Observable): return self._ignored_tls_errors
def set_ignored_tls_errors(self, errors): + if errors is None: + errors = set() self._ignored_tls_errors = errors
@property @@ -204,6 +209,10 @@ class Client(Observable): def peer_certificate(self): return self._peer_certificate, self._peer_certificate_errors
+ @property + def current_address(self): + return self._current_address + @property def current_connection_type(self): return self._current_address.type @@ -242,6 +251,10 @@ class Client(Observable): def local_address(self): return self._local_address
+ @property + def remote_address(self): + return self._remote_address + @property def connection_types(self): if self._custom_host is not None: @@ -273,6 +286,13 @@ class Client(Observable): def set_protocols(self, protocols): self._allowed_protocols = protocols
+ def set_sm_disabled(self, value): + self._sm_disabled = value + + @property + def sm_disabled(self): + return self._sm_disabled + @property def client_cert(self): return self._client_cert, self._client_cert_pass @@ -423,6 +443,7 @@ class Client(Observable): def _on_connected(self, connection, _signal_name): self.set_state(StreamState.CONNECTED) self._local_address = connection.local_address + self._remote_address = connection.remote_address
def _on_disconnected(self, _connection, _signal_name): self.state = StreamState.DISCONNECTED
===================================== nbxmpp/connection.py ===================================== @@ -54,6 +54,7 @@ class Connection(Observable): self._client_cert = client_cert self._address = address self._local_address = None + self._remote_address = None self._state = None
self._state = TCPState.DISCONNECTED @@ -68,6 +69,10 @@ class Connection(Observable): def local_address(self): return self._local_address
+ @property + def remote_address(self): + return self._remote_address + @property def peer_certificate(self): return (self._peer_certificate, self._peer_certificate_errors)
===================================== nbxmpp/namespaces.py ===================================== @@ -146,11 +146,13 @@ class _Namespaces: STREAM: str = 'http://affinix.com/jabber/stream' STREAMS: str = 'http://etherx.jabber.org/streams' STREAM_MGMT: str = 'urn:xmpp:sm:3' + STYLING: str = 'urn:xmpp:styling:0' TIME_REVISED: str = 'urn:xmpp:time' TLS: str = 'urn:ietf:params:xml:ns:xmpp-tls' TUNE: str = 'http://jabber.org/protocol/tune' VCARD: str = 'vcard-temp' VCARD_UPDATE: str = 'vcard-temp:x:update' + VCARD_CONVERSION: str = 'urn:xmpp:pep-vcard-conversion:0' VERSION: str = 'jabber:iq:version' XHTML_IM: str = 'http://jabber.org/protocol/xhtml-im' XHTML: str = 'http://www.w3.org/1999/xhtml'
===================================== nbxmpp/protocol.py ===================================== @@ -735,7 +735,7 @@ def validate_domainpart(domainpart): domainpart = domainpart[:-1]
try: - domainpart = idna.encode(domainpart) + domainpart = idna.encode(domainpart, uts46=True) except Exception: raise DomainpartNotAllowedChar
===================================== nbxmpp/smacks.py ===================================== @@ -103,6 +103,10 @@ class Smacks: def send_enable(self): if not self.sm_supported: return + + if self._client.sm_disabled: + return + enable = Node(Namespace.STREAM_MGMT + ' enable', attrs={'resume': 'true'}) self._client.send_nonza(enable, now=False) self._log.debug('Send enable')
===================================== nbxmpp/tcp.py ===================================== @@ -83,12 +83,12 @@ class TCPConnection(Connection):
def _on_event(self, _socket_client, event, _connectable, connection): if event == Gio.SocketClientEvent.CONNECTING: - remote_address = connection.get_remote_address() + self._remote_address = connection.get_remote_address().to_string() use_proxy = self._address.proxy is not None target = 'proxy' if use_proxy else self._address.domain self._log.info('Connecting to %s (%s)', target, - remote_address.to_string()) + self._remote_address)
def _check_certificate(self, _connection, certificate, errors): self._peer_certificate = certificate @@ -286,6 +286,13 @@ class TCPConnection(Connection): self._log.error('Write Error: %s', error) return
+ except RuntimeError as error: + # PyGObject raises a RuntimeError when it failed to for some reason + # to convert the GError. Why it failed to convert is printed by + # PyGObject + self._log.error(error) + return + data = data.decode() self._log_stanza(data, received=False)
@@ -358,6 +365,8 @@ class TCPConnection(Connection): self._con.get_socket().shutdown(True, True) except GLib.Error as error: self._log.info(error) + self._input_closed = True + self._output_closed = True self.state = TCPState.DISCONNECTED self.notify(signal_name) self.destroy()
===================================== nbxmpp/websocket.py ===================================== @@ -169,6 +169,8 @@ class WebsocketConnection(Connection): self._output_closed = True
def _finalize(self, signal_name): + self._input_closed = True + self._output_closed = True self.state = TCPState.DISCONNECTED self.notify(signal_name) self.destroy()
===================================== setup.cfg ===================================== @@ -1,6 +1,6 @@ [metadata] name = nbxmpp -version = 1.0.1 +version = 1.0.2 description = XMPP Library author = Yann Leboulanger, Philipp Hoerist author_email = gajim-devel@gajim.org
View it on GitLab: https://dev.gajim.org/gajim/python-nbxmpp/-/compare/cc239585527c99ae3ff65a9d...