Check "connection" usage for when stream or channel would be better.

This commit is contained in:
Nick Mathewson 2021-05-18 11:17:28 -04:00
parent 6d6290bcd5
commit 80535dda01
5 changed files with 14 additions and 13 deletions

View File

@ -18,7 +18,7 @@ use serde::Deserialize;
use std::collections::HashMap;
#[derive(FromArgs, Debug, Clone)]
/// Make a connection to the Tor network, open a SOCKS port, and proxy
/// Connect to the Tor network, open a SOCKS port, and proxy
/// traffic.
///
/// This is a demo; you get no stability guarantee.

View File

@ -61,7 +61,7 @@ pub enum ChanMsg {
/// as part of authentication
AuthChallenge(AuthChallenge),
/// Part of channel negotiation: used to authenticate relays when they
/// initiate connection
/// initiate the channel.
Authenticate(Authenticate),
/// Not yet used
Authorize(Authorize),
@ -539,7 +539,7 @@ caret_int! {
CONNECTFAILED = 6,
/// Connected to a relay, but its OR identity wasn't as requested.
OR_IDENTITY = 7,
/// The OR connection carrying this circuit died.
/// One of the OR channels carrying this circuit died.
CHANNEL_CLOSED = 8,
/// Circuit expired for being too dirty or old
FINISHED = 9,

View File

@ -1,8 +1,9 @@
//! A general interface for Tor client usage.
//!
//! To construct a client, run the `TorClient::bootstrap()` method.
//! Once the client is bootstrapped, you can make connections over the Tor
//! network using `TorClient::connect()`.
//! Once the client is bootstrapped, you can make anonymous
//! connections ("streams") over the Tor network using
//! `TorClient::connect()`.
use tor_circmgr::TargetPort;
use tor_dirmgr::DirMgrConfig;
use tor_proto::circuit::IpVersionPreference;
@ -15,7 +16,7 @@ use std::time::Duration;
use anyhow::{anyhow, Context, Result};
use log::info;
/// An active client connection to the Tor network.
/// An active client session on the Tor network.
///
/// While it's running, it will fetch directory information, build
/// circuits, and make connections for you.
@ -125,8 +126,8 @@ impl<R: Runtime> TorClient<R> {
})
}
/// Launch a connection to the provided address and port over the Tor
/// network.
/// Launch an anonymized connection to the provided address and
/// port over the Tor network.
///
/// Note that because Tor prefers to do DNS resolution on the remote
/// side of the network, this function takes its address as a string.

View File

@ -263,7 +263,7 @@ impl Channel {
Ok(())
}
/// Return true if this connection is closed and therefore unusable.
/// Return true if this channel is closed and therefore unusable.
pub fn is_closing(&self) -> bool {
self.closed.load(Ordering::SeqCst)
}

View File

@ -539,8 +539,8 @@ impl ClientCirc {
Ok(RawCellStream::new(target, receiver))
}
/// Start a DataStream connection to the given address and port,
/// using a BEGIN cell.
/// Start a DataStream (anonymized connection) to the given
/// address and port, using a BEGIN cell.
async fn begin_data_stream(self: Arc<Self>, msg: RelayMsg) -> Result<DataStream> {
let stream = self.begin_stream_impl(msg).await?;
// TODO: waiting for a response here preculdes optimistic data.
@ -559,7 +559,7 @@ impl ClientCirc {
}
}
/// Start a connection to the given address and port, using a BEGIN
/// Start a stream to the given address and port, using a BEGIN
/// cell.
///
/// The use of a string for the address is intentional: you should let
@ -575,7 +575,7 @@ impl ClientCirc {
self.begin_data_stream(beginmsg.into()).await
}
/// Start a new connection to the last relay in the circuit, using
/// Start a new stream to the last relay in the circuit, using
/// a BEGIN_DIR cell.
pub async fn begin_dir_stream(self: Arc<Self>) -> Result<DataStream> {
self.begin_data_stream(RelayMsg::BeginDir).await