2022-02-26 07:07:18 +00:00
|
|
|
import config
|
|
|
|
import logger
|
|
|
|
|
|
|
|
from getsocks import get_socks
|
|
|
|
from torpeer import TorPeer
|
2022-03-21 06:03:53 +00:00
|
|
|
from gossip.peerset import gossip_peer_set
|
2022-02-26 07:07:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
def on_announce_rec(api, data=None):
|
|
|
|
socks_address, socks_port = get_socks()[0]
|
|
|
|
|
|
|
|
announced = data['address']
|
|
|
|
try:
|
|
|
|
announced = announced.decode('utf-8')
|
|
|
|
except AttributeError:
|
|
|
|
pass
|
|
|
|
|
|
|
|
if announced == config.get('tor.transport_address'):
|
|
|
|
logger.warn("Recieved announcement for our own node, which shouldnt happen")
|
|
|
|
return
|
|
|
|
|
|
|
|
announced += '.onion'
|
|
|
|
|
|
|
|
data['callback'](
|
2022-03-21 06:03:53 +00:00
|
|
|
gossip_peer_set,
|
2022-02-26 07:07:18 +00:00
|
|
|
TorPeer(socks_address, socks_port, announced))
|