Make coarsetime dependency and traffic-timestamping non-optional.

Previously coarsetime and the traffic-timestamp feature were
enabled, since they were only required for a small corner of the
guardmgr algorithm.

But in 1.0 and beyond we'll be adding a bunch of other features (eg,
netflow padding, DoS prevention) that will need coarsetime all over
the place.

And since we're going to be doing coarsetime all over the place, the
previous justification for making traffic-timestamping optional (the
tiny performance hit) is no longer relevant.
This commit is contained in:
Nick Mathewson 2022-02-25 10:31:01 -05:00
parent 3d623f5a1f
commit 3d7d609922
4 changed files with 3 additions and 13 deletions

View File

@ -24,7 +24,7 @@ tor-netdir = { path="../tor-netdir", version = "0.0.4"}
tor-linkspec = { path="../tor-linkspec", version = "0.0.3"}
tor-llcrypto = { path="../tor-llcrypto", version = "0.0.3"}
tor-persist = { path="../tor-persist", version = "0.0.3"}
tor-proto = { path="../tor-proto", version = "0.0.4", features=["traffic-timestamp"] }
tor-proto = { path="../tor-proto", version = "0.0.4" }
tor-rtcompat = { path="../tor-rtcompat", version = "0.0.4"}
tor-units = { path="../tor-units", version = "0.0.3"}

View File

@ -15,7 +15,6 @@ default = []
hs = []
ntor_v3 = []
tokio = ["tokio-crate", "tokio-util"]
traffic-timestamp = ["coarsetime"]
[dependencies]
tor-llcrypto = { path = "../tor-llcrypto", version = "0.0.3"}
@ -30,6 +29,7 @@ tor-cell = { path = "../tor-cell", version = "0.0.3"}
arrayref = "0.3"
bytes = "1"
cipher = "0.3.0"
coarsetime = "0.1.20"
digest = "0.10.0"
futures = "0.3.14"
asynchronous-codec = "0.6.0"
@ -47,8 +47,6 @@ zeroize = "1"
tokio-crate = { package = "tokio", version = "1.4", optional = true }
tokio-util = { version = "0.6", features = ["compat"], optional = true }
coarsetime = { version = "0.1.20", optional = true }
[dev-dependencies]
tor-rtcompat = { path = "../tor-rtcompat", version = "0.0.4", features = [ "tokio", "native-tls" ] }
hex-literal = "0.3"

View File

@ -130,7 +130,6 @@ pub type Result<T> = std::result::Result<T, Error>;
/// Timestamp object that we update whenever we get incoming traffic.
///
/// Used to implement [`time_since_last_incoming_traffic`]
#[cfg(feature = "traffic-timestamp")]
static LAST_INCOMING_TRAFFIC: util::ts::OptTimestamp = util::ts::OptTimestamp::new();
/// Called whenever we receive incoming traffic.
@ -138,16 +137,11 @@ static LAST_INCOMING_TRAFFIC: util::ts::OptTimestamp = util::ts::OptTimestamp::n
/// Used to implement [`time_since_last_incoming_traffic`]
#[inline]
pub(crate) fn note_incoming_traffic() {
#[cfg(feature = "traffic-timestamp")]
{
LAST_INCOMING_TRAFFIC.update();
}
LAST_INCOMING_TRAFFIC.update();
}
/// Return the amount of time since we last received "incoming traffic".
///
/// Requires that the `traffic-timestamp` feature is enabled.
///
/// This is a global counter, and is subject to interference from
/// other users of the `tor_proto`. Its only permissible use is for
/// checking how recently we have been definitely able to receive
@ -157,7 +151,6 @@ pub(crate) fn note_incoming_traffic() {
/// cell, and whenever we complete a channel handshake.
///
/// Returns `None` if we never received "incoming traffic".
#[cfg(feature = "traffic-timestamp")]
pub fn time_since_last_incoming_traffic() -> Option<std::time::Duration> {
LAST_INCOMING_TRAFFIC.time_since_update().map(Into::into)
}

View File

@ -2,5 +2,4 @@
pub(crate) mod ct;
pub(crate) mod err;
#[cfg(feature = "traffic-timestamp")]
pub(crate) mod ts;