Philipp Hörist pushed to branch master at gajim / python-nbxmpp

Commits:

9 changed files:

Changes:

  • README.md
    ... ... @@ -9,6 +9,7 @@
    9 9
     - GLib >= 2.60
    
    10 10
     - libsoup
    
    11 11
     - precis-i18n
    
    12
    +- packaging
    
    12 13
     - idna
    
    13 14
     
    
    14 15
     ## Optional Runtime Requirements
    

  • debian/control
    1 1
     Source: python3-nbxmpp-nightly
    
    2
    -Section: python
    
    2
    +Section: net
    
    3 3
     Priority: optional
    
    4 4
     Maintainer: Gajim Maintainers <ci@gajim.org>
    
    5
    -Build-Depends: debhelper-compat (= 13),
    
    5
    +Build-Depends:
    
    6
    +    debhelper (>= 13),
    
    6 7
         dh-python,
    
    7 8
         libglib2.0-0 (>= 2.60),
    
    8 9
         gir1.2-soup-2.4,
    
    9 10
         python3-all,
    
    10 11
         python3-gi,
    
    11
    -    python3-gssapi,
    
    12 12
         python3-idna,
    
    13
    +    python3-packaging,
    
    13 14
         python3-precis-i18n,
    
    14 15
         python3-setuptools,
    
    15 16
     Standards-Version: 4.1.4
    
    ... ... @@ -22,10 +23,14 @@ Package: python3-nbxmpp-nightly
    22 23
     Architecture: all
    
    23 24
     Depends: ${misc:Depends},
    
    24 25
         ${python3:Depends},
    
    26
    +    libglib2.0-0 (>= 2.60),
    
    25 27
         gir1.2-soup-2.4,
    
    26
    -    python3-gi
    
    28
    +    python3-gi,
    
    29
    +    python3-idna,
    
    30
    +    python3-packaging,
    
    31
    +    python3-precis-i18n,
    
    27 32
     Recommends: python3-gssapi,
    
    28 33
     Breaks: gajim (<< 1.4~)
    
    29 34
     Description: Non blocking XMPP Python library
    
    30
    - nbxmpp is a Python library that provides a way for Python applications
    
    31
    - to use the XMPP network. This library was initially a fork of xmpppy.
    35
    + python-nbxmpp is a Python library that provides a way for Python applications 
    
    36
    + to use the XMPP network. This library was initially a fork of xmpppy.
    \ No newline at end of file

  • nbxmpp/client.py
    ... ... @@ -212,6 +212,14 @@ class Client(Observable):
    212 212
         def ignore_tls_errors(self):
    
    213 213
             return self._ignore_tls_errors
    
    214 214
     
    
    215
    +    @property
    
    216
    +    def tls_version(self):
    
    217
    +        return self._con.tls_version
    
    218
    +
    
    219
    +    @property
    
    220
    +    def ciphersuite(self):
    
    221
    +        return self._con.ciphersuite
    
    222
    +
    
    215 223
         def set_ignore_tls_errors(self, ignore):
    
    216 224
             self._ignore_tls_errors = ignore
    
    217 225
     
    

  • nbxmpp/connection.py
    ... ... @@ -15,6 +15,8 @@
    15 15
     # You should have received a copy of the GNU General Public License
    
    16 16
     # along with this program; If not, see <http://www.gnu.org/licenses/>.
    
    17 17
     
    
    18
    +from typing import Optional
    
    19
    +
    
    18 20
     import logging
    
    19 21
     
    
    20 22
     from gi.repository import Gio
    
    ... ... @@ -65,6 +67,14 @@ class Connection(Observable):
    65 67
             self._ignore_tls_errors = ignore_tls_errors
    
    66 68
             self._ignored_tls_errors = ignored_tls_errors
    
    67 69
     
    
    70
    +    @property
    
    71
    +    def tls_version(self) -> Optional[int]:
    
    72
    +        return None
    
    73
    +
    
    74
    +    @property
    
    75
    +    def ciphersuite(self) -> Optional[int]:
    
    76
    +        return None
    
    77
    +
    
    68 78
         @property
    
    69 79
         def local_address(self):
    
    70 80
             return self._local_address
    

  • nbxmpp/const.py
    ... ... @@ -19,7 +19,14 @@ from enum import Enum
    19 19
     from enum import IntEnum
    
    20 20
     from functools import total_ordering
    
    21 21
     
    
    22
    +from packaging.version import Version
    
    23
    +
    
    22 24
     from gi.repository import Gio
    
    25
    +from gi.repository import GLib
    
    26
    +
    
    27
    +
    
    28
    +GLIB_VERSION = Version(
    
    29
    +    f'{GLib.MAJOR_VERSION}.{GLib.MINOR_VERSION}.{GLib.MICRO_VERSION}')
    
    23 30
     
    
    24 31
     
    
    25 32
     class IqType(Enum):
    

  • nbxmpp/examples/__init__.py

  • nbxmpp/tcp.py
    ... ... @@ -17,6 +17,7 @@
    17 17
     
    
    18 18
     import logging
    
    19 19
     from collections import deque
    
    20
    +from typing import Optional
    
    20 21
     
    
    21 22
     from gi.repository import GLib
    
    22 23
     from gi.repository import Gio
    
    ... ... @@ -26,6 +27,7 @@ from nbxmpp.const import TCPState
    26 27
     from nbxmpp.const import ConnectionType
    
    27 28
     from nbxmpp.util import utf8_decode
    
    28 29
     from nbxmpp.util import convert_tls_error_flags
    
    30
    +from nbxmpp.util import min_version
    
    29 31
     from nbxmpp.connection import Connection
    
    30 32
     
    
    31 33
     log = logging.getLogger('nbxmpp.tcp')
    
    ... ... @@ -62,6 +64,24 @@ class TCPConnection(Connection):
    62 64
     
    
    63 65
             self._keepalive_id = None
    
    64 66
     
    
    67
    +    @property
    
    68
    +    def tls_version(self) -> Optional[int]:
    
    69
    +        if self._con is None:
    
    70
    +            return None
    
    71
    +
    
    72
    +        if min_version('GLib', '2.69.0'):
    
    73
    +            tls_con = self._con.get_base_io_stream()
    
    74
    +            return tls_con.get_protocol_version()
    
    75
    +
    
    76
    +    @property
    
    77
    +    def ciphersuite(self) -> Optional[int]:
    
    78
    +        if self._con is None:
    
    79
    +            return None
    
    80
    +
    
    81
    +        if min_version('GLib', '2.69.0'):
    
    82
    +            tls_con = self._con.get_base_io_stream()
    
    83
    +            return tls_con.get_ciphersuite_name()
    
    84
    +
    
    65 85
         def connect(self):
    
    66 86
             self.state = TCPState.CONNECTING
    
    67 87
     
    

  • nbxmpp/util.py
    ... ... @@ -31,13 +31,15 @@ import logging
    31 31
     from logging import LoggerAdapter
    
    32 32
     from collections import defaultdict
    
    33 33
     import xml.etree.ElementTree as ET
    
    34
    -
    
    35 34
     from functools import lru_cache
    
    36 35
     
    
    36
    +from packaging.version import Version
    
    37
    +
    
    37 38
     from gi.repository import Gio
    
    38 39
     
    
    39 40
     from nbxmpp.protocol import DiscoInfoMalformed
    
    40 41
     from nbxmpp.const import GIO_TLS_ERRORS
    
    42
    +from nbxmpp.const import GLIB_VERSION
    
    41 43
     from nbxmpp.namespaces import Namespace
    
    42 44
     from nbxmpp.protocol import StanzaMalformed
    
    43 45
     from nbxmpp.protocol import StreamHeader
    
    ... ... @@ -405,6 +407,12 @@ def is_websocket_stream_error(stanza: Node) -> bool:
    405 407
                 stanza.getNamespace() == Namespace.STREAMS)
    
    406 408
     
    
    407 409
     
    
    410
    +def min_version(name: str, min_version: str) -> bool:
    
    411
    +    if name == 'GLib':
    
    412
    +        return GLIB_VERSION >= Version(min_version)
    
    413
    +    raise ValueError('Unknown library name')
    
    414
    +
    
    415
    +
    
    408 416
     class Observable:
    
    409 417
         def __init__(self, log_: logging.Logger):
    
    410 418
             self._log = log_
    

  • setup.cfg
    ... ... @@ -18,6 +18,7 @@ python_requires = >=3.9
    18 18
     packages = find:
    
    19 19
     install_requires =
    
    20 20
         precis-i18n>=1.0.0
    
    21
    +    packaging
    
    21 22
         idna
    
    22 23
     
    
    23 24
     [options.extras_require]