pub struct Circuit {
pub id: CircuitId,
pub status: CircStatus,
pub path: Vec<RelayInfo>,
}Expand description
Information about an active Tor circuit.
A circuit is a path through the Tor network consisting of multiple relay hops. Circuits are used to route traffic anonymously by encrypting data in layers that are peeled off at each hop.
§Circuit Lifecycle
Circuits progress through several states:
- Launched: Circuit creation has begun
- Extended: Circuit is being extended to additional hops
- Built: Circuit is fully constructed and ready for use
- Failed: Circuit construction failed
- Closed: Circuit has been closed
§Fields
id: Unique identifier for this circuitstatus: Current state of the circuitpath: Ordered list of relays in the circuit (guard → middle → exit)
§Example
use stem_rs::controller::Controller;
use stem_rs::CircStatus;
let mut controller = Controller::from_port("127.0.0.1:9051".parse()?).await?;
controller.authenticate(None).await?;
for circuit in controller.get_circuits().await? {
if circuit.status == CircStatus::Built {
println!("Circuit {} has {} hops:", circuit.id, circuit.path.len());
for (i, relay) in circuit.path.iter().enumerate() {
println!(" Hop {}: {} ({:?})", i + 1, relay.fingerprint, relay.nickname);
}
}
}§See Also
Controller::get_circuits: Retrieve all active circuitsController::new_circuit: Create a new circuitCircStatus: Circuit status enumeration
Fields§
§id: CircuitIdUnique identifier for this circuit.
status: CircStatusCurrent status of the circuit.
See CircStatus for possible values.
path: Vec<RelayInfo>Ordered list of relays in the circuit path.
The first relay is the guard (entry) node, and the last relay is typically the exit node. The path may be empty for newly launched circuits that haven’t yet established any hops.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Circuit
impl RefUnwindSafe for Circuit
impl Send for Circuit
impl Sync for Circuit
impl Unpin for Circuit
impl UnwindSafe for Circuit
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