Welcome to mirror list, hosted at ThFree Co, Russian Federation.

dev.gajim.org/gajim/python-nbxmpp.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlovetox <philipp@hoerist.com>2020-05-30 12:47:17 +0300
committerlovetox <philipp@hoerist.com>2020-05-30 12:47:17 +0300
commitfe0542eedee09a2902c45034adec8ad223010b22 (patch)
tree8fb07f6abcf493ba184f4b75e7da7034073cb3a3
parentab9c8f040aec946386f6c876ca75ee20c7631014 (diff)
Client: Expose local address
-rw-r--r--nbxmpp/client.py8
-rw-r--r--nbxmpp/connection.py5
-rw-r--r--nbxmpp/tcp.py2
3 files changed, 14 insertions, 1 deletions
diff --git a/nbxmpp/client.py b/nbxmpp/client.py
index ec52363..5012676 100644
--- a/nbxmpp/client.py
+++ b/nbxmpp/client.py
@@ -112,6 +112,7 @@ class Client(Observable):
self._peer_certificate_errors = None
self._con = None
+ self._local_address = None
self._mode = Mode.CLIENT
self._ping_source_id = None
@@ -238,6 +239,10 @@ class Client(Observable):
self._xmpp_state_machine()
@property
+ def local_address(self):
+ return self._local_address
+
+ @property
def connection_types(self):
return list(self._allowed_con_types or [ConnectionType.DIRECT_TLS,
ConnectionType.START_TLS])
@@ -411,8 +416,9 @@ class Client(Observable):
# Alias for backwards compat
return self.send_stanza(stanza)
- def _on_connected(self, _connection, _signal_name):
+ def _on_connected(self, connection, _signal_name):
self.set_state(StreamState.CONNECTED)
+ self._local_address = connection.local_address
def _on_disconnected(self, _connection, _signal_name):
self.state = StreamState.DISCONNECTED
diff --git a/nbxmpp/connection.py b/nbxmpp/connection.py
index 6fc06b6..a58bc2f 100644
--- a/nbxmpp/connection.py
+++ b/nbxmpp/connection.py
@@ -53,6 +53,7 @@ class Connection(Observable):
self._client_cert = client_cert
self._address = address
+ self._local_address = None
self._state = None
self._state = TCPState.DISCONNECTED
@@ -64,6 +65,10 @@ class Connection(Observable):
self._ignored_tls_errors = ignored_tls_errors
@property
+ def local_address(self):
+ return self._local_address
+
+ @property
def peer_certificate(self):
return (self._peer_certificate, self._peer_certificate_errors)
diff --git a/nbxmpp/tcp.py b/nbxmpp/tcp.py
index bdaa074..361dacd 100644
--- a/nbxmpp/tcp.py
+++ b/nbxmpp/tcp.py
@@ -127,6 +127,8 @@ class TCPConnection(Connection):
self._con.set_graceful_disconnect(True)
self._con.get_socket().set_keepalive(True)
+ self._local_address = self._con.get_local_address()
+
self.state = TCPState.CONNECTED
use_proxy = self._address.proxy is not None