mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-17 19:03:42 +01:00
connectd: new daemon to handle connections.
This is just copying most of gossipd/gossip.c into connectd/connect.c. It shares the same wire format as gossipd during transition, and changes are deliberately minimal. It also has an additional message 'connect_reconnected' which it sends to the master daemon to tell it to kill a peer; gossipd relied on closing the gossipfd to do this, but connectd doesn't maintain an fd with remote peers. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
8e3bc84634
commit
eab83ca79b
2
Makefile
2
Makefile
@ -193,6 +193,7 @@ include openingd/Makefile
|
||||
include channeld/Makefile
|
||||
include closingd/Makefile
|
||||
include onchaind/Makefile
|
||||
include connectd/Makefile
|
||||
include lightningd/Makefile
|
||||
include cli/Makefile
|
||||
include doc/Makefile
|
||||
@ -421,6 +422,7 @@ BIN_PROGRAMS = \
|
||||
PKGLIBEXEC_PROGRAMS = \
|
||||
lightningd/lightning_channeld \
|
||||
lightningd/lightning_closingd \
|
||||
lightningd/lightning_connectd \
|
||||
lightningd/lightning_gossipd \
|
||||
lightningd/lightning_hsmd \
|
||||
lightningd/lightning_onchaind \
|
||||
|
99
connectd/Makefile
Normal file
99
connectd/Makefile
Normal file
@ -0,0 +1,99 @@
|
||||
#! /usr/bin/make
|
||||
|
||||
# Designed to be run one level up
|
||||
connectd-wrongdir:
|
||||
$(MAKE) -C .. connectd-all
|
||||
|
||||
default: connectd-all
|
||||
|
||||
# Control daemon uses this:
|
||||
LIGHTNINGD_CONNECT_CONTROL_HEADERS := connectd/gen_connect_wire.h connectd/gen_connect_gossip_wire.h
|
||||
LIGHTNINGD_CONNECT_CONTROL_SRC := connectd/gen_connect_wire.c connectd/gen_connect_gossip_wire.c
|
||||
LIGHTNINGD_CONNECT_CONTROL_OBJS := $(LIGHTNINGD_CONNECT_CONTROL_SRC:.c=.o)
|
||||
|
||||
# connectd needs these:
|
||||
LIGHTNINGD_CONNECT_HEADERS := connectd/gen_connect_wire.h \
|
||||
connectd/gen_connect_gossip_wire.h \
|
||||
connectd/connect.h \
|
||||
gossipd/handshake.h \
|
||||
gossipd/netaddress.h \
|
||||
gossipd/tor_autoservice.h \
|
||||
gossipd/tor.h
|
||||
LIGHTNINGD_CONNECT_SRC := $(LIGHTNINGD_CONNECT_HEADERS:.h=.c)
|
||||
LIGHTNINGD_CONNECT_OBJS := $(LIGHTNINGD_CONNECT_SRC:.c=.o)
|
||||
|
||||
# Make sure these depend on everything.
|
||||
ALL_OBJS += $(LIGHTNINGD_CONNECT_OBJS)
|
||||
ALL_PROGRAMS += lightningd/lightning_connectd
|
||||
ALL_GEN_HEADERS += connectd/gen_connect_wire.h connectd/gen_connect_gossip_wire.h
|
||||
|
||||
# For checking
|
||||
LIGHTNINGD_CONNECT_ALLSRC_NOGEN := $(filter-out connectd/gen_%, $(LIGHTNINGD_CONNECT_CLIENT_SRC) $(LIGHTNINGD_CONNECT_SRC))
|
||||
LIGHTNINGD_CONNECT_ALLHEADERS_NOGEN := $(filter-out connectd/gen_%, $(LIGHTNINGD_CONNECT_CLIENT_HEADERS) $(LIGHTNINGD_CONNECT_HEADERS))
|
||||
|
||||
# Add to headers which any object might need.
|
||||
LIGHTNINGD_HEADERS_GEN += $(LIGHTNINGD_CONNECT_HEADERS)
|
||||
|
||||
# Common source we use.
|
||||
CONNECTD_COMMON_OBJS := \
|
||||
common/base32.o \
|
||||
common/bech32.o \
|
||||
common/bech32_util.o \
|
||||
common/bip32.o \
|
||||
common/crypto_state.o \
|
||||
common/crypto_sync.o \
|
||||
common/cryptomsg.o \
|
||||
common/daemon.o \
|
||||
common/daemon_conn.o \
|
||||
common/derive_basepoints.o \
|
||||
common/dev_disconnect.o \
|
||||
common/features.o \
|
||||
common/gen_status_wire.o \
|
||||
common/msg_queue.o \
|
||||
common/pseudorand.o \
|
||||
common/status.o \
|
||||
common/status_wire.o \
|
||||
common/subdaemon.o \
|
||||
common/timeout.o \
|
||||
common/type_to_string.o \
|
||||
common/utils.o \
|
||||
common/utxo.o \
|
||||
common/version.o \
|
||||
common/wireaddr.o \
|
||||
common/wire_error.o \
|
||||
gossipd/gen_gossip_wire.o \
|
||||
hsmd/client.o \
|
||||
hsmd/gen_hsm_client_wire.o \
|
||||
lightningd/gossip_msg.o \
|
||||
wire/gen_onion_wire.o
|
||||
|
||||
$(LIGHTNINGD_CONNECT_OBJS): $(LIGHTNINGD_HEADERS) $(LIGHTNINGD_CONNECT_HEADERS)
|
||||
|
||||
$(LIGHTNINGD_CONNECT_CONTROL_OBJS) : $(LIGHTNINGD_CONNECT_CONTROL_HEADERS)
|
||||
|
||||
connectd-all: lightningd/lightning_connectd
|
||||
|
||||
lightningd/lightning_connectd: $(LIGHTNINGD_CONNECT_OBJS) $(CONNECTD_COMMON_OBJS) $(BITCOIN_OBJS) $(WIRE_OBJS)
|
||||
|
||||
connectd/gen_connect_wire.h: $(WIRE_GEN) connectd/connect_wire.csv
|
||||
$(WIRE_GEN) --header $@ connect_wire_type < connectd/connect_wire.csv > $@
|
||||
|
||||
connectd/gen_connect_wire.c: $(WIRE_GEN) connectd/connect_wire.csv
|
||||
$(WIRE_GEN) ${@:.c=.h} connect_wire_type < connectd/connect_wire.csv > $@
|
||||
|
||||
connectd/gen_connect_gossip_wire.h: $(WIRE_GEN) connectd/connect_gossip_wire.csv
|
||||
$(WIRE_GEN) --header $@ connect_gossip_wire_type < connectd/connect_gossip_wire.csv > $@
|
||||
|
||||
connectd/gen_connect_gossip_wire.c: $(WIRE_GEN) connectd/connect_gossip_wire.csv
|
||||
$(WIRE_GEN) ${@:.c=.h} connect_gossip_wire_type < connectd/connect_gossip_wire.csv > $@
|
||||
|
||||
check-source: $(LIGHTNINGD_CONNECT_ALLSRC_NOGEN:%=check-src-include-order/%) $(LIGHTNINGD_CONNECT_ALLHEADERS_NOGEN:%=check-hdr-include-order/%)
|
||||
check-source-bolt: $(LIGHTNINGD_CONNECT_SRC:%=bolt-check/%) $(LIGHTNINGD_CONNECT_HEADERS:%=bolt-check/%)
|
||||
check-whitespace: $(LIGHTNINGD_CONNECT_ALLSRC_NOGEN:%=check-whitespace/%) $(LIGHTNINGD_CONNECT_ALLHEADERS_NOGEN:%=check-whitespace/%)
|
||||
|
||||
clean: connectd-clean
|
||||
|
||||
connectd-clean:
|
||||
$(RM) $(LIGHTNINGD_CONNECT_OBJS) connectd/gen_*
|
||||
|
||||
-include connectd/test/Makefile
|
1940
connectd/connect.c
Normal file
1940
connectd/connect.c
Normal file
File diff suppressed because it is too large
Load Diff
10
connectd/connect.h
Normal file
10
connectd/connect.h
Normal file
@ -0,0 +1,10 @@
|
||||
#ifndef LIGHTNING_CONNECTD_CONNECT_H
|
||||
#define LIGHTNING_CONNECTD_CONNECT_H
|
||||
#include "config.h"
|
||||
|
||||
struct io_conn;
|
||||
struct reaching;
|
||||
|
||||
struct io_plan *connection_out(struct io_conn *conn, struct reaching *reach);
|
||||
|
||||
#endif /* LIGHTNING_CONNECTD_CONNECT_H */
|
11
connectd/connect_gossip_wire.csv
Normal file
11
connectd/connect_gossip_wire.csv
Normal file
@ -0,0 +1,11 @@
|
||||
# Communication between gossipd and connectd.
|
||||
gossip_new_peer,4000
|
||||
gossip_new_peer,,id,struct pubkey
|
||||
# Did we negotiate LOCAL_GOSSIP_QUERIES?
|
||||
gossip_new_peer,,gossip_queries_feature,bool
|
||||
# Did they offer LOCAL_INITIAL_ROUTING_SYNC?
|
||||
gossip_new_peer,,initial_routing_sync,bool
|
||||
|
||||
# if success: + fd.
|
||||
gossip_new_peer_reply,4100
|
||||
gossip_new_peer_reply,,success,bool
|
|
3
connectd/connect_wire.csv
Normal file
3
connectd/connect_wire.csv
Normal file
@ -0,0 +1,3 @@
|
||||
# connectd->master: disconnect this peer please (due to reconnect).
|
||||
connect_reconnected,2112
|
||||
connect_reconnected,,id,struct pubkey
|
|
@ -96,6 +96,7 @@ static struct lightningd *new_lightningd(const tal_t *ctx)
|
||||
static const char *daemons[] = {
|
||||
"lightning_channeld",
|
||||
"lightning_closingd",
|
||||
"lightning_connectd",
|
||||
"lightning_gossipd",
|
||||
"lightning_hsmd",
|
||||
"lightning_onchaind",
|
||||
|
Loading…
Reference in New Issue
Block a user