diff options
author | Philipp Hörist <philipp@hoerist.com> | 2023-11-07 00:54:06 +0300 |
---|---|---|
committer | Philipp Hörist <philipp@hoerist.com> | 2023-11-07 00:54:06 +0300 |
commit | 67e1a9e68b449e55dc4e4590868fd140e6efe155 (patch) | |
tree | 391c3bcda572facbf4837ce7f8f17c3b05f6d7f0 | |
parent | 24d5889a333503e02bf4a0614ea9d823c25bc129 (diff) |
feat: Websocket: Make TLS properties available
-rw-r--r-- | nbxmpp/connection.py | 17 | ||||
-rw-r--r-- | nbxmpp/tcp.py | 22 |
2 files changed, 15 insertions, 24 deletions
diff --git a/nbxmpp/connection.py b/nbxmpp/connection.py index 5a72c22..8a692d0 100644 --- a/nbxmpp/connection.py +++ b/nbxmpp/connection.py @@ -22,6 +22,7 @@ import logging from gi.repository import Gio from nbxmpp.const import TCPState +from nbxmpp.util import min_version from nbxmpp.util import Observable from nbxmpp.util import LogAdapter @@ -69,11 +70,23 @@ class Connection(Observable): @property def tls_version(self) -> Optional[int]: - return None + if self._tls_con is None: + return None + + if not min_version('GLib', '2.69.0'): + return None + + return self._tls_con.get_protocol_version() @property def ciphersuite(self) -> Optional[str]: - return None + if self._tls_con is None: + return None + + if not min_version('GLib', '2.69.0'): + return None + + return self._tls_con.get_ciphersuite_name() def get_channel_binding_data( self, diff --git a/nbxmpp/tcp.py b/nbxmpp/tcp.py index d44c071..dc4a11c 100644 --- a/nbxmpp/tcp.py +++ b/nbxmpp/tcp.py @@ -17,7 +17,6 @@ import logging from collections import deque -from typing import Optional from gi.repository import GLib from gi.repository import Gio @@ -27,7 +26,6 @@ from nbxmpp.const import TCPState from nbxmpp.const import ConnectionType from nbxmpp.util import utf8_decode from nbxmpp.util import convert_tls_error_flags -from nbxmpp.util import min_version from nbxmpp.connection import Connection log = logging.getLogger('nbxmpp.tcp') @@ -64,26 +62,6 @@ class TCPConnection(Connection): self._keepalive_id = None - @property - def tls_version(self) -> Optional[int]: - if self._tls_con is None: - return None - - if not min_version('GLib', '2.69.0'): - return None - - return self._tls_con.get_protocol_version() - - @property - def ciphersuite(self) -> Optional[str]: - if self._tls_con is None: - return None - - if not min_version('GLib', '2.69.0'): - return None - - return self._tls_con.get_ciphersuite_name() - def connect(self): self.state = TCPState.CONNECTING |