mirror of
https://github.com/aljazceru/lightning.git
synced 2026-01-08 16:44:22 +01:00
We would return success from connect even though the peer was closing; this is technically correct but fairly undesirable. Better is to pass every connect attempt to connectd, and have it block if the peer is exiting (and retry), otherwise tell us it's already connected. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
5.3 KiB
5.3 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> |
| 7 | msgtype,connectd_init,2000 |
| 8 | msgdata,connectd_init,chainparams,chainparams, |
| 9 | msgdata,connectd_init,our_features,feature_set, |
| 10 | msgdata,connectd_init,id,node_id, |
| 11 | msgdata,connectd_init,num_wireaddrs,u16, |
| 12 | msgdata,connectd_init,wireaddrs,wireaddr_internal,num_wireaddrs |
| 13 | msgdata,connectd_init,listen_announce,enum addr_listen_announce,num_wireaddrs |
| 14 | msgdata,connectd_init,tor_proxyaddr,?wireaddr, |
| 15 | msgdata,connectd_init,use_tor_proxy_always,bool, |
| 16 | msgdata,connectd_init,dev_allow_localhost,bool, |
| 17 | msgdata,connectd_init,use_dns,bool, |
| 18 | msgdata,connectd_init,tor_password,wirestring, |
| 19 | msgdata,connectd_init,use_v3_autotor,bool, |
| 20 | msgdata,connectd_init,timeout_secs,u32, |
| 21 | msgdata,connectd_init,websocket_helper,wirestring, |
| 22 | msgdata,connectd_init,websocket_port,u16, |
| 23 | msgdata,connectd_init,dev_fast_gossip,bool, |
| 24 | # If this is set, then fd 5 is dev_disconnect_fd. |
| 25 | msgdata,connectd_init,dev_disconnect,bool, |
| 26 | # Connectd->master, here are the addresses I bound, can announce. |
| 27 | msgtype,connectd_init_reply,2100 |
| 28 | msgdata,connectd_init_reply,num_bindings,u16, |
| 29 | msgdata,connectd_init_reply,bindings,wireaddr_internal,num_bindings |
| 30 | msgdata,connectd_init_reply,num_announceable,u16, |
| 31 | msgdata,connectd_init_reply,announceable,wireaddr,num_announceable |
| 32 | msgdata,connectd_init_reply,failmsg,?wirestring, |
| 33 | # Activate the connect daemon, so others can connect. |
| 34 | msgtype,connectd_activate,2025 |
| 35 | # Do we listen? |
| 36 | msgdata,connectd_activate,listen,bool, |
| 37 | # Connectd->master, I am ready. |
| 38 | msgtype,connectd_activate_reply,2125 |
| 39 | msgdata,connectd_activate_reply,failmsg,?wirestring, |
| 40 | # connectd->master: disconnect this peer please (due to reconnect). |
| 41 | msgtype,connectd_reconnected,2112 |
| 42 | msgdata,connectd_reconnected,id,node_id, |
| 43 | # Master -> connectd: connect to a peer. |
| 44 | msgtype,connectd_connect_to_peer,2001 |
| 45 | msgdata,connectd_connect_to_peer,id,node_id, |
| 46 | msgdata,connectd_connect_to_peer,seconds_waited,u32, |
| 47 | msgdata,connectd_connect_to_peer,len,u32, |
| 48 | msgdata,connectd_connect_to_peer,addrs,wireaddr,len |
| 49 | msgdata,connectd_connect_to_peer,addrhint,?wireaddr_internal, |
| 50 | # Connectd->master: connect failed. |
| 51 | msgtype,connectd_connect_failed,2020 |
| 52 | msgdata,connectd_connect_failed,id,node_id, |
| 53 | msgdata,connectd_connect_failed,failcode,errcode_t, |
| 54 | msgdata,connectd_connect_failed,failreason,wirestring, |
| 55 | msgdata,connectd_connect_failed,seconds_to_delay,u32, |
| 56 | msgdata,connectd_connect_failed,addrhint,?wireaddr_internal, |
| 57 | # Connectd -> master: we got a peer. Plus fd for peer daemon |
| 58 | msgtype,connectd_peer_connected,2002 |
| 59 | msgdata,connectd_peer_connected,id,node_id, |
| 60 | msgdata,connectd_peer_connected,addr,wireaddr_internal, |
| 61 | msgdata,connectd_peer_connected,remote_addr,?wireaddr, |
| 62 | msgdata,connectd_peer_connected,incoming,bool, |
| 63 | msgdata,connectd_peer_connected,flen,u16, |
| 64 | msgdata,connectd_peer_connected,features,u8,flen |
| 65 | # master -> connectd: peer no longer wanted, you can disconnect. |
| 66 | msgtype,connectd_discard_peer,2015 |
| 67 | msgdata,connectd_discard_peer,id,node_id, |
| 68 | # master -> connectd: give message to peer and disconnect. |
| 69 | msgtype,connectd_peer_final_msg,2003 |
| 70 | msgdata,connectd_peer_final_msg,id,node_id, |
| 71 | msgdata,connectd_peer_final_msg,len,u16, |
| 72 | msgdata,connectd_peer_final_msg,msg,u8,len |
| 73 | # connectd->master: You said to connect, but we already were. |
| 74 | msgtype,connectd_peer_already_connected,2007 |
| 75 | msgdata,connectd_peer_already_connected,id,node_id, |
| 76 | # master -> connectd: do you have a memleak? |
| 77 | msgtype,connectd_dev_memleak,2033 |
| 78 | msgtype,connectd_dev_memleak_reply,2133 |
| 79 | msgdata,connectd_dev_memleak_reply,leak,bool, |
| 80 | # Ping/pong test. Waits for a reply if it expects one. |
| 81 | msgtype,connectd_ping,2030 |
| 82 | msgdata,connectd_ping,id,node_id, |
| 83 | msgdata,connectd_ping,num_pong_bytes,u16, |
| 84 | msgdata,connectd_ping,len,u16, |
| 85 | msgtype,connectd_ping_reply,2130 |
| 86 | # False if we there was already a ping in progress. |
| 87 | msgdata,connectd_ping_reply,sent,bool, |
| 88 | # 0 == no pong expected, otherwise length of pong. |
| 89 | msgdata,connectd_ping_reply,totlen,u16, |
| 90 | # We tell lightningd we got an onionmsg |
| 91 | msgtype,connectd_got_onionmsg_to_us,2145 |
| 92 | msgdata,connectd_got_onionmsg_to_us,obs2,bool, |
| 93 | msgdata,connectd_got_onionmsg_to_us,node_alias,pubkey, |
| 94 | msgdata,connectd_got_onionmsg_to_us,self_id,?secret, |
| 95 | msgdata,connectd_got_onionmsg_to_us,reply_blinding,?pubkey, |
| 96 | msgdata,connectd_got_onionmsg_to_us,reply_first_node,?pubkey, |
| 97 | msgdata,connectd_got_onionmsg_to_us,reply_path_len,u16, |
| 98 | msgdata,connectd_got_onionmsg_to_us,reply_path,onionmsg_path,reply_path_len |
| 99 | msgdata,connectd_got_onionmsg_to_us,rawmsg_len,u16, |
| 100 | msgdata,connectd_got_onionmsg_to_us,rawmsg,u8,rawmsg_len |
| 101 | # Lightningd tells us to send an onion message. |
| 102 | msgtype,connectd_send_onionmsg,2041 |
| 103 | msgdata,connectd_send_onionmsg,obs2,bool, |
| 104 | msgdata,connectd_send_onionmsg,id,node_id, |
| 105 | msgdata,connectd_send_onionmsg,onion_len,u16, |
| 106 | msgdata,connectd_send_onionmsg,onion,u8,onion_len |
| 107 | msgdata,connectd_send_onionmsg,blinding,pubkey, |
| 108 | # A custom message that we got from a peer and don't know how to handle, so we |
| 109 | # forward it to the master for further handling. |
| 110 | msgtype,connectd_custommsg_in,2110 |
| 111 | msgdata,connectd_custommsg_in,id,node_id, |
| 112 | msgdata,connectd_custommsg_in,msg_len,u16, |
| 113 | msgdata,connectd_custommsg_in,msg,u8,msg_len |
| 114 | # A custom message that the lightningd tells us to send to the peer. |
| 115 | msgtype,connectd_custommsg_out,2011 |
| 116 | msgdata,connectd_custommsg_out,id,node_id, |
| 117 | msgdata,connectd_custommsg_out,msg_len,u16, |
| 118 | msgdata,connectd_custommsg_out,msg,u8,msg_len |