Commit Graph

80 Commits

Author SHA1 Message Date
Nick Mathewson f34faec7d9 tor-dirmgr: Create a bootstrap-status exporting mechanism.
The interface is similar to the one exposed by `arti-client`: it
internally uses postage::watch to give a series of events showing
when a bootstrap status is changing.

Thanks to the existing state/driver separation in the DirMgr design
we don't need much new logic: each download state needs to expose
(internally) how far along it is in its download, which the
bootstrap code passes to the DirMgr if it has changed.

I believe that in the long run, we'll probably want to expose more
(or different) information here, and we'll want to process it
differently.  With that in mind, I've made the API for
`DirBootstrapStatus` deliberately narrow, so that we can change its
of its internal later on without breaking code that depends on it.

(The information exposed by this commit is not yet summarized in
`arti-client`.)

Part of #96.
2022-01-18 13:06:08 -05:00
Nick Mathewson 1bd2790d51 Implement the basics of a bootstrap-status API.
The purpose of a this API is to tell the user how far along Arti is
in getting bootstrapped, and if it's stuck, what it's stuck on.

This API doesn't yet expose any useful information: by the time it's
observable to a client, it's always "100% bootstrapped."  But I'm
putting it in a MR now so that we can review the basic idea, and to
avoid conflicts with later work on tickets like #293 and #278.

This is part of #96.
2022-01-13 10:29:49 -05:00
Nick Mathewson f89b0bc752 guardmgr::..::sample_test: Fix intermittent failure.
This test should only fail very rarely (around 1/2.4e8) when guards
are chosen from a list of 20 with uniform probability.  But that
wasn't what we were doing on the mock test network: we were choosing
from a list of 10 viable guards, with nonuniform probability.

As a fix, we change the test network probabilities so that the
guards _are_ chosen with a uniform probability for this test, and we
use a modified version of the test network where there are indeed 20
Guard-flagged relays with the required DirCache=2 protocol.

Closes #276.
2022-01-11 11:35:16 -05:00
Nick Mathewson 7d3482ca1a Bump all crate versions to 0.0.3. 2022-01-11 09:40:32 -05:00
Nick Mathewson 1b6b889c2c Run "cargo update". 2022-01-11 09:27:22 -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
eta b01f695f53 Merge branch 'arti-bench' into 'main'
Introduce an experimental benchmarking utility for Arti

See merge request tpo/core/arti!195
2021-12-16 20:47:47 +00:00
eta 06a94288ca Introduce an experimental benchmarking utility for Arti
The new `arti-bench` crate does a simple end-to-end benchmark test
embedding Arti: it generates some random data (of configurable amount,
depending on command-line parameters), and then sends said data back and
forth via Arti (which should be configured to use a local Chutney
network).

Additionally, the benchmark can also be run via a local SOCKS5 server
(in order to benchmark the performance via a local Chutney node, for
comparison).

The `tests/chutney/arti-bench.sh` sets up and tears down Chutney as
required to make this work.

This is very much a first cut; there are many things that should
eventually get added, such as support for multiple connections, JSON
output capabilities, running multiple tests, ...
2021-12-16 16:12:59 +00:00
Nick Mathewson 7f4578bec1 Refactor directory events to use a FlagPublisher mechanism.
This approach tries to preserve the current interface, but uses a
counter-based event backend to implement a coalescing stream of
events that can be represented as small integers.  The advantage
here is that publishing events no longer needs to be a blocking
operation, since there is no queue to fill up.
2021-12-14 14:05:02 -05:00
eta 8040f7afb2 Merge branch 'reconfigure' into 'main'
Make most arti-client fields reconfigurable.

See merge request tpo/core/arti!181
2021-12-13 14:49:23 +00:00
Trinity Pointard 7dd1a20d42 update rusqlite and revert minimal version change 2021-12-09 11:51:39 +01:00
Nick Mathewson 4536c2ac87 Upgrade to digest v0.10.0
We generally try to track the latest rust-crypto traits when we can:
fortunately, this upgrade didn't break much, considering.
2021-12-07 20:33:46 -05:00
Nick Mathewson b3b6a92145 Add a few tests to tor-config. 2021-12-07 19:52:49 -05:00
Nick Mathewson 606d64eac5 Sketch API for reconfiguration.
This patch doesn't actually make anything reconfigurable, but it
does create an API that will tell you "you can't change the value of
that!"  If the API looks reasonable, I can start making it possible
to change the values of individual items.
2021-12-07 15:42:14 -05:00
eta 47c3163ce5 Merge branch 'bug252' into 'main'
Make DNS fields in arti-client/src/client.rs configurable

Closes #252

See merge request tpo/core/arti!171
2021-12-07 17:27:38 +00:00
eta 45b96579b8 Merge branch 'preemptive-config' into 'main'
Allow configurability on preemptive circuits

Closes #245

See merge request tpo/core/arti!164
2021-12-07 15:04:42 +00:00
Neel Chauhan 0e9c2d274e Allow configurability on preemptive circuits 2021-12-07 15:04:41 +00:00
Nick Mathewson d33d7f7fdd tor-netdir: Use reproducible RNG in tests.
The rand crate's documentation says it's not okay to rely on StdRng
having reproducible output.  So instead, let's switch to ChaCha12Rng
instead (which is what StrRng currently uses).
2021-12-06 15:11:03 -05:00
Neel Chauhan f32a10865e Make DNS fields in arti-client/src/client.rs configurable 2021-12-03 10:28:42 -08:00
Neel Chauhan d586925388 tor-netdir: Use bitflags for WeightKind 2021-11-30 15:16:12 -08:00
Nick Mathewson 92c56eaa83 One more "cargo update" before the release. 2021-11-30 09:17:31 -05:00
Nick Mathewson eef81d9d57 Bump every crate by one patch version. 2021-11-29 15:21:58 -05:00
Nick Mathewson 805e558045 Run "cargo update" to get latest versions.
Also fix a couple of warnings introduced by now-unneeded imports
with new ed25519 crate.

This is part of the process for releasing our next version.
2021-11-29 14:52:53 -05:00
eta e35a8bf60e Merge branch 'arti-client-config' into 'main'
Further configuration refactoring

See merge request tpo/core/arti!137
2021-11-22 15:43:22 +00:00
eta ee2ec31ede Merge commit '98f38dc' (arti!131) into HEAD
This commit message totally gives away the cursed way in which I use
git. branches? what are those?
2021-11-22 14:40:18 +00:00
eta 98f38dc186 Initial cut at a typed event framework for arti (arti#230).
This implements a basic typed event broadcast mechanism, as described in
arti#230: consumers of the new `tor-events` crate can emit `TorEvent`
events, which others can consume via the `TorEventReceiver`.

Under the hood, the crate uses the `async-broadcast`
(https://github.com/smol-rs/async-broadcast) crate, and a
`futures::mpsc::UnboundedSender` for the event emitters; these are glued
together in the `EventReactor`, which must be run in a background thread
for things to work. (This is done so event sending is always cheap and
non-blocking, since `async-broadcast` senders don't have this
functionality.)

Additionally, the `TorEventKind` type is used to implement selective
event reception / emission: receivers can subscribe to certain event
types (and in fact start out receiving nothing), which filters the set
of events they receive. Having no subscribers for a given event type
means it won't even be emitted in the first place, making things more
efficient.
2021-11-22 14:39:38 +00:00
Nick Mathewson aa83a5e38a Ensure that every section-level config type has a builder() function. 2021-11-21 10:54:34 -05:00
Nick Mathewson 5184f5ba84 Move top-level configuration downwards from `arti` to `arti-config`.
To do this at all neatly, I had to split out `tor-config` from
`arti-config` again, and putting the lower level stuff (paths,
builder errors) into tor-config.  I also changed our use of
derive_builder to always use a common error type, to avoid
error type proliferation.
2021-11-18 11:37:48 -05:00
Nick Mathewson f0dc4a973d Merge remote-tracking branch 'origin/mr/131' 2021-11-17 19:26:28 -05:00
Trinity Pointard ab8e4cb6f0 update dependencies 2021-11-17 20:17:08 +01:00
Nick Mathewson e5c5519f7b Remove dependency from arti-client to tor-config.
I'm about to make tor-config a higher-level module, so it can't be a
dependency for tor-config.
2021-11-16 16:01:55 -05:00
Nick Mathewson 727e420d5c Remove unused "dirs" dependency from tor-persist. 2021-11-16 15:51:35 -05:00
Nick Mathewson f92ad644c9 tor-proto: Use tor-rtcompat macros for testing, not tokio.
Closes #222.
2021-11-15 12:57:01 -05:00
Nick Mathewson 236255514a Update to simple_asn1 0.6.1.
This is a security fix for a panic.

Closes #236
2021-11-14 18:00:45 -05:00
eta 197816d14c Completely overhaul the tor-proto circuit reactor
Rather like e8e9699c3c ("Get rid of
tor-proto's ChannelImpl, and use the reactor more instead"), this
admittedly rather large commit refactors the way circuits in `tor-proto`
work, centralising all of the logic in one large nonblocking reactor
which other things send messages into and out of, instead of having a
bunch of `-Impl` types that are protected by mutexes.

Congestion control becomes a lot simpler with this refactor, since the
reactor can manage both stream- and circuit-level congestion control
unilaterally without having to share this information with consumers,
meaning we can get rid of some locks.

The way streams work also changes, in order to facilitate better
handling of backpressure / fairness between streams: each stream now has
a set of channels to send and receive messages over, instead of sending
relay cells directly onto the channel (now, the reactor pulls messages
off each stream in each map, and tries to avoid doing so if it won't be
able to forward them yet).

Additionally, a lot of "close this circuit / stream" messages aren't
required any more, since that state is simply indicated by one end of a
channel going away. This should make cleanup a lot less brittle.

Getting all of this to work involved writing a fair deal of intricate
nonblocking code in Reactor::run_once that tries very hard to be mindful
of making backpressure work correctly (and congestion control); the old
code could get away with having tasks .await on things, but the new
reactor can't really do this (as it'd lock the reactor up), so has to do
everything in a nonblocking manner.
2021-11-12 15:04:24 +00:00
Nick Mathewson 03cca4ddda Upgrade to async-native-tls 0.4.0 2021-11-12 08:36:41 -05:00
Nick Mathewson 99aefe4bb8 Remove usage of tracing-test 0.1
It requires tracing-subscriber 0.2, which is a lower version than we
want, and which causes trouble with our minimal-versions CI test.

There is a pending issue to fix this; we can reinstate tracing-test
once it is merged:  https://github.com/dbrgn/tracing-test/pull/11
2021-11-11 11:01:32 -05:00
Nick Mathewson 4717bb270f Tests for tor-dirmgr::bootstrap 2021-11-11 08:58:48 -05:00
Nick Mathewson 83d9f2299e Replace all println/eprintln calls outside of arti CLI with trace. 2021-11-04 11:04:59 -04:00
eta e8e9699c3c Get rid of tor-proto's ChannelImpl, and use the reactor more instead
Instead of awkwardly sharing the internals of a `tor-proto` `Channel`
between the reactor task and any other tasks, move most of the internals
into the reactor and have other tasks communicate with the reactor via
message-passing to allocate circuits and send cells.

This makes a lot of things simple, and has convenient properties like
not needing to wrap the `Channel` in an `Arc` (though some places in the
code still do this for now).

A lot of test code required tweaking in order to deal with the refactor;
in fact, fixing the tests probably took longer than writing the mainline
code (!). Importantly, we now use `tokio`'s `tokio::test` annotation
instead of `async_test`, so that we can run things in the background
(which is required to have reactors running for the circuit tests).

This is an instance of #205, and also kind of #217.
2021-11-03 13:19:45 +00:00
Nick Mathewson dddf67a902 Use coarsetime to build an incoming traffic timestamp.
We need this for the circuit timeout estimator (#57).  It needs to
know "how recently have we got some incoming traffic", so that it
can tell whether a circuit has truly timed out, or whether the
entire network is down.

I'm implementing this with coarsetime, since we need to update these
in response to every single incoming cell, and we need the timestamp
operation to be _fast_.

(This reinstates an earlier commit, f30b2280, which I reverted
because we didn't need it at the time.)

Closes #179.
2021-11-02 12:17:11 -04:00
Nick Mathewson d272afb341 Cargo.lock: v0.0.1 is now published. 2021-10-29 11:58:28 -04:00
Nick Mathewson f7a72d7f62 Update Cargo.lock in preparation for Arti 0.0.1 release. 2021-10-29 09:40:35 -04:00
Nick Mathewson 2fae63b5ae Upgrade to fslock version 0.2
This version makes all locks per-handle rather than per-process, by
moving from lockf() to flock() on unix.
2021-10-27 14:52:09 -04:00
eta 4fa0122dde Improve and future-proof the `arti` CLI
This switches out `arti`'s argument-parsing library with `clap`, which
is a lot more featureful (and very widely used within the Rust
ecosystem). We also now use a lot of `clap`'s features to improve the
CLI experience:

- The CLI now expects a subcommand (currently, either "help", or "proxy"
  for the existing SOCKS proxy behaviour). This should let us add
  additional non-SOCKS-proxy features to arti in future.
- `clap` supports default values determined at runtime, so the way the
  default config file is loaded was changed: now, we determine the
  OS-specific path for said file before invoking `clap`, so the help
  command can show it properly.
  - The behaviour of `tor_config` was also changed; now, one simply
    specifies a list of configuration files to load, together with
    whether they're required.
  - That function also way overused generics; this has been fixed.
- Instead of using the ARTI_LOG environment variable to configure
  logging, one now uses the `-l, --log-level` CLI option.
  (The intent is for this option to be more discoverable by users.)
- The `proxy` subcommand allows the user to override the SOCKS port used
  on the CLI without editing the config file.
2021-10-27 19:11:48 +01:00
Nick Mathewson 968ffa3d6c Migrate tor-dirmgr from chrono to time 0.3
(This appears to be the emerging consensus of how to handle
RUSTSEC-2020-0159.)
2021-10-24 11:12:06 -04:00
Nick Mathewson 4893e9a15f Migrate tor-netdoc from chrono to time 0.3
(This appears to be the emerging consensus of how to handle
RUSTSEC-2020-0159.)
2021-10-24 10:50:21 -04:00
Nick Mathewson 89de07686d Upgrade to latest tracing-{subscriber,journald} 2021-10-23 22:23:26 -04:00
Nick Mathewson fa266c5644 Upgrade to new version of simple_asn1. 2021-10-22 15:44:37 -04:00
Nick Mathewson 7c7a388e28 Rename tor_client/arti_tor_client to arti_client.
Solves a name conflict with the existing tor_client create.

Closes #130.
2021-10-21 14:22:11 -04:00