Skip to content

Commit

Permalink
[net] tor-dialer: revert to panic and document why
Browse files Browse the repository at this point in the history
  • Loading branch information
y committed Nov 16, 2023
1 parent e4eb675 commit 521bc80
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/net/transport/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,11 @@ impl Dialer {
}

/// Dial an instantiated [`Dialer`]. This creates a connection and returns a stream.

/// The Tor-based Dialer variants can panic: this is intended. There exists validation
/// for hosts and ports in other parts of the codebase. A panic occurring here
/// likely indicates a configuration issue on the part of the user. It is preferable
/// in this case that the user is alerted to this problem via a panic.
pub async fn dial(&self, timeout: Option<Duration>) -> Result<Box<dyn PtStream>> {
match &self.variant {
#[cfg(feature = "p2p-tcp")]
Expand All @@ -214,8 +219,8 @@ impl Dialer {

#[cfg(feature = "p2p-tor")]
DialerVariant::Tor(dialer) => {
let host = self.endpoint.host_str().ok_or(Error::InvalidDialerScheme)?;
let port = self.endpoint.port().ok_or(Error::InvalidDialerScheme)?;
let host = self.endpoint.host_str().unwrap();
let port = self.endpoint.port().unwrap();
// Extract error reports (i.e. very detailed debugging)
// from arti-client in order to help debug Tor connections.
// https://docs.rs/arti-client/latest/arti_client/#reporting-arti-errors
Expand All @@ -233,8 +238,8 @@ impl Dialer {

#[cfg(feature = "p2p-tor")]
DialerVariant::TorTls(dialer) => {
let host = self.endpoint.host_str().ok_or(Error::InvalidDialerScheme)?;
let port = self.endpoint.port().ok_or(Error::InvalidDialerScheme)?;
let host = self.endpoint.host_str().unwrap();
let port = self.endpoint.port().unwrap();
// Extract error reports (i.e. very detailed debugging)
// from arti-client in order to help debug Tor connections.
// https://docs.rs/arti-client/latest/arti_client/#reporting-arti-errors
Expand Down

0 comments on commit 521bc80

Please sign in to comment.