pub struct Stream {
pub id: StreamId,
pub status: StreamStatus,
pub circuit_id: Option<CircuitId>,
pub target_host: String,
pub target_port: u16,
}Expand description
Information about an active Tor stream.
A stream represents a single TCP connection being routed through a Tor circuit. Streams are created when applications connect through Tor’s SOCKS proxy and are attached to circuits for routing.
§Stream Lifecycle
Streams progress through several states:
- New: Stream created, awaiting circuit attachment
- SentConnect: CONNECT command sent to exit relay
- Succeeded: Connection established successfully
- Failed: Connection attempt failed
- Closed: Stream has been closed
§Fields
id: Unique identifier for this streamstatus: Current state of the streamcircuit_id: The circuit this stream is attached to (if any)target_host: Destination hostname or IP addresstarget_port: Destination port number
§Example
use stem_rs::controller::Controller;
use stem_rs::StreamStatus;
let mut controller = Controller::from_port("127.0.0.1:9051".parse()?).await?;
controller.authenticate(None).await?;
for stream in controller.get_streams().await? {
println!("Stream {} -> {}:{} ({:?})",
stream.id,
stream.target_host,
stream.target_port,
stream.status
);
if let Some(ref circuit_id) = stream.circuit_id {
println!(" Attached to circuit {}", circuit_id);
}
}§See Also
Controller::get_streams: Retrieve all active streamsController::attach_stream: Attach a stream to a circuitStreamStatus: Stream status enumeration
Fields§
§id: StreamIdUnique identifier for this stream.
status: StreamStatusCurrent status of the stream.
See StreamStatus for possible values.
circuit_id: Option<CircuitId>The circuit this stream is attached to, if any.
Streams in the New or Detached state may not be attached to
any circuit. Once attached, this field contains the circuit ID.
target_host: StringDestination hostname or IP address.
This is the target the stream is connecting to through Tor.
target_port: u16Destination port number.
The TCP port on the target host. May be 0 if not specified.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Stream
impl RefUnwindSafe for Stream
impl Send for Stream
impl Sync for Stream
impl Unpin for Stream
impl UnwindSafe for Stream
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more