Add the necessary APIs for bridge-based circuit construction.

This commit is contained in:
Nick Mathewson 2022-09-26 09:41:45 -04:00
parent 1196e1b680
commit 3272c6fb04
2 changed files with 11 additions and 0 deletions

View File

@ -182,6 +182,7 @@ impl<'a> ExitPathBuilder<'a> {
}
let guard_usage = b.build().expect("Failed while building guard usage!");
let (guard, mut mon, usable) = guardmgr.select_guard(guard_usage, Some(netdir))?;
// TODO pt-client: First try as_circ_target; then try get_relay.
let guard = guard.get_relay(netdir).ok_or_else(|| {
internal!(
"Somehow the guardmgr gave us an unlisted guard {:?}!",

View File

@ -1345,8 +1345,18 @@ impl FirstHop {
}
/// Look up this guard in `netdir`.
pub fn get_relay<'a>(&self, netdir: &'a NetDir) -> Option<Relay<'a>> {
// TODO pt-client: This should always return "None" for a bridge.
self.id().get_relay(netdir)
}
/// If possible, return a view of this object that can be used to build a circuit.
///
/// TODO pt-client: This will need to return "Some" only for bridges that have
/// a bridge descriptor.
#[allow(clippy::missing_panics_doc)]
pub fn as_circ_target(&self) -> Option<tor_linkspec::OwnedCircTarget> {
todo!() // TODO pt-client: Implement
}
}
// This is somewhat redundant with the implementations in crate::guard::Guard.