Commit Graph

535 Commits

Author SHA1 Message Date
Ian Jackson 821091ae95 Apply suggestions to better describe the purpose of LogGuards. 2022-01-10 13:23:11 -05:00
Nick Mathewson 1a16f5a7d6 Tracing configuration for logfiles, per-target filters
Previously we could only configure one global tracing filter that
applied to stdout and journald.  There was no support for log files,
either.

This patch fixes both issues, by substantially revising the
configuration format: There are now separate filters for each log
file, for journald, and for the console log.  Because we want to
allow multiple logfiles, they have to go into an array in the
configuration.

The configuration logic has grown a bit complicated in its types,
since the tracing_subscriber crate would prefer to have the complete
structure of tracing Layers known statically. That's fine when you
know how many you have, and which kinds there will be, but for
the runtime-configuration case we need to mess around with
`Box<dyn Layer ...>`.

I also had to switch from tracing_subscriber's EnvFilter to its
Targets filter.  It seems "EnvFilter" can only be applied as a Layer
in itself, and won't work as a Filter on an individual Layer.

Closes #166.

Closes #170.
2022-01-10 13:23:11 -05:00
Nick Mathewson 736763fb51 Move tracing setup into a separate module.
No code changes here yet.
2022-01-10 13:17:02 -05:00
eta de1b19c22a Fixup broken doc comment from arti!220
That's what I get for blindly trusting @nickm :p
2022-01-10 15:10:41 +00:00
eta c42fac09a5 Merge branch 'ticket_281' into 'main'
Expose and rename stream timeout config.

Closes #281

See merge request tpo/core/arti!231
2022-01-10 15:05:31 +00:00
Nick Mathewson 01c851ad46 Expose and rename stream timeout config.
Previously we kept this in an ambiguously named type,
`ClientTimeoutConfig`. But everything we do right now is client
related! So `StreamTimeoutConfig` is a better name.

Also, we'd previously neglected to expose the builder for this type
from `TorClientConfigBuilder`. Now we do.

Closes #281.
2022-01-10 09:46:43 -05:00
Nick Mathewson 7819dd7bac Make the arti_client::Result type public.
Closes #280.
2022-01-10 09:33:26 -05:00
eta da848a1b9c Merge branch 'ticket_178' into 'main'
Fix ticket 178: Don't use a NetDir until we have microdescriptors for all of our primary guards.

Closes #178

See merge request tpo/core/arti!220
2022-01-10 14:02:24 +00:00
eta 4b1a3976cb Merge branch 'bug274' into 'main'
Fix busy-loop when consensus is near expiring.

Closes #274

See merge request tpo/core/arti!223
2022-01-10 13:47:52 +00:00
eta e6e65d6574 Merge branch 'minimize_deps' into 'main'
Minimize the required version for each dependency.

Closes #275

See merge request tpo/core/arti!228
2022-01-10 13:44:53 +00:00
Neel Chauhan 439b8b3e64 Use *_with_prefs() for Option<ConnectPrefs> callers in TorClient::connect 2022-01-08 13:36:49 -08:00
Nick Mathewson 4841b50c9f Minimize the required version for each dependency.
I found these versions empirically, by using the following process:

First, I used `cargo tree --depth 1 --kind all` to get a list of
every immediate dependency we had.

Then, I used `cargo upgrade --workspace package@version` to change
each dependency to the earliest version with which (in theory) the
current version is semver-compatible.  IOW, if the current version
was 3.2.3, I picked "3".  If the current version was 0.12.8, I
picked "0.12".

Then, I used `cargo +nightly upgrade -Z minimal-versions` to
downgrade Cargo.lock to the minimal listed version for each
dependency.  (I had to override a few packages; see .gitlab-ci.yml
for details).

Finally, I repeatedly increased the version of each of our
dependencies until our code compiled and the tests passed.  Here's
what I found that we need:

anyhow >= 1.0.5: Earlier versions break our hyper example.

async-broadcast >= 0.3.2: Earlier versions fail our tests.

async-compression 0.3.5: Earlier versions handled futures and tokio
    differently.

async-trait >= 0.1.2: Earlier versions are too buggy to compile our
    code.

clap 2.33.0: For Arg::default_value_os().

coarsetime >= 0.1.20: exposed as_ticks() function.

curve25519-dalek >= 3.2: For is_identity().

generic-array 0.14.3: Earlier versions don't implement
    From<&[T; 32]>

httparse >= 1.2: Earlier versions didn't implement Error.

itertools at 0.10.1: For at_most_once.

rusqlite >= 0.26.3: for backward compatibility with older rustc.

serde 1.0.103: Older versions break our code.

serde_json >= 1.0.50: Since we need its Value type to implement Eq.

shellexpand >= 2.1: To avoid a broken dirs crate version.

tokio >= 1.4: For Handle::block_on().

tracing >= 0.1.18: Previously, tracing_core and tracing had separate
    LevelFilter types.

typenum >= 1.12: Compatibility with rust-crypto crates

x25519-dalek >= 1.2.0: For was_contributory().

Closes #275.
2022-01-07 19:08:58 -05:00
Nick Mathewson e9a507af67 Merge branch 'circ_self_by_ref' 2022-01-07 14:48:21 -05:00
Nick Mathewson c123138f74 Merge branch 'remove-type-annotation' into 'main'
tor-circmgr: Remove a type annotation in a method call

See merge request tpo/core/arti!225
2022-01-07 19:33:04 +00:00
Nick Mathewson 0151ceceb0 ClientCirc: change some methods to take &self
Previously they took Arc<Self>, and then Self, but &self is perfectly
fine here.
2022-01-07 13:55:26 -05:00
Nick Mathewson debac8b973 circmgr: Fix a pair of clippy warnings. 2022-01-07 13:53:21 -05:00
Ian Jackson d63a251afc tor-circmgr: Remove Arc around ClientCirc
See the new commentary text on `ClientCirc` for the rationale.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2022-01-07 18:19:20 +00:00
Ian Jackson 14d7edc5f8 tor-circmgr: tests: Do fake circuit equality by id
We are going to get rid of the Arc.  Happily there is an id which is
always constructed uniquely and preserved by clone.

(auto-deref lets us make the function take &Self instead of &Arc)

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2022-01-07 18:16:43 +00:00
Ian Jackson 7c55141e3f tor-circmgr: tests: Introduce and use FakeCirc::eq()
This removes a lot of open-coded Arc::ptr_eq() calls

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2022-01-07 18:16:43 +00:00
Ian Jackson a034ef3526 tor-circmgr: Replace some Arc::clone with .clone()
This will make the code work when it's not an Arc any more.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2022-01-07 18:16:39 +00:00
Nick Mathewson d9b423c17f Fix busy-loop when consensus is near expiring.
When our current consensus is getting close to being invalid (but
it isn't invalid yet), we try to get a new one. So far, so good.

But we had a bug: when we went to get a new consensus, we'd see that we
had a perfectly fine not-yet-invalid consensus in our cache, reload it,
find that it was ready, and continue!

This patch fixes our behavior: If we have a usable consensus, then
when we reset the bootstrapping process, we ignore any cached consensus.

Fixes bug #274.
2022-01-07 13:16:06 -05:00
Ian Jackson 5469579ca9 tor-circmgr: Remove a type annotation in a method call
This is a method, so the resolution is automatic.  It's not clear to
me why this was written out this way, given that extend_ntor is right
above.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2022-01-07 18:12:27 +00:00
Ian Jackson 19a104e2cc tor-circmgr: Require that AbstractCirc are Clone
We are going to get rid of a lot of Arc, so we need the underlying
thing to be Clone.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2022-01-07 18:12:15 +00:00
Nick Mathewson e8e0f67336 Only replace netdir once we have enough guard MDs.
This prevents a security-failure condition that could happen if our
directory caches don't give us these microdescriptors, but we
nevertheless decide that the directory is usable.

Closes #178
2022-01-06 15:58:43 -05:00
Nick Mathewson 723894b9ea Tests for new guardmgr functionality. 2022-01-06 15:58:36 -05:00
Nick Mathewson 5ac0fcb7ef Add API to check if primary MDs are missing.
We need this information to know if it's okay to migrate to a new
NetDir, or if we need to download more information first.

Part of #178.
2022-01-06 15:58:23 -05:00
Neel Chauhan 5dfedb4c6f De-Arc-ify Buildable for ClientCirc 2022-01-06 12:22:49 -08:00
eta f08854bc69 Merge branch 'main' into 'remove_unused_rngs'
# Conflicts:
#   crates/tor-circmgr/src/build.rs
2022-01-06 15:48:42 +00:00
eta ea41fa3346 Merge branch 'refactor/unwrap-or-default' into 'main'
prefer 'unwrap_or_default' to manual constructor

See merge request tpo/core/arti!215
2022-01-06 15:36:12 +00:00
Nick Mathewson db65fdd04e guardmgr: Don't use no-md guards for data circs.
If we don't know a current microdescriptor for a guard, we can't use it
for multihop circuits, since we don't know its onion keys.

This is part of a fix for #178.
2022-01-06 09:52:21 -05:00
Nick Mathewson 214ac17eed Move a comment to the right place. 2022-01-06 09:05:08 -05:00
Nick Mathewson 5c3300867d Merge remote-tracking branch 'origin/mr/214' 2022-01-06 09:02:09 -05:00
Nick Mathewson 3a456100a8 Merge remote-tracking branch 'origin/mr/217' 2022-01-06 08:30:25 -05:00
Nick Mathewson c15168be61 Merge remote-tracking branch 'origin/mr/212' 2022-01-06 08:28:13 -05:00
Ian Jackson 1e70d56737 arti-bench: Remove a FIXME by saying it's OK for this program to panic 2022-01-06 11:58:01 +00:00
Daniel Eades d68e934716 prefer 'unwrap_or_default' to manual constructor 2022-01-01 19:14:29 +00:00
Daniel Eades 592642a9e6 extend lints to include 'clippy::all' 2021-12-28 20:15:40 +00:00
Neel Chauhan d72d37ff4a Remove a bunch of unused RNGs 2021-12-25 18:44:55 -08:00
Neel Chauhan 383843f0d7 tor-circmgr: Don't clone parameters in create_chantarget() 2021-12-25 17:22:38 -08:00
Neel Chauhan 7dba3d8c51 tor-proto: In begin_stream_impl(), if number of hops is zero, don't continue 2021-12-25 16:01:22 -08:00
Nick Mathewson efe74e8c9b Only count timeouts when we've seen net activity.
This closes arti#256.  It makes our behavior match Tor's more closely,
though it has a simpler implementation than Tor. I think that the extra
complexity in Tor's logic is because we used to record timeouts in
the histogram as well as in the success/failure log.
2021-12-20 15:34:17 -05:00
Nick Mathewson 09d0c20c94 Merge branch 'eta/instant-checked-add' into 'main'
preemptive.rs: Use Instant::checked_add instead of raw subtraction

See merge request tpo/core/arti!206
2021-12-20 20:07:59 +00:00
eta 091065454e preemptive.rs: Use Instant::checked_add instead of raw subtraction
The implementations of `Add` / `Sub` (et al.) on `std::time::Instant`
can panic if the underlying OS structure can't represent the result
(like arti#266). Use Instant::checked_add and print a warning instead,
to prevent panicking.

Also, we now add instead of subtracting; I suspect it's reasonable that
you might not be able to go backward past the first `Instant` created on
some platforms, but going *forward* should probably work?
2021-12-20 19:27:55 +00:00
eta 0cdf65c256 Merge branch 'refactor/must-use-self' into 'main'
address clippy's latest lint

See merge request tpo/core/arti!205
2021-12-20 18:38:18 +00:00
Nick Mathewson 6303a71d58 tor-proto: Replace XXXs with references to arti#269
These will require thought; should we ignore them, act on them, or
continue to  treat them as internal errors?
2021-12-20 10:56:24 -05:00
Nick Mathewson 26fc8073f2 Remove XXXs from tor-circmgr::mgr
IIUC, these anticipatd a need to store min_exit_circs_per_port in
CircMgr.  But the current design, where it goes into preemptive.rs and
thence to usage, seems to work fine.
2021-12-20 10:46:13 -05:00
Nick Mathewson f73f6a4e80 arti-client: Change an XXXX to a TODO.
We _do_ reject bad hostnames: just not where I once thought we might.
We need to decide if the current behavior is what we want (and I think
it is, probably?).
2021-12-20 10:02:24 -05:00
Nick Mathewson a2afb29806 Change an UTF-8 XXX to a TODO.
We're assuming that prop285 is accepted in some form.
2021-12-20 09:54:41 -05:00
Nick Mathewson 8cf143217e tor-netdoc: Change an XXX to a TODO.
Our behavior in handling not-yet-valid router descriptors doesn't match
the C Tor implementation, but it's not a big deal:
we don't currently use router descriptors at all.
2021-12-20 09:46:56 -05:00
Nick Mathewson 6299ca70b4 tor-netdoc: Use a more correct error type
If we fail to convert a curve25519 key to an ed25519 key for checking
the onion-key crosscert, don't call that an internal error: it means
that something is wrong with the provided ntor key.
2021-12-20 08:58:30 -05:00