Skip to content

Commit

Permalink
Makefile: update to include fix for remote_addr generation.
Browse files Browse the repository at this point in the history
Now it's formatted properly, we don't need the patch.

But we need to explicitly marshal/unmarshal into a byte stream,
which involves some code rearrangement.

Signed-off-by: Rusty Russell <[email protected]>
  • Loading branch information
rustyrussell committed May 19, 2022
1 parent 685fa25 commit abd01a1
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 34 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ CCANDIR := ccan

# Where we keep the BOLT RFCs
BOLTDIR := ../bolts/
DEFAULT_BOLTVERSION := c4a0369e705ad43babee50dd0466f162567e6427
DEFAULT_BOLTVERSION := 105c2e5e9f17c68e8c19dc4ca548600a0b8f66f0
# Can be overridden on cmdline.
BOLTVERSION := $(DEFAULT_BOLTVERSION)

Expand Down
46 changes: 27 additions & 19 deletions connectd/peer_exchange_initmsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,29 +91,37 @@ static struct io_plan *peer_init_received(struct io_conn *conn,
/* fetch optional tlv `remote_addr` */
remote_addr = NULL;

/* BOLT-remote-address #1:
/* BOLT #1:
* The receiving node:
* ...
* - MAY use the `remote_addr` to update its `node_annoucement`
* - MAY use the `remote_addr` to update its `node_announcement`
*/
if (tlvs->remote_addr) {
switch (tlvs->remote_addr->type) {
case ADDR_TYPE_IPV4:
case ADDR_TYPE_IPV6:
const u8 *cursor = tlvs->remote_addr;
size_t len = tal_bytelen(tlvs->remote_addr);

remote_addr = tal(peer, struct wireaddr);
if (fromwire_wireaddr(&cursor, &len, remote_addr)) {
switch (remote_addr->type) {
case ADDR_TYPE_IPV4:
case ADDR_TYPE_IPV6:
#if DEVELOPER /* ignore private addresses (non-DEVELOPER builds) */
if (address_routable(tlvs->remote_addr, true))
if (!address_routable(remote_addr, true))
#else
if (address_routable(tlvs->remote_addr, false))
if (!address_routable(remote_addr, false))
#endif /* DEVELOPER */
remote_addr = tal_steal(peer, tlvs->remote_addr);
break;
/* We are only interested in IP addresses */
case ADDR_TYPE_TOR_V2_REMOVED:
case ADDR_TYPE_TOR_V3:
case ADDR_TYPE_DNS:
case ADDR_TYPE_WEBSOCKET:
break;
}
remote_addr = tal_free(remote_addr);
break;
/* We are only interested in IP addresses */
case ADDR_TYPE_TOR_V2_REMOVED:
case ADDR_TYPE_TOR_V3:
case ADDR_TYPE_DNS:
case ADDR_TYPE_WEBSOCKET:
remote_addr = tal_free(remote_addr);
break;
}
} else
remote_addr = tal_free(remote_addr);
}

/* The globalfeatures field is now unused, but there was a
Expand Down Expand Up @@ -217,7 +225,7 @@ struct io_plan *peer_exchange_initmsg(struct io_conn *conn,
/* set optional tlv `remote_addr` on incoming IP connections */
tlvs->remote_addr = NULL;

/* BOLT-remote-address #1:
/* BOLT #1:
* The sending node:
* ...
* - SHOULD set `remote_addr` to reflect the remote IP address (and port) of an
Expand All @@ -229,8 +237,8 @@ struct io_plan *peer_exchange_initmsg(struct io_conn *conn,
switch (addr->u.wireaddr.type) {
case ADDR_TYPE_IPV4:
case ADDR_TYPE_IPV6:
tlvs->remote_addr = tal(tlvs, struct wireaddr);
*tlvs->remote_addr = addr->u.wireaddr;
tlvs->remote_addr = tal_arr(tlvs, u8, 0);
towire_wireaddr(&tlvs->remote_addr, &addr->u.wireaddr);
break;
/* Only report IP addresses back for now */
case ADDR_TYPE_TOR_V2_REMOVED:
Expand Down
13 changes: 0 additions & 13 deletions wire/extracted_peer_01_remote_addr.patch

This file was deleted.

2 changes: 1 addition & 1 deletion wire/peer_wire.csv
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgdata,init,tlvs,init_tlvs,
tlvtype,init_tlvs,networks,1
tlvdata,init_tlvs,networks,chains,chain_hash,...
tlvtype,init_tlvs,remote_addr,3
tlvdata,init_tlvs,remote_addr,remote_addr,wireaddr,
tlvdata,init_tlvs,remote_addr,data,byte,...
msgtype,error,17
msgdata,error,channel_id,channel_id,
msgdata,error,len,u16,
Expand Down

0 comments on commit abd01a1

Please sign in to comment.