-
Notifications
You must be signed in to change notification settings - Fork 946
introduce support for alternative addresses for peer connections #7422
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
8cd3547
183ca77
5a9c205
e43ab91
1be20b5
14b873d
9b5a55d
3f8bd91
6be03fc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,6 +66,9 @@ struct peer { | |
bool channel_ready[NUM_SIDES]; | ||
u64 next_index[NUM_SIDES]; | ||
|
||
/* ID of peer */ | ||
struct node_id id; | ||
|
||
/* --developer? */ | ||
bool developer; | ||
|
||
|
@@ -169,6 +172,9 @@ struct peer { | |
u64 revocations_received; | ||
u8 channel_flags; | ||
|
||
/* Alt address for peer connections not publicly announced */ | ||
u8 *my_alt_addr; | ||
|
||
/* Make sure timestamps move forward. */ | ||
u32 last_update_timestamp; | ||
|
||
|
@@ -533,6 +539,17 @@ static void handle_peer_splice_locked(struct peer *peer, const u8 *msg) | |
check_mutual_splice_locked(peer); | ||
} | ||
|
||
static void send_peer_my_alt_addr(struct peer *peer) | ||
{ | ||
/* Send my alt addr to peer db */ | ||
u8 *peer_msg = towire_peer_alt_addr(peer, peer->my_alt_addr); | ||
peer_write(peer->pps, take(peer_msg)); | ||
|
||
/* We need the addrs in my own db too for later whitelist confirmation */ | ||
u8 *msg = towire_channeld_my_alt_addr(tmpctx, peer->my_alt_addr); | ||
wire_sync_write(MASTER_FD, take(msg)); | ||
} | ||
Comment on lines
+548
to
+551
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a very weird thing for channeld to do. It's more gossipy than channel-related. These days, this kind of thing is handled by connectd. |
||
|
||
static void handle_peer_channel_ready(struct peer *peer, const u8 *msg) | ||
{ | ||
struct channel_id chanid; | ||
|
@@ -4158,6 +4175,9 @@ static void peer_in(struct peer *peer, const u8 *msg) | |
|
||
check_tx_abort(peer, msg); | ||
|
||
if (peer->my_alt_addr) | ||
send_peer_my_alt_addr(peer); | ||
|
||
/* If we're in STFU mode and aren't waiting for a STFU mode | ||
* specific message, the only valid message was tx_abort */ | ||
if (is_stfu_active(peer) && !peer->stfu_wait_single_msg) { | ||
|
@@ -4290,6 +4310,7 @@ static void peer_in(struct peer *peer, const u8 *msg) | |
case WIRE_ONION_MESSAGE: | ||
case WIRE_PEER_STORAGE: | ||
case WIRE_YOUR_PEER_STORAGE: | ||
case WIRE_PEER_ALT_ADDR: | ||
abort(); | ||
} | ||
|
||
|
@@ -5660,6 +5681,18 @@ static void handle_dev_quiesce(struct peer *peer, const u8 *msg) | |
maybe_send_stfu(peer); | ||
} | ||
|
||
static void handle_channeld_peer_alt_addr(struct peer *peer, const u8 *msg) | ||
{ | ||
u8 *my_alt_addr; | ||
|
||
if (!fromwire_channeld_peer_alt_addr(peer, msg, &my_alt_addr)) | ||
master_badmsg(WIRE_CHANNELD_PEER_ALT_ADDR, msg); | ||
|
||
u8 *peer_msg = towire_peer_alt_addr(peer, my_alt_addr); | ||
peer_write(peer->pps, take(peer_msg)); | ||
tal_free(my_alt_addr); | ||
} | ||
|
||
static void req_in(struct peer *peer, const u8 *msg) | ||
{ | ||
enum channeld_wire t = fromwire_peektype(msg); | ||
|
@@ -5699,6 +5732,9 @@ static void req_in(struct peer *peer, const u8 *msg) | |
case WIRE_CHANNELD_SEND_ERROR: | ||
handle_send_error(peer, msg); | ||
return; | ||
case WIRE_CHANNELD_PEER_ALT_ADDR: | ||
handle_channeld_peer_alt_addr(peer, msg); | ||
return; | ||
case WIRE_CHANNELD_SPLICE_INIT: | ||
handle_splice_init(peer, msg); | ||
return; | ||
|
@@ -5762,6 +5798,7 @@ static void req_in(struct peer *peer, const u8 *msg) | |
case WIRE_CHANNELD_SPLICE_STATE_ERROR: | ||
case WIRE_CHANNELD_LOCAL_ANCHOR_INFO: | ||
case WIRE_CHANNELD_REESTABLISHED: | ||
case WIRE_CHANNELD_MY_ALT_ADDR: | ||
break; | ||
} | ||
master_badmsg(-1, msg); | ||
|
@@ -5847,7 +5884,9 @@ static void init_channel(struct peer *peer) | |
&reestablish_only, | ||
&peer->experimental_upgrade, | ||
&peer->splice_state->inflights, | ||
&peer->local_alias)) { | ||
&peer->local_alias, | ||
&peer->my_alt_addr, | ||
&peer->id)) { | ||
master_badmsg(WIRE_CHANNELD_INIT, msg); | ||
} | ||
|
||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.