Commit Graph

1750 Commits

Author SHA1 Message Date
Nick Mathewson b0fd7cff8e Merge remote-tracking branch 'origin/mr/102' 2021-10-26 13:01:01 -04:00
Nick Mathewson da45008644 Merge branch 'pb_lite_squashed' 2021-10-26 12:03:51 -04:00
Nick Mathewson 682f31b1bf Avoid a strange borrow syntax in tor_guardmgr::sample
I'm not sure what I was thinking here.
2021-10-26 12:03:23 -04:00
Nick Mathewson 72ebaed16b Do not blame a guard for failures on non-random circuits.
We must not apply our new path-bias behavior (where we blame a guard
if it gives us too many indeterminate circuit failures) if the path
was not chosen at random.  If too many random paths fail, we know
that's suspicious, since the other relays are a random sample.  But
if a bunch of user-provided paths fail, that could simply be because
the user's chosen exit is down.
2021-10-26 12:03:23 -04:00
Nick Mathewson 8c69b5d389 Implement a "lightweight" form of pathbias detection.
We now track, for every guard: the total number of successful
circuits we've built through it, along with the total number of
"indeterminate" circuits.

Recall that a circuit's status is "indeterminate" if it has failed
for a reason that _might_ be the guard's fault, or might not be the
guard's fault.  For example, if extending to the second hop of the
circuit fails, we have no way to know whether the guard deliberately
refused to connect there, or whether the second hop is just offline.

But we don't want to forgive all indeterminate circuit failures: if
we did, then a malicious guard could simply reject any second hops
that it didn't like, thereby filtering the client into a chosen
set of circuits.

As a stopgap solution, this patch now makes guards become
permanently disabled if the fraction of their circuit failures
becomes too high.

See also general-purpose path bias selection (arti#65), and Mike's
idea for changing the guard reachability definition (torspec#67).
This patch doesn't do either of those.

Closes #185.
2021-10-26 12:03:23 -04:00
eta e8419abd25 Overhaul the way WaitFor and the MockSleepProvider work
Instead of racily advancing time forward, this commit attempts to rework
how WaitFor works, such that it makes advances when all sleeper futures
that have been created have been polled (by handing the MockSleepRuntime
a Waker with which to wake up the WaitFor).

The above described mechanics work well enough for the double timeout
test, but fail in the presence of code that spawns asynchronous /
background tasks that must make progress before time is advanced for the
test to work properly. In order to deal with these cases, a set of APIs
are introduced in order to block time from being advanced until some
code has run, and a carveout added in order to permit small advances in
time where required.

(In some cases, code needed to be hacked up a bit in order to be made
properly testable using these APIs; the `MockablePlan` trait included in
here is somewhat unfortunate.)

This should fix arti#149.
2021-10-26 16:33:23 +01:00
Nick Mathewson a3c472c67f Tests and refactoring for IsolationMap. 2021-10-26 09:58:09 -04:00
Nick Mathewson be4823818e TorClient::resolve_ptr should take an IpAddr. 2021-10-26 09:42:25 -04:00
Nick Mathewson 1b6098d00f More tests for arti_client::address 2021-10-26 09:32:41 -04:00
Nick Mathewson fadb6727d6 Merge branch 'isolate_clients' 2021-10-26 08:00:27 -04:00
Nick Mathewson 5f2d2c1cac Upgrade curve25519-dalek requirement to 3.2.0
We need this now that we check for contributory behavior.
2021-10-25 14:06:57 -04:00
Dimitris Apostolou c26dc07fbb
Fix typos and cleanup 2021-10-25 19:58:42 +03:00
Nick Mathewson 47234655ce Turn StreamIsolation into a separate type.
Now that we have two kinds of isolation tokens (those set on a
stream, and those set by the stream's associated TorClient), we
need a more sophisticated kind of isolation.

This fixes the bug introduced with the previous commit, where
per-stream tokens would override per-TorClient tokens.
2021-10-25 12:32:18 -04:00
Nick Mathewson 16f6ee4b54 Add an isolate_client() function to create an isolated TorClient.
When two TorClients are isolated, their streams shouldn't share
circuits, even though they share internal circuit and guard state.
2021-10-25 12:02:44 -04:00
Nick Mathewson 84f81d14eb guardmgr: Don't use guards that are marked as unlisted.
Closes #202.
2021-10-25 10:27:13 -04:00
Nick Mathewson b477f12d83 s/arti-arti-client/arti-client/ and regenerate readme files 2021-10-25 08:40:00 -04:00
Nick Mathewson 529d5d5efb Fix a typo in a comment. 2021-10-25 08:25:59 -04:00
Nick Mathewson c4710ce929 Remove chrono exception from cargo_audit.sh 2021-10-24 11:33:12 -04: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 e00a1c59ae Run "cargo fix --edition-idioms=2018". 2021-10-22 09:05:45 -04:00
Nick Mathewson 730be38867 Replace references to arti-client in the documentation. 2021-10-21 14:22:21 -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
Nick Mathewson e9a29b4523 Remove #![allow(clippy::unnecessary_wraps)] in tor-proto. 2021-10-21 14:03:32 -04:00
Nick Mathewson 6af5700c5d Remove #![allow(unreachable_pub)] in shared_ref.rs 2021-10-21 14:00:38 -04:00
Nick Mathewson babd0b53ae Remove #![allow(clippy::unwrap_used)] in cmdline.rs 2021-10-21 13:59:37 -04:00
Nick Mathewson 55ef69724c Remove #![allow_unused] in tor_chanmgr::mgr 2021-10-21 13:48:06 -04:00
Nick Mathewson 7159941ae1 Remove #![allow(dead_code)] in timeouts.rs 2021-10-21 13:42:53 -04:00
Nick Mathewson f3dc66d964 Merge branch 'share_state' 2021-10-21 13:34:38 -04:00
Nick Mathewson 8a99833777 Implement the guard side of shared state directories. 2021-10-21 13:31:38 -04:00
David Goulet b863e63a21 fallbackdir: Regenerate list for October 2021
Closes #200

Signed-off-by: David Goulet <dgoulet@torproject.org>
2021-10-21 09:18:03 -04:00
Nick Mathewson fdddb74de4 Mark consensus as "not-pending" even if its microdescs come from cache.
Previously our code would clear the 'pending' flag on a consensus
only when a _downloaded_ md made it become usable.

Closes #199.
2021-10-20 14:04:54 -04:00
Nick Mathewson 43506601dc Move tor-dirmgr to use a sync::Mutex.
The futures:🔒:Mutex was unnecessary, since we never held it
when we were suspending.
2021-10-20 13:46:44 -04:00
Nick Mathewson c8cfbda339 Finish the timeout-inference side of shared state. 2021-10-20 13:13:15 -04:00
Nick Mathewson db0921fd7e Add a timeout estimator to take estimates from another process. 2021-10-20 12:41:59 -04:00
Nick Mathewson 16ec1d21f2 Allow type of timeout estimator to change at runtime.
This is a big change, but it does simplify the type of Builder a
little, and isolates locking across different (potential) timeout
estimator types.
2021-10-20 12:06:58 -04:00
Nick Mathewson fe85f44fd0 Remove try_lock from StorageHandle. 2021-10-20 09:42:34 -04:00
Nick Mathewson 7b6ed9dab6 Replace the return type of StorageMgr::try_lock with a tristate
It's useful to know now only if we now have the lock, but also if we
just got it for the first time.
2021-10-20 09:37:53 -04:00
Nick Mathewson 650c5a358c Remove unused d_pre from DiffResult. 2021-10-20 08:17:37 -04:00
Nick Mathewson b53abdb67e Implement the "request_loyalty" configuration option 2021-10-19 16:25:52 -04:00
Nick Mathewson 445ec6d220 Fix most warnings from nightly.
(One represents code that I forgot to write.)
2021-10-19 16:21:12 -04:00
Nick Mathewson fc1556461f Fix a broken rustdoc link. 2021-10-19 16:07:13 -04:00
eta e4a3ae492a tor-client/examples: add `hyper` example
The new `hyper` tor-client example demonstrates integrating arti with the
popular Rust `hyper` HTTP library by implementing a custom Hyper "connector"
(a type that can initiate connections to HTTP servers) that proxies said
connections via the Tor network.
2021-10-19 15:59:02 -04:00
Nick Mathewson fb2c7cb85a Also implement tokio Async{Read,Write} on Data{Reader,Writer}.
This will let callers use the tokio traits on these types too, if
they call `split()` on the DataStream.

(Tokio also has a `tokio::io::split()` method, but it requires a
lock whereas `DataStream::split()` doesn't.)
2021-10-19 15:49:49 -04:00
Nick Mathewson a9a9f70eb9 Add a little documentation about when you'll need the tokio trait. 2021-10-19 15:48:55 -04:00
Nick Mathewson f5a7916717 Merge remote-tracking branch 'origin/mr/97' 2021-10-19 15:39:18 -04:00
Nick Mathewson ed6ca1bc18 Move TorClientBuilder into tor_client::config, for consistency. 2021-10-19 15:34:27 -04:00
Nick Mathewson d245147c7f Make elements of TorClientConfig private. 2021-10-19 15:29:36 -04:00