MCPcopy Create free account
hub / github.com/ElementsProject/lightning / handle_discovered_ip

Function handle_discovered_ip

gossipd/gossipd.c:346–386  ·  view source on GitHub ↗

lightningd tells us it has discovered and verified new `remote_addr`. * We can use this to update our node announcement. */

Source from the content-addressed store, hash-verified

344/* lightningd tells us it has discovered and verified new `remote_addr`.
345 * We can use this to update our node announcement. */
346static void handle_discovered_ip(struct daemon *daemon, const u8 *msg)
347{
348 struct wireaddr discovered_ip;
349
350 if (!fromwire_gossipd_discovered_ip(msg, &discovered_ip))
351 master_badmsg(WIRE_GOSSIPD_DISCOVERED_IP, msg);
352
353 switch (discovered_ip.type) {
354 case ADDR_TYPE_IPV4:
355 if (daemon->discovered_ip_v4 != NULL &&
356 wireaddr_eq_without_port(daemon->discovered_ip_v4,
357 &discovered_ip))
358 break;
359 tal_free(daemon->discovered_ip_v4);
360 daemon->discovered_ip_v4 = tal_dup(daemon, struct wireaddr,
361 &discovered_ip);
362 goto update_node_annoucement;
363 case ADDR_TYPE_IPV6:
364 if (daemon->discovered_ip_v6 != NULL &&
365 wireaddr_eq_without_port(daemon->discovered_ip_v6,
366 &discovered_ip))
367 break;
368 tal_free(daemon->discovered_ip_v6);
369 daemon->discovered_ip_v6 = tal_dup(daemon, struct wireaddr,
370 &discovered_ip);
371 goto update_node_annoucement;
372
373 /* ignore all other cases */
374 case ADDR_TYPE_TOR_V2_REMOVED:
375 case ADDR_TYPE_TOR_V3:
376 case ADDR_TYPE_DNS:
377 case ADDR_TYPE_WEBSOCKET:
378 break;
379 }
380 return;
381
382update_node_annoucement:
383 status_debug("Update our node_announcement for discovered address: %s",
384 fmt_wireaddr(tmpctx, &discovered_ip));
385 maybe_send_own_node_announce(daemon, false);
386}
387
388/*~ This is where connectd tells us about a new peer we might want to
389 * gossip with. */

Callers 1

recv_reqFunction · 0.85

Calls 5

wireaddr_eq_without_portFunction · 0.85
tal_freeFunction · 0.85
fmt_wireaddrFunction · 0.85
master_badmsgFunction · 0.50

Tested by

no test coverage detected