Commit fe0542ee authored by Philipp Hörist's avatar Philipp Hörist
Browse files

Client: Expose local address

parent ab9c8f04
Pipeline #5731 failed with stages
......@@ -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
......@@ -237,6 +238,10 @@ class Client(Observable):
self.state = state
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,
......@@ -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
......
......@@ -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
......@@ -63,6 +64,10 @@ class Connection(Observable):
self._ignore_tls_errors = ignore_tls_errors
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)
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment