[Core] Use external_address in external_ip alert handler

Unit tests are segfaulting and this is a result of a subsequent call to
pop_alert creating a dangling pointer to alert.message method.

Replace alert.message call with correct external_address property that
doesn't require any parsing and wonder trigger segfault to expired
pointer.

https://github.com/arvidn/libtorrent/issues/6437
This commit is contained in:
Calum Lind 2021-09-30 19:57:45 +01:00
parent 1e6cc03946
commit a5a7da4a1a
1 changed files with 3 additions and 12 deletions

View File

@ -1626,18 +1626,9 @@ class TorrentManager(component.Component):
self.handle_torrents_status_callback(self.torrents_status_requests.pop())
def on_alert_external_ip(self, alert):
"""Alert handler for libtorrent external_ip_alert
Note:
The alert.message IPv4 address format is:
'external IP received: 0.0.0.0'
and IPv6 address format is:
'external IP received: 0:0:0:0:0:0:0:0'
"""
external_ip = decode_bytes(alert.message()).split(' ')[-1]
log.info('on_alert_external_ip: %s', external_ip)
component.get('EventManager').emit(ExternalIPEvent(external_ip))
"""Alert handler for libtorrent external_ip_alert"""
log.info('on_alert_external_ip: %s', alert.external_address)
component.get('EventManager').emit(ExternalIPEvent(alert.external_address))
def on_alert_performance(self, alert):
"""Alert handler for libtorrent performance_alert"""