mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-20 02:27:51 +01:00
fe96fe10c7
It's become clear that our network options are insufficient, with the coming addition of Tor and unix domain support. Currently: 1. We always bind to local IPv4 and IPv6 sockets, unless --port=0, --offline, or any address is specified explicitly. If they're routable, we announce. 2. --addr is used to announce, but not to control binding. After this change: 1. --port is deprecated. 2. --addr controls what we bind to and announce. 3. --bind-addr/--announce-addr can be used to control one and not the other. 4. Unless --autolisten=0, we add local IPv4 & IPv6 port 9735 (and announce if they are routable). 5. --offline still overrides listening (though announcing is still the same). This means we can bind to as many ports/interfaces as we want, and for special effects we can announce different things (eg. we're sitting behind a port forward or a proxy). What remains to implement is semi-automatic binding: we should be able to say '--addr=0.0.0.0:9999' and have the address resolve at bind time, or even '--addr=0.0.0.0:0' and have the port autoresolve too (you could determine what it was from 'lightning-cli getinfo'. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8.4 KiB
8.4 KiB
1 | #include <common/cryptomsg.h> |
---|---|
2 | #include <common/wireaddr.h> |
3 | #include <wire/gen_onion_wire.h> |
4 | # Initialize the gossip daemon. |
5 | gossipctl_init,3000 |
6 | gossipctl_init,,broadcast_interval,u32 |
7 | gossipctl_init,,chain_hash,struct bitcoin_blkid |
8 | gossipctl_init,,id,struct pubkey |
9 | gossipctl_init,,gflen,u16 |
10 | gossipctl_init,,gfeatures,gflen*u8 |
11 | gossipctl_init,,lflen,u16 |
12 | gossipctl_init,,lfeatures,lflen*u8 |
13 | gossipctl_init,,num_wireaddrs,u16 |
14 | gossipctl_init,,wireaddrs,num_wireaddrs*struct wireaddr |
15 | gossipctl_init,,listen_announce,num_wireaddrs*enum addr_listen_announce |
16 | gossipctl_init,,rgb,3*u8 |
17 | gossipctl_init,,alias,32*u8 |
18 | gossipctl_init,,update_channel_interval,u32 |
19 | gossipctl_init,,reconnect,bool |
20 | # Activate the gossip daemon, so others can connect. |
21 | gossipctl_activate,3025 |
22 | # Do we listen? |
23 | gossipctl_activate,,listen,bool |
24 | # Gossipd->master, I am ready. |
25 | gossipctl_activate_reply,3125 |
26 | # Master -> gossipd: Optional hint for where to find peer. |
27 | gossipctl_peer_addrhint,3014 |
28 | gossipctl_peer_addrhint,,id,struct pubkey |
29 | gossipctl_peer_addrhint,,addr,struct wireaddr |
30 | # Master -> gossipd: connect to a peer. |
31 | gossipctl_connect_to_peer,3001 |
32 | gossipctl_connect_to_peer,,id,struct pubkey |
33 | # Gossipd->master: result (not a reply since it can be out-of-order, but |
34 | # you will get one reply for every request). |
35 | gossipctl_connect_to_peer_result,3020 |
36 | gossipctl_connect_to_peer_result,,id,struct pubkey |
37 | # True it connected. |
38 | gossipctl_connect_to_peer_result,,connected,bool |
39 | # Otherwise, why we can't reach them. |
40 | gossipctl_connect_to_peer_result,,failreason,wirestring |
41 | # Master -> gossipd: try to always maintain connection to this peer (or not) |
42 | gossipctl_peer_important,3010 |
43 | gossipctl_peer_important,,id,struct pubkey |
44 | gossipctl_peer_important,,important,bool |
45 | # Gossipd -> master: we got a peer. Two fds: peer and gossip |
46 | gossip_peer_connected,3002 |
47 | gossip_peer_connected,,id,struct pubkey |
48 | gossip_peer_connected,,addr,struct wireaddr |
49 | gossip_peer_connected,,crypto_state,struct crypto_state |
50 | gossip_peer_connected,,gflen,u16 |
51 | gossip_peer_connected,,gfeatures,gflen*u8 |
52 | gossip_peer_connected,,lflen,u16 |
53 | gossip_peer_connected,,lfeatures,lflen*u8 |
54 | # Gossipd -> master: peer sent non-gossip packet. Two fds: peer and gossip |
55 | gossip_peer_nongossip,3003 |
56 | gossip_peer_nongossip,,id,struct pubkey |
57 | gossip_peer_nongossip,,addr,struct wireaddr |
58 | gossip_peer_nongossip,,crypto_state,struct crypto_state |
59 | gossip_peer_nongossip,,gflen,u16 |
60 | gossip_peer_nongossip,,gfeatures,gflen*u8 |
61 | gossip_peer_nongossip,,lflen,u16 |
62 | gossip_peer_nongossip,,lfeatures,lflen*u8 |
63 | gossip_peer_nongossip,,len,u16 |
64 | gossip_peer_nongossip,,msg,len*u8 |
65 | # Master -> gossipd: release a peer (so we can open a channel) |
66 | gossipctl_release_peer,3004 |
67 | gossipctl_release_peer,,id,struct pubkey |
68 | # Gossipd -> master: reply to gossip_release_peer. Two fds: peer and gossip. |
69 | gossipctl_release_peer_reply,3104 |
70 | gossipctl_release_peer_reply,,addr,struct wireaddr |
71 | gossipctl_release_peer_reply,,crypto_state,struct crypto_state |
72 | gossipctl_release_peer_reply,,gflen,u16 |
73 | gossipctl_release_peer_reply,,gfeatures,gflen*u8 |
74 | gossipctl_release_peer_reply,,lflen,u16 |
75 | gossipctl_release_peer_reply,,lfeatures,lflen*u8 |
76 | # Gossipd -> master: reply to gossip_release_peer if we couldn't find the peer. |
77 | gossipctl_release_peer_replyfail,3204 |
78 | # master -> gossipd: take back peer, with optional msg. (+peer fd, +gossip fd) |
79 | gossipctl_hand_back_peer,3013 |
80 | gossipctl_hand_back_peer,,id,struct pubkey |
81 | gossipctl_hand_back_peer,,crypto_state,struct crypto_state |
82 | gossipctl_hand_back_peer,,len,u16 |
83 | gossipctl_hand_back_peer,,msg,len*u8 |
84 | # master -> gossipd: peer has disconnected. |
85 | gossipctl_peer_disconnected,3015 |
86 | gossipctl_peer_disconnected,,id,struct pubkey |
87 | # Pass JSON-RPC getnodes call through |
88 | gossip_getnodes_request,3005 |
89 | # Can be 0 or 1 currently |
90 | gossip_getnodes_request,,num,u16 |
91 | gossip_getnodes_request,,id,num*struct pubkey |
92 | #include <lightningd/gossip_msg.h> |
93 | gossip_getnodes_reply,3105 |
94 | gossip_getnodes_reply,,num_nodes,u16 |
95 | gossip_getnodes_reply,,nodes,num_nodes*struct gossip_getnodes_entry |
96 | # Pass JSON-RPC getroute call through |
97 | gossip_getroute_request,3006 |
98 | gossip_getroute_request,,source,struct pubkey |
99 | gossip_getroute_request,,destination,struct pubkey |
100 | gossip_getroute_request,,msatoshi,u64 |
101 | gossip_getroute_request,,riskfactor,u16 |
102 | gossip_getroute_request,,final_cltv,u32 |
103 | gossip_getroute_request,,fuzz,double |
104 | gossip_getroute_request,,seed,struct siphash_seed |
105 | gossip_getroute_reply,3106 |
106 | gossip_getroute_reply,,num_hops,u16 |
107 | gossip_getroute_reply,,hops,num_hops*struct route_hop |
108 | gossip_getchannels_request,3007 |
109 | # In practice, 0 or 1. |
110 | gossip_getchannels_request,,num,u16 |
111 | gossip_getchannels_request,,short_channel_id,num*struct short_channel_id |
112 | gossip_getchannels_reply,3107 |
113 | gossip_getchannels_reply,,num_channels,u16 |
114 | gossip_getchannels_reply,,nodes,num_channels*struct gossip_getchannels_entry |
115 | # Ping/pong test. Waits for a reply if it expects one. |
116 | gossip_ping,3008 |
117 | gossip_ping,,id,struct pubkey |
118 | gossip_ping,,num_pong_bytes,u16 |
119 | gossip_ping,,len,u16 |
120 | gossip_ping_reply,3108 |
121 | # False if id in gossip_ping was unknown. |
122 | gossip_ping_reply,,sent,bool |
123 | # 0 == no pong expected |
124 | gossip_ping_reply,,totlen,u16 |
125 | # Given a short_channel_id, return the endpoints |
126 | gossip_resolve_channel_request,3009 |
127 | gossip_resolve_channel_request,,channel_id,struct short_channel_id |
128 | gossip_resolve_channel_reply,3109 |
129 | gossip_resolve_channel_reply,,num_keys,u16 |
130 | gossip_resolve_channel_reply,,keys,num_keys*struct pubkey |
131 | # The main daemon asks for peers |
132 | gossip_getpeers_request,3011 |
133 | # 0 or 1 |
134 | gossip_getpeers_request,,num,u16 |
135 | gossip_getpeers_request,,id,num*struct pubkey |
136 | gossip_getpeers_reply,3111 |
137 | gossip_getpeers_reply,,num,u16 |
138 | gossip_getpeers_reply,,id,num*struct pubkey |
139 | gossip_getpeers_reply,,addr,num*struct wireaddr |
140 | gossip_getpeers_reply,,numnodes,u16 |
141 | gossip_getpeers_reply,,nodes,numnodes*struct gossip_getnodes_entry |
142 | # Channel daemon can ask for updates for a specific channel, for sending |
143 | # errors. Must be distinct from WIRE_CHANNEL_ANNOUNCEMENT etc. gossip msgs! |
144 | gossip_get_update,3012 |
145 | gossip_get_update,,short_channel_id,struct short_channel_id |
146 | # If channel isn't known, update will be empty. |
147 | gossip_get_update_reply,3112 |
148 | gossip_get_update_reply,,len,u16 |
149 | gossip_get_update_reply,,update,len*u8 |
150 | # Gossipd can tell channeld etc about gossip to fwd. |
151 | gossip_send_gossip,3016 |
152 | gossip_send_gossip,,len,u16 |
153 | gossip_send_gossip,,gossip,len*u8 |
154 | # Both sides have seen the funding tx being locked, but we have not |
155 | # yet reached the announcement depth. So we add the channel locally so |
156 | # we can use it already. |
157 | gossip_local_add_channel,3017 |
158 | gossip_local_add_channel,,short_channel_id,struct short_channel_id |
159 | gossip_local_add_channel,,chain_hash,struct bitcoin_blkid |
160 | gossip_local_add_channel,,remote_node_id,struct pubkey |
161 | gossip_local_add_channel,,cltv_expiry_delta,u16 |
162 | gossip_local_add_channel,,htlc_minimum_msat,u64 |
163 | gossip_local_add_channel,,fee_base_msat,u32 |
164 | gossip_local_add_channel,,fee_proportional_millionths,u32 |
165 | # Gossipd->master get this tx output please. |
166 | gossip_get_txout,3018 |
167 | gossip_get_txout,,short_channel_id,struct short_channel_id |
168 | # master->gossipd here is the output, or empty if none. |
169 | gossip_get_txout_reply,3118 |
170 | gossip_get_txout_reply,,short_channel_id,struct short_channel_id |
171 | gossip_get_txout_reply,,satoshis,u64 |
172 | gossip_get_txout_reply,,len,u16 |
173 | gossip_get_txout_reply,,outscript,len*u8 |
174 | # client->gossipd: Disable the channel matching the short_channel_id |
175 | gossip_disable_channel,3019 |
176 | gossip_disable_channel,,short_channel_id,struct short_channel_id |
177 | gossip_disable_channel,,direction,u8 |
178 | gossip_disable_channel,,active,bool |
179 | # master->gossipd a routing failure occurred |
180 | gossip_routing_failure,3021 |
181 | gossip_routing_failure,,erring_node,struct pubkey |
182 | gossip_routing_failure,,erring_channel,struct short_channel_id |
183 | gossip_routing_failure,,failcode,u16 |
184 | gossip_routing_failure,,len,u16 |
185 | gossip_routing_failure,,channel_update,len*u8 |
186 | # master->gossipd temporarily mark a channel unroutable |
187 | # (used in case of unparseable onion reply) |
188 | gossip_mark_channel_unroutable,3022 |
189 | gossip_mark_channel_unroutable,,channel,struct short_channel_id |
190 | # master->gossipd: Request to disconnect from a peer. |
191 | gossipctl_peer_disconnect,3023 |
192 | gossipctl_peer_disconnect,,id,struct pubkey |
193 | # Gossipd -> master: reply to gossip_peer_disconnect with peer id. |
194 | gossipctl_peer_disconnect_reply,3123 |
195 | # Gossipd -> master: reply to gossip_peer_disconnect if we couldn't find the peer. |
196 | gossipctl_peer_disconnect_replyfail,3223 |
197 | gossipctl_peer_disconnect_replyfail,,isconnected,bool |
198 | # master -> gossipd: a potential funding outpoint was spent, please forget the eventual channel |
199 | gossip_outpoint_spent,3024 |
200 | gossip_outpoint_spent,,short_channel_id,struct short_channel_id |