diff --git a/Makefile b/Makefile index c6345fc4ee2d..ba8e5d8504f5 100644 --- a/Makefile +++ b/Makefile @@ -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) diff --git a/connectd/peer_exchange_initmsg.c b/connectd/peer_exchange_initmsg.c index eea73188a52c..f43b66164825 100644 --- a/connectd/peer_exchange_initmsg.c +++ b/connectd/peer_exchange_initmsg.c @@ -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 @@ -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 @@ -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: diff --git a/wire/extracted_peer_01_remote_addr.patch b/wire/extracted_peer_01_remote_addr.patch deleted file mode 100644 index 5e9aeb46348e..000000000000 --- a/wire/extracted_peer_01_remote_addr.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/wire/peer_wire.csv b/wire/peer_wire.csv -index a028ddc66..4043c6350 100644 ---- a/wire/peer_wire.csv -+++ b/wire/peer_wire.csv -@@ -6,6 +6,8 @@ msgdata,init,features,byte,flen - 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, - msgtype,error,17 - msgdata,error,channel_id,channel_id, - msgdata,error,len,u16, diff --git a/wire/peer_wire.csv b/wire/peer_wire.csv index a028ddc66d92..497d43b52fe8 100644 --- a/wire/peer_wire.csv +++ b/wire/peer_wire.csv @@ -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,