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

Function connectd_init

lightningd/connect_control.c:725–797  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

723}
724
725int connectd_init(struct lightningd *ld)
726{
727 int fds[2];
728 u8 *msg;
729 int hsmfd;
730 struct wireaddr_internal *wireaddrs = ld->proposed_wireaddr;
731 enum addr_listen_announce *listen_announce = ld->proposed_listen_announce;
732 const char *websocket_helper_path;
733 void *ret;
734
735 websocket_helper_path = subdaemon_path(tmpctx, ld,
736 "lightning_websocketd");
737
738 if (socketpair(AF_LOCAL, SOCK_STREAM, 0, fds) != 0)
739 fatal("Could not socketpair for connectd<->gossipd");
740
741 hsmfd = hsm_get_global_fd(ld, HSM_PERM_ECDH);
742
743 ld->connectd = new_global_subd(ld, "lightning_connectd",
744 connectd_wire_name, connectd_msg,
745 take(&hsmfd), take(&fds[1]),
746 /* Not take(): we share it */
747 ld->dev_disconnect_fd >= 0 ?
748 &ld->dev_disconnect_fd : NULL,
749 NULL);
750 if (!ld->connectd)
751 err(1, "Could not subdaemon connectd");
752
753 /* If no addr specified, hand wildcard to connectd */
754 if (tal_count(wireaddrs) == 0 && ld->autolisten) {
755 wireaddrs = tal_arrz(tmpctx, struct wireaddr_internal, 1);
756 listen_announce = tal_arr(tmpctx, enum addr_listen_announce, 1);
757 wireaddrs->itype = ADDR_INTERNAL_ALLPROTO;
758 wireaddrs->u.allproto.is_websocket = false;
759 wireaddrs->u.allproto.port = ld->portnum;
760 *listen_announce = ADDR_LISTEN_AND_ANNOUNCE;
761 } else
762 /* Make it clear that autolisten is not active! */
763 ld->autolisten = false;
764
765 msg = towire_connectd_init(tmpctx, chainparams,
766 ld->our_features,
767 &ld->our_nodeid,
768 wireaddrs,
769 listen_announce,
770 ld->proxyaddr,
771 ld->always_use_proxy || ld->pure_tor_setup,
772 ld->dev_allow_localhost,
773 ld->config.use_dns,
774 ld->tor_service_password ? ld->tor_service_password : "",
775 ld->config.connection_timeout_secs,
776 websocket_helper_path,
777 ld->message_padding,
778 ld->dev_fast_gossip,
779 ld->dev_disconnect_fd >= 0,
780 ld->dev_no_ping_timer,
781 ld->dev_handshake_no_reply,
782 ld->dev_throttle_gossip,

Callers 1

mainFunction · 0.70

Calls 7

hsm_get_global_fdFunction · 0.85
errFunction · 0.85
io_loopFunction · 0.85
subdaemon_pathFunction · 0.70
fatalFunction · 0.70
new_global_subdFunction · 0.70
subd_reqClass · 0.70

Tested by

no test coverage detected