Commit Graph

3152 Commits

Author SHA1 Message Date
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
eta 082a968eb8 Merge branch 'move-system-config' into 'main'
Move SystemConfig to arti::cfg

Closes #418 and #314

See merge request tpo/core/arti!427
2022-03-23 11:43:19 +00:00
eta c35bd79f5c Merge branch 'more_iso_docs' into 'main'
Expand documentation for isolation traits

See merge request tpo/core/arti!420
2022-03-23 11:42:51 +00:00
Nick Mathewson 84b98136c2 Merge branch 'channel_retries' into 'main'
Change rules for retrying guards (and marking them broken)

See merge request tpo/core/arti!426
2022-03-21 20:02:08 +00:00
Nick Mathewson ee204328dd Expand some comments based on review from @diziet. 2022-03-21 15:16:00 -04:00
Nick Mathewson 4a644a9879 circmgr: When planning, only keep one error; log them all. 2022-03-21 15:06:05 -04:00
Nick Mathewson b0b1c5c469 Merge branch 'comment' into 'main'
Adjust a comment

See merge request tpo/core/arti!428
2022-03-21 18:25:03 +00:00
Ian Jackson 9de0c024bf Adjust a comment
Noticed this while reviewing !426
2022-03-21 17:44:50 +00:00
Nick Mathewson 9ee502cbec Fix build with Rust 1.53.
Pattern bindings after `@` weren't stabilized then :/
2022-03-21 12:15:23 -04:00
Ian Jackson 1c213d4d89 Move SystemConfig to arti::cfg
Fixes #314, #418.
2022-03-21 15:54:11 +00:00
Nick Mathewson 28553d1cf4 Merge branch 'move-more-config' into 'main'
Move almost all of the rest of options.rs to arti crate

See merge request tpo/core/arti!425
2022-03-21 14:46:46 +00:00
Nick Mathewson 1ec0ed45c8 dirmgr: Note errors and inform the circmgr about them.
Some error types indicate that the guard has failed as a dircache.
We should treat these errors as signs to close the circuit, and to
mark the guard as having failed.
2022-03-21 10:27:53 -04:00
Nick Mathewson 8306a9cdcf GuardMgr:: generalize GuardId::from_relay. 2022-03-21 10:27:53 -04:00
Ian Jackson c3d56fb137 Run rustfmt to tidy up imports 2022-03-21 13:27:07 +00:00
Nick Mathewson 24e89a470f GuardMgr: new API to record guard problems from outside the crate.
We'll need this so that we can say "This guard behaved bogusly
as a directory cache; try somebody else."
2022-03-21 09:06:32 -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 87a3f6b58a dirclient: Remember the source of each resposne we receive. 2022-03-21 09:06:32 -04:00
Nick Mathewson 138287beb5 Reformat tor-dirclient Cargo.toml 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
Nick Mathewson 451a53a5bf circmgr: use AllGuardsDown to retry better
If all guards are down and they won't be retriable for a while, try
waiting that long to get whichever guard _is_ retriable.

Additionally, if we are making multiple circuit plans in parallel,
only report our planning as having failed if we failed at making
_all_ the plans.  Previously we treated any failure as fatal for the
other plans, which could lead to trouble in the case when guards
were all down or pending.

Part of #407.
2022-03-21 09:06:32 -04:00
Nick Mathewson eed1f06662 GuardMgr: revise handling of "all guards are down".
When all guards are down, we would previously mark them all as up,
and retry aggressively.  But that's far too aggressive: if there's
something wrong with our ability to connect to guards, it makes us
hammer the network over and over, ignoring all the guard retry
timeouts in practice.

Instead,
  * We now allow the `pick_guard()` function to fail without
    automatically retrying.
  * We give different errors in the cases when all our guards are
    down, and when all of the guards selected by our active usage
    are down.
  * Our "guards are down" error includes the time at which a guard
    will next be retriable.

This is part of #407.
2022-03-21 09:06:32 -04:00
Nick Mathewson cb103e04cf GuardMgr: use decorrelated-jitter backoff for retrying guards.
C tor used one schedule, and guard-spec specified another.  But in
reality we should probably use a randomized schedule to retry
guards, for the reasons explained in the documentation for
RetrySchedule.

I've chosen the minima to be not too far from our previous minima
for primary and non-primary guards.

This is part of #407.
2022-03-21 09:06:32 -04:00
Nick Mathewson fdd80dbf5b derive_builder: more entries in Cargo.lock 2022-03-21 09:04:00 -04:00
Ian Jackson a1236406c8 Merge branch 'udp-cleanup-410' into 'main'
UdpSocket: remove support for connect().

Closes #410

See merge request tpo/core/arti!424
2022-03-21 12:45:28 +00:00
Ian Jackson 94f4728a1c ApplicationConfig: abolish accessor 2022-03-21 12:39:50 +00:00
Ian Jackson 85cf744e9e Move ApplicationConfig to arti crate
Code motion and import fixups.
2022-03-21 12:39:50 +00:00
Ian Jackson 6986a433aa socks: abolish config accessors
Making these fields pub(crate) is quite reasonable and does away with
the need for accessors.
2022-03-21 12:39:50 +00:00
Ian Jackson 77b425ea0c Move ProxyConfig to arti crate
We put this in cfg.rs, rather than (say) socks.rs, because it has
config relating to both socks.rs and dns.rs.

Code motion and import fixups.
2022-03-21 12:39:50 +00:00
Nick Mathewson 98105da708 Merge branch 'move-log' into 'main'
Combine logging config and implementation in arti lib crate

See merge request tpo/core/arti!421
2022-03-21 12:14:06 +00:00
Ian Jackson f7c9910a43 Tidy up filt_from_opt_str
This was clumsy.  Now it is brought together it can be simplified.
2022-03-21 11:44:21 +00:00
Ian Jackson 75a7c91161 Abolish logging filter option accessors
This de-duplicates the code that was in those accessors, and is now in
filt_from_opt_str.

Code motion and direct field access.
2022-03-21 11:44:21 +00:00
Ian Jackson 7e64f65d76 Abolish easy accessors for logging config
There are no longer needed, because the code that uses this
configuration now lives in the same module as the configuration
itself.
2022-03-21 11:44:21 +00:00
Ian Jackson 32d3076a82 Move logging configuration from arti_config::options to arti::logging
Code motion and import fixups.
2022-03-21 11:44:21 +00:00
Ian Jackson b51fccb70e Rename arti::trace module to arti::logging
We are going to move LoggingConfig here.  We should follow the
already-public name IMO.
2022-03-21 11:42:44 +00:00
Ian Jackson 8aea5c9e43 Move ArtiConfig to new arti::cfg module
Code motion and import fixups.
2022-03-21 11:42:33 +00:00
Nick Mathewson ff05ed61d7 Merge branch 'accessors' into 'main'
Abolish some accessors in drmgr

See merge request tpo/core/arti!423
2022-03-18 21:14:14 +00:00
Ian Jackson 25dab822f1 Add semver note 2022-03-18 16:49:25 -04:00
Ian Jackson d651a894de dirmgr: Authority: Abolish v3ident accessor
This makes this information crate-private.  The crate can reasonably
just access it.
2022-03-18 16:49:25 -04:00
Ian Jackson d1a9ed62f7 dirmgr: Authority: Move a method used only for testing 2022-03-18 16:49:25 -04:00
Ian Jackson 23cac566e1 dirmgr: Authority: Abolish two unused accessors 2022-03-18 16:49:25 -04:00
Ian Jackson 9c5480480a dirmgr: NetworkConfig: Abolish accessors
Using accessors for crate-only fields is otiose.
2022-03-18 16:49:25 -04:00
Ian Jackson a6d4109414 dirmgr: NetworkConfig: Rename fallbacks struct field
Rename this to be named the same as its accessor, and use the rename
feature of builder and serde.  (The shorter name is nicer in the code
IMO.)
2022-03-18 16:49:25 -04:00
Nick Mathewson 2aa5f45bc8 UdpSocket: remove support for connect().
Currently, Arti doesn't need this.  But once it does, it will be
way better to have a separate type for connected sockets, rather
than having to error-check every time somebody gives us a socket.

Part of #410
2022-03-18 15:39:40 -04:00
Nick Mathewson 0fdbe701c5 Merge branch 'anyhow' into 'main'
Actually throw an anyhow

See merge request tpo/core/arti!422
2022-03-18 16:32:16 +00:00
Ian Jackson 5a2f1b89f3 Actually throw an anyhow
Prompted by a compiler warning which I weirdly can't seem to reproduce?
2022-03-18 15:52:28 +00:00
Ian Jackson 981e6d7f01 Merge branch 'circ_path_api' into 'main'
ClientCirc: add functions to return the circuit's actual path

Closes #415

See merge request tpo/core/arti!419
2022-03-18 12:38:29 +00:00
Nick Mathewson cb29921e16 Expand documentation for isolation traits
These aren't complete yet; I'm just making this commit to capture
the notes we took on a pad when we were discussing these APIs.

Part of #414.
2022-03-17 13:49:32 -04:00