Commit Graph

1940 Commits

Author SHA1 Message Date
Nick Mathewson 2223398eb1 Make NetDirProvider require Send and Sync.
Our own code is the only stuff that consumes NetDirProvider, and all
the code that consumes it wants it to be Send and Sync.

Making this change avoids our having to define a new function to
upcast Arc<dyn Foo> to Arc<dyn NetDirProvider + Send + Sync>.
2022-06-07 11:44:51 -04:00
Nick Mathewson 3502a12da2 Add a `sleep` function to TaskSchedule.
Having this alias makes it easier to implement more complex
schedules, like those used in DirMgr.
2022-06-07 10:41:44 -04:00
Nick Mathewson 897a2d5fa0 Add "suspend" and "resume" to TaskSchedule.
Unlike "cancel" and "fire", "suspend" and "resume" don't change any
pending timers or events: they just prevent execution of those
events for a while, and let them resume later on.
2022-06-07 10:11:49 -04:00
Nick Mathewson aa3a81c3ba Upgrade serial_test dev-dependency to 0.7.0 2022-06-07 09:22:24 -04:00
Nick Mathewson 7f785b66c2 Upgrade float_eq dev-dependency to 1.0.0 2022-06-07 08:03:55 -04:00
Nick Mathewson df06e7b9bc Upgrade tls-api to latest versions in arti-hyper. 2022-06-07 08:01:39 -04:00
Dimitris Apostolou 8488192ba1
Fix typos 2022-06-05 18:47:51 +03:00
Nick Mathewson 018fda4f73 Merge branch 'testing-rng' into 'main'
New facility for deterministic and reproducible test PRNGs.

See merge request tpo/core/arti!561
2022-06-02 21:11:36 +00:00
Nick Mathewson 0e6a54351d Add an upcast_arc function to NetDirProvider.
This uses some apparently-standard trickery to implement a function
that lets us upcast from Arc<dyn Subtrait> to Arc<dyn Supertrait>.

I considered as alternatives `as_dyn_trait` and `cast_dyn_object`.
Both were nice, but generated a far larger interface than this.
2022-06-02 17:06:11 -04:00
Nick Mathewson 1076f25031 Rewrite tests in tor-netdir to use testing_rng()
The randomized tests in this crate take a lot of iterations to
converge, so they default to using a deterministic PRNG seed with
few iterations and higher tolerance, and they only randomize the
tests (with more iterations and tighter tolerances) when you
explicitly opt in to randomization.

(If you specify a seed explicitly, you're doing that to reproduce a
randomized case, so we use the same behavior.)
2022-06-02 15:48:41 -04:00
Nick Mathewson b4c0febd97 Refactor fallback-set tests to work with deterministic PRNG.
The trouble was that one of the helper functions they used
did not take a PRNG as an argument.
2022-06-02 14:59:55 -04:00
Nick Mathewson 967ea67b7d Use testing_rng() in tests throughout our crates.
This only affects uses of thread_rng(), and affects them all more or
less indiscriminately.  One test does not work with
ARTI_TEST_PRNG=deterministic; the next commit will fix it.
2022-06-02 14:56:42 -04:00
Nick Mathewson 69d352a7c7 New facility for deterministic and reproducible test PRNGs.
The new `testing_rng()` function is meant as a replacement for
thread_rng() for use in unit tests.  By default, it uses a randomly
seeded RNG, but prints the seed before the test so that you can
reproduce any failures that occur.  You can override this via the
environment to use a previous seed, or by using a deterministic
seed for all your tests.

Backend for #486.
2022-06-02 14:51:51 -04:00
Ian Jackson c2d8dac1ce Merge branch 'better-fs-mistrust-badpermissions-string' into 'main'
fs-mistrust: Improve BadPermission string

See merge request tpo/core/arti!554
2022-06-02 11:15:52 +00:00
Ian Jackson 9f4fe6a484 tor-config: Fix a doc link
Nightly cargo doc complaints about this.
2022-06-01 15:48:45 +01:00
Nick Mathewson 07dc49a2dc Fix a copy-paste error in Ed25519 parsing tests.
We accidentally tried to validate (invalid) ed25519 keys
as curve25519 keys.
2022-06-01 08:32:09 -04:00
Nick Mathewson 3de2496303 Add test for parsing bad tor version with too many elements.
This is a coverage-driven test.
2022-06-01 08:32:09 -04:00
Nick Mathewson 3e693fa717 Add test for mutability of RelayFamily. 2022-06-01 08:32:09 -04:00
Nick Mathewson 526fd424f7 Tests for tor_netdoc::util::intern 2022-06-01 08:32:09 -04:00
Ian Jackson 98ccd7e7e2 Merge branch 'lint' into 'main'
lints: Make lint blocks consistent and ensure they stay that way

Closes #469

See merge request tpo/core/arti!557
2022-05-31 18:27:53 +00:00
Alex Xu (Hello71) bc6b02045e fs-mistrust: Improve BadPermission string
To me, "Incorrect permissions on file or directory /path: g=w o=w"
implies that the current permissions on /path are 022.

Change the message to "Incorrect permissions: /path is
u=rwx,g=rwx,o=rwx; need g-w,o-w", which is closer to chmod syntax and is
more useful in non-interactive environments such as CI and support.
2022-05-31 14:23:01 -04:00
Alex Xu (Hello71) 201107906c fs-mistrust: BadPermission(_, _) -> BadPermission(..)
Next commit adds another parameter to Error::BadPermission.
2022-05-31 14:15:03 -04:00
Nick Mathewson a53b3d67d8 Merge branch 'data-stream-err' into 'main'
proto: Only ready a DataStream if CONNECTED was succesfully received

See merge request tpo/core/arti!556
2022-05-31 17:05:39 +00:00
Ian Jackson 9aec60871c Merge branch 'config-test' into 'main'
arti config: Check that example config is exhaustive

See merge request tpo/core/arti!546
2022-05-31 16:33:27 +00:00
trinity-1686a 1d41ae92c7 use the right feature name for llcrypto openssl 2022-05-31 18:27:51 +02:00
Ian Jackson 558ae0673d Merge branch 'self_digests_error_if_0' into 'main'
tor-dirclient: Require that self.digests is nonempty

See merge request tpo/core/arti!553
2022-05-31 16:21:28 +00:00
David Goulet 710709313b proto: Only ready a DataStream if CONNECTED was succesfully received
Signed-off-by: David Goulet <dgoulet@torproject.org>
2022-05-31 12:20:18 -04:00
Ian Jackson 89c4f76b6c tor-config: Suppress unwrap lint in tests
As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/546#note_2808892
2022-05-31 16:58:14 +01:00
Nick Mathewson d707f6215e Merge branch 'config-desc' into 'main'
arti-config: Change description of tombstone crate

See merge request tpo/core/arti!558
2022-05-31 15:25:44 +00:00
Ian Jackson 5b684020ed tor-config: resolve_option tests: disable rsutfmt 2022-05-31 16:06:32 +01:00
Ian Jackson c2fa37c56a tor-config: Add comprehensive tests for resolve_option 2022-05-31 16:06:32 +01:00
Ian Jackson 32e4baa4c4 arti: Demote itertools back to dev-dependency 2022-05-31 15:45:07 +01:00
Ian Jackson c938eeb386 arti-config: Change description of tombstone crate
I was looking to see if we could delete this altogether but I
discovered that on lib.rs the description does not say it's a removed
crate, in the summaries.

Fix this.
2022-05-31 15:26:41 +01:00
Ian Jackson fec706c2f3 lints: Make lint blocks consistent
The remaining consequences of running add_warning
2022-05-31 15:24:11 +01:00
Ian Jackson 91b341de34 lints: arti-testing: Move some allows outside the auto block 2022-05-31 15:24:01 +01:00
Ian Jackson de92a295fb lints: tor-protover: Move two allows outside the auto block
These need to survive.
2022-05-31 15:24:01 +01:00
Ian Jackson 4f42101554 lints: Add let_unit_value allow to all crates
From running add_warning, with manual picking of the right
hunks/lines.
2022-05-31 15:23:52 +01:00
Nick Mathewson f67c0eaf50 Merge branch 'tor-config-tests' into 'main'
Add a few coverage-based tests to tor-config.

See merge request tpo/core/arti!540
2022-05-31 14:08:51 +00:00
Ian Jackson 4634c1712b lints: arti: Move some allows outside the auto block
These need to survive.
2022-05-31 14:39:17 +01:00
Nick Mathewson ca94ec72ef Add a few coverage-based tests to tor-config.
There's nothing major here, but it does fill in a few gaps.
2022-05-31 08:59:30 -04:00
Nick Mathewson 9fed0b39fa Merge branch 'dbg' into 'main'
Revert "Remove dbg!()s in tor-config"

See merge request tpo/core/arti!552
2022-05-31 12:38:59 +00:00
Ian Jackson ba0843da4a lints: Add lint block delimiters to every crate
This was the result of:
  maint/add_warning crates/*/src/{lib,main}.rs
and then manually curating the results.
2022-05-31 13:00:31 +01:00
Ian Jackson 1351945d87 lints: arti-config: Re-add standard lint list
We are going to make lints the same for every crate.
2022-05-31 13:00:31 +01:00
Ian Jackson eb49bc7f46 lints: Suppress unknown lints in a way that works on nightly too
This is ridiculous.
2022-05-31 13:00:21 +01:00
Neel Chauhan 04579c0328 tor-dirclient: Require that self.digests is nonempty 2022-05-30 11:46:54 -07:00
trinity-1686a 0f290da005 add support for openssl backend in llcrypto 2022-05-30 17:22:31 +02:00
Ian Jackson fe9fb6b6ee arti config: Check that example config is exhaustive
This is the final piece of #457.
2022-05-30 16:03:01 +01:00
Ian Jackson 0a324f843f mistrust: Canonicalise prefix from Some("") to None
This allows us to add the proper default example to the arti example
config file.
2022-05-30 16:00:45 +01:00
Ian Jackson ca60859dff arti: config: Canonicalise ports, and provide example dns_port
Now the validated configuration will never be `Some(0)`, even if that
is what was written in the config file.  The arti CLI parser can still
produce this, so we don't touch the code that actually uses this.

(Without the canonicalisation the default builder produces `None` for
the `dns_port`, but the example would produce `Some(0)`, which is
semantically identical but fails the test.)

See https://gitlab.torproject.org/tpo/core/arti/-/issues/488 for some
background.
2022-05-30 16:00:45 +01:00
Ian Jackson fbfaecdf72 config: Provide tor_config::resolve_option and resolve journald
Canonicalise the `logging.journald` setting in the validated
configuration.  Now it will never be `Some("")`, even if that is what
was written in the config file.

This allows us to write `journald = ""` in the example configuration.
(Without the canonicalisation the default builder produces `None` and
the example would produce `Some("")`, which are semantically identical
but fail the test.)

See https://gitlab.torproject.org/tpo/core/arti/-/issues/488 for some
background.
2022-05-30 16:00:45 +01:00
Ian Jackson fb54b5b032 arti: config example: Add entries for tor_network fields
These weren't previously discussed.  It's not practical or useful to
show the actual default values here.
2022-05-30 16:00:45 +01:00
Ian Jackson 116b6c30e0 arti: config example: Add some missing defaults
Found by my forthcoming test.
2022-05-30 16:00:45 +01:00
Ian Jackson d365d73889 arti: example config: Arrange to uncomment logfiles
This makes the config default parser see just "[ ]", an empty list,
which is indeed the default.
2022-05-30 16:00:45 +01:00
Ian Jackson b88c1c1093 tor-config: Drop Serialize and Deserialize from a test type
These violate our rule that *built* structs ought not to be desr.
But this is just in a test.
2022-05-30 16:00:45 +01:00
Ian Jackson c8d5681ff1 arti: Make ProxyConfig no longer Deserialize
That this remained was an oversight.
2022-05-30 16:00:45 +01:00
Ian Jackson e0d9d24348 arti: cfg: Actually uncomment *all* the things in the example 2022-05-30 16:00:45 +01:00
Ian Jackson 017906cdc7 tor-dirmgr: Fix DirSkewTolerance
This was upposed to be one day, I presume!

Also complete a truncated sentence in the docs.
2022-05-30 16:00:45 +01:00
Ian Jackson 5824992471 Merge branch 'post-release-fix-20220527' into 'main'
Fix minor issues found while publishing crates for Arti 0.4.0

See merge request tpo/core/arti!547
2022-05-30 14:57:49 +00:00
Ian Jackson ea80f124ff Merge branch 'bug487' into 'main'
fs-mistrust: add getegid() to getgrouplist() output.

Closes #487

See merge request tpo/core/arti!548
2022-05-30 14:56:49 +00:00
Ian Jackson 064521dcf2 Merge branch 'arti-cfg-tests' into 'main'
add unit tests for ArtiConfig public functions

See merge request tpo/core/arti!551
2022-05-30 14:23:11 +00:00
Ian Jackson aa5e647bd2 Merge branch 'chore/integrate_cargo_sort' into 'main'
Lexically sort Cargo.toml dependencies

Closes #490

See merge request tpo/core/arti!549
2022-05-30 14:19:19 +00:00
Ian Jackson 5327059775 Merge branch 'mistrust_osstring_limitation' into 'main'
fs-mistrust: Document problems with non-UTF8 OsString in toml

See merge request tpo/core/arti!538
2022-05-30 09:54:10 +00:00
trinity-1686a 266b278c74 deduplicate dns requests based on transaction id 2022-05-30 09:52:11 +00:00
michael mccune db6842f666 add unit tests for ArtiConfig public functions
this change adds some simple tests for the ArtiConfig public getter
functions to help expand coverage in this crate.
2022-05-28 20:41:31 -04:00
Orhun Parmaksız bfd41ddb5f
Lexically sort Cargo.toml dependencies
Utilize cargo-sort: https://github.com/DevinR528/cargo-sort

Signed-off-by: Orhun Parmaksız <orhunparmaksiz@gmail.com>
2022-05-28 20:05:51 +03:00
Nick Mathewson a58eaa2893 fs-mistrust: add getegid() to getgrouplist() output.
This fixes a unit test failure in weird environments (like some
containers) where the current effective GID is not included in the
list of current groups.

Closes #487.

Bug reported by @sjm217.
2022-05-27 14:14:29 -04:00
Nick Mathewson 5b1622c283 tor-rtcompat: Fix a warning when building with no backends.
Cargo publish (and probably nobody else!) builds this crate with no
features enabled.  When you do that, you get a warning about an
unused `use std::io`.

Fixing that.
2022-05-27 14:07:06 -04:00
Nick Mathewson 9d36925700 Move tor-error crate to the "rust-patterns" category.
There is no "tor" category; crates.io warned about this.
2022-05-27 14:02:17 -04:00
Ian Jackson 35e3841e4c Revert "Remove dbg!()s in tor-config"
This was done because Nightly Rust complained about these, despite
them all being in tests.  That is now fixed upstream:
  https://github.com/rust-lang/rust-clippy/issues/8758
  https://github.com/rust-lang/rust-clippy/pull/8838

This reverts commit 9d26a91886.
2022-05-27 18:14:03 +01:00
Ian Jackson 0173fce2e9 tor-netdoc: Allow suppressing unknown lints
We want to supress the unused_macro_rules lint in one place but it's
new in Nightly and this triggers yet another lint.
2022-05-27 17:36:54 +01:00
Ian Jackson 1f067c0237 tor-netdoc: Suppress new "unused_macro_rules" lint in one place
The compiler can apparently tell that we aren't generating compile
errors!  Also that we're not yet using a feature provided here.

(New lint in currently Nightly.)
2022-05-27 17:36:52 +01:00
Nick Mathewson 4326aa1de9 Regenerate version bump from previous commit.
This commit was made by reverting the previous commit, then
re-running the script I used to generate it.  In theory there should
be no semantic changes: only changes due to improved formatting from
cargo edit.
2022-05-27 10:18:52 -04:00
Nick Mathewson b232365a75 Semantic version changes for Arti 0.4.0 release
I followed the following procedure to make these changes:

* I used maint/changed_crates to find out which crates had changed
  since 0.3.0.
* I used grep and maint/list_crates to sort those crates in
  topological (dependency) order.
* I looked through semver_status to find which crates were listed as
  having semver-relevant changes (new APIs and breaking changes).
* I scanned through the git logs of the crates with no
  semver-relevant changes listed to confirm that, indeed, they had
  no changes.  For those crates, I incremented their patch-level
  version _without_ changing the version that other crates depend on.
* I scanned through the git logs of the crates with no
  semver-relevant changes listed to confirm that, indeed, they had
  no obvious breaking changes.
* I treated all crates that depend on `arti` and/or `arti-client` as
  having breaking changes.
* I identified crates that depend on crates that have changed, even
  if they have not changed themselves, and identified them as having
  a non-breaking change.
* For all of the crates, I used `cargo set-version -p $CRATE --bump
  $STATUS` (where `STATUS` is `patch` or `minor`) to update the
  versions, and the depended-upon versions.
2022-05-27 09:01:20 -04:00
Nick Mathewson 45d21d2520 Bump versions of trivially-changed crates.
These crates had only clippy fixes that do not affect their
behavior:
        tor-bytes
        tor-cell
        tor-events
        tor-linkspec
        tor-netdir
        tor-socksproto

This crate only had the cargo-husky dependency removed, which
does not affect compatibility:
        tor-llcrypto

Since these changes have no compatibility effects, it is not
necessary to bump the versions of these crates which other crates
depend on.
2022-05-27 08:52:44 -04:00
Nick Mathewson fbc5218af6 Update tor-config README.md. 2022-05-27 08:34:52 -04:00
Nick Mathewson b4a87687f5 Fix a link with nightly rustdoc 2022-05-26 15:40:39 -04:00
Nick Mathewson 487742ea3d fs-mistrust: Document problems with non-UTF8 OsString in toml
It turns out that the `toml` crate can't handle OsString, since
`toml` doesn't support serialize_newtype_variant, and the `serde`
crate tries to serialize OsString using that method.

In this commit we document that limitation, and test that we can at
least round-trip through json.

Found by inspecting test coverage.
2022-05-26 10:36:35 -04:00
Nick Mathewson ae08a023fb Merge branch 'tests-20220525' into 'main'
Add a few coverage-driven tests

See merge request tpo/core/arti!536
2022-05-26 14:35:32 +00:00
Nick Mathewson c33a9d1f4e Remove some stray dbg!() calls. 2022-05-26 09:59:48 -04:00
Nick Mathewson 68b0419752 Merge branch 'standardise-shell' into 'main'
Standardise shell

Closes #425

See merge request tpo/core/arti!533
2022-05-26 12:53:14 +00:00
Ian Jackson 4bf87d61ca Merge branch 'config-split' into 'main'
Break TorClientConfig out of ArtiConfig and warn on unknown config keys

Closes #459 and #417

See merge request tpo/core/arti!529
2022-05-26 10:40:43 +00:00
Ian Jackson c5a8e453b9 tor-config: load: clippy: adopt two suggestions
We can have mem::take, hooray.
2022-05-26 11:03:48 +01:00
Ian Jackson 42ccb68446 tor-config: load: Add missing "not".
As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/529#note_2807331
2022-05-26 10:57:26 +01:00
Ian Jackson f5561c8cdb tor-config: load: Make UnrecognizedKeys not pub
This was a slip.

As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/529#note_2807330
2022-05-26 10:57:04 +01:00
trinity-1686a b380c25e66 update readmes 2022-05-25 22:25:58 +02:00
Nick Mathewson 60023ef656 Test a few more corner cases in tor-persist
Also, if we get an IoError from a call to fs-mistrust, report it as
an IoError.
2022-05-25 15:57:19 -04:00
Nick Mathewson bbc7470dc5 More tests for ClockSkew. 2022-05-25 15:57:19 -04:00
Nick Mathewson 7c86e0a6b3 Merge branch 'no-disable-arti-permission-checks' into 'main'
ci: don't disable arti permission checks, fix resulting issues

See merge request tpo/core/arti!530
2022-05-25 19:42:32 +00:00
Ian Jackson ed95d50d49 tor-config: load: Add reversed test 2022-05-25 19:15:47 +01:00
Ian Jackson ce96f0d9ce tor-config: Add duplicative doc comments as per review 2022-05-25 19:15:47 +01:00
Ian Jackson 21a064d4f8 tor-config: load: example: Document what it does and who might write it 2022-05-25 19:15:47 +01:00
Ian Jackson 3eab61603a tor-config: load: Add a newline
This makes the function a tiny bit clearer.
2022-05-25 19:15:47 +01:00
Ian Jackson bf97190a9f tor-config: load: Write actual definition of the Resolvable trait
This is not a doc comment because we don't want it to be public: it
must refer to private fields, etc.
2022-05-25 19:15:47 +01:00
Ian Jackson 80ddae3d4b arti: Better doc for ArtiCombinedConfig 2022-05-25 19:15:47 +01:00
Ian Jackson 2b65e1250e tor-config: load: Explain why not write out macro call n times 2022-05-25 19:15:47 +01:00
Ian Jackson 1ee2be9d6d tor-config: docs: add more docs about load, esp. traits 2022-05-25 19:15:47 +01:00
Ian Jackson 337b4a7231 tor-config: docs: add a lot of context and overview and xrefs 2022-05-25 19:15:47 +01:00
Ian Jackson 40b433d4ba tor-config: load: Avoid destructuring assignment
Not available in our MSRV.
2022-05-25 19:15:47 +01:00
Ian Jackson b552c4e2bf tor-config: load: Intersection: add more commentary 2022-05-25 19:15:47 +01:00
Ian Jackson 5661df823f tor-config: load: Drop a needless call to .into_iter()
I think this is a leftover from a previous version of this expression.
2022-05-25 19:15:47 +01:00
Ian Jackson a8a3661503 tor-config: load: Fix a misleading comment
As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/529#note_2807070
2022-05-25 19:15:47 +01:00
Ian Jackson 964794bfa0 tor-config: load: Rename shorter_let
Instead of the wrong "prefix_len".  As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/529#note_2807068
2022-05-25 19:15:47 +01:00
Ian Jackson 26715c5550 tor-config: load: Docs 2022-05-25 19:15:47 +01:00
Ian Jackson 4f62c3ded1 tor-config: Typo fixes (as per review comments) 2022-05-25 19:15:47 +01:00
Ian Jackson 28c1f707a1 tor-config: load: Introduce UnrecognizedKeys enum
As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/529#note_2807078

This is in fact much clearer than the Option.
2022-05-25 19:15:47 +01:00
Ian Jackson 151d28c90f Run rustfmt following renaming
Split into its own commit to avoid churn in the rename commits.
2022-05-25 16:41:50 +01:00
Ian Jackson 0803296bd6 tor-config: Rename resolve_return_unrecognized, ..._ignore_...
As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/529#note_2807077
2022-05-25 16:41:05 +01:00
Ian Jackson 9f426e2c57 tor-config: Rename "ignored" to "unrecognized" throughout
As per review comments
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/529#note_2807076
2022-05-25 16:40:02 +01:00
Ian Jackson e9538a7eef Merge branch 'no_nochange' into 'main'
DirMgr:: Remove Error::NoChange as redundant.

Closes #484

See merge request tpo/core/arti!532
2022-05-25 14:35:32 +00:00
Alex Xu (Hello71) 85b4b5620d fs-mistrust: allow symlinks to have any permissions 2022-05-25 10:27:45 -04:00
Ian Jackson 4b0459d204 Merge branch 'bug475' into 'main'
ConfigurationSources: Allow config files to be world-readable.

Closes #475

See merge request tpo/core/arti!528
2022-05-25 14:23:12 +00:00
Nick Mathewson 52a338a378 Merge branch 'socks-errors' into 'main'
reply socks error on more codepath

Closes #258

See merge request tpo/core/arti!531
2022-05-25 13:13:18 +00:00
Nick Mathewson 0caa5bcba5 DirMgr:: Remove Error::NoChange as redundant.
Now that the relevant functions now report changed/not-changed
status via a boolean out-parameter (see !527), there's no reason to
have a separate NoChanged error case.

Closes #484.
2022-05-25 08:58:37 -04:00
Nick Mathewson 3b837eb7f4 Typo fixes (automated with "typos"). 2022-05-24 19:21:12 -04:00
trinity-1686a 801380780f reply socks error on more codepath 2022-05-25 00:02:14 +02:00
Nick Mathewson 92f0f97fe8 Merge branch 'isolation-example' into 'main'
add example for Isolation

Closes #414

See merge request tpo/core/arti!524
2022-05-24 19:34:14 +00:00
eta 608d0cbcc2 Merge branch 'bug482' into 'main'
DirMgr: Stop load-from-cache process when there is no change.

Closes #482

See merge request tpo/core/arti!527
2022-05-24 19:33:42 +00:00
Ian Jackson 9c88158740 tor-config: Example for load module 2022-05-24 20:14:57 +01:00
Ian Jackson bb8e205b0d tor-config: Tests for ignored config key handling 2022-05-24 20:14:57 +01:00
Ian Jackson 09f26f2d68 tor-config: Track and (by default) warn on ignored config keys 2022-05-24 20:14:57 +01:00
Ian Jackson e1bc599db2 tor-config: Tests for support functions for tracking ignored keys 2022-05-24 20:14:57 +01:00
Ian Jackson 865ae13502 tor-config: Support functions for tracking ignored config keys
This turns out to need quite a complicated algorithm.
2022-05-24 20:14:57 +01:00
Ian Jackson 9e526aad7c Split TorClientConfig out of ArtiConfig, and Resolvable trait
This gets rid of `#[serde(flatten)]` which prevents serde_ignored (and
other kinds of introspection) from working properly.

The price is now that the toplevel has to deal with two configuration
objects.

The Resolvable trait is overkill right now, but is going to do More
Things in a moment.  In particular, we need the impl on tuples, so
that the whole config can be processed in one go.
2022-05-24 20:14:57 +01:00
Nick Mathewson 460117f2b0 Allow use of RetainMut, since we do not require Rust 1.61 yet. 2022-05-24 15:09:00 -04:00
Ian Jackson 687e5c369e tor-config: Introduce Builder trait and ConfigReolveError
We are going to need this for some generic code which is going to
appear shortly.  Having it produced by impl_standard_builder seems
best.  But that does mean being able to disable it, so extra stuff in
the macro.  Nothing uses this trait yet.

ConfigResolveError is not used now either, but will be in a moment.
2022-05-24 20:08:40 +01:00
Ian Jackson d15cc75821 arti tests: Introduce bld_tor variable
We are going to reorganise ArtiConfig to not contain a
TorClientConfig.  This test case's calls to bld.tor() will all need to
change.  Do this in advance to make that future commit more readable.
2022-05-24 20:08:40 +01:00
Ian Jackson fcdac71be7 tor-config: Add a lint allow
I don't understand why this isn't tripping all the time.  Maybe
because this is in a macro.  Anyway, I am going to add a new
invocation of this macro from within a test where, empirically, it
trips.
2022-05-24 20:08:40 +01:00
trinity-1686a 78b815e0d3 mention isolation is an advanced topic and most usage don't require implementing the trait 2022-05-24 18:25:32 +02:00
Nick Mathewson 5a5a828db6 ConfigurationSources: Allow config files to be world-readable.
Fixes #475.
2022-05-24 11:05:57 -04:00
Nick Mathewson 924cc380d4 Use serde attrs instead of manual impls 2022-05-24 10:54:02 -04:00
Nick Mathewson 25c64db575 Apply fs-mistrust to logfile directories. 2022-05-24 10:54:02 -04:00
Nick Mathewson b1fc4bd03b Make fs-mistrust configurable from the top level.
This change requires a little refactoring of TorClientBuilder: now,
instead of enabling or disabling mistrust, it enables or disables
the decision to _override_ the mistrust in the config.
2022-05-24 10:54:02 -04:00
Nick Mathewson 12f2a47fcb Write custom serde impls for Trusted{User,Group}
We support all of the following (in TOML notation):

```
user = "rose"  # by name
user = 413     # by ID
user = false   # no user
user = ":current"  # A 'special' user.

user = { name: "rose" }
user = { id: 413 }
user = { special: ":none" }
user = { special: ":current" }
```
2022-05-24 10:54:02 -04:00
Nick Mathewson 9dd7b99de1 Add serde derives for MistrustBuilder.
The Group and User (de)serialization is pretty ugly, and I can't
vouch for the correcness of MistrustBuilder.  I will seek feedback
before I proceed.
2022-05-24 10:54:02 -04:00
Nick Mathewson 330582a142 fs-mistrust: Add Group and User types.
This will help make the actual configuration more serializable,
I hope.
2022-05-24 10:54:02 -04:00
Nick Mathewson 95200383b5 fs-mistrust: make Mistrust have a corresponding Builder type.
This is an approximately minimal revision to get Builder in place;
subsequent commits will clean up the API.
2022-05-24 10:54:02 -04:00
Nick Mathewson baa58daace fs-mistrust: rename fields
This renaming will make things slightly simpler for declaring a
builder.
2022-05-24 10:54:02 -04:00
Ian Jackson 85faa1c0f6 Merge branch 'upgrades-20220523' into 'main'
Update to newer sanitize-filename and tinystr.

See merge request tpo/core/arti!523
2022-05-24 13:22:01 +00:00
Nick Mathewson 8e15c97f56 DirMgr: Stop load-from-cache process when there is no change.
Previously in !511 I had introduced a bug where, if there was an
error more serious than "no change", that error would keep us from
noticing that we had no change, and we'd loop until the safety
counter ran out.  Then we'd panic.

This commit fixes the bug by reintroducing the `changed` boolean --
this time as an outparam for the add_from_* methods.

Fixes #482.
2022-05-24 08:50:20 -04:00
trinity-1686a b279b09b0c add example for Isolation 2022-05-23 22:40:08 +02:00
Nick Mathewson c27b3cb701 Update to newer sanitize-filename and tinystr. 2022-05-23 16:02:50 -04:00
Nick Mathewson 546ae3000e Resolve the new `derive_partial_eq_without_eq` lint.
It's a little overzealous sometimes, but it's mostly to the good.
2022-05-23 12:55:37 -04:00
Nick Mathewson 2f1803f4c6 Suppress clippy warnings in tor-basic-utils.
These are warnings that we've decided it's okay to suppress elsewhere.
2022-05-23 12:55:37 -04:00
Nick Mathewson aaa8bfcb53 Merge branch 'remove_dbgs' into 'main'
Remove dbg!()s in tor-config, and fix nightly CI

See merge request tpo/core/arti!516
2022-05-23 16:18:46 +00:00
eta 0861827d90 Merge branch 'update-min-async-compression' into 'main'
async-compression minimum version 0.3.5 -> 0.3.14

Closes #473

See merge request tpo/core/arti!521
2022-05-23 15:43:28 +00:00
Jim Newsome e33cae6cb6
async-compression minimum version 0.3.5 -> 0.3.14
0.3.14 is the first released version to include
e724673876,
which fixes https://gitlab.torproject.org/tpo/core/arti/-/issues/473
2022-05-23 10:01:18 -05:00
michael mccune 0d8f520faf add unit tests for arti_client::StreamPrefs
this change adds unit tests for the public methods of StreamPrefs. although
these are mostly "setter" style functions, the tests confirm the basic
expectations and operation.
2022-05-23 10:55:17 -04:00
Ian Jackson 2fc6c8a194 prepare_send_from: clippy: Replace some or_else with or 2022-05-23 11:28:05 +01:00
Ian Jackson 86d5768c05 prepare_send_from: clippy: Have dprintln explicitly return () 2022-05-23 11:28:05 +01:00
Ian Jackson d3f261d5ef prepare_send_from: clippy: Avoid a lint
I think this is worse code, but it's not *significantly* worse.
2022-05-23 11:28:05 +01:00
Ian Jackson 24dde5ddf1 prepare_send_from: clippy: Add missing docs
I intend to reintroduce this in its own MR.
2022-05-23 11:28:05 +01:00
Ian Jackson 739e5b52b1 prepare_send_from: clippy: Replace two unwraps 2022-05-23 11:28:05 +01:00
Ian Jackson 94038a9227 prepare_send_from: Break out get_output! macro
So we can change unwrap to expect, which makes this too long to repeat.
2022-05-23 11:28:05 +01:00
Ian Jackson 9fd0050acf prepare_send_from: docs and comments improvements
Apropos review.
2022-05-23 11:28:05 +01:00
Ian Jackson 426ff28b73 prepare_send_from: Add tests
When I added these tests, they didn't find any bugs in my own
implementation, but I did find a bug in futures::future::unfold.
See the in-code comment.
2022-05-23 11:28:05 +01:00
Ian Jackson 793782acc8 channel: Provide and use Sink::prepare_send_from
This is a general-purpose implementation of the ad-hoc approach
currently taken in (eg) crates/tor-proto/src/channel/reactor.rs,
with an API intended to defned against the more obvious mistakes.

This allows us to separate the two concerns: the channel reactor can
focus on handling channel cells and control messages and is over 2.5x
shorter.

The complexity of the manual sink implementation, and the machinery
needed to avoid having to suspend while holding an item, are dealt
with separately.  That separate implemenation now has proper
documentation.  (Tests are in the nest commit to avoid this one being
even more unwieldy.)

We use `extend` to define this as an extension trait.  A competitor is
`ext` but in my personal projects I have found `extend` slightly
better.
2022-05-23 11:28:05 +01:00
Nick Mathewson 994426d18c Add a couple of "pub use" to make nightly rustdoc pass. 2022-05-20 12:12:23 -04:00
Nick Mathewson 9d26a91886 Remove dbg!()s in tor-config
This should satisfy our CI and turn it green again.
2022-05-20 10:34:32 -04:00
eta b4e9e42278 Merge branch 'cert_dl_recovery_v3' into 'main'
DirMgr: Revise error handling to better tolerate reset-able failures

Closes #412 and #439

See merge request tpo/core/arti!511
2022-05-19 12:32:31 +00:00
Nick Mathewson 5b5b4bbbea Simplify advance and reset functions with mem::replace. 2022-05-19 08:09:05 -04:00
Nick Mathewson eab0046d0e Explain why we call update_status unconditionally. 2022-05-19 08:04:57 -04:00
Nick Mathewson 6aebb18e64 Remove BootstrapAction::Impossible
It does nothing that Fatal does not.  Suggested by @eta in review.
2022-05-19 08:00:41 -04:00
Nick Mathewson c70916c0d9 Fix compilation with Rust 1.56. 2022-05-17 14:58:36 -04:00
Nick Mathewson 5de1b93195 DirMgr: Remove blocking_error return path. 2022-05-17 12:25:32 -04:00
Nick Mathewson 53ed5f40cf DirMgr: Unify error return paths
We no longer have separate return paths for recoverable and fatal
errors; instead, they are merged, and distinguished based on
recovery actions.

Since it is now possible for download() to give an error that should
_not_ destroy the previous state, it takes `&mut Box<dyn DirState>`.
This change unfortunately means that we can no longer call `state =
state.advance()`, but instead have to do some mem::swap junk with
poisoned values.  Any better solution would be a good thing.

Additionally, the reset() and advance() methods can no longer fail.

There is still a separate return path for reset-triggering errors;
I'm about to fix that.
2022-05-17 12:25:32 -04:00
Nick Mathewson d7a3fd2c17 DirMgr: Remove special handling of "changed" boolean 2022-05-17 10:16:15 -04:00
Ian Jackson 273879cb14 Placate rustfmt
I found the previous layout *much* better.  Ah well.
2022-05-17 15:04:10 +01:00
Ian Jackson 298b2421f0 Do backtrace string matching test only on some platforms.
"Fixes" #455 by suppressing the test.

This is !509 redux.
2022-05-17 15:03:46 +01:00
Nick Mathewson 6bacf3b303 DirMgr: Start refactoring error handling.
This commit adds a couple of new error types that we will soon want
to distinguish, and a new way of classifying errors.  These are not
yet all used.
2022-05-17 09:52:44 -04:00
Nick Mathewson f83146bef4 Fix a portability issue with Rust 1.56 2022-05-16 15:02:28 -04:00
Nick Mathewson e37e37a31c Give an error if the cache violates If-Modified-Since.
This should be sufficient to detect several kinds of nefariousness
that we'd previously overlooked.
2022-05-16 12:49:49 -04:00
Nick Mathewson 37f6730077 Add missing extend_tolerance to add_consensus_text.
This should have gone in when we fixed #412
2022-05-16 12:49:49 -04:00
Nick Mathewson ffc864015a DirMgr: Blame the correct cache for consensus validation failure 2022-05-16 12:49:49 -04:00
Nick Mathewson c55738e745 Move consensus signature verification to add-document code.
Previously, we did this in `advance()`, but that wasn't so great: it
meant that we could fail in the advance() code, whereas the calls to
`advance()` treated errors as fatal.

This treats failed verification as a blocking error that requires a
reset.

Fixes one aspect of #439.
2022-05-16 12:49:49 -04:00
Nick Mathewson d1af40e638 On a blocking error, blame the appropriate directory cache
Fortunately, the only error type that we need to handle blocking
errors with actually has a DirSource in it already.
2022-05-16 12:49:49 -04:00
Nick Mathewson 40539cb25e DirMgr: Add a way for a state to report a blocking error.
(A blocking error is one that means that the current bootstrap
attempt has failed, and must be restarted.)
2022-05-16 12:42:25 -04:00
Nick Mathewson b94f56d6f5 Implement nonfatal errors in add_from_* 2022-05-16 12:42:25 -04:00
Nick Mathewson d8bd862f2b DirMgr: Let add_from_* distinguish non-fatal errors
Previously all errors were treated as non-fatal.

The add_from_* implementations don't yet behave properly;
I'll fix them in subsequent commits.
2022-05-16 12:42:25 -04:00
Nick Mathewson f70ad60e65 DirMgr: Improve display for DocSource
(Also, implement Display for tor_dirclient::SourceInfo).
2022-05-16 12:42:25 -04:00
Nick Mathewson ef2640acfa DirMgr: make DocSource useful by having it include dirserver info.
Previously DocSource would tell you whether the document was from
a local store or a cache server, but it wouldn't tell you _which_
server it came from.

This change required adding DocSource as an argument to
DirState::add_from_download.
2022-05-16 12:42:25 -04:00
Nick Mathewson fb432924a3 Merge branch 'main' into 'ticket_466'
# Conflicts:
#   doc/semver_status.md
2022-05-16 15:10:00 +00:00
eta 9d8ce43298 Revert "Merge branch 'backtrace' into 'main'"
This reverts merge request !509
2022-05-16 15:01:02 +00:00
eta d69fc2faf9 Merge branch 'backtrace' into 'main'
Do backtrace string matching test only on Linux

See merge request tpo/core/arti!509
2022-05-16 15:00:43 +00:00
Ian Jackson 777b2c123f Do backtrace string matching test only on Linux
"Fixes" #455 by suppressing the test.
2022-05-16 15:00:43 +00:00
Dimitris Apostolou 58dc576887
Fix typo 2022-05-14 20:02:53 +03:00
Nick Mathewson 934de16098 Merge branch 'arti-config-2' into 'main'
Abolish arti-config, replacing with tombstone crate

See merge request tpo/core/arti!508
2022-05-13 12:30:24 +00:00
Nick Mathewson f482a5bdd5 Merge branch 'builder-default-3' into 'main'
impl_standard_builder: Test the Deserialize impl and have it generate ::builder

See merge request tpo/core/arti!507
2022-05-13 12:14:30 +00:00
Ian Jackson 4e2bd6c798 Abolish arti-config, replacing with tombstone crate 2022-05-13 12:42:30 +01:00
Ian Jackson ef36882807 arti-config abolition: Change references to use tor_config
Generally, change the paths that mention the crate name to go via a
module-level "use".

This involves adding tor-config as a direct dependency for a few
crates.
2022-05-13 12:42:30 +01:00
Ian Jackson b6b5d05e1b tor-config: Provide useful documentation for sources module 2022-05-13 12:42:30 +01:00
Ian Jackson 44d2f5ccfd arti-config abolition: Move functionality to tor-config
This crate no longer has any reason to exist.  All its remaining
functionality is generic enough to go into tor-config.

In this commit, we move the contents of lib.rs into a new file in
tor-config.  It contains:

 * Code motion
 * The minimal "mod" and "use" changes
 * The minimal doc comment
 * A new a compat alias for ConfigurationSources.

The compat alias is there because various crates currently speak of
arti_config::ConfigurationSources and it is most convenient to fix
them up after the type is available in tor_config.
2022-05-13 12:42:30 +01:00
Ian Jackson 9a3205aeba arti-config abolition: Add deps to tor-config
These are needed to support the code which is moving.
2022-05-13 12:41:27 +01:00
Ian Jackson cdde87846c arti-config: Move default config file test to arti-client
That's where this definitions is now.  This test ought to have been
moved in
  Move default_config_file() into arti-client
2022-05-13 12:41:27 +01:00
Ian Jackson bdb7cb7a6d Fix comment location 2022-05-13 10:58:29 +01:00
Ian Jackson d7f84b92ab config load: Move mistrust checking to load()
As per
  https://gitlab.torproject.org/tpo/core/arti/-/issues/472
Experimentation convinced me the Mistrust should be within the
ConfigurationSources.
2022-05-13 10:58:29 +01:00
Ian Jackson 58c753429f arti-bench: Disable all fs permissions (fs-mistrust) checks
This is a benchmarking tool, and fs-mistrust doesn't like the
permissions in our CI.  The env var ARTI_FS_DISABLE_PERMISSION_CHECKS
is (of course) specific to arti.  Maybe it should be honoured here,
or this should be done via the config files.

But disabling this is fine for now.
2022-05-13 10:56:56 +01:00
Ian Jackson 8f724ad767 impl_standard_builder: Better comments explaining the parser 2022-05-13 10:46:31 +01:00
Ian Jackson be5bc04c02 impl_standard_builder: Have it generate FooConfig::builder
This deletes many handcoded impls.  It also generates lots of impls
that we previously didn't have.
2022-05-12 18:50:26 +01:00
Ian Jackson 86a3e006d3 impl_standard_builder: Test the Deserialize impl
Test the Deserialize impl of every config struct.

This detects bugs like the one fixed in !502.

The macro now becomes more complex because it needs to take options.
Right now this tt-munching option parser is overkill, but this
leave space for further options in the future.
2022-05-12 18:50:26 +01:00
Nick Mathewson f0eac61838 Merge branch 'network-config-error' into 'main'
Delete tor_dirmgr::Error::BadNetworkConfig

See merge request tpo/core/arti!506
2022-05-12 16:43:26 +00:00
Nick Mathewson 1698a2fea1 Merge branch 'template' into 'main'
Make the example config file into a template and move it to arti

See merge request tpo/core/arti!503
2022-05-12 16:34:00 +00:00
eta 2255778afa Merge branch 'builder-default-bis' into 'main'
impl_standard_builder followup

See merge request tpo/core/arti!505
2022-05-12 15:57:56 +00:00
Ian Jackson d847d49858 Delete tor_dirmgr::Error::BadNetworkConfig
This was anomalous, in that it contains &'static str, rather than a
proper nested error (eg a config::ConfigError, maybe).

But in fact it tursn out it is now not constructed.  The last
construction site was removed a long time ago in
  Use derive_builder for Authority and FallbackDir.
2022-05-12 16:49:06 +01:00
Ian Jackson c1c6f2b376 Rename impl_standard_builder from impl_default_via_builder
I have Plans for this macro.  In particular:

 * I have a wip branch which tests that the Builder can be
   deserialised from an empty config (ie, that config reading
   of a config with a blank section for this item works).

 * I think we should autogenerate $Config::builder(),
   and promote that, rather than $ConfigBuilder::default().
   This macro could do that.
2022-05-12 15:59:13 +01:00
Ian Jackson 888d6e0511 config: Replace more handwritten impl Default 2022-05-12 15:59:10 +01:00
Ian Jackson 400266b2c5 config: Move macro calls to next to the struct
This macro is kind of derive-y.  Also it has a test in it, and failing
to call it could allow bugs to exist, as well as missing bits of API.
Putting it next to the structs makes it easy to see that it's actually
been called.
2022-05-12 15:58:38 +01:00
Nick Mathewson 2a5ee2c8c9 Merge branch 'ticket_412_467' into 'main'
Teach DirMgr to use slightly untimely directories

Closes #467 and #412

See merge request tpo/core/arti!500
2022-05-12 14:42:51 +00:00
Ian Jackson cb42c01dd7 arti-example-config.toml: Add a slightly improved comment 2022-05-12 14:55:39 +01:00
Ian Jackson bb166c14da arti-example-config.toml: Re-un-comment the example settings in test 2022-05-12 14:55:39 +01:00
Ian Jackson f18373a7d6 arti-example-config.toml: Comment out all the example settings
We expect that a user may copy this file and uses it as a starting
point for their own configuration.

When they do that, we don't want them to freeze the default config in
time.  Instead, we can expect them to uncomment settings they wish to
change.  Then when they upgrade arti, *other* settings will get the
new defaults, which I think is right.
2022-05-12 14:55:39 +01:00
Ian Jackson 85a310d7cc arti-example-config: Mark some non-default examples more clearly
Now,
  git-grep '^#[^ ]' crates/arti/src/arti-example-config.toml
has no ouptut.

This prepares us for the next commit.
2022-05-12 14:55:39 +01:00
Ian Jackson 1105e63141 config defaults: Test that empty deser is the same 2022-05-12 14:55:39 +01:00
Ian Jackson 8aab5a3996 ARTI_EXAMPLE_CONFIG: Rename from ARTI_DEFAULTS
The defaults are built into the code.  This is a doc-commented example
file, not the primary specification of what the defaults are.
2022-05-12 14:55:39 +01:00
Ian Jackson c9c8344b73 ARTI_DEFAULTS: Move to arti crate 2022-05-12 14:55:39 +01:00
Ian Jackson afa64bf397 config defaults: No longer apply ARTI_DEFAULTS in load()
This is redundant, because the defaults have to be supplied by the
config builders (usually via builder default attributes).

That this is actually done and correct is tested by the
`default_config()` test case in arti/src/cfg.rs.
2022-05-12 14:55:03 +01:00
Ian Jackson 58f53bae5b config defaults: Test that going via builder explicitly is the same
Add this test even though our construction of the Default and Builder
ought to trivially ensure that it's true.
2022-05-12 14:55:03 +01:00
Nick Mathewson 24c7dea38d Resolve DOCDOC comments in tor-dirmgr. 2022-05-12 09:45:05 -04:00
eta 5990df53fe Merge branch 'arti-config-1' into 'main'
arti-config: Move cmdline to tor-config

See merge request tpo/core/arti!498
2022-05-12 13:07:43 +00:00
eta aaf133de49 Merge branch 'clippy' into 'main'
Improvements prompted by clippy, and disable one lint

See merge request tpo/core/arti!497
2022-05-12 13:07:02 +00:00
eta 7207b17567 Merge branch 'builder-default' into 'main'
Provide and use macro for impl Derive via Builder

See merge request tpo/core/arti!499
2022-05-12 12:52:37 +00:00
Ian Jackson 04b8729d6b Add correct serde(default) attrs for humantime_serde::option
Discovered by a test case in my local tree.  The test case was
macro-generated by an extension of impl_standard_builder (which
macro istself currently awaiting review, arti!499)

Have also sent an MR to update the upstream docs
  https://github.com/jean-airoldie/humantime-serde/pull/8
2022-05-12 11:34:53 +01:00
Ian Jackson 0cc94d449e clippy: Change a binding to (), and allow clippy::let_unit_value
The type of ret.map_err(codec_err_to_chan)? is ().  ISTM that
writing `let () = ` makes it clear that there is nothing there,
but the lint forbids this.

This lint is warn by default and trips here for me on current nightly.

It seems wrong to me.  We should be able to make it clear to the
reader that there is nothing here - note how this differs from the
lines below where Ready contains msg.  A let () binding is a good way
to do that.

I think the lint allow ought to be added everywhere, but that doesn't
seem easy right now - see this issue about maint/add_warning:
   https://gitlab.torproject.org/tpo/core/arti/-/issues/469
2022-05-11 18:52:12 +01:00
Ian Jackson 0717595781 clippy: Use write! rather than push_str, format
This does involve unwrap, but of course that can't fail unless the
formats fail, which would already panic (that's implied by format!).
2022-05-11 18:52:12 +01:00
Nick Mathewson 2e99c9fe64 dirmgr: use set_skew_limit.
With this API we can now stop consensus download attempts early if
any consensus that the directory cache gave us would be necessarily
too far in the future or in the past.

This saves wasted bandwidth for clients with skewed clocks.

Closes #466.
2022-05-11 13:52:07 -04:00
Ian Jackson 4a06ce01e1 clippy: Drop an unused lifetime 2022-05-11 18:51:07 +01:00
Nick Mathewson 0c939d45fc dirclient: add the ability to reject circuits that are too skewed.
This will help implement #466.
2022-05-11 13:48:55 -04:00
Ian Jackson 7909a51ff4 No longer derive Default on three structs which derive Builder 2022-05-11 18:27:15 +01:00
Ian Jackson 3420fe735d Define and use impl_default_via_builder 2022-05-11 18:27:15 +01:00
Ian Jackson ab3bd9d6d5 arti-config: Move cmdline to tor-config
This does not know anything about arti, only about TOML and Config.

Code motion, plus necessary import adjustments.
2022-05-11 18:23:05 +01:00
Nick Mathewson 0c05baa68b Add a channel accessor to ClientCirc.
I need this so that I can expose the skew time for the directory
that a circuit will use, when I only have the circuit.
2022-05-11 13:02:36 -04:00
Nick Mathewson dd20ac45ab Note a TODO in exitpath construction. 2022-05-11 12:42:38 -04:00
Nick Mathewson 9e040e7809 Adjust if-modified-since field on the basis of tolerated skew
If we're happy with a directory from 3 days ago, we should say
"if-modified-since 3 days ago".

This patch is larger than I'd like, since I had to add &DirMgrConfig
as an argument to the functions that make a  consensus request.

Closes #467.
2022-05-11 12:36:51 -04:00
Nick Mathewson db8bdbf924 tor-dirmgr: update status reporting to consider skew tolerance
In our status reporting code, we consider an
expired-but-still-usable directory still bootstrapped, but not 100%
bootstrapped.
2022-05-11 12:11:30 -04:00
Nick Mathewson 1dafba706d Make reset_time() for incomplete directories more generous.
Since we want to be willing to use older consensuses, we don't
necessarily want to reset a download just because the consensus is
expired.

This new behavior isn't ideal either; I've added a TODO that relates
to #433.

Related of #412
2022-05-11 12:11:17 -04:00
Nick Mathewson 7dec007d63 Add DirSkewTolerance section to DirMgr configuration.
This new section describes how much variance we accept when it comes
to expired and not-yet-valid directory documents.  (Currently, the
only ones where this matters for are consensus documents and
authority certificates.)  A document that is invalid by no more than
these tolerances is not _live_, but it can still be used.

These tolerances serve two purposes:

 * First, they allow clients to run with a little more clock skew
   than they would tolerate otherwise.
 * Second, they allow clients to survive the situation where the
   authorities are unable to reach a consensus for a day or two.

Compare with Tor's REASONABLY_LIVE_TIME and NETWORKSTATUS_ALLOW_SKEW
constants; also compare with proposal 212.

Closes #412.
2022-05-11 12:11:17 -04:00
Nick Mathewson 12d1752ad5 tor-netdoc: Add a Lifetime::valid_at method. 2022-05-11 12:11:17 -04:00
Ian Jackson 8fe62da871 Move default_config_file() into arti-client
This will let other embedders use it.
2022-05-11 15:53:03 +01:00
Ian Jackson c76c79d023 ConfigurationSources: Have the generics take Into<owned>
These generic arguments weren't consistent.  It doesn't make sense ot
insist on getting a borrowed type and then cloning it.  So tidy things
up in the direction of taking owned values, which is what
ConfigurationSources actually needs.

(My personal preference would be &dyn to avoid monomorphisation code
bloat but that was controversial last time I proposed it somewhere.)
2022-05-11 15:53:03 +01:00
Ian Jackson c9fee15cbf ConfigurationSource: Move "usual" logic for construction 2022-05-11 15:53:03 +01:00
Ian Jackson 93da612984 default_config_file(): Have it return Result, not Option
Discarding this error is not right.
2022-05-11 15:53:03 +01:00
Ian Jackson 26b3115586 tor-config: Export CfgPathError
It is not clear to me how this `pub enum` survived the "inaccessible
pub" lint.
2022-05-11 15:53:03 +01:00
Ian Jackson e363b79a01 ConfigurationSource: Rename new to new_empty
This emphasises its nature.  We're going to provide a more cooked
constructor in a moment.
2022-05-11 15:53:03 +01:00
eta 864fd03917 Improve documentation around Cargo features; make Runtime require Debug
- arti#445 highlighted the lack of good documentation around Arti's
  multiple runtime support, as well as it being difficult to determine
  what runtime was actually in use.
- Improve the documentation to solve the first problem.
- To solve the second problem, make Runtime require Debug (which is
  arguably a good idea anyway, since it makes them easier to embed in
  things), and print out the current runtime's Debug information when
  arti is invoked with `--version`.
- (It also prints out other Cargo features, too!)

fixes arti#445
2022-05-11 13:26:35 +01:00
eta 0597c31a6f Merge branch 'dirmgr-purification-2' into 'main'
Refactor the tor-dirmgr bootstrapping code more gracefully

See merge request tpo/core/arti!488
2022-05-10 17:10:45 +00:00
eta 6fc7a864c7 Remove cargo-husky, and replace with manual instructions
A build script reaching into your .git/hooks/ and modifying them
nonconsensually was a bit of a horrifying concept, and also made it hard
to build arti with the feature disabled. Remove this crate, and replace
it with manual instructions on how to install the hooks in
CONTRIBUTING.md.
2022-05-10 13:36:49 +01:00
eta 33b2b428bd tor-dirmgr: move apply_netdir_changes() to be a DirMgr method 2022-05-10 13:29:39 +01:00
eta 27f4657ff1 tor-dirmgr: small fixups for the bootstrapping refactor
- Some FIXMEs got removed or amended.
- AddMicrodescs now yields a mutable reference, so we can use .drain()
  and reuse the allocation.
- Some panics were downgraded to debug_asserts.
2022-05-10 13:29:39 +01:00
eta 8347f8cb7e tor-dirmgr/bootstrap.rs: error on older netdirs, add log line
- We don't want to inadvertently replace our netdir with one that's
  actually older, so detect and error on this condition.
- Also, print a debug line when we get a new netdir without enough
  guards.
- (An unrelated TODO was also added.)
2022-05-10 13:29:39 +01:00
eta 2c28e217dd tor-dirmgr/state.rs: take an object to get a netdir, not a netdir
- Taking a previous netdir directly and keeping it around before we need
  it is a bit of a waste of memory, and also doesn't mesh well with how
  SharedMutArc works.
- To remedy this, introduce a new trait `PreviousNetDir` and have the
  state machines take that instead. (I was a bit tempted to just pass in
  the SharedMutArc directly. Maybe I should've done that.)
2022-05-10 13:29:39 +01:00
eta 27073a5d23 tor-dirmgr/state.rs: remove GetConsensusState::bodge_new
- (Also fixes up some dirfilter stuff, whoops.)
2022-05-10 11:50:07 +01:00