2022-06-26 19:43:16 +00:00
|
|
|
import config
|
2022-09-27 17:21:00 +00:00
|
|
|
from logger import log as logging
|
2022-06-26 19:43:16 +00:00
|
|
|
from gossip.server import gossip_server_socket_file
|
|
|
|
|
|
|
|
from unixpeer import UnixPeer
|
|
|
|
|
|
|
|
|
|
|
|
def on_announce_rec(api, data=None):
|
|
|
|
|
|
|
|
announced: str = data['address']
|
|
|
|
try:
|
|
|
|
announced = announced.decode('utf-8')
|
|
|
|
except AttributeError:
|
|
|
|
pass
|
|
|
|
announced = announced.strip()
|
2022-07-11 15:27:13 +00:00
|
|
|
if not announced.endswith('.sock'):
|
|
|
|
return
|
|
|
|
|
2022-06-26 19:43:16 +00:00
|
|
|
if announced == gossip_server_socket_file:
|
|
|
|
return
|
|
|
|
|
2022-09-27 17:21:00 +00:00
|
|
|
logging.info(f"Peer {announced} announced to us.")
|
2022-06-26 19:43:16 +00:00
|
|
|
|
|
|
|
data['callback'](UnixPeer(announced))
|