Skip to content

Commit

Permalink
fix(base-node): assign correct base dir to tor identity (#4081)
Browse files Browse the repository at this point in the history
Description
---
Fixes regression: prepend the base directory to the tor identity file location.

Motivation and Context
---
The regression caused the tor identity, and therefore public address, to be shared amongst multiple base nodes.
This causes `DialedPublicKeyMismatch` errors that have been observed in logs.

How Has This Been Tested?
---
Manually checked that two base nodes have different tor identities and the file location is relative to the base dir.
  • Loading branch information
sdbondi authored May 6, 2022
1 parent e165c33 commit 1464f8b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
3 changes: 3 additions & 0 deletions applications/tari_base_node/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ impl BaseNodeConfig {
if !self.identity_file.is_absolute() {
self.identity_file = base_path.as_ref().join(self.identity_file.as_path());
}
if !self.tor_identity_file.is_absolute() {
self.tor_identity_file = base_path.as_ref().join(self.tor_identity_file.as_path());
}
if !self.data_dir.is_absolute() {
self.data_dir = base_path.as_ref().join(self.data_dir.as_path());
}
Expand Down
6 changes: 5 additions & 1 deletion comms/core/src/connection_manager/dialer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ use futures::{
};
use log::*;
use tari_shutdown::{Shutdown, ShutdownSignal};
use tari_utilities::hex::Hex;
use tokio::{
io::{AsyncRead, AsyncWrite, AsyncWriteExt},
sync::{mpsc, oneshot},
Expand Down Expand Up @@ -355,7 +356,10 @@ where
.ok_or(ConnectionManagerError::InvalidStaticPublicKey)?;

if &authenticated_public_key != expected_public_key {
return Err(ConnectionManagerError::DialedPublicKeyMismatch);
return Err(ConnectionManagerError::DialedPublicKeyMismatch {
authenticated_pk: authenticated_public_key.to_hex(),
expected_pk: expected_public_key.to_hex(),
});
}

Ok(authenticated_public_key)
Expand Down
10 changes: 8 additions & 2 deletions comms/core/src/connection_manager/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,14 @@ pub enum ConnectionManagerError {
ListenerError { address: String, details: String },
#[error("Transport error for {address}: {details}")]
TransportError { address: String, details: String },
#[error("The peer authenticated to a public key which did not match the dialed peer's public key")]
DialedPublicKeyMismatch,
#[error(
"The peer authenticated to public key '{authenticated_pk}' which did not match the dialed peer's public key \
'{expected_pk}'"
)]
DialedPublicKeyMismatch {
authenticated_pk: String,
expected_pk: String,
},
#[error("The noise transport failed to provide a valid static public key for the peer")]
InvalidStaticPublicKey,
// This is a String because we need this error to be clonable so that we can
Expand Down

0 comments on commit 1464f8b

Please sign in to comment.