Commit Graph

2345 Commits

Author SHA1 Message Date
Trinity Pointard 954395573a update fslock to compile android 2021-09-25 12:01:45 +02:00
Nick Mathewson b51e2ff5b3 Upgrade memmap2, directories, and dirs dependencies. 2021-09-23 08:26:29 -04:00
Daniel Eades 9a3b183679 remove unused dep 2021-09-19 09:47:57 +01:00
Jani Monoses 5f1f239d51 Enable js feature for getrandom for WASM.
By default rand does not build for WASM browser targets.
2021-09-17 06:43:02 +03:00
Jani Monoses 08c9edfc54 Stop using anyhow in tor-dirclient. 2021-09-16 14:27:04 -04:00
Nick Mathewson 039601f179 tor-netdir: Add a by_id_pair() function to look up a relay by both IDs. 2021-09-16 10:19:35 -04:00
Jani Monoses b0bb7bd100 Do not use set_ prefix on derive_builder setters 2021-09-16 08:41:04 +03:00
Daniel Eades 27cca71978 derive 'Default' where possible 2021-09-11 20:02:33 +01:00
Nick Mathewson 1c08bb44c8 Add identity-based accessors (and indices) to NetDir.
(Thank goodness for rust; we messed up the coherency in C here so
many times, but I'm pretty sure that this time around we can't have
gotten it wrong.)
2021-09-10 15:13:57 -04:00
Nick Mathewson e5ef19962b Merge remote-tracking branch 'origin/mr/77' 2021-09-10 10:26:14 -04:00
Nick Mathewson 0949582fab Use derive_builder for Authority and FallbackDir. 2021-09-10 10:03:33 -04:00
Nick Mathewson 8bfb04f562 Suppress a cognitive-complexity lint in tests 2021-09-09 14:20:55 -04:00
Nick Mathewson 1c97918d67 Typo fixes 2021-09-09 13:06:05 -04:00
Nick Mathewson 9b2df3edd8 Add guard-related network parameters. 2021-09-09 13:01:52 -04:00
Nick Mathewson 0635ec6721 Add an IntegerDays numeric type. 2021-09-09 12:32:13 -04:00
Nick Mathewson 41f96c4f2f Use macros and traits to simplify the declaration of parameters.
Previously, we'd have to declare the field for a parameter in one
place, its default in a second, and its consensus key in a third.
That's error-prone and not so fun!  This patch changes the
way we declare parameters so that we declare a structure once,
and macros expand it to all do the right thing.

This required a few new traits and implementations to ensure
uniformity across the types that can go in parameters: We need every
parameter type to implement TryFrom<i32> and to implement
SaturatingFromInt32.

Eventually we might want SaturatingFromInt32 to be a more generic
SaturatingFrom, but that's not for now.
2021-09-09 09:29:04 -04:00
Nick Mathewson a00248723d Use derive_builder for the rest of tor_dirmgr::config 2021-09-09 07:38:12 -04:00
Jani Monoses 4d52f99020 Create a separate logging section in config. 2021-09-09 10:38:29 +03:00
Nick Mathewson 372c38e041 Use derive_builder for DownloadScheduleConfig 2021-09-08 17:55:18 -04:00
Nick Mathewson d42d910a4f Use derive_builder for NetworkConfig. 2021-09-08 17:46:00 -04:00
Nick Mathewson 6996c0f1b5 Merge remote-tracking branch 'origin/mr/73' 2021-09-08 16:04:58 -04:00
Nick Mathewson d9dc6f9d5c Fix clippy warnings in tests with --all-features 2021-09-08 14:28:38 -04:00
Nick Mathewson ab0c80de2b Fix/suppress a few more clippy lints in tests.
I'm alright with allowing cognitive-complexity violations in the
tests.
2021-09-08 14:20:47 -04:00
Nick Mathewson 949313e288 Merge remote-tracking branch 'origin/mr/71' 2021-09-08 14:14:39 -04:00
Nick Mathewson 9ba16a3104 Check for correct-ish decoding of all parameters. 2021-09-08 13:46:24 -04:00
Nick Mathewson 929cf84073 Add validation function to WeightSet
Our relay selection code can give wrong answers if we overflow
u64::MAX, so let's make sure we never do that.
2021-09-08 12:38:20 -04:00
Nick Mathewson 0468b41f33 Replace weighted-choice code with rand::seq::SliceRandom.
Doing this makes the code faster, lets us throw away some code, and
makes it easier to add a "choose-N-disjoint relays" implementation.

See large comment about plusses and minuses of new code.  (Note that
the old implementation wasn't constant-time either.)
2021-09-08 12:22:56 -04:00
Daniel Eades fb3b8b84b5 fix/silence clippy lints in test modules 2021-09-08 17:28:31 +02:00
Nick Mathewson 9cf1fa36f4 More tests in pareto.rs 2021-09-08 09:18:23 -04:00
Nick Mathewson 74fa18458e Use same defaults for abandon and close times in timeout code.
On torspec!40, Mike says:

    I don't think there is a practical difference here. As per
    Section 2.4.5, if 60 seconds is not enough and causes the
    liveness test to fail due to too many timeouts, we will double
    the initial timeout.

This makes our behavior the same as C tor.
2021-09-07 14:53:50 -04:00
Nick Mathewson 5d7b08993e Stop making abandoned/successful circuit counts persistent
The C Tor implementation doesn't do this, and Mike says:

   I think it is a reasonable enough assumption that if Tor has
   restarted, this kind data is no longer fresh enough to be
   accurate for this purpose. This is also only 20 circuits here,
   and typical timeouts are now around 1-2 seconds or less.. So a
   restarted client with a timeout that is too low for a new
   internet connection will figure this out pretty quickly. I think
   that is OK.

(from torspec!40)
2021-09-07 14:50:36 -04:00
Nick Mathewson e5cb5de223 A little more test coverage in tor-circmgr::mgr 2021-09-07 14:43:55 -04:00
Nick Mathewson 6c37f78e58 tor_circmgr::mgr -- refactor some duplicate code. 2021-09-07 14:24:16 -04:00
Nick Mathewson 45e880f507 Rename pick_action to clarify that it can modify self 2021-09-07 14:14:31 -04:00
Jani Monoses 39e39cd277 Make journald an optional feature. 2021-09-07 20:56:37 +03:00
Nick Mathewson 353a16ce7e Exclude tor-bytes fuzzing helper code from tarpaulin coverage. 2021-09-07 13:30:53 -04:00
Nick Mathewson 358b3e1ea0 Update corpus and links. 2021-09-07 12:32:50 -04:00
Nick Mathewson f0de653af1 Fix bugs in last fuzzer code. 2021-09-07 12:29:28 -04:00
Nick Mathewson 97692e3cc2 Improvements to array-of-u8 handling in tor-bytes.
Now that we have const generics, we can use them.  We can also avoid
an extra clone in the implementation for [u8; N].

Nothing in our codebase requires that we use Reader or Writer on a
GenericArray holding anything other than u8, so I've switched back
to the more efficient implementation there.

I've added a fuzzer case for the new method, but apparently rustc nightly isn't working too
well with fuzzers for me; I'm going to try it tomorrow.
2021-09-07 09:46:54 -04:00
Jani Monoses d5b0d76435 Do not log to journald by default 2021-09-07 15:56:17 +03:00
Jani Monoses 92d0ae26a9 Allow logging to journald.
Log to journald when available, add journald config option.
Separate logging setup into its own function.
2021-09-07 15:54:42 +03:00
Nick Mathewson bd2c9fd8c1 Document every macro.
(The nightly version of clippy now includes macros for its
missing_docs_in_private_items lint.)
2021-09-07 08:44:47 -04:00
Jani Monoses 25b4421fa6 Fix typos 2021-09-07 07:52:00 +03:00
Nick Mathewson 781dc4bd64 Light refactoring and documentation improvements in proxy.rs 2021-08-27 14:22:15 -04:00
Nick Mathewson 557a0ff40b Move all crates into a `crates` subdirectory.
This will cause some pain for now, but now is really the best time
to do this kind of thing.
2021-08-27 09:53:09 -04:00