Loading Cargo.lock +1 −0 Original line number Diff line number Diff line Loading @@ -3314,6 +3314,7 @@ dependencies = [ "thiserror", "tor-circmgr", "tor-error", "tor-linkspec", "tor-llcrypto", "tor-netdoc", "tor-proto", Loading crates/tor-dirclient/Cargo.toml +1 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ routerdesc = [] [dependencies] tor-circmgr = { path = "../tor-circmgr", version = "0.1.0" } tor-error = { path = "../tor-error", version = "0.1.0" } tor-linkspec = { path = "../tor-linkspec", version = "0.1.0" } tor-llcrypto = { path = "../tor-llcrypto", version = "0.1.0" } tor-proto = { path = "../tor-proto", version = "0.1.0" } tor-netdoc = { path = "../tor-netdoc", version = "0.1.0" } Loading crates/tor-dirclient/src/lib.rs +1 −1 Original line number Diff line number Diff line Loading @@ -111,7 +111,7 @@ where // TODO(nickm) This should be an option, and is too long. let begin_timeout = Duration::from_secs(5); let source = SourceInfo::new(circuit.unique_id()); let source = SourceInfo::from_circuit(&circuit); // Launch the stream. let mut stream = runtime Loading crates/tor-dirclient/src/response.rs +15 −6 Original line number Diff line number Diff line //! Define a response type for directory requests. use tor_proto::circuit::UniqId; use tor_linkspec::OwnedChanTarget; use tor_proto::circuit::{ClientCirc, UniqId}; use crate::Error; Loading @@ -22,13 +23,12 @@ pub struct DirResponse { /// /// We use this to remember when a request has failed, so we can /// abandon the circuit. /// /// (In the future, we will probably want to use this structure to /// remember that the cache isn't working.) #[derive(Debug, Clone)] pub struct SourceInfo { /// Unique identifier for the circuit we're using circuit: UniqId, /// Identity of the directory cache that provided us this information. cache_id: OwnedChanTarget, } impl DirResponse { Loading Loading @@ -85,12 +85,21 @@ impl DirResponse { impl SourceInfo { /// Construct a new SourceInfo pub(crate) fn new(circuit: UniqId) -> Self { SourceInfo { circuit } pub(crate) fn from_circuit(circuit: &ClientCirc) -> Self { SourceInfo { circuit: circuit.unique_id(), cache_id: circuit.first_hop(), } } /// Return the unique circuit identifier for the circuit on which /// we received this info. pub fn unique_circ_id(&self) -> &UniqId { &self.circuit } /// Return information about the peer from which we received this info. pub fn cache_id(&self) -> &OwnedChanTarget { &self.cache_id } } Loading
Cargo.lock +1 −0 Original line number Diff line number Diff line Loading @@ -3314,6 +3314,7 @@ dependencies = [ "thiserror", "tor-circmgr", "tor-error", "tor-linkspec", "tor-llcrypto", "tor-netdoc", "tor-proto", Loading
crates/tor-dirclient/Cargo.toml +1 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ routerdesc = [] [dependencies] tor-circmgr = { path = "../tor-circmgr", version = "0.1.0" } tor-error = { path = "../tor-error", version = "0.1.0" } tor-linkspec = { path = "../tor-linkspec", version = "0.1.0" } tor-llcrypto = { path = "../tor-llcrypto", version = "0.1.0" } tor-proto = { path = "../tor-proto", version = "0.1.0" } tor-netdoc = { path = "../tor-netdoc", version = "0.1.0" } Loading
crates/tor-dirclient/src/lib.rs +1 −1 Original line number Diff line number Diff line Loading @@ -111,7 +111,7 @@ where // TODO(nickm) This should be an option, and is too long. let begin_timeout = Duration::from_secs(5); let source = SourceInfo::new(circuit.unique_id()); let source = SourceInfo::from_circuit(&circuit); // Launch the stream. let mut stream = runtime Loading
crates/tor-dirclient/src/response.rs +15 −6 Original line number Diff line number Diff line //! Define a response type for directory requests. use tor_proto::circuit::UniqId; use tor_linkspec::OwnedChanTarget; use tor_proto::circuit::{ClientCirc, UniqId}; use crate::Error; Loading @@ -22,13 +23,12 @@ pub struct DirResponse { /// /// We use this to remember when a request has failed, so we can /// abandon the circuit. /// /// (In the future, we will probably want to use this structure to /// remember that the cache isn't working.) #[derive(Debug, Clone)] pub struct SourceInfo { /// Unique identifier for the circuit we're using circuit: UniqId, /// Identity of the directory cache that provided us this information. cache_id: OwnedChanTarget, } impl DirResponse { Loading Loading @@ -85,12 +85,21 @@ impl DirResponse { impl SourceInfo { /// Construct a new SourceInfo pub(crate) fn new(circuit: UniqId) -> Self { SourceInfo { circuit } pub(crate) fn from_circuit(circuit: &ClientCirc) -> Self { SourceInfo { circuit: circuit.unique_id(), cache_id: circuit.first_hop(), } } /// Return the unique circuit identifier for the circuit on which /// we received this info. pub fn unique_circ_id(&self) -> &UniqId { &self.circuit } /// Return information about the peer from which we received this info. pub fn cache_id(&self) -> &OwnedChanTarget { &self.cache_id } }