fix: pierce the firewall on server-brokered reverse connects
When the server asks us to connect to a peer (a ConnectToPeer we receive, carrying the server's correlation token), we dial that peer and must announce ourselves with a PierceFirewall quoting the token — not a PeerInit — so the remote peer can correlate its own indirect request (search-result / upload delivery). The outbound handshake now sends PierceFirewall when the peer carries a server token and PeerInit only for direct GetPeerAddress dials (token None). Direct and firewalled e2e paths are unchanged.
This commit is contained in:
@@ -586,19 +586,27 @@ impl PeerActor {
|
|||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Connections we initiated must announce themselves with a PeerInit
|
// Connections we initiated must announce themselves; inbound peers
|
||||||
// (peer code 1); inbound peers already sent us theirs, so we stay
|
// already sent us theirs, so we stay silent for them. A direct dial
|
||||||
// silent for them. `get_buffer` prepends the length prefix the peer's
|
// (resolved via GetPeerAddress, token None) sends a PeerInit; a dial we
|
||||||
// MessageReader expects.
|
// make because the server asked us to (a brokered ConnectToPeer carries
|
||||||
|
// the server's token) must instead PierceFirewall with that token so
|
||||||
|
// the remote peer can correlate its own request. `get_buffer` prepends
|
||||||
|
// the length prefix the peer's MessageReader expects.
|
||||||
if self.outbound {
|
if self.outbound {
|
||||||
let init = MessageFactory::build_peer_init_message(
|
let handshake = match token {
|
||||||
|
Some(server_token) => {
|
||||||
|
MessageFactory::build_pierce_firewall_message(server_token)
|
||||||
|
}
|
||||||
|
None => MessageFactory::build_peer_init_message(
|
||||||
&self.own_username,
|
&self.own_username,
|
||||||
connection_type,
|
connection_type,
|
||||||
token.unwrap_or(0),
|
0,
|
||||||
);
|
),
|
||||||
if let Err(e) = stream.write_all(&init.get_buffer()) {
|
};
|
||||||
|
if let Err(e) = stream.write_all(&handshake.get_buffer()) {
|
||||||
error!(
|
error!(
|
||||||
"[peer:{}] Failed to send PeerInit handshake: {}",
|
"[peer:{}] Failed to send outbound handshake: {}",
|
||||||
username, e
|
username, e
|
||||||
);
|
);
|
||||||
self.disconnect_with_error(e);
|
self.disconnect_with_error(e);
|
||||||
|
|||||||
Reference in New Issue
Block a user