Philipp Hörist pushed to branch master at gajim / python-nbxmpp
Commits:
-
387445a1
by lovetox at 2020-08-12T15:18:38+02:00
3 changed files:
Changes:
| ... | ... | @@ -115,6 +115,7 @@ class Client(Observable): |
| 115 | 115 |
|
| 116 | 116 |
self._con = None
|
| 117 | 117 |
self._local_address = None
|
| 118 |
+ self._remote_address = None
|
|
| 118 | 119 |
self._mode = Mode.CLIENT
|
| 119 | 120 |
|
| 120 | 121 |
self._ping_source_id = None
|
| ... | ... | @@ -208,6 +209,10 @@ class Client(Observable): |
| 208 | 209 |
def peer_certificate(self):
|
| 209 | 210 |
return self._peer_certificate, self._peer_certificate_errors
|
| 210 | 211 |
|
| 212 |
+ @property
|
|
| 213 |
+ def current_address(self):
|
|
| 214 |
+ return self._current_address
|
|
| 215 |
+ |
|
| 211 | 216 |
@property
|
| 212 | 217 |
def current_connection_type(self):
|
| 213 | 218 |
return self._current_address.type
|
| ... | ... | @@ -246,6 +251,10 @@ class Client(Observable): |
| 246 | 251 |
def local_address(self):
|
| 247 | 252 |
return self._local_address
|
| 248 | 253 |
|
| 254 |
+ @property
|
|
| 255 |
+ def remote_address(self):
|
|
| 256 |
+ return self._remote_address
|
|
| 257 |
+ |
|
| 249 | 258 |
@property
|
| 250 | 259 |
def connection_types(self):
|
| 251 | 260 |
if self._custom_host is not None:
|
| ... | ... | @@ -434,6 +443,7 @@ class Client(Observable): |
| 434 | 443 |
def _on_connected(self, connection, _signal_name):
|
| 435 | 444 |
self.set_state(StreamState.CONNECTED)
|
| 436 | 445 |
self._local_address = connection.local_address
|
| 446 |
+ self._remote_address = connection.remote_address
|
|
| 437 | 447 |
|
| 438 | 448 |
def _on_disconnected(self, _connection, _signal_name):
|
| 439 | 449 |
self.state = StreamState.DISCONNECTED
|
| ... | ... | @@ -54,6 +54,7 @@ class Connection(Observable): |
| 54 | 54 |
self._client_cert = client_cert
|
| 55 | 55 |
self._address = address
|
| 56 | 56 |
self._local_address = None
|
| 57 |
+ self._remote_address = None
|
|
| 57 | 58 |
self._state = None
|
| 58 | 59 |
|
| 59 | 60 |
self._state = TCPState.DISCONNECTED
|
| ... | ... | @@ -68,6 +69,10 @@ class Connection(Observable): |
| 68 | 69 |
def local_address(self):
|
| 69 | 70 |
return self._local_address
|
| 70 | 71 |
|
| 72 |
+ @property
|
|
| 73 |
+ def remote_address(self):
|
|
| 74 |
+ return self._remote_address
|
|
| 75 |
+ |
|
| 71 | 76 |
@property
|
| 72 | 77 |
def peer_certificate(self):
|
| 73 | 78 |
return (self._peer_certificate, self._peer_certificate_errors)
|
| ... | ... | @@ -83,12 +83,12 @@ class TCPConnection(Connection): |
| 83 | 83 |
|
| 84 | 84 |
def _on_event(self, _socket_client, event, _connectable, connection):
|
| 85 | 85 |
if event == Gio.SocketClientEvent.CONNECTING:
|
| 86 |
- remote_address = connection.get_remote_address()
|
|
| 86 |
+ self._remote_address = connection.get_remote_address().to_string()
|
|
| 87 | 87 |
use_proxy = self._address.proxy is not None
|
| 88 | 88 |
target = 'proxy' if use_proxy else self._address.domain
|
| 89 | 89 |
self._log.info('Connecting to %s (%s)',
|
| 90 | 90 |
target,
|
| 91 |
- remote_address.to_string())
|
|
| 91 |
+ self._remote_address)
|
|
| 92 | 92 |
|
| 93 | 93 |
def _check_certificate(self, _connection, certificate, errors):
|
| 94 | 94 |
self._peer_certificate = certificate
|