Skip to content

Commit

Permalink
feat: improve universe comms (#6533)
Browse files Browse the repository at this point in the history
Description
---
- Improved universe comms by defaulting to bypass tor for outbound tcp
connections.
- Refrain from dialling tcp
'ConnectionManagerConfig::default().listener_address'

Motivation and Context
---
We need to improve Universe connectivity.

How Has This Been Tested?
---
Unit tests pass
System-level testing [**TBD**]

What process can a PR reviewer use to test or verify this change?
---
Code review

<!-- Checklist -->
<!-- 1. Is the title of your PR in the form that would make nice release
notes? The title, excluding the conventional commit
tag, will be included exactly as is in the CHANGELOG, so please think
about it carefully. -->


Breaking Changes
---

- [x] None
- [ ] Requires data directory on base node to be deleted
- [ ] Requires hard fork
- [ ] Other - Please specify

<!-- Does this include a breaking change? If so, include this line as a
footer -->
<!-- BREAKING CHANGE: Description what the user should do, e.g. delete a
database, resync the chain -->
  • Loading branch information
hansieodendaal authored Sep 6, 2024
1 parent 5e3cf3b commit 3b2c88e
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 10 deletions.
6 changes: 3 additions & 3 deletions base_layer/p2p/src/transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ pub struct TorTransportConfig {
/// When these peer addresses are encountered when dialing another peer, the tor proxy is bypassed and the
/// connection is made directly over TCP. /ip4, /ip6, /dns, /dns4 and /dns6 are supported.
pub proxy_bypass_addresses: Vec<Multiaddr>,
/// When set to true, outbound TCP connections bypass the tor proxy. Defaults to false for better privacy, setting
/// to true may improve network performance for TCP nodes.
/// When set to true, outbound TCP connections bypass the tor proxy. Defaults to 'true' for better network
/// performance for TCP nodes; set it to 'false' for better privacy.
pub proxy_bypass_for_outbound_tcp: bool,
/// If set, instructs tor to forward traffic the provided address. Otherwise, an OS-assigned port on 127.0.0.1
/// is used.
Expand Down Expand Up @@ -196,7 +196,7 @@ impl Default for TorTransportConfig {
control_auth: TorControlAuthentication::Auto,
onion_port: NonZeroU16::new(18141).unwrap(),
proxy_bypass_addresses: vec![],
proxy_bypass_for_outbound_tcp: false,
proxy_bypass_for_outbound_tcp: true,
forward_address: None,
listener_address_override: None,
identity: None,
Expand Down
6 changes: 3 additions & 3 deletions common/config/presets/c_base_node_c.toml
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,9 @@ listener_self_liveness_check_interval = 15
# When these peer addresses are encountered when dialing another peer, the tor proxy is bypassed and the connection is
# made directly over TCP. /ip4, /ip6, /dns, /dns4 and /dns6 are supported. (e.g. ["/dns4/my-foo-base-node/tcp/9998"])
#tor.proxy_bypass_addresses = []
# When using the tor transport and set to true, outbound TCP connections bypass the tor proxy. Defaults to false for
# better privacy
#tor.proxy_bypass_for_outbound_tcp = false
# When using the tor transport and set to true, outbound TCP connections bypass the tor proxy. Defaults to 'true' for
# better network performance for TCP nodes; set it to 'false' for better privacy.
#tor.proxy_bypass_for_outbound_tcp = true
# If set, instructs tor to forward traffic the provided address. (e.g. "/dns4/my-base-node/tcp/32123") (default = OS-assigned port)
#tor.forward_address =
# If set, the listener will bind to this address instead of the forward_address. You need to make sure that this listener is connectable from the forward_address.
Expand Down
6 changes: 3 additions & 3 deletions common/config/presets/d_console_wallet.toml
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,9 @@ event_channel_size = 3500
# When these peer addresses are encountered when dialing another peer, the tor proxy is bypassed and the connection is
# made directly over TCP. /ip4, /ip6, /dns, /dns4 and /dns6 are supported. (e.g. ["/dns4/my-foo-base-node/tcp/9998"])
#tor.proxy_bypass_addresses = []
# When using the tor transport and set to true, outbound TCP connections bypass the tor proxy. Defaults to false for
# better privacy
#tor.proxy_bypass_for_outbound_tcp = false
# When using the tor transport and set to true, outbound TCP connections bypass the tor proxy. Defaults to 'true' for
# better network performance for TCP nodes; set it to 'false' for better privacy.
#tor.proxy_bypass_for_outbound_tcp = true
# If set, instructs tor to forward traffic the provided address. (e.g. "/ip4/127.0.0.1/tcp/0") (default = )
#tor.forward_address =

Expand Down
13 changes: 12 additions & 1 deletion comms/core/src/connection_manager/dialer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,18 @@ where
DialState,
Result<(NoiseSocket<TTransport::Output>, Multiaddr), ConnectionManagerError>,
) {
let addresses = dial_state.peer().addresses.clone().into_vec();
let addresses = dial_state
.peer()
.addresses
.clone()
.into_vec()
.iter()
.filter(|&a| {
a == &"/memory/0".parse::<Multiaddr>().expect("will not fail") || // Used for tests, allowed
a != &ConnectionManagerConfig::default().listener_address // Not allowed to dial the default
})
.cloned()
.collect::<Vec<_>>();
if addresses.is_empty() {
let node_id_hex = dial_state.peer().node_id.clone().to_hex();
trace!(
Expand Down

0 comments on commit 3b2c88e

Please sign in to comment.