Skip to content
Snippets Groups Projects
Commit 7b12b54d authored by Nick Mathewson's avatar Nick Mathewson :game_die:
Browse files

tor-netdoc: Put the "routerdesc" document type behind a feature.

Nothing in arti currently uses this document type.  Eventually it
will be useful for relays and for bridge clients.

I've left the "SHA1 digest of a router descriptor" type available
unconditinoally, however, since it does get used in a few places.

Part of #125.
parent 1a3292da
No related branches found
No related tags found
No related merge requests found
......@@ -11,8 +11,15 @@ categories = [ "parser-implementations" ]
repository="https://gitlab.torproject.org/tpo/core/arti.git/"
[features]
default = []
# Enable code to build the objects that represent different network documents.
build_docs = [ "rand" ]
# Enable the "router descriptor" document type, which is needed by relays and
# bridge clients.
routerdesc = []
[dependencies]
tor-llcrypto = { path="../tor-llcrypto", version = "0.0.1"}
tor-bytes = { path="../tor-bytes", version = "0.0.1"}
......
......@@ -14,6 +14,7 @@ libfuzzer-sys = "0.3"
[dependencies.tor-netdoc]
path = ".."
features = [ "routerdesc" ]
# Prevent this from interfering with workspaces
[workspace]
......
......@@ -32,4 +32,13 @@
pub mod authcert;
pub mod microdesc;
pub mod netstatus;
#[cfg(any(doc, feature = "routerdesc"))]
pub mod routerdesc;
#[allow(missing_docs, clippy::missing_docs_in_private_items)]
#[cfg(not(any(doc, feature = "routerdesc")))]
pub mod routerdesc {
/// The digest of a RouterDesc document, as reported in a NS consensus.
pub type RdDigest = [u8; 20];
}
......@@ -27,6 +27,11 @@
//! TODO: There should be accessor functions for some or all of the
//! fields in RouterDesc. I'm deferring those until I know what they
//! should be.
//!
//! # Availability
//!
//! Most of this module is only available when this crate is built with the
//! `routerdesc` feature enabled.
use crate::parse::keyword::Keyword;
use crate::parse::parser::{Section, SectionRules};
use crate::parse::tokenize::{ItemResult, NetDocReader};
......
......@@ -24,6 +24,14 @@
//! inside directory documents. Finally, the [`doc`] module defines
//! the parsers for the documents themselves.
//!
//! # Features
//!
//! `build_docs`: enable code to construct the objects representing different
//! network documents.
//!
//! `routerdesc`: enable support for the "router descriptor" docment type, which
//! is needed by bridge clients and relays.
//!
//! # Caveat haxxor: limitations and infelicities
//!
//! TODO: This crate requires that all of its inputs be valid UTF-8:
......
......@@ -492,6 +492,7 @@ impl<'a, 'b, K: Keyword> MaybeItem<'a, 'b, K> {
/// If this item is present, parse its argument at position `idx`.
/// Treat the absence or malformedness of the argument as an error,
/// but treat the absence of this item as acceptable.
#[cfg(any(test, feature = "routerdesc"))]
pub(crate) fn parse_arg<V: FromStr>(&self, idx: usize) -> Result<Option<V>>
where
Error: From<V::Err>,
......
......@@ -9,6 +9,7 @@ pub(crate) use b16impl::*;
pub(crate) use b64impl::*;
pub(crate) use curve25519impl::*;
pub(crate) use ed25519impl::*;
#[cfg(feature = "routerdesc")]
pub(crate) use edcert::*;
pub(crate) use fingerprint::*;
pub(crate) use rsa::*;
......@@ -253,6 +254,7 @@ mod rsa {
}
/// Types for decoding Ed25519 certificates
#[cfg(feature = "routerdesc")]
mod edcert {
use crate::{Error, Pos, Result};
use tor_cert::{CertType, Ed25519Cert, KeyUnknownCert};
......
......@@ -36,6 +36,7 @@ impl<'a, I: Iterator, F: FnMut(&I::Item) -> bool> PauseAt<'a, I, F> {
}
}
/// Replace the predicate on a PauseAt, returning a new PauseAt.
#[cfg(any(test, feature = "routerdesc"))]
pub(crate) fn new_pred<F2>(self, pred: F2) -> PauseAt<'a, I, F2>
where
F2: FnMut(&I::Item) -> bool,
......
......@@ -22,5 +22,6 @@ We can delete older sections here after we bump the releases.
tor-client: MODIFIED
tor-dirclient: MODIFIED
tor-llcrypto: BREAKING
tor-netdoc: BREAKING
tor-persist: BREAKING if `testing` feature is enabled.
tor-proto: BREAKING
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment