From 69bb6313fd16a232d06af9596c6b3bb72115a0f1 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Fri, 12 Nov 2021 13:54:03 -0500 Subject: [PATCH] Remove the unused `published` field from GenericRouterStatus. This field isn't used in modern Tor, and has never been used in Arti. If tor!489 is merged, then it will no longer contain a useful value in future consensuses. We shouldn't store it, or else somebody else will get the smart idea of using it for something. This commit breaks API compatibility for tor-netdoc with the `build_docs` feature enabled. I haven't entered that into the semver_status.md file, since we already have a pending tor-netdoc API breaker in !129. --- crates/tor-netdoc/src/doc/netstatus/build.rs | 1 - crates/tor-netdoc/src/doc/netstatus/rs.rs | 12 +++--------- crates/tor-netdoc/src/doc/netstatus/rs/build.rs | 13 ------------- 3 files changed, 3 insertions(+), 23 deletions(-) diff --git a/crates/tor-netdoc/src/doc/netstatus/build.rs b/crates/tor-netdoc/src/doc/netstatus/build.rs index faf8b5872..8bb0d6a93 100644 --- a/crates/tor-netdoc/src/doc/netstatus/build.rs +++ b/crates/tor-netdoc/src/doc/netstatus/build.rs @@ -432,7 +432,6 @@ mod test { .rs() .nickname("Fred".into()) .identity([155; 20].into()) - .published(now - one_hour * 6) .add_or_port(SocketAddr::from(([10, 0, 0, 60], 9100))) .add_or_port("[f00f::1]:9200".parse().unwrap()) .dir_port(66) diff --git a/crates/tor-netdoc/src/doc/netstatus/rs.rs b/crates/tor-netdoc/src/doc/netstatus/rs.rs index 34ad32dbc..31b64c23d 100644 --- a/crates/tor-netdoc/src/doc/netstatus/rs.rs +++ b/crates/tor-netdoc/src/doc/netstatus/rs.rs @@ -63,13 +63,6 @@ struct GenericRouterStatus { nickname: String, /// Fingerprint of the old-style RSA identity for this relay. identity: RsaIdentity, - /// Declared time at which the router descriptor for this relay - /// was published. - /// - /// This value should be ignored for all purposes; see - /// [proposal 275](https://gitlab.torproject.org/tpo/core/torspec/-/blob/master/proposals/275-md-published-time-is-silly.txt). - #[allow(dead_code)] // TODO: remove this some day? - published: time::SystemTime, /// A list of address:port values where this relay can be reached. addrs: Vec, /// Declared OR port for this relay. @@ -266,7 +259,9 @@ where let identity = RsaIdentity::from_bytes(ident.as_bytes()) .ok_or_else(|| Error::BadArgument(r_item.pos(), "Wrong identity length".to_string()))?; let skip = if microdesc_format { 0 } else { 1 }; - let published: time::SystemTime = { + // We check that the published time is well-formed, but we never use it + // for anything in a consensus document. + let _ignore_published: time::SystemTime = { // TODO: It's annoying to have to do this allocation, since we // already have a slice that contains both of these arguments. // Instead, we could get a slice of arguments: we'd have to add @@ -326,7 +321,6 @@ where Ok(GenericRouterStatus { nickname, identity, - published, addrs, or_port, dir_port, diff --git a/crates/tor-netdoc/src/doc/netstatus/rs/build.rs b/crates/tor-netdoc/src/doc/netstatus/rs/build.rs index a462f3f53..9089c8ce7 100644 --- a/crates/tor-netdoc/src/doc/netstatus/rs/build.rs +++ b/crates/tor-netdoc/src/doc/netstatus/rs/build.rs @@ -9,7 +9,6 @@ use tor_llcrypto::pk::rsa::RsaIdentity; use tor_protover::Protocols; use std::net::SocketAddr; -use std::time::SystemTime; /// A Builder object for creating a RouterStatus and adding it to a /// consensus. @@ -19,8 +18,6 @@ pub struct RouterStatusBuilder { nickname: Option, /// See [`GenericRouterStatus::identity`]. identity: Option, - /// See [`GenericRouterStatus::published`]. - published: Option, /// See [`GenericRouterStatus::addrs`]. addrs: Vec, /// See [`GenericRouterStatus::dir_port`]. @@ -43,7 +40,6 @@ impl RouterStatusBuilder { RouterStatusBuilder { nickname: None, identity: None, - published: None, addrs: Vec::new(), dir_port: 0, doc_digest: None, @@ -71,13 +67,6 @@ impl RouterStatusBuilder { self.identity = Some(identity); self } - /// 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 routerstatus. /// /// At least one value here is required. @@ -138,7 +127,6 @@ impl RouterStatusBuilder { let identity = self .identity .ok_or(Error::CannotBuild("Missing RSA identity"))?; - let published = self.published.unwrap_or_else(SystemTime::now); if self.addrs.is_empty() { return Err(Error::CannotBuild("No addresses")); } @@ -158,7 +146,6 @@ impl RouterStatusBuilder { Ok(GenericRouterStatus { nickname, identity, - published, addrs: self.addrs.clone(), or_port, dir_port: self.dir_port,