~ Nodes (can) advertize one or more addresses in their node_announcement: * these are lower priority than ones explicitly supplied to the `connect` * command, though. */
| 181 | * these are lower priority than ones explicitly supplied to the `connect` |
| 182 | * command, though. */ |
| 183 | static void append_gossmap_addresses(struct wireaddr_internal **wireaddrs, |
| 184 | struct daemon *daemon, |
| 185 | const struct node_id *node_id) |
| 186 | { |
| 187 | struct gossmap_node *node; |
| 188 | u8 *nannounce; |
| 189 | struct node_id id; |
| 190 | secp256k1_ecdsa_signature signature; |
| 191 | u32 timestamp; |
| 192 | u8 *addresses, *features; |
| 193 | u8 rgb_color[3], alias[32]; |
| 194 | struct tlv_node_ann_tlvs *na_tlvs; |
| 195 | struct wireaddr *alladdrs, *addrs[3]; |
| 196 | struct gossmap *gossmap = get_gossmap(daemon); |
| 197 | |
| 198 | node = gossmap_find_node(gossmap, node_id); |
| 199 | if (!node) |
| 200 | return; |
| 201 | |
| 202 | nannounce = gossmap_node_get_announce(tmpctx, gossmap, |
| 203 | node); |
| 204 | if (!nannounce) |
| 205 | return; |
| 206 | |
| 207 | if (!fromwire_node_announcement(tmpctx, nannounce, |
| 208 | &signature, &features, |
| 209 | ×tamp, |
| 210 | &id, rgb_color, alias, |
| 211 | &addresses, |
| 212 | &na_tlvs)) { |
| 213 | status_broken("Bad node_announcement for %s in gossip_store: %s", |
| 214 | fmt_node_id(tmpctx, node_id), |
| 215 | tal_hex(tmpctx, nannounce)); |
| 216 | return; |
| 217 | } |
| 218 | |
| 219 | alladdrs = fromwire_wireaddr_array(tmpctx, addresses); |
| 220 | if (!alladdrs) { |
| 221 | status_broken("Bad wireaddrs in node_announcement in gossip_store: %s", |
| 222 | tal_hex(tmpctx, nannounce)); |
| 223 | return; |
| 224 | } |
| 225 | |
| 226 | /* Orders the gossip addresses. |
| 227 | * |
| 228 | * Ignore deprecated protocols. Adds all IPv6 addresses, followed by |
| 229 | * IPv4 and then TOR. This ensures we are modern and use IPv6 when |
| 230 | * possible, falling back to direct (faster) IPv4 and finally (less |
| 231 | * stable) TOR connections. */ |
| 232 | for (size_t i = 0; i < ARRAY_SIZE(addrs); i++) |
| 233 | addrs[i] = tal_arr(tmpctx, struct wireaddr, 0); |
| 234 | |
| 235 | for (size_t i = 0; i < tal_count(alladdrs); i++) { |
| 236 | /* A switch, so compiler tells you to update it if we |
| 237 | * add a new type! */ |
| 238 | switch (alladdrs[i].type) { |
| 239 | case ADDR_TYPE_IPV6: |
| 240 | case ADDR_TYPE_DNS: |
no test coverage detected