Commit Graph

69 Commits

Author SHA1 Message Date
eta 8509dbc920 Merge branch 'upgrade_dependencies' into 'main'
Upgrade various dependencies, now that we are MSRV 1.56

Closes #313 and #334

See merge request tpo/core/arti!476
2022-04-27 12:27:28 +00:00
Nick Mathewson 5484bcc21f Merge branch 'download-schedule' into 'main'
DownloadSchedule: Introduce Builder

See merge request tpo/core/arti!473
2022-04-26 18:47:08 +00:00
Nick Mathewson aaab6f3812 Upgrade to AES 0.8
Now that we require Rust 1.56, we can upgrade to AES 0.8.  This
forces us to have some slight API changes.

We require cipher 0.4.1, not cipher 0.4.0, since 0.4.0 has
compatibility issues with Rust 1.56.
2022-04-26 12:16:22 -04:00
Ian Jackson 20d61dd4d4 DirMgrConfig: Rename two fields that contained a _config
This entire struct is config.  This is otiose.
2022-04-26 15:29:33 +01:00
Ian Jackson d2cc0aa50a Document breaking changes to DownloadSchedule etc. 2022-04-26 15:19:52 +01:00
Nick Mathewson c1ea419477 Merge branch 'main' into 'msrv_1_56'
# Conflicts:
#   crates/tor-config/Cargo.toml
#   crates/tor-dirmgr/src/state.rs
#   doc/semver_status.md
2022-04-26 12:45:16 +00:00
Nick Mathewson d1fcd3eeae Update semver_status to note that all crates have had a breaking change. 2022-04-25 13:31:06 -04:00
Ian Jackson 3f44078227 Add semver note about added macros in tor-condfig 2022-04-25 18:19:03 +01:00
Ian Jackson f6506721ab Add semver notes for AuthorityListBuilder, PredictedPortsListBuilder
These were omitted in the earlier commits.
2022-04-25 18:15:25 +01:00
Ian Jackson 166af2c3f6 Fix error return type of AuthorityBuilder 2022-04-25 12:41:39 +01:00
Ian Jackson 79decd4ac8 logfiles: Introduce LogfileListConfigBuilder
In
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/462#note_2797697
we decided not to do this.

However, having looked again at the way the FallbackList works, I
think there is a lot of value in making these two things (and anything
else like them[1]) as similar as possible.

[1] At least PreemptiveCircuitConfig.initial_predicted_ports and
NetworkConfig.authorities need the same treatment, and perhaps also
GuardUsage.restrictions (although there is no
GuardRestrictionBuilder).

In the irc discussion I imagined `LogfilesConfigBuilder` as opposed to
`LogfileConfigBuilder` (differing only in the `s`) which would be bad,
but we can use `List` instead.

We do *not* need to abstract away the validated version of the config.
Providing a type alias helps the derive_builder sub_builder DTRT
without needing special overrides.

I have split this commit so that we can drop it, if we conclude it's
not wanted.
2022-04-22 17:48:03 +01:00
Ian Jackson 962b6c32e1 fallback list: Introduce and use FallbackListBuilder
Now the network fallbacks configuration wants to Deserialize
a Vec<FallbackDirBuilder>, rather than validated Vec<FallbackDir>.

Methods on FallbackListBuilder are as per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/462#note_2797697
mutatis mutandi for the fact that this struct has only fallbacks in it.
2022-04-22 17:48:03 +01:00
Nick Mathewson 482c022e23 circmgr: Remove now-unused scheduled entry points.
Now that we have TaskSchedule, we don't need to expose these any
longer.
2022-04-12 09:04:10 -04:00
Nick Mathewson cf362fac9f Implement a better clock skew estimator.
This time, our estimator discards outliers, takes the mean of what's
left, and uses the standard deviation to try to figure out how
seriously to take our report of skew/not-skew.

These estimates are still not actually used.
2022-04-11 12:34:16 -04:00
Nick Mathewson 0050045867 ChanMgr: Return provenance information from get_or_launch
We need this since we want to report certain conditions only when
they happen on a new channel, not if we observe them on a
preexisting channel.
2022-04-07 10:46:06 -04:00
Nick Mathewson 9160b55c57 chanmgr: bubble ClockSkew up through the Error object.
Fortunately, we don't need a separate type here: authenticated
clock skew can only come attached to a `tor_proto::Error`.

We also remove skew from `tor_proto::Error::HandshakeCertsExpired`,
since it would now be redundant.
2022-04-07 10:15:28 -04:00
Nick Mathewson 7656ab0931 Channel: Expose our view of whether the clock is skewed, and the age
of a channel.

At first I wanted to have this information not be a part of channels
at all, but it is a fairly tiny amount of data, and the alternatives
are pretty crufty.
2022-04-07 10:07:35 -04:00
Nick Mathewson 142e28cd96 Merge branch 'main' into 'separate_dir_status'
# Conflicts:
#   doc/semver_status.md
2022-04-06 13:33:01 +00:00
Nick Mathewson 2c51316604 Merge branch 'main' into 'retriable'
# Conflicts:
#   doc/semver_status.md
2022-04-05 14:48:51 +00:00
Nick Mathewson 57608f9609 Add RetrySchedule::reset()
Previously the code would do stuff like

```
    schedule = RetrySchedule::new(INITIAL_DELAY);
```

which is needlessly verbose, since the schedule already keeps track
of its initial delay.
2022-04-04 12:32:18 -04:00
Nick Mathewson 86c59dd1f3 circmgr: Avoid a race condition in circuit usage restriction
We were treating restrict_mut() failures as internal errors, and
using internal errors to represent them.  But in fact, these
failures are entirely possible based on timing.  Here's how it
happens:

* Two different circuit requests arrive at the same time, and both
  notice a pending circuit that they could use.
* The pending circuit completes; both pending requests are notified.
* The first request calls restrict_mut(), and restricts the request
  in such a way that the second couldn't use it.
* The second request calls restrict_mut(), and gets a failure.

Because of this issue, we treat these errors as transient failures
and just wait for another circuit.

Closes #427.

(This is not a breaking API change, since `AbstractSpec` is a
crate-private trait.)
2022-04-04 11:14:52 -04:00
Nick Mathewson 58a1e89c8d rtmock: add the ability to make a connection time out. 2022-04-02 15:48:41 -04:00
Nick Mathewson 3103549cba socksproto: remove some unused accessors. 2022-04-02 12:01:20 -04:00
Nick Mathewson 4a3df6a26f Clean out semver_status.md 2022-04-01 11:18:35 -04:00
Nick Mathewson ea520898fd Implement Ord for Ed25519Identity. 2022-03-30 10:39:09 -04:00
Nick Mathewson b28863f03d Update semver_status from recent round of movement. 2022-03-30 10:39:09 -04:00
Nick Mathewson 80b65c3a4d Move fallback.rs into guardmgr.
This is the logical place for it, I think: the GuardMgr's job is to
pick the first hop for a circuit depending on remembered status for
possible first hops.  Making this change will let us streamline the
code that interacts with these objects.
2022-03-30 10:34:48 -04:00
eta ac64bdea27 Make daemon tasks self-contained; introduce NetDirProvider
The various background daemon tasks that `arti-client` used to spawn are
now handled inside their respective crates instead, with functions
provided to spawn them that return `TaskHandle`s.

This required introducing a new trait, `NetDirProvider`, which steals
some functionality from the `DirProvider` trait to enable `tor-circmgr`
to depend on it (`tor-circmgr` is a dependency of `tor-dirmgr`, so it
can't depend on `DirProvider` directly).

While we're at it, we also make some of the tasks wait for events from
the `NetDirProvider` instead of sleeping, slightly increasing
efficiency.
2022-03-30 14:26:43 +01:00
Nick Mathewson 791394cd2b Merge branch 'netinfo-clock-skew' into 'main'
tor-proto: add the ability to learn clock skew from NETINFO cells

See merge request tpo/core/arti!410
2022-03-23 12:49:36 +00:00
Nick Mathewson 0b2cf533ee tor-proto: better errors when handshake fails due to untimely certs
We now check the handshake certificates unconditionally, and only
report them as _expired_ as a last resort.

(Rationale: if somebody is presenting the wrong identity from a year
ago, it is more interesting that they are presenting the wrong ID
than it is that they are doing so with an expired cert.

We also now report a different error if the certificate is expired,
but its expiration is within the range of reported clock skew.

(Rationale: it's helpful to distinguish this case, so that we can
blame the failure on possible clock skew rather than definitely
attributing it to a misbehaving relay.)

Part of #405.
2022-03-23 08:24:36 -04:00
Nick Mathewson 3885a2c05b tor-proto: add a backend to detect reported clock skew.
NETINFO cells, which are sent in every handshake, may contain
timestamps.  This patch adds an accessor for the timestamp in the
Netinfo messages, and teaches the tor-proto code how to compute the
minimum clock skew in the code.

The computation isn't terribly precise, but it doesn't need to be:
Tor should work fine if your clock is accurate to within a few
hours.

This patch also notes a Y2038 problem in the protocol: see
torspec#80.

Part of #405.
2022-03-23 08:24:36 -04:00
Nick Mathewson acfa0f7770 dirclient: Collect and expose peer information from errors.
This commit refactors the dirclient error type into two cases:
errors when constructing a circuit, and errors that occur once we
already have a one-hop circuit.  The latter can usually be
attributed to the specific cache we're talking to.

This commit also adds a function to expose the information about
which directory gave us the info.
2022-03-21 09:06:32 -04:00
Nick Mathewson d38aafa054 Expose more peer information from circuit build failures
We already have the ability to get peer information from ChanMgr
errors, and therefore from any RetryErrors that contain ChanMgr
errors.

This commit adds optional peer information to tor-proto errors, and
a function to expose whatever peer information is available.
2022-03-21 09:06:32 -04:00
Nick Mathewson d778a92225 circmgr: Change API for using FallbackDirs
It'll soon more convenient to pass in FallbackDirs as a slice of
references, rather than just a slice of FallbackDirs: I'm going to
be changing how we handle these in tor-dirmgr.
2022-03-21 09:06:32 -04:00
Ian Jackson 25dab822f1 Add semver note 2022-03-18 16:49:25 -04:00
Nick Mathewson d39557b851 Define accessors for circuit hops.
Closes #415
2022-03-17 12:36:57 -04:00
Nick Mathewson 2c5d985227 Update semver_status.md for isolation changes 2022-03-17 08:50:30 -04:00
Ian Jackson a5ea3533c5 semver notes. 2022-03-16 19:38:12 +00:00
trinity-1686a b7daa9ff12 add integration test and fill semver_status 2022-03-14 21:19:19 +01:00
Nick Mathewson 8f430fd58d Merge branch 'main' into 'intern-more'
# Conflicts:
#   doc/semver_status.md
2022-03-14 14:19:44 +00:00
Ian Jackson dbd7388991 humantime_serde_option: Add note about semver 2022-03-14 10:34:28 +00:00
Nick Mathewson a98ae2a1f0 Canonicalize and intern protover lines on descriptors
This should save around 1MB per consensus, since every relay has a
'protocols' lines, but there are only a few distinct possibilities
for such a line.

Closes #385.
2022-03-11 16:56:12 -05:00
Ian Jackson 927594c3a6 Merge branch 'arti-lib' into 'main'
arti: Move all code from binary crate to library crate

See merge request tpo/core/arti!403
2022-03-11 19:57:53 +00:00
Nick Mathewson b835a48528 Merge branch 'smaller_routerstatus' into 'main'
tor-netdoc: Save allocation space in GenericRouterstatus

Closes #387

See merge request tpo/core/arti!400
2022-03-11 19:55:22 +00:00
Nick Mathewson b40e06c64a Add a missing newline. 2022-03-11 14:03:29 -05:00
Nick Mathewson e7c584f1b3 netdoc: Make versions smaller in GenericRouterStatus
When the version is a Tor version, we can just parse it; otherwise,
we can intern it.  This shrinks GenericRouterStatus and avoids a lot
of extra help allocations.
2022-03-11 14:03:29 -05:00
Ian Jackson e40bf8dfbf Add note about semver. 2022-03-11 18:28:37 +00:00
Ian Jackson d320413912 Merge branch 'config-flatten' into 'main'
Make ArtiConfigBuilder contain a TorClientConfigBuilder

See merge request tpo/core/arti!401
2022-03-11 18:22:23 +00:00
Ian Jackson 3fa42f63d0 config work: Add semver note. 2022-03-11 17:34:15 +00:00
Nick Mathewson 837c7d717b Follow-up from arti!318
Make update_config only conditionally exported; add semver-status update.
2022-03-11 11:34:51 -05:00