Prefer "relay" over "router" in docs and APIs.
This commit is contained in:
parent
90e96b32c8
commit
e2139e8afc
|
@ -187,7 +187,7 @@ impl PartialNetDir {
|
|||
}
|
||||
}
|
||||
|
||||
// Compute the weights we'll want to use for these routers.
|
||||
// Compute the weights we'll want to use for these relays.
|
||||
let weights = weight::WeightSet::from_consensus(&consensus, ¶ms);
|
||||
|
||||
let mut netdir = NetDir {
|
||||
|
@ -197,7 +197,7 @@ impl PartialNetDir {
|
|||
weights,
|
||||
};
|
||||
|
||||
for rs in netdir.consensus.routers().iter() {
|
||||
for rs in netdir.consensus.relays().iter() {
|
||||
netdir.mds.insert(MdEntry::Absent(*rs.md_digest()));
|
||||
}
|
||||
PartialNetDir { netdir }
|
||||
|
@ -270,7 +270,7 @@ impl NetDir {
|
|||
// TODO: I'd like if if we could memoize this so we don't have to
|
||||
// do so many hashtable lookups.
|
||||
self.consensus
|
||||
.routers()
|
||||
.relays()
|
||||
.iter()
|
||||
.map(move |rs| self.relay_from_rs(rs))
|
||||
}
|
||||
|
@ -294,8 +294,8 @@ impl NetDir {
|
|||
pub fn params(&self) -> &NetParameters {
|
||||
&self.params
|
||||
}
|
||||
/// Return weighted the fraction of routers we can use. We only
|
||||
/// consider routers that match the predicate `usable`. We weight
|
||||
/// Return weighted the fraction of relays we can use. We only
|
||||
/// consider relays that match the predicate `usable`. We weight
|
||||
/// this bandwidth according to the provided `role`.
|
||||
///
|
||||
/// Note that this function can return NaN if the consensus contains
|
||||
|
@ -325,7 +325,7 @@ impl NetDir {
|
|||
/// enough microdescriptors to build.
|
||||
///
|
||||
/// NOTE: This function can return NaN if the consensus contained
|
||||
/// zero bandwidth for some type of router we need.
|
||||
/// zero bandwidth for some type of relay we need.
|
||||
fn frac_usable_paths(&self) -> f64 {
|
||||
self.frac_for_role(WeightRole::Guard, |u| u.rs.is_flagged_guard())
|
||||
* self.frac_for_role(WeightRole::Middle, |_| true)
|
||||
|
@ -379,7 +379,7 @@ impl NetDir {
|
|||
|
||||
impl MdReceiver for NetDir {
|
||||
fn missing_microdescs(&self) -> Box<dyn Iterator<Item = &MdDigest> + '_> {
|
||||
Box::new(self.consensus.routers().iter().filter_map(move |rs| {
|
||||
Box::new(self.consensus.relays().iter().filter_map(move |rs| {
|
||||
let d = rs.md_digest();
|
||||
match self.mds.get(d) {
|
||||
Some(MdEntry::Absent(d)) => Some(d),
|
||||
|
@ -532,7 +532,7 @@ mod test {
|
|||
use std::collections::HashSet;
|
||||
use std::time::{Duration, SystemTime};
|
||||
use tor_llcrypto::pk::rsa;
|
||||
use tor_netdoc::doc::netstatus::{Lifetime, RouterFlags, RouterWeight};
|
||||
use tor_netdoc::doc::netstatus::{Lifetime, RelayFlags, RelayWeight};
|
||||
|
||||
fn rsa_example() -> rsa::PublicKey {
|
||||
let der = hex!("30818902818100d527b6c63d6e81d39c328a94ce157dccdc044eb1ad8c210c9c9e22487b4cfade6d4041bd10469a657e3d82bc00cf62ac3b6a99247e573b54c10c47f5dc849b0accda031eca6f6e5dc85677f76dec49ff24d2fcb2b5887fb125aa204744119bb6417f45ee696f8dfc1c2fc21b2bae8e9e37a19dc2518a2c24e7d8fd7fac0f46950203010001");
|
||||
|
@ -542,13 +542,13 @@ mod test {
|
|||
// Build a fake network with enough information to enable some basic
|
||||
// tests.
|
||||
fn construct_network() -> (MdConsensus, Vec<Microdesc>) {
|
||||
let f = RouterFlags::RUNNING | RouterFlags::VALID | RouterFlags::V2DIR;
|
||||
let f = RelayFlags::RUNNING | RelayFlags::VALID | RelayFlags::V2DIR;
|
||||
// define 4 groups of flags
|
||||
let flags = [
|
||||
f,
|
||||
f | RouterFlags::EXIT,
|
||||
f | RouterFlags::GUARD,
|
||||
f | RouterFlags::EXIT | RouterFlags::GUARD,
|
||||
f | RelayFlags::EXIT,
|
||||
f | RelayFlags::GUARD,
|
||||
f | RelayFlags::EXIT | RelayFlags::GUARD,
|
||||
];
|
||||
|
||||
let now = SystemTime::now();
|
||||
|
@ -565,7 +565,7 @@ mod test {
|
|||
// Its identity fingerprints are set to `idx`, repeating.
|
||||
// They all get the same address.
|
||||
let flags = flags[(idx / 10) as usize];
|
||||
let policy = if flags.contains(RouterFlags::EXIT) {
|
||||
let policy = if flags.contains(RelayFlags::EXIT) {
|
||||
"accept 80,443"
|
||||
} else {
|
||||
"reject 1-65535"
|
||||
|
@ -584,12 +584,12 @@ mod test {
|
|||
.testing_md()
|
||||
.unwrap();
|
||||
let protocols = if idx % 2 == 0 {
|
||||
// even-numbered routers are dircaches.
|
||||
// even-numbered relays are dircaches.
|
||||
"DirCache=2".parse().unwrap()
|
||||
} else {
|
||||
"".parse().unwrap()
|
||||
};
|
||||
let weight = RouterWeight::Measured(1000 * (idx % 10 + 1) as u32);
|
||||
let weight = RelayWeight::Measured(1000 * (idx % 10 + 1) as u32);
|
||||
bld.rs()
|
||||
.identity([idx; 20].into())
|
||||
.add_or_port("127.0.0.1:9001".parse().unwrap())
|
||||
|
@ -634,7 +634,7 @@ mod test {
|
|||
|
||||
let missing: HashSet<_> = dir.missing_microdescs().collect();
|
||||
assert_eq!(missing.len(), 40);
|
||||
assert_eq!(missing.len(), dir.netdir.consensus.routers().len());
|
||||
assert_eq!(missing.len(), dir.netdir.consensus.relays().len());
|
||||
for md in microdescs.iter() {
|
||||
assert!(missing.contains(md.digest()));
|
||||
}
|
||||
|
@ -780,7 +780,7 @@ mod test {
|
|||
for idx in 20..30 {
|
||||
assert_eq!(picked[idx], 0);
|
||||
}
|
||||
// We didn't we any non-default weights, so the other routers get
|
||||
// We didn't we any non-default weights, so the other relays get
|
||||
// weighted proportional to their bandwidth.
|
||||
check_close(picked[19], (total * 10) / 110);
|
||||
check_close(picked[38], (total * 9) / 110);
|
||||
|
|
|
@ -13,13 +13,13 @@
|
|||
//! use it for other roles, or to use it less commonly for them.
|
||||
|
||||
use crate::params::{NetParameters, Param};
|
||||
use tor_netdoc::doc::netstatus::{MdConsensus, MdConsensusRouterStatus, NetParams, RouterWeight};
|
||||
use tor_netdoc::doc::netstatus::{self, MdConsensus, MdConsensusRouterStatus, NetParams};
|
||||
|
||||
/// Helper: Calculate the function we should use to find initial relay
|
||||
/// bandwidths.
|
||||
fn pick_bandwidth_fn<'a, I>(mut weights: I) -> BandwidthFn
|
||||
where
|
||||
I: Clone + Iterator<Item = &'a RouterWeight>,
|
||||
I: Clone + Iterator<Item = &'a netstatus::RelayWeight>,
|
||||
{
|
||||
let has_measured = weights.clone().any(|w| w.is_measured());
|
||||
let has_nonzero = weights.clone().any(|w| w.is_nonzero());
|
||||
|
@ -62,10 +62,10 @@ enum BandwidthFn {
|
|||
|
||||
impl BandwidthFn {
|
||||
/// Apply this function to the measured or unmeasured bandwidth
|
||||
/// of a single router.
|
||||
fn apply(&self, w: &RouterWeight) -> u32 {
|
||||
/// of a single relay.
|
||||
fn apply(&self, w: &netstatus::RelayWeight) -> u32 {
|
||||
use netstatus::RelayWeight::*;
|
||||
use BandwidthFn::*;
|
||||
use RouterWeight::*;
|
||||
match (self, w) {
|
||||
(Uniform, _) => 1,
|
||||
(IncludeUnmeasured, Unmeasured(u)) => *u,
|
||||
|
@ -77,9 +77,9 @@ impl BandwidthFn {
|
|||
}
|
||||
}
|
||||
|
||||
/// Possible ways to weight routers when selecting them a random.
|
||||
/// Possible ways to weight relays when selecting them a random.
|
||||
///
|
||||
/// Routers are weighted by a function of their bandwidth that
|
||||
/// Relays are weighted by a function of their bandwidth that
|
||||
/// depends on how scarce that "kind" of bandwidth is. For
|
||||
/// example, if Exit bandwidth is rare, then Exits should be
|
||||
/// less likely to get chosen for the middle hop of a path.
|
||||
|
@ -194,7 +194,7 @@ impl WeightKind {
|
|||
/// weighted bandwidth.
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct WeightSet {
|
||||
/// How to find the bandwidth to use when picking a router by weighted
|
||||
/// How to find the bandwidth to use when picking a relay by weighted
|
||||
/// bandwidth.
|
||||
///
|
||||
/// (This tells us us whether to count unmeasured relays, whether
|
||||
|
@ -220,16 +220,16 @@ impl WeightSet {
|
|||
}
|
||||
|
||||
/// Find the 64-bit weight to report for a relay of `kind` whose weight in
|
||||
/// the consensus is `router_weight` when using it for `role`.
|
||||
/// the consensus is `relay_weight` when using it for `role`.
|
||||
fn weight_bw_for_role(
|
||||
&self,
|
||||
kind: WeightKind,
|
||||
router_weight: &RouterWeight,
|
||||
relay_weight: &netstatus::RelayWeight,
|
||||
role: WeightRole,
|
||||
) -> u64 {
|
||||
let ws = &self.w[kind.idx()];
|
||||
|
||||
let router_bw = self.bandwidth_fn.apply(router_weight);
|
||||
let router_bw = self.bandwidth_fn.apply(relay_weight);
|
||||
// Note a subtlety here: we multiply the two values _before_
|
||||
// we shift, to improve accuracy. We know that this will be
|
||||
// safe, since the inputs are both u32, and so cannot overflow
|
||||
|
@ -240,10 +240,10 @@ impl WeightSet {
|
|||
|
||||
/// Compute the correct WeightSet for a provided MdConsensus.
|
||||
pub(crate) fn from_consensus(consensus: &MdConsensus, params: &NetParameters) -> Self {
|
||||
let bandwidth_fn = pick_bandwidth_fn(consensus.routers().iter().map(|rs| rs.weight()));
|
||||
let bandwidth_fn = pick_bandwidth_fn(consensus.relays().iter().map(|rs| rs.weight()));
|
||||
let weight_scale = params.get(Param::BwWeightScale);
|
||||
let total_bw = consensus
|
||||
.routers()
|
||||
.relays()
|
||||
.iter()
|
||||
.map(|rs| bandwidth_fn.apply(rs.weight()) as u64)
|
||||
.sum();
|
||||
|
@ -375,8 +375,9 @@ fn log2_upper(n: u64) -> u32 {
|
|||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
use netstatus::RelayWeight as RW;
|
||||
use std::time::{Duration, SystemTime};
|
||||
use tor_netdoc::doc::netstatus::{Lifetime, RouterFlags, RouterStatusBuilder};
|
||||
use tor_netdoc::doc::netstatus::{Lifetime, RelayFlags, RouterStatusBuilder};
|
||||
|
||||
#[test]
|
||||
fn t_clamp() {
|
||||
|
@ -413,24 +414,20 @@ mod test {
|
|||
let empty = [];
|
||||
assert_eq!(pick_bandwidth_fn(empty.iter()), BandwidthFn::Uniform);
|
||||
|
||||
let all_zero = [
|
||||
RouterWeight::Unmeasured(0),
|
||||
RouterWeight::Measured(0),
|
||||
RouterWeight::Unmeasured(0),
|
||||
];
|
||||
let all_zero = [RW::Unmeasured(0), RW::Measured(0), RW::Unmeasured(0)];
|
||||
assert_eq!(pick_bandwidth_fn(all_zero.iter()), BandwidthFn::Uniform);
|
||||
|
||||
let all_unmeasured = [RouterWeight::Unmeasured(9), RouterWeight::Unmeasured(2222)];
|
||||
let all_unmeasured = [RW::Unmeasured(9), RW::Unmeasured(2222)];
|
||||
assert_eq!(
|
||||
pick_bandwidth_fn(all_unmeasured.iter()),
|
||||
BandwidthFn::IncludeUnmeasured
|
||||
);
|
||||
|
||||
let some_measured = [
|
||||
RouterWeight::Unmeasured(10),
|
||||
RouterWeight::Measured(7),
|
||||
RouterWeight::Measured(4),
|
||||
RouterWeight::Unmeasured(0),
|
||||
RW::Unmeasured(10),
|
||||
RW::Measured(7),
|
||||
RW::Measured(4),
|
||||
RW::Unmeasured(0),
|
||||
];
|
||||
assert_eq!(
|
||||
pick_bandwidth_fn(some_measured.iter()),
|
||||
|
@ -440,7 +437,7 @@ mod test {
|
|||
// This corresponds to an open question in
|
||||
// `pick_bandwidth_fn`, about what to do when the only nonzero
|
||||
// weights are unmeasured.
|
||||
let measured_all_zero = [RouterWeight::Unmeasured(10), RouterWeight::Measured(0)];
|
||||
let measured_all_zero = [RW::Unmeasured(10), RW::Measured(0)];
|
||||
assert_eq!(
|
||||
pick_bandwidth_fn(measured_all_zero.iter()),
|
||||
BandwidthFn::Uniform
|
||||
|
@ -449,8 +446,8 @@ mod test {
|
|||
|
||||
#[test]
|
||||
fn t_apply_bwfn() {
|
||||
use netstatus::RelayWeight::*;
|
||||
use BandwidthFn::*;
|
||||
use RouterWeight::*;
|
||||
|
||||
assert_eq!(Uniform.apply(&Measured(7)), 1);
|
||||
assert_eq!(Uniform.apply(&Unmeasured(0)), 1);
|
||||
|
@ -485,7 +482,7 @@ mod test {
|
|||
assert_eq!(
|
||||
ws.weight_bw_for_role(
|
||||
WeightKind(FLG_GUARD | FLG_DIR),
|
||||
&RouterWeight::Unmeasured(7777),
|
||||
&RW::Unmeasured(7777),
|
||||
WeightRole::Guard
|
||||
),
|
||||
0
|
||||
|
@ -494,7 +491,7 @@ mod test {
|
|||
assert_eq!(
|
||||
ws.weight_bw_for_role(
|
||||
WeightKind(FLG_GUARD | FLG_DIR),
|
||||
&RouterWeight::Measured(7777),
|
||||
&RW::Measured(7777),
|
||||
WeightRole::Guard
|
||||
),
|
||||
7777 * 5904
|
||||
|
@ -503,7 +500,7 @@ mod test {
|
|||
assert_eq!(
|
||||
ws.weight_bw_for_role(
|
||||
WeightKind(FLG_GUARD | FLG_DIR),
|
||||
&RouterWeight::Measured(7777),
|
||||
&RW::Measured(7777),
|
||||
WeightRole::Middle
|
||||
),
|
||||
7777 * 4096
|
||||
|
@ -512,7 +509,7 @@ mod test {
|
|||
assert_eq!(
|
||||
ws.weight_bw_for_role(
|
||||
WeightKind(FLG_GUARD | FLG_DIR),
|
||||
&RouterWeight::Measured(7777),
|
||||
&RW::Measured(7777),
|
||||
WeightRole::Exit
|
||||
),
|
||||
7777 * 10000
|
||||
|
@ -521,7 +518,7 @@ mod test {
|
|||
assert_eq!(
|
||||
ws.weight_bw_for_role(
|
||||
WeightKind(FLG_GUARD | FLG_DIR),
|
||||
&RouterWeight::Measured(7777),
|
||||
&RW::Measured(7777),
|
||||
WeightRole::BeginDir
|
||||
),
|
||||
7777 * 4096
|
||||
|
@ -530,7 +527,7 @@ mod test {
|
|||
assert_eq!(
|
||||
ws.weight_bw_for_role(
|
||||
WeightKind(FLG_GUARD | FLG_DIR),
|
||||
&RouterWeight::Measured(7777),
|
||||
&RW::Measured(7777),
|
||||
WeightRole::Unweighted
|
||||
),
|
||||
7777
|
||||
|
@ -538,8 +535,8 @@ mod test {
|
|||
|
||||
// Now try those last few with routerstatuses.
|
||||
let rs = rs_builder()
|
||||
.set_flags(RouterFlags::GUARD | RouterFlags::V2DIR)
|
||||
.weight(RouterWeight::Measured(7777))
|
||||
.set_flags(RelayFlags::GUARD | RelayFlags::V2DIR)
|
||||
.weight(RW::Measured(7777))
|
||||
.build()
|
||||
.unwrap();
|
||||
assert_eq!(ws.weight_rs_for_role(&rs, WeightRole::Exit), 7777 * 10000);
|
||||
|
@ -564,19 +561,19 @@ mod test {
|
|||
|
||||
#[test]
|
||||
fn weight_flags() {
|
||||
let rs1 = rs_builder().set_flags(RouterFlags::EXIT).build().unwrap();
|
||||
let rs1 = rs_builder().set_flags(RelayFlags::EXIT).build().unwrap();
|
||||
assert_eq!(WeightKind::for_rs(&rs1).0, FLG_EXIT);
|
||||
|
||||
let rs1 = rs_builder().set_flags(RouterFlags::GUARD).build().unwrap();
|
||||
let rs1 = rs_builder().set_flags(RelayFlags::GUARD).build().unwrap();
|
||||
assert_eq!(WeightKind::for_rs(&rs1).0, FLG_GUARD);
|
||||
|
||||
let rs1 = rs_builder().set_flags(RouterFlags::V2DIR).build().unwrap();
|
||||
let rs1 = rs_builder().set_flags(RelayFlags::V2DIR).build().unwrap();
|
||||
assert_eq!(WeightKind::for_rs(&rs1).0, FLG_DIR);
|
||||
|
||||
let rs1 = rs_builder().build().unwrap();
|
||||
assert_eq!(WeightKind::for_rs(&rs1).0, 0);
|
||||
|
||||
let rs1 = rs_builder().set_flags(RouterFlags::all()).build().unwrap();
|
||||
let rs1 = rs_builder().set_flags(RelayFlags::all()).build().unwrap();
|
||||
assert_eq!(WeightKind::for_rs(&rs1).0, FLG_EXIT | FLG_GUARD | FLG_DIR);
|
||||
}
|
||||
|
||||
|
@ -596,16 +593,16 @@ mod test {
|
|||
for _ in 0..10 {
|
||||
rs_builder()
|
||||
.identity(rng.gen::<[u8; 20]>().into()) // random id
|
||||
.weight(RouterWeight::Unmeasured(1_000_000))
|
||||
.set_flags(RouterFlags::GUARD | RouterFlags::EXIT)
|
||||
.weight(RW::Unmeasured(1_000_000))
|
||||
.set_flags(RelayFlags::GUARD | RelayFlags::EXIT)
|
||||
.build_into(&mut bld)
|
||||
.unwrap();
|
||||
}
|
||||
for n in 0..30 {
|
||||
rs_builder()
|
||||
.identity(rng.gen::<[u8; 20]>().into()) // random id
|
||||
.weight(RouterWeight::Measured(1_000 * n))
|
||||
.set_flags(RouterFlags::GUARD | RouterFlags::EXIT)
|
||||
.weight(RW::Measured(1_000 * n))
|
||||
.set_flags(RelayFlags::GUARD | RelayFlags::EXIT)
|
||||
.build_into(&mut bld)
|
||||
.unwrap();
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
//! as bridges), clients use those relays' self-signed router
|
||||
//! descriptors ([routerdesc::RouterDesc]). These router descriptors
|
||||
//! are also uploaded to the authorities in order to tell them about
|
||||
//! routers and their status.
|
||||
//! relays and their status.
|
||||
//!
|
||||
//! All of these formats are described in
|
||||
//! [dir-spec.txt](https://spec.torproject.org/dir-spec).
|
||||
|
@ -25,9 +25,7 @@
|
|||
//!
|
||||
//! Tor recognizes other kinds of documents that this crate doesn't
|
||||
//! parse yet. There are "ExtraInfo documents" that encode
|
||||
//! information about relays that almost nobody needs. There are
|
||||
//! "ns-flavored" consensus documents that list all the router
|
||||
//! descriptors on the network, instead of listing microdescriptors.
|
||||
//! information about relays that almost nobody needs.
|
||||
//! Finally, there are the voting documents themselves that authorities
|
||||
//! use in order to calculate the consensus.
|
||||
|
||||
|
|
|
@ -350,7 +350,7 @@ bitflags! {
|
|||
/// they are not listed in this type.
|
||||
///
|
||||
/// The bit values used to represent the flags have no meaning.
|
||||
pub struct RouterFlags: u16 {
|
||||
pub struct RelayFlags: u16 {
|
||||
/// Is this a directory authority?
|
||||
const AUTHORITY = (1<<0);
|
||||
/// Is this relay marked as a bad exit?
|
||||
|
@ -397,25 +397,22 @@ bitflags! {
|
|||
/// Recognized weight fields on a single relay in a consensus
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
#[non_exhaustive]
|
||||
pub enum RouterWeight {
|
||||
pub enum RelayWeight {
|
||||
// TODO SPEC: Document that these are u32 in dir-spec.txt
|
||||
/// An unmeasured weight for a router.
|
||||
/// An unmeasured weight for a relay.
|
||||
Unmeasured(u32),
|
||||
/// An measured weight for a router.
|
||||
/// An measured weight for a relay.
|
||||
Measured(u32),
|
||||
}
|
||||
|
||||
impl RouterWeight {
|
||||
impl RelayWeight {
|
||||
/// Return true if this weight is the result of a successful measurement
|
||||
pub fn is_measured(&self) -> bool {
|
||||
matches!(self, RouterWeight::Measured(_))
|
||||
matches!(self, RelayWeight::Measured(_))
|
||||
}
|
||||
/// Return true if this weight is nonzero
|
||||
pub fn is_nonzero(&self) -> bool {
|
||||
!matches!(
|
||||
self,
|
||||
RouterWeight::Unmeasured(0) | RouterWeight::Measured(0)
|
||||
)
|
||||
!matches!(self, RelayWeight::Unmeasured(0) | RelayWeight::Measured(0))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -483,8 +480,9 @@ pub struct Consensus<RS> {
|
|||
header: ConsensusHeader,
|
||||
/// List of voters whose votes contributed to this consensus.
|
||||
voters: Vec<ConsensusVoterInfo>,
|
||||
/// A list of the relays on the network, with one entry per relay.
|
||||
routers: Vec<RS>,
|
||||
/// A list of routerstatus entries for the relays on the network,
|
||||
/// with one entry per relay.
|
||||
relays: Vec<RS>,
|
||||
/// Footer for the consensus object.
|
||||
footer: Footer,
|
||||
}
|
||||
|
@ -520,8 +518,8 @@ impl<RS> Consensus<RS> {
|
|||
}
|
||||
|
||||
/// Return a slice of all the routerstatus entries in this consensus.
|
||||
pub fn routers(&self) -> &[RS] {
|
||||
&self.routers[..]
|
||||
pub fn relays(&self) -> &[RS] {
|
||||
&self.relays[..]
|
||||
}
|
||||
|
||||
/// Return a mapping from keywords to integers representing how
|
||||
|
@ -967,35 +965,35 @@ impl ConsensusVoterInfo {
|
|||
}
|
||||
}
|
||||
|
||||
impl std::str::FromStr for RouterFlags {
|
||||
impl std::str::FromStr for RelayFlags {
|
||||
type Err = std::convert::Infallible;
|
||||
fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
|
||||
Ok(match s {
|
||||
"Authority" => RouterFlags::AUTHORITY,
|
||||
"BadExit" => RouterFlags::BAD_EXIT,
|
||||
"Exit" => RouterFlags::EXIT,
|
||||
"Fast" => RouterFlags::FAST,
|
||||
"Guard" => RouterFlags::GUARD,
|
||||
"HSDir" => RouterFlags::HSDIR,
|
||||
"NoEdConsensus" => RouterFlags::NO_ED_CONSENSUS,
|
||||
"Stable" => RouterFlags::STABLE,
|
||||
"StaleDesc" => RouterFlags::STALE_DESC,
|
||||
"Running" => RouterFlags::RUNNING,
|
||||
"Valid" => RouterFlags::VALID,
|
||||
"V2Dir" => RouterFlags::V2DIR,
|
||||
_ => RouterFlags::empty(),
|
||||
"Authority" => RelayFlags::AUTHORITY,
|
||||
"BadExit" => RelayFlags::BAD_EXIT,
|
||||
"Exit" => RelayFlags::EXIT,
|
||||
"Fast" => RelayFlags::FAST,
|
||||
"Guard" => RelayFlags::GUARD,
|
||||
"HSDir" => RelayFlags::HSDIR,
|
||||
"NoEdConsensus" => RelayFlags::NO_ED_CONSENSUS,
|
||||
"Stable" => RelayFlags::STABLE,
|
||||
"StaleDesc" => RelayFlags::STALE_DESC,
|
||||
"Running" => RelayFlags::RUNNING,
|
||||
"Valid" => RelayFlags::VALID,
|
||||
"V2Dir" => RelayFlags::V2DIR,
|
||||
_ => RelayFlags::empty(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl RouterFlags {
|
||||
/// Parse a router-flags entry from an "s" line.
|
||||
fn from_item(item: &Item<'_, NetstatusKwd>) -> Result<RouterFlags> {
|
||||
impl RelayFlags {
|
||||
/// Parse a relay-flags entry from an "s" line.
|
||||
fn from_item(item: &Item<'_, NetstatusKwd>) -> Result<RelayFlags> {
|
||||
if item.kwd() != NetstatusKwd::RS_S {
|
||||
return Err(Error::Internal(item.pos()));
|
||||
}
|
||||
// These flags are implicit.
|
||||
let mut flags: RouterFlags = RouterFlags::RUNNING | RouterFlags::VALID;
|
||||
let mut flags: RelayFlags = RelayFlags::RUNNING | RelayFlags::VALID;
|
||||
|
||||
let mut prev: Option<&str> = None;
|
||||
for s in item.args() {
|
||||
|
@ -1017,15 +1015,15 @@ impl RouterFlags {
|
|||
}
|
||||
}
|
||||
|
||||
impl Default for RouterWeight {
|
||||
fn default() -> RouterWeight {
|
||||
RouterWeight::Unmeasured(0)
|
||||
impl Default for RelayWeight {
|
||||
fn default() -> RelayWeight {
|
||||
RelayWeight::Unmeasured(0)
|
||||
}
|
||||
}
|
||||
|
||||
impl RouterWeight {
|
||||
impl RelayWeight {
|
||||
/// Parse a routerweight from a "w" line.
|
||||
fn from_item(item: &Item<'_, NetstatusKwd>) -> Result<RouterWeight> {
|
||||
fn from_item(item: &Item<'_, NetstatusKwd>) -> Result<RelayWeight> {
|
||||
if item.kwd() != NetstatusKwd::RS_W {
|
||||
return Err(Error::Internal(item.pos()));
|
||||
}
|
||||
|
@ -1036,13 +1034,13 @@ impl RouterWeight {
|
|||
let unmeas = params.params.get("Unmeasured");
|
||||
|
||||
let bw = match bw {
|
||||
None => return Ok(RouterWeight::Unmeasured(0)),
|
||||
None => return Ok(RelayWeight::Unmeasured(0)),
|
||||
Some(b) => *b,
|
||||
};
|
||||
|
||||
match unmeas {
|
||||
None | Some(0) => Ok(RouterWeight::Measured(bw)),
|
||||
Some(1) => Ok(RouterWeight::Unmeasured(bw)),
|
||||
None | Some(0) => Ok(RelayWeight::Measured(bw)),
|
||||
Some(1) => Ok(RelayWeight::Unmeasured(bw)),
|
||||
_ => Err(Error::BadArgument(
|
||||
item.pos(),
|
||||
"unmeasured value".to_string(),
|
||||
|
@ -1271,14 +1269,14 @@ impl<RS: ParseRouterStatus + RouterStatus> Consensus<RS> {
|
|||
voters.push(voter);
|
||||
}
|
||||
|
||||
let mut routers: Vec<RS> = Vec::new();
|
||||
while let Some((pos, router)) = Self::take_routerstatus(r)? {
|
||||
if let Some(prev) = routers.last() {
|
||||
if prev.rsa_identity() >= router.rsa_identity() {
|
||||
let mut relays: Vec<RS> = Vec::new();
|
||||
while let Some((pos, routerstatus)) = Self::take_routerstatus(r)? {
|
||||
if let Some(prev) = relays.last() {
|
||||
if prev.rsa_identity() >= routerstatus.rsa_identity() {
|
||||
return Err(Error::WrongSortOrder(pos));
|
||||
}
|
||||
}
|
||||
routers.push(router);
|
||||
relays.push(routerstatus);
|
||||
}
|
||||
|
||||
let footer = Self::take_footer(r)?;
|
||||
|
@ -1286,7 +1284,7 @@ impl<RS: ParseRouterStatus + RouterStatus> Consensus<RS> {
|
|||
let consensus = Consensus {
|
||||
header,
|
||||
voters,
|
||||
routers,
|
||||
relays,
|
||||
footer,
|
||||
};
|
||||
|
||||
|
@ -1584,8 +1582,8 @@ mod test {
|
|||
assert!(consensus.key_is_correct(&certs).is_ok());
|
||||
let consensus = consensus.check_signature(&certs)?;
|
||||
|
||||
assert_eq!(6, consensus.routers().len());
|
||||
let r0 = &consensus.routers()[0];
|
||||
assert_eq!(6, consensus.relays().len());
|
||||
let r0 = &consensus.relays()[0];
|
||||
assert_eq!(
|
||||
r0.md_digest(),
|
||||
&hex!("73dabe0a0468f4f7a67810a18d11e36731bb1d2ec3634db459100609f3b3f535")
|
||||
|
@ -1683,34 +1681,34 @@ mod test {
|
|||
#[test]
|
||||
fn test_weight() {
|
||||
let w = gettok("w Unmeasured=1 Bandwidth=6\n").unwrap();
|
||||
let w = RouterWeight::from_item(&w).unwrap();
|
||||
let w = RelayWeight::from_item(&w).unwrap();
|
||||
assert!(!w.is_measured());
|
||||
assert!(w.is_nonzero());
|
||||
|
||||
let w = gettok("w Bandwidth=10\n").unwrap();
|
||||
let w = RouterWeight::from_item(&w).unwrap();
|
||||
let w = RelayWeight::from_item(&w).unwrap();
|
||||
assert!(w.is_measured());
|
||||
assert!(w.is_nonzero());
|
||||
|
||||
let w = RouterWeight::default();
|
||||
let w = RelayWeight::default();
|
||||
assert!(!w.is_measured());
|
||||
assert!(!w.is_nonzero());
|
||||
|
||||
let w = gettok("w Mustelid=66 Cheato=7 Unmeasured=1\n").unwrap();
|
||||
let w = RouterWeight::from_item(&w).unwrap();
|
||||
let w = RelayWeight::from_item(&w).unwrap();
|
||||
assert!(!w.is_measured());
|
||||
assert!(!w.is_nonzero());
|
||||
|
||||
let w = gettok("r foo\n").unwrap();
|
||||
let w = RouterWeight::from_item(&w);
|
||||
let w = RelayWeight::from_item(&w);
|
||||
assert!(w.is_err());
|
||||
|
||||
let w = gettok("r Bandwidth=6 Unmeasured=Frog\n").unwrap();
|
||||
let w = RouterWeight::from_item(&w);
|
||||
let w = RelayWeight::from_item(&w);
|
||||
assert!(w.is_err());
|
||||
|
||||
let w = gettok("r Bandwidth=6 Unmeasured=3\n").unwrap();
|
||||
let w = RouterWeight::from_item(&w);
|
||||
let w = RelayWeight::from_item(&w);
|
||||
assert!(w.is_err());
|
||||
}
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ pub struct ConsensusBuilder<RS> {
|
|||
/// See [`Consensus::voters`]
|
||||
voters: Vec<ConsensusVoterInfo>,
|
||||
/// See [`Consensus::routers`]
|
||||
routers: Vec<RS>,
|
||||
relays: Vec<RS>,
|
||||
/// See [`Footer::weights`]
|
||||
weights: NetParams<i32>,
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ impl<RS> ConsensusBuilder<RS> {
|
|||
shared_rand_prev: None,
|
||||
shared_rand_cur: None,
|
||||
voters: Vec::new(),
|
||||
routers: Vec::new(),
|
||||
relays: Vec::new(),
|
||||
weights: NetParams::new(),
|
||||
}
|
||||
}
|
||||
|
@ -179,7 +179,7 @@ impl<RS> ConsensusBuilder<RS> {
|
|||
|
||||
/// Insert a single routerstatus into this builder.
|
||||
pub(crate) fn add_rs(&mut self, rs: RS) -> &mut Self {
|
||||
self.routers.push(rs);
|
||||
self.relays.push(rs);
|
||||
self
|
||||
}
|
||||
}
|
||||
|
@ -231,14 +231,14 @@ impl<RS: RouterStatus + Clone> ConsensusBuilder<RS> {
|
|||
weights: self.weights.clone(),
|
||||
};
|
||||
|
||||
let mut routers = self.routers.clone();
|
||||
routers.sort_by_key(|r| *r.rsa_identity());
|
||||
let mut relays = self.relays.clone();
|
||||
relays.sort_by_key(|r| *r.rsa_identity());
|
||||
// TODO: check for duplicates?
|
||||
|
||||
Ok(Consensus {
|
||||
header,
|
||||
voters: self.voters.clone(),
|
||||
routers,
|
||||
relays,
|
||||
footer,
|
||||
})
|
||||
}
|
||||
|
@ -386,7 +386,7 @@ impl VoterInfoBuilder {
|
|||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
use crate::doc::netstatus::RouterFlags;
|
||||
use crate::doc::netstatus::RelayFlags;
|
||||
|
||||
use std::time::{Duration, SystemTime};
|
||||
|
||||
|
@ -435,8 +435,8 @@ mod test {
|
|||
.add_or_port("[f00f::1]:9200".parse().unwrap())
|
||||
.dir_port(66)
|
||||
.doc_digest([99; 32])
|
||||
.set_flags(RouterFlags::FAST)
|
||||
.add_flags(RouterFlags::STABLE | RouterFlags::V2DIR)
|
||||
.set_flags(RelayFlags::FAST)
|
||||
.add_flags(RelayFlags::STABLE | RelayFlags::V2DIR)
|
||||
.version("Arti 0.0.0".into())
|
||||
.protos("DirCache=7".parse().unwrap())
|
||||
.build_into(&mut builder)
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
pub(crate) mod build;
|
||||
|
||||
use super::{
|
||||
ConsensusFlavor, NetstatusKwd, ParseRouterStatus, RouterFlags, RouterStatus, RouterWeight,
|
||||
ConsensusFlavor, NetstatusKwd, ParseRouterStatus, RelayFlags, RelayWeight, RouterStatus,
|
||||
};
|
||||
use crate::doc::microdesc::MdDigest;
|
||||
use crate::doc::routerdesc::RdDigest;
|
||||
|
@ -79,14 +79,14 @@ struct GenericRouterStatus<D> {
|
|||
/// Digest of the document for this relay.
|
||||
doc_digest: D,
|
||||
/// Flags applied by the authorities to this relay.
|
||||
flags: RouterFlags,
|
||||
flags: RelayFlags,
|
||||
/// Version of the software that this relay is running.
|
||||
version: Option<String>,
|
||||
/// List of subprotocol versions supported by this relay.
|
||||
protos: Protocols,
|
||||
/// Information about how to weight this relay when choosing a
|
||||
/// relay at random.
|
||||
weight: RouterWeight,
|
||||
weight: RelayWeight,
|
||||
}
|
||||
|
||||
// TODO: These methods should probably become, in whole or in part,
|
||||
|
@ -99,7 +99,7 @@ macro_rules! implement_accessors {
|
|||
self.rs.addrs.iter()
|
||||
}
|
||||
/// Return the declared weight of this routerstatus in the directory.
|
||||
pub fn weight(&self) -> &RouterWeight {
|
||||
pub fn weight(&self) -> &RelayWeight {
|
||||
&self.rs.weight
|
||||
}
|
||||
/// Return the ORPort addresses of this routerstatus
|
||||
|
@ -114,8 +114,8 @@ macro_rules! implement_accessors {
|
|||
pub fn nickname(&self) -> &String {
|
||||
&self.rs.nickname
|
||||
}
|
||||
/// Return the router flags of this routerstatus.
|
||||
pub fn flags(&self) -> &RouterFlags {
|
||||
/// Return the relay flags of this routerstatus.
|
||||
pub fn flags(&self) -> &RelayFlags {
|
||||
&self.rs.flags
|
||||
}
|
||||
/// Return the version of this routerstatus.
|
||||
|
@ -125,23 +125,23 @@ macro_rules! implement_accessors {
|
|||
/// Return true if the ed25519 identity on this relay reflects a
|
||||
/// true consensus among the authorities.
|
||||
pub fn ed25519_id_is_usable(&self) -> bool {
|
||||
!self.rs.flags.contains(RouterFlags::NO_ED_CONSENSUS)
|
||||
!self.rs.flags.contains(RelayFlags::NO_ED_CONSENSUS)
|
||||
}
|
||||
/// Return true if this routerstatus is listed with the BadExit flag.
|
||||
pub fn is_flagged_bad_exit(&self) -> bool {
|
||||
self.rs.flags.contains(RouterFlags::BAD_EXIT)
|
||||
self.rs.flags.contains(RelayFlags::BAD_EXIT)
|
||||
}
|
||||
/// Return true if this routerstatus is listed with the v2dir flag.
|
||||
pub fn is_flagged_v2dir(&self) -> bool {
|
||||
self.rs.flags.contains(RouterFlags::V2DIR)
|
||||
self.rs.flags.contains(RelayFlags::V2DIR)
|
||||
}
|
||||
/// Return true if this routerstatus is listed with the Exit flag.
|
||||
pub fn is_flagged_exit(&self) -> bool {
|
||||
self.rs.flags.contains(RouterFlags::EXIT)
|
||||
self.rs.flags.contains(RelayFlags::EXIT)
|
||||
}
|
||||
/// Return true if this routerstatus is listed with the Guard flag.
|
||||
pub fn is_flagged_guard(&self) -> bool {
|
||||
self.rs.flags.contains(RouterFlags::GUARD)
|
||||
self.rs.flags.contains(RelayFlags::GUARD)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -287,7 +287,7 @@ where
|
|||
}
|
||||
|
||||
// S line
|
||||
let flags = RouterFlags::from_item(sec.required(RS_S)?)?;
|
||||
let flags = RelayFlags::from_item(sec.required(RS_S)?)?;
|
||||
|
||||
// V line
|
||||
let version = sec.maybe(RS_V).args_as_str().map(str::to_string);
|
||||
|
@ -303,7 +303,7 @@ where
|
|||
// W line
|
||||
let weight = sec
|
||||
.get(RS_W)
|
||||
.map(RouterWeight::from_item)
|
||||
.map(RelayWeight::from_item)
|
||||
.transpose()?
|
||||
.unwrap_or_else(Default::default);
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
use super::{GenericRouterStatus, MdConsensusRouterStatus, NsConsensusRouterStatus};
|
||||
use crate::doc::microdesc::MdDigest;
|
||||
use crate::doc::netstatus::{ConsensusBuilder, RouterFlags, RouterWeight};
|
||||
use crate::doc::netstatus::{ConsensusBuilder, RelayFlags, RelayWeight};
|
||||
use crate::doc::routerdesc::RdDigest;
|
||||
use crate::{Error, Result};
|
||||
use tor_llcrypto::pk::rsa::RsaIdentity;
|
||||
|
@ -28,13 +28,13 @@ pub struct RouterStatusBuilder<D> {
|
|||
/// See [`GenericRouterStatus::doc_digest`].
|
||||
doc_digest: Option<D>,
|
||||
/// See [`GenericRouterStatus::flags`].
|
||||
flags: RouterFlags,
|
||||
flags: RelayFlags,
|
||||
/// See [`GenericRouterStatus::version`].
|
||||
version: Option<String>,
|
||||
/// See [`GenericRouterStatus::protos`].
|
||||
protos: Option<Protocols>,
|
||||
/// See [`GenericRouterStatus::weight`].
|
||||
weight: Option<RouterWeight>,
|
||||
weight: Option<RelayWeight>,
|
||||
}
|
||||
|
||||
impl<D: Clone> RouterStatusBuilder<D> {
|
||||
|
@ -47,14 +47,14 @@ impl<D: Clone> RouterStatusBuilder<D> {
|
|||
addrs: Vec::new(),
|
||||
dir_port: 0,
|
||||
doc_digest: None,
|
||||
flags: RouterFlags::empty(),
|
||||
flags: RelayFlags::empty(),
|
||||
version: None,
|
||||
protos: None,
|
||||
weight: None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Set the nickname for this router.
|
||||
/// Set the nickname for this routerstatus.
|
||||
///
|
||||
/// This value defaults to "Unnamed".
|
||||
pub fn nickname(&mut self, nickname: String) -> &mut Self {
|
||||
|
@ -62,7 +62,7 @@ impl<D: Clone> RouterStatusBuilder<D> {
|
|||
self
|
||||
}
|
||||
|
||||
/// Set the RSA identity for this router.
|
||||
/// Set the RSA identity for this routerstatus.
|
||||
///
|
||||
/// (The Ed25519 identity is in the microdescriptor).
|
||||
///
|
||||
|
@ -71,63 +71,64 @@ impl<D: Clone> RouterStatusBuilder<D> {
|
|||
self.identity = Some(identity);
|
||||
self
|
||||
}
|
||||
/// Set the publication time for this router.
|
||||
/// Set the publication time for this routerstatus.
|
||||
///
|
||||
/// This value is optional, and does nothing (TODO).
|
||||
pub fn published(&mut self, published: SystemTime) -> &mut Self {
|
||||
self.published = Some(published);
|
||||
self
|
||||
}
|
||||
/// Add an OrPort at `addr` to this router.
|
||||
/// Add an OrPort at `addr` to this routerstatus.
|
||||
///
|
||||
/// At least one value here is required.
|
||||
pub fn add_or_port(&mut self, addr: SocketAddr) -> &mut Self {
|
||||
self.addrs.push(addr);
|
||||
self
|
||||
}
|
||||
/// Set a directory port for this router.
|
||||
/// Set a directory port for this routerstatus.
|
||||
///
|
||||
/// Nothing in Arti uses this value; it defaults to 0.
|
||||
pub fn dir_port(&mut self, dir_port: u16) -> &mut Self {
|
||||
self.dir_port = dir_port;
|
||||
self
|
||||
}
|
||||
/// Set the document digest for this router.
|
||||
/// Set the document digest for this routerstatus.
|
||||
///
|
||||
/// This value is required.
|
||||
pub fn doc_digest(&mut self, doc_digest: D) -> &mut Self {
|
||||
self.doc_digest = Some(doc_digest);
|
||||
self
|
||||
}
|
||||
/// Replace the current flags in this router with `flags`.
|
||||
pub fn set_flags(&mut self, flags: RouterFlags) -> &mut Self {
|
||||
/// Replace the current flags in this routerstatus with `flags`.
|
||||
pub fn set_flags(&mut self, flags: RelayFlags) -> &mut Self {
|
||||
self.flags = flags;
|
||||
self
|
||||
}
|
||||
/// Make all the flags in `flags` become set on this router,
|
||||
/// Make all the flags in `flags` become set on this routerstatus,
|
||||
/// in addition to the flags already set.
|
||||
pub fn add_flags(&mut self, flags: RouterFlags) -> &mut Self {
|
||||
pub fn add_flags(&mut self, flags: RelayFlags) -> &mut Self {
|
||||
self.flags |= flags;
|
||||
self
|
||||
}
|
||||
/// Set the version of this router.
|
||||
/// Set the version of the relay described in this routerstatus.
|
||||
///
|
||||
/// This value is optional.
|
||||
pub fn version(&mut self, version: String) -> &mut Self {
|
||||
self.version = Some(version);
|
||||
self
|
||||
}
|
||||
/// Set the list of subprotocols supported by this router.
|
||||
/// Set the list of subprotocols supported by the relay described
|
||||
/// by this routerstatus.
|
||||
///
|
||||
/// This value is required.
|
||||
pub fn protos(&mut self, protos: Protocols) -> &mut Self {
|
||||
self.protos = Some(protos);
|
||||
self
|
||||
}
|
||||
/// Set the weight of this router for random selection.
|
||||
/// Set the weight of this routerstatus for random selection.
|
||||
///
|
||||
/// This value is optional; it defaults to 0.
|
||||
pub fn weight(&mut self, weight: RouterWeight) -> &mut Self {
|
||||
pub fn weight(&mut self, weight: RelayWeight) -> &mut Self {
|
||||
self.weight = Some(weight);
|
||||
self
|
||||
}
|
||||
|
@ -152,7 +153,7 @@ impl<D: Clone> RouterStatusBuilder<D> {
|
|||
.as_ref()
|
||||
.ok_or(Error::CannotBuild("Missing protocols"))?
|
||||
.clone();
|
||||
let weight = self.weight.unwrap_or(RouterWeight::Unmeasured(0));
|
||||
let weight = self.weight.unwrap_or(RelayWeight::Unmeasured(0));
|
||||
|
||||
Ok(GenericRouterStatus {
|
||||
nickname,
|
||||
|
|
|
@ -52,7 +52,7 @@ pub type RdDigest = [u8; 20];
|
|||
/// A router descriptor, with possible annotations.
|
||||
#[allow(dead_code)]
|
||||
pub struct AnnotatedRouterDesc {
|
||||
/// Annotation for this router; possibly empty.
|
||||
/// Annotation for this router descriptor; possibly empty.
|
||||
ann: RouterAnnotation,
|
||||
/// Underlying router descriptor; signatures not checked yet.
|
||||
router: UncheckedRouterDesc,
|
||||
|
@ -84,22 +84,23 @@ pub struct RouterAnnotation {
|
|||
/// it is valid, using is_expired_at().
|
||||
#[allow(dead_code)] // don't warn about fields not getting read.
|
||||
pub struct RouterDesc {
|
||||
/// Human-readable nickname for this router.
|
||||
/// Human-readable nickname for this relay.
|
||||
///
|
||||
/// This is not secure, and not guaranteed to be unique.
|
||||
nickname: String,
|
||||
/// IPv4 address for this router.
|
||||
/// IPv4 address for this relay.
|
||||
ipv4addr: Option<net::Ipv4Addr>,
|
||||
/// IPv4 ORPort for this router
|
||||
/// IPv4 ORPort for this relay.
|
||||
orport: u16,
|
||||
/// IPv6 address and port for this router.
|
||||
/// IPv6 address and port for this relay.
|
||||
// TODO: we don't use a socketaddrv6 because we don't care about
|
||||
// the flow and scope fields. We should decide whether that's a
|
||||
// good idea.
|
||||
ipv6addr: Option<(net::Ipv6Addr, u16)>,
|
||||
/// Directory port for contacting this router for HTTP directory downloads.
|
||||
/// Directory port for contacting this relay for direct HTTP
|
||||
/// directory downloads.
|
||||
dirport: u16,
|
||||
/// Declared uptime for this router in seconds.
|
||||
/// Declared uptime for this relay, in seconds.
|
||||
uptime: Option<u64>,
|
||||
/// Time when this router descriptor was published.
|
||||
published: time::SystemTime,
|
||||
|
@ -202,7 +203,7 @@ decl_keyword! {
|
|||
}
|
||||
}
|
||||
|
||||
/// Rules for parsing a set of router annotations.
|
||||
/// Rules for parsing a set of router descriptor annotations.
|
||||
static ROUTER_ANNOTATIONS: Lazy<SectionRules<RouterKwd>> = Lazy::new(|| {
|
||||
use RouterKwd::*;
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
//!
|
||||
//! TODO: Possibly, this module should be extracted into a crate of
|
||||
//! its own. I'm not 100% sure though -- does anything need versions
|
||||
//! but not router docs?
|
||||
//! but not network docs?
|
||||
|
||||
use std::cmp::Ordering;
|
||||
use std::fmt::{self, Display, Formatter};
|
||||
|
|
|
@ -575,7 +575,7 @@ impl ClientCirc {
|
|||
self.begin_data_stream(beginmsg.into()).await
|
||||
}
|
||||
|
||||
/// Start a new connection to the last router in the circuit, using
|
||||
/// Start a new connection 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
|
||||
|
|
|
@ -62,9 +62,9 @@ caret_enum! {
|
|||
HSIntro = 5,
|
||||
/// Providing an onion service rendezvous point
|
||||
HSRend = 6,
|
||||
/// Describing a relay's functionality as a router descriptor
|
||||
/// Describing a relay's functionality using router descriptors.
|
||||
Desc = 7,
|
||||
/// Describing a relay's functionality as a microdescriptor.
|
||||
/// Describing a relay's functionality using microdescriptors.
|
||||
MicroDesc = 8,
|
||||
/// Describing the network as a consensus directory document.
|
||||
Cons = 9,
|
||||
|
|
Loading…
Reference in New Issue