summaryrefslogtreecommitdiff
path: root/crates/tor-netdoc/src/doc
diff options
context:
space:
mode:
Diffstat (limited to 'crates/tor-netdoc/src/doc')
-rw-r--r--crates/tor-netdoc/src/doc/microdesc.rs5
-rw-r--r--crates/tor-netdoc/src/doc/netstatus.rs58
-rw-r--r--crates/tor-netdoc/src/doc/netstatus/rs.rs7
-rw-r--r--crates/tor-netdoc/src/doc/netstatus/rs/md.rs5
-rw-r--r--crates/tor-netdoc/src/doc/netstatus/rs/ns.rs5
-rw-r--r--crates/tor-netdoc/src/doc/routerdesc.rs5
6 files changed, 84 insertions, 1 deletions
diff --git a/crates/tor-netdoc/src/doc/microdesc.rs b/crates/tor-netdoc/src/doc/microdesc.rs
index 01947dad1..1aab39626 100644
--- a/crates/tor-netdoc/src/doc/microdesc.rs
+++ b/crates/tor-netdoc/src/doc/microdesc.rs
@@ -52,6 +52,11 @@ pub type MdDigest = [u8; 32];
/// A single microdescriptor.
#[allow(dead_code)]
+#[cfg_attr(
+ feature = "dangerous-expose-struct-fields",
+ visible::StructFields(pub),
+ non_exhaustive
+)]
#[derive(Clone, Debug)]
pub struct Microdesc {
/// The SHA256 digest of the text of this microdescriptor. This
diff --git a/crates/tor-netdoc/src/doc/netstatus.rs b/crates/tor-netdoc/src/doc/netstatus.rs
index 5b4f1ea4e..7ae6510f2 100644
--- a/crates/tor-netdoc/src/doc/netstatus.rs
+++ b/crates/tor-netdoc/src/doc/netstatus.rs
@@ -235,6 +235,11 @@ impl ConsensusFlavor {
/// The signature of a single directory authority on a networkstatus document.
#[allow(dead_code)]
+#[cfg_attr(
+ feature = "dangerous-expose-struct-fields",
+ visible::StructFields(pub),
+ non_exhaustive
+)]
#[derive(Debug, Clone)]
pub struct Signature {
/// The name of the digest algorithm used to make the signature.
@@ -251,6 +256,11 @@ pub struct Signature {
/// A collection of signatures that can be checked on a networkstatus document
#[allow(dead_code)]
+#[cfg_attr(
+ feature = "dangerous-expose-struct-fields",
+ visible::StructFields(pub),
+ non_exhaustive
+)]
#[derive(Debug, Clone)]
pub struct SignatureGroup {
/// The sha256 of the document itself
@@ -263,6 +273,12 @@ pub struct SignatureGroup {
/// A shared-random value produced by the directory authorities.
#[allow(dead_code)]
+#[cfg_attr(
+ feature = "dangerous-expose-struct-fields",
+ visible::StructFields(pub),
+ visibility::make(pub),
+ non_exhaustive
+)]
#[derive(Debug, Clone)]
struct SharedRandVal {
/// How many authorities revealed shares that contributed to this value.
@@ -281,6 +297,12 @@ struct SharedRandVal {
/// NOTE: this type is separate from the header parts that are only in
/// votes or only in consensuses, even though we don't implement votes yet.
#[allow(dead_code)]
+#[cfg_attr(
+ feature = "dangerous-expose-struct-fields",
+ visible::StructFields(pub),
+ visibility::make(pub),
+ non_exhaustive
+)]
#[derive(Debug, Clone)]
struct CommonHeader {
/// What kind of consensus document is this? Absent in votes and
@@ -308,6 +330,12 @@ struct CommonHeader {
/// The header of a consensus networkstatus.
#[allow(dead_code)]
+#[cfg_attr(
+ feature = "dangerous-expose-struct-fields",
+ visible::StructFields(pub),
+ visibility::make(pub),
+ non_exhaustive
+)]
#[derive(Debug, Clone)]
struct ConsensusHeader {
/// Header fields common to votes and consensuses
@@ -326,6 +354,12 @@ struct ConsensusHeader {
///
/// (Corresponds to a dir-source line.)
#[allow(dead_code)]
+#[cfg_attr(
+ feature = "dangerous-expose-struct-fields",
+ visible::StructFields(pub),
+ visibility::make(pub),
+ non_exhaustive
+)]
#[derive(Debug, Clone)]
struct DirSource {
/// human-readable nickname for this authority.
@@ -398,8 +432,8 @@ bitflags! {
}
/// Recognized weight fields on a single relay in a consensus
-#[derive(Debug, Clone, Copy)]
#[non_exhaustive]
+#[derive(Debug, Clone, Copy)]
pub enum RelayWeight {
/// An unmeasured weight for a relay.
Unmeasured(u32),
@@ -420,6 +454,12 @@ impl RelayWeight {
/// All information about a single authority, as represented in a consensus
#[allow(dead_code)]
+#[cfg_attr(
+ feature = "dangerous-expose-struct-fields",
+ visible::StructFields(pub),
+ visibility::make(pub),
+ non_exhaustive
+)]
#[derive(Debug, Clone)]
struct ConsensusVoterInfo {
/// Contents of the dirsource line about an authority
@@ -433,6 +473,12 @@ struct ConsensusVoterInfo {
/// The signed footer of a consensus netstatus.
#[allow(dead_code)]
+#[cfg_attr(
+ feature = "dangerous-expose-struct-fields",
+ visible::StructFields(pub),
+ visibility::make(pub),
+ non_exhaustive
+)]
#[derive(Debug, Clone)]
struct Footer {
/// Weights to be applied to certain classes of relays when choosing
@@ -477,6 +523,11 @@ pub trait RouterStatus: Sealed {
/// TODO: This should possibly turn into a parameterized type, to represent
/// votes and ns consensuses.
#[allow(dead_code)]
+#[cfg_attr(
+ feature = "dangerous-expose-struct-fields",
+ visible::StructFields(pub),
+ non_exhaustive
+)]
#[derive(Debug, Clone)]
pub struct Consensus<RS> {
/// Part of the header shared by all consensus types.
@@ -1401,6 +1452,11 @@ impl<RS: RouterStatus + ParseRouterStatus> Consensus<RS> {
/// check_signature() on that result with the set of certs that you
/// have. Make sure only to provide authority certificates representing
/// real authorities!
+#[cfg_attr(
+ feature = "dangerous-expose-struct-fields",
+ visible::StructFields(pub),
+ non_exhaustive
+)]
#[derive(Debug, Clone)]
pub struct UnvalidatedConsensus<RS> {
/// The consensus object. We don't want to expose this until it's
diff --git a/crates/tor-netdoc/src/doc/netstatus/rs.rs b/crates/tor-netdoc/src/doc/netstatus/rs.rs
index fde46fe33..b985187ca 100644
--- a/crates/tor-netdoc/src/doc/netstatus/rs.rs
+++ b/crates/tor-netdoc/src/doc/netstatus/rs.rs
@@ -27,6 +27,12 @@ pub use md::MdConsensusRouterStatus;
pub use ns::NsConsensusRouterStatus;
/// Shared implementation of MdConsensusRouterStatus and NsConsensusRouterStatus.
+#[cfg_attr(
+ feature = "dangerous-expose-struct-fields",
+ visible::StructFields(pub),
+ visibility::make(pub),
+ non_exhaustive
+)]
#[derive(Debug, Clone)]
struct GenericRouterStatus<D> {
/// The nickname for this relay.
@@ -150,6 +156,7 @@ pub(crate) use implement_accessors;
/// Helper to decode a document digest in the format in which it
/// appears in a given kind of routerstatus.
+#[cfg_attr(feature = "dangerous-expose-struct-fields", visibility::make(pub))]
trait FromRsString: Sized {
/// Try to decode the given object.
fn decode(s: &str) -> Result<Self>;
diff --git a/crates/tor-netdoc/src/doc/netstatus/rs/md.rs b/crates/tor-netdoc/src/doc/netstatus/rs/md.rs
index 8a104211f..7664c3c06 100644
--- a/crates/tor-netdoc/src/doc/netstatus/rs/md.rs
+++ b/crates/tor-netdoc/src/doc/netstatus/rs/md.rs
@@ -17,6 +17,11 @@ use tor_llcrypto::pk::rsa::RsaIdentity;
use tor_protover::Protocols;
/// A single relay's status, as represented in a microdesc consensus.
+#[cfg_attr(
+ feature = "dangerous-expose-struct-fields",
+ visible::StructFields(pub),
+ non_exhaustive
+)]
#[derive(Debug, Clone)]
pub struct MdConsensusRouterStatus {
/// Underlying generic routerstatus object.
diff --git a/crates/tor-netdoc/src/doc/netstatus/rs/ns.rs b/crates/tor-netdoc/src/doc/netstatus/rs/ns.rs
index a5bc502f6..56e6bd3eb 100644
--- a/crates/tor-netdoc/src/doc/netstatus/rs/ns.rs
+++ b/crates/tor-netdoc/src/doc/netstatus/rs/ns.rs
@@ -20,6 +20,11 @@ use std::convert::TryInto;
/// A single relay's status, as represented in a "ns" consensus.
///
/// Only available if `tor-netdoc` is built with the `ns_consensus` feature.
+#[cfg_attr(
+ feature = "dangerous-expose-struct-fields",
+ visible::StructFields(pub),
+ non_exhaustive
+)]
#[derive(Debug, Clone)]
pub struct NsConsensusRouterStatus {
/// Underlying generic routerstatus object.
diff --git a/crates/tor-netdoc/src/doc/routerdesc.rs b/crates/tor-netdoc/src/doc/routerdesc.rs
index 7986e62ab..c129c2335 100644
--- a/crates/tor-netdoc/src/doc/routerdesc.rs
+++ b/crates/tor-netdoc/src/doc/routerdesc.rs
@@ -91,6 +91,11 @@ pub struct RouterAnnotation {
/// Before using this type to connect to a relay, you MUST check that
/// it is valid, using is_expired_at().
#[allow(dead_code)] // don't warn about fields not getting read.
+#[cfg_attr(
+ feature = "dangerous-expose-struct-fields",
+ visible::StructFields(pub),
+ non_exhaustive
+)]
pub struct RouterDesc {
/// Human-readable nickname for this relay.
///