Files
lightning/connectd/connectd_wire.csv
Rusty Russell f1ed373c97 connectd: be more graceful when we an address is in use.
Aditya had this issue due to a config line, and the result was hard
to diagnose even for me.

It's now:

```
$ ./lightningd/lightningd --network=regtest --addr=:18444
2022-02-26T05:01:28.705Z **BROKEN** connectd: Failed to bind socket for 0.0.0.0:18444: Address already in use
```

Whereas before it doesn't even give the address it's trying to bind:

```
rusty@rusty-XPS-13-9370:~/devel/cvs/lightning (master)$ ./lightningd/lightningd --network=regtest --addr=:18444
lightning_connectd: Failed to bind on 2 socket: Address already in use (version v0.10.2-331-g86b83e4)
0x558a8b8d9a12 send_backtrace
	common/daemon.c:33
0x558a8b8e91e1 status_failed
	common/status.c:221
0x558a8b8c8e4f make_listen_fd
	connectd/connectd.c:1090
0x558a8b8c8f55 handle_wireaddr_listen
	connectd/connectd.c:1129
0x558a8b8c993d setup_listeners
	connectd/connectd.c:1312
0x558a8b8ca344 connect_init
	connectd/connectd.c:1517
0x558a8b8cbb57 recv_req
	connectd/connectd.c:1896
0x558a8b8d9f9f handle_read
	common/daemon_conn.c:31
0x558a8b9247c1 next_plan
	ccan/ccan/io/io.c:59
0x558a8b9253c9 do_plan
	ccan/ccan/io/io.c:407
0x558a8b92540b io_ready
	ccan/ccan/io/io.c:417
0x558a8b9276fe io_loop
	ccan/ccan/io/poll.c:453
0x558a8b8cbf36 main
	connectd/connectd.c:2033
0x7fe4d02940b2 ???
	???:0
0x558a8b8c285d ???
	???:0
0xffffffffffffffff ???
	???:0
2022-02-26T05:02:27.547Z **BROKEN** connectd: Failed to bind on 2 socket: Address already in use (version v0.10.2-331-g86b83e4)
2022-02-26T05:02:27.547Z **BROKEN** connectd: backtrace: common/daemon.c:38 (send_backtrace) 0x558a8b8d9a68
2022-02-26T05:02:27.547Z **BROKEN** connectd: backtrace: common/status.c:221 (status_failed) 0x558a8b8e91e1
2022-02-26T05:02:27.547Z **BROKEN** connectd: backtrace: connectd/connectd.c:1090 (make_listen_fd) 0x558a8b8c8e4f
2022-02-26T05:02:27.548Z **BROKEN** connectd: backtrace: connectd/connectd.c:1129 (handle_wireaddr_listen) 0x558a8b8c8f55
2022-02-26T05:02:27.548Z **BROKEN** connectd: backtrace: connectd/connectd.c:1312 (setup_listeners) 0x558a8b8c993d
2022-02-26T05:02:27.548Z **BROKEN** connectd: backtrace: connectd/connectd.c:1517 (connect_init) 0x558a8b8ca344
2022-02-26T05:02:27.548Z **BROKEN** connectd: backtrace: connectd/connectd.c:1896 (recv_req) 0x558a8b8cbb57
2022-02-26T05:02:27.548Z **BROKEN** connectd: backtrace: common/daemon_conn.c:31 (handle_read) 0x558a8b8d9f9f
2022-02-26T05:02:27.548Z **BROKEN** connectd: backtrace: ccan/ccan/io/io.c:59 (next_plan) 0x558a8b9247c1
2022-02-26T05:02:27.548Z **BROKEN** connectd: backtrace: ccan/ccan/io/io.c:407 (do_plan) 0x558a8b9253c9
2022-02-26T05:02:27.548Z **BROKEN** connectd: backtrace: ccan/ccan/io/io.c:417 (io_ready) 0x558a8b92540b
2022-02-26T05:02:27.548Z **BROKEN** connectd: backtrace: ccan/ccan/io/poll.c:453 (io_loop) 0x558a8b9276fe
2022-02-26T05:02:27.548Z **BROKEN** connectd: backtrace: connectd/connectd.c:2033 (main) 0x558a8b8cbf36
2022-02-26T05:02:27.548Z **BROKEN** connectd: backtrace: (null):0 ((null)) 0x7fe4d02940b2
2022-02-26T05:02:27.548Z **BROKEN** connectd: backtrace: (null):0 ((null)) 0x558a8b8c285d
2022-02-26T05:02:27.548Z **BROKEN** connectd: backtrace: (null):0 ((null)) 0xffffffffffffffff
2022-02-26T05:02:27.548Z **BROKEN** connectd: STATUS_FAIL_INTERNAL_ERROR: Failed to bind on 2 socket: Address already in use
lightningd: connectd failed (exit status 242), exiting.
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2022-03-05 15:48:03 +10:30

5.1 KiB

1#include <bitcoin/block.h>
2#include <common/cryptomsg.h>
3#include <common/features.h>
4#include <common/node_id.h>
5#include <common/wireaddr.h>
6#include <wire/onion_wire.h>
7msgtype,connectd_init,2000
8msgdata,connectd_init,chainparams,chainparams,
9msgdata,connectd_init,our_features,feature_set,
10msgdata,connectd_init,id,node_id,
11msgdata,connectd_init,num_wireaddrs,u16,
12msgdata,connectd_init,wireaddrs,wireaddr_internal,num_wireaddrs
13msgdata,connectd_init,listen_announce,enum addr_listen_announce,num_wireaddrs
14msgdata,connectd_init,tor_proxyaddr,?wireaddr,
15msgdata,connectd_init,use_tor_proxy_always,bool,
16msgdata,connectd_init,dev_allow_localhost,bool,
17msgdata,connectd_init,use_dns,bool,
18msgdata,connectd_init,tor_password,wirestring,
19msgdata,connectd_init,use_v3_autotor,bool,
20msgdata,connectd_init,timeout_secs,u32,
21msgdata,connectd_init,websocket_helper,wirestring,
22msgdata,connectd_init,websocket_port,u16,
23msgdata,connectd_init,dev_fast_gossip,bool,
24# If this is set, then fd 5 is dev_disconnect_fd.
25msgdata,connectd_init,dev_disconnect,bool,
26# Connectd->master, here are the addresses I bound, can announce.
27msgtype,connectd_init_reply,2100
28msgdata,connectd_init_reply,num_bindings,u16,
29msgdata,connectd_init_reply,bindings,wireaddr_internal,num_bindings
30msgdata,connectd_init_reply,num_announcable,u16,
31msgdata,connectd_init_reply,announcable,wireaddr,num_announcable
32msgdata,connectd_init_reply,failmsg,?wirestring,
33# Activate the connect daemon, so others can connect.
34msgtype,connectd_activate,2025
35# Do we listen?
36msgdata,connectd_activate,listen,bool,
37# Connectd->master, I am ready.
38msgtype,connectd_activate_reply,2125
39# connectd->master: disconnect this peer please (due to reconnect).
40msgtype,connectd_reconnected,2112
41msgdata,connectd_reconnected,id,node_id,
42# Master -> connectd: connect to a peer.
43msgtype,connectd_connect_to_peer,2001
44msgdata,connectd_connect_to_peer,id,node_id,
45msgdata,connectd_connect_to_peer,seconds_waited,u32,
46msgdata,connectd_connect_to_peer,len,u32,
47msgdata,connectd_connect_to_peer,addrs,wireaddr,len
48msgdata,connectd_connect_to_peer,addrhint,?wireaddr_internal,
49# Connectd->master: connect failed.
50msgtype,connectd_connect_failed,2020
51msgdata,connectd_connect_failed,id,node_id,
52msgdata,connectd_connect_failed,failcode,errcode_t,
53msgdata,connectd_connect_failed,failreason,wirestring,
54msgdata,connectd_connect_failed,seconds_to_delay,u32,
55msgdata,connectd_connect_failed,addrhint,?wireaddr_internal,
56# Connectd -> master: we got a peer. Plus fd for peer daemon
57msgtype,connectd_peer_connected,2002
58msgdata,connectd_peer_connected,id,node_id,
59msgdata,connectd_peer_connected,addr,wireaddr_internal,
60msgdata,connectd_peer_connected,remote_addr,?wireaddr,
61msgdata,connectd_peer_connected,incoming,bool,
62msgdata,connectd_peer_connected,flen,u16,
63msgdata,connectd_peer_connected,features,u8,flen
64# master -> connectd: peer has disconnected.
65msgtype,connectd_peer_disconnected,2015
66msgdata,connectd_peer_disconnected,id,node_id,
67# master -> connectd: give message to peer and disconnect.
68msgtype,connectd_peer_final_msg,2003
69msgdata,connectd_peer_final_msg,id,node_id,
70msgdata,connectd_peer_final_msg,len,u16,
71msgdata,connectd_peer_final_msg,msg,u8,len
72# master -> connectd: do you have a memleak?
73msgtype,connectd_dev_memleak,2033
74msgtype,connectd_dev_memleak_reply,2133
75msgdata,connectd_dev_memleak_reply,leak,bool,
76# Ping/pong test. Waits for a reply if it expects one.
77msgtype,connectd_ping,2030
78msgdata,connectd_ping,id,node_id,
79msgdata,connectd_ping,num_pong_bytes,u16,
80msgdata,connectd_ping,len,u16,
81msgtype,connectd_ping_reply,2130
82# False if we there was already a ping in progress.
83msgdata,connectd_ping_reply,sent,bool,
84# 0 == no pong expected, otherwise length of pong.
85msgdata,connectd_ping_reply,totlen,u16,
86# We tell lightningd we got an onionmsg
87msgtype,connectd_got_onionmsg_to_us,2145
88msgdata,connectd_got_onionmsg_to_us,obs2,bool,
89msgdata,connectd_got_onionmsg_to_us,node_alias,pubkey,
90msgdata,connectd_got_onionmsg_to_us,self_id,?secret,
91msgdata,connectd_got_onionmsg_to_us,reply_blinding,?pubkey,
92msgdata,connectd_got_onionmsg_to_us,reply_first_node,?pubkey,
93msgdata,connectd_got_onionmsg_to_us,reply_path_len,u16,
94msgdata,connectd_got_onionmsg_to_us,reply_path,onionmsg_path,reply_path_len
95msgdata,connectd_got_onionmsg_to_us,rawmsg_len,u16,
96msgdata,connectd_got_onionmsg_to_us,rawmsg,u8,rawmsg_len
97# Lightningd tells us to send an onion message.
98msgtype,connectd_send_onionmsg,2041
99msgdata,connectd_send_onionmsg,obs2,bool,
100msgdata,connectd_send_onionmsg,id,node_id,
101msgdata,connectd_send_onionmsg,onion_len,u16,
102msgdata,connectd_send_onionmsg,onion,u8,onion_len
103msgdata,connectd_send_onionmsg,blinding,pubkey,
104# A custom message that we got from a peer and don't know how to handle, so we
105# forward it to the master for further handling.
106msgtype,connectd_custommsg_in,2110
107msgdata,connectd_custommsg_in,id,node_id,
108msgdata,connectd_custommsg_in,msg_len,u16,
109msgdata,connectd_custommsg_in,msg,u8,msg_len
110# A custom message that the lightningd tells us to send to the peer.
111msgtype,connectd_custommsg_out,2011
112msgdata,connectd_custommsg_out,id,node_id,
113msgdata,connectd_custommsg_out,msg_len,u16,
114msgdata,connectd_custommsg_out,msg,u8,msg_len