Commit Graph

3367 Commits

Author SHA1 Message Date
Ian Jackson 83b9fbea99 list_builder: Use $crate namespaced imports
I don't think we need to bother with things in the prelude,
but doing it for serde and ConfigBuildError seems nice.

Noticed while writing a test case.
2022-04-25 18:23:02 +01:00
Ian Jackson ce877e4421 Document defaults for all the config lists
And add an imprecation in define_list_config_builder's doc comment do
do so in future for other invocations of the macro.

Add add the missing full stops.
2022-04-25 18:22:54 +01:00
Ian Jackson bb81a412ea define_list_config_builder: Provide example of item_build
As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/471#note_2798027
2022-04-25 18:20:21 +01:00
Ian Jackson bfd0e48a5c define_list_config_builder: Expand generated docs for methods etc.
Requested in
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/471#note_2798022
2022-04-25 18:20:21 +01:00
Ian Jackson 3f44078227 Add semver note about added macros in tor-condfig 2022-04-25 18:19:03 +01:00
Ian Jackson f6506721ab Add semver notes for AuthorityListBuilder, PredictedPortsListBuilder
These were omitted in the earlier commits.
2022-04-25 18:15:25 +01:00
Ian Jackson 8664766270 Rename macro_first_nonempty (from macro_coalesce_args)
As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/471#note_2798026
2022-04-25 18:15:25 +01:00
Ian Jackson 1f215da1a3 Rename ThingListBuilder::replace (from set)
As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/471#note_2798024
2022-04-25 18:15:25 +01:00
Nick Mathewson 2f6bc6bdc4 squash! Bump every crate's edition to 2021.
Remove all `use` statements for `TryFrom` and `TryInto`.  These are
now redundant in Rust 2021.
2022-04-25 13:06:26 -04:00
Nick Mathewson b60b0a266a Bump every crate's edition to 2021.
This is an automated change made with a perl one-liner and verified
with grep -L and grep -l.

Some warnings are introduced with this change; they will be removed
in subsequent commits.

See arti#208 for older discussion on this issue.
2022-04-25 13:05:31 -04:00
Nick Mathewson ca05b0904c Add 'rust-version = "1.56"' to every Cargo.toml file.
This change was made automatically with a perl one-liner, and
confirmed with `grep -L`.

The `rust-version` field itself was introduced in 1.56.0.
2022-04-25 13:04:31 -04:00
Nick Mathewson 0069fd2206 Reformat all not-yet-reformatted Cargo.toml files.
There are no semantic changes here; only formatting.  This is in
preparation for other changes (wrt MSRV and edition)
2022-04-25 13:04:31 -04:00
Nick Mathewson 6f3f351140 Increase our MSRV to 1.56.
Our support policy says that we can update to any Rust released at
least 6 months ago; 1.56 came out on 21 October 2021.

This doesn't yet change any code: it just increases the version
we say we need in our README, and the version we test against in
CI.

Our main justification for this change is to be able to upgrade to
newer versions of our dependencies, including `async_executors` >=
0.5, `aes` >= 0.8, and `cipher` >= 0.4.
2022-04-25 13:03:31 -04:00
Ian Jackson dca4f3ede1 Use better syntax for doc comment attribute
As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/471#note_2798020
2022-04-25 17:05:30 +01:00
Ian Jackson 24518675db Introduce PredictedPortsListBuilder
This means that `NetworkConfig::initial_predicted_ports` is now like
the other list-like things, returning `&mut list_builder` with the same
`set()` and `append()` methods.
2022-04-25 17:05:30 +01:00
Ian Jackson 961f6b527e config list-builder: Allow overriding the per-item build method
This will be useful especially for simple lists where the entry
doesn't need a separate builder type.
2022-04-25 17:04:23 +01:00
Ian Jackson d98d7a60bd macro_coalesce_args: New helper macro 2022-04-25 17:04:05 +01:00
Ian Jackson 4ad9e5e4b0 Introduce AuthorityListBuilder in NetworkConfigBuilder
NetworkConfigBuilder needs to not contain any validated structs, so
that its serde does not expose the validated details.

AuthorityListBuilder is what ought to go here - and it contains
Vec<AuthorityBuilder>, not Vec<Authority>.  As a consequence, many
places now deal with AuthorityBuilder, rather than Authority.
2022-04-25 12:54:51 +01:00
Ian Jackson 166af2c3f6 Fix error return type of AuthorityBuilder 2022-04-25 12:41:39 +01:00
Ian Jackson 0036b91662 Introduce define_list_config_builder macro
This replaces two almost-identical sets of structs and impls.  More
are on the way, as per
  https://gitlab.torproject.org/tpo/core/arti/-/issues/447
2022-04-25 12:41:00 +01:00
Ian Jackson 62aa071998 logging: Drop a pointless .within() call
Since "logfiles: Introduce LogfileListConfigBuilder", this code is in
LogfileListConfigBuilder::build(), which is called by derive_builder's
generated LoggingConfig::build(), and which will add a file context
itself due to the `sub_builder` feature.

So this is otiose.  And, we are about to replace this whole thing with
macro_rules-generated code (which won't do this).
2022-04-25 12:38:36 +01:00
Ian Jackson 144f886e72 Merge branch 'integers' into 'main'
Better handling of integer overflows

See merge request tpo/core/arti!466
2022-04-25 09:50:12 +00:00
Ian Jackson 07de58370e retry-error: Provide AbsRetryTime::from_sub and use it
This same calculation was in the code three times.
2022-04-25 10:42:52 +01:00
Ian Jackson 0d4c53bb2d Merge branch 'experimental-v3ident-public' into 'main'
Authority: make v3ident public under experimental-api

See merge request tpo/core/arti!463
2022-04-25 09:31:05 +00:00
Ian Jackson 174883ee6d Merge branch 'fix-typos' into 'main'
Fix typos bothering rust-nightly pipeline

See merge request tpo/core/arti!464
2022-04-25 09:27:50 +00:00
Ian Jackson 96fdaa7934 Merge branch 'test' into 'main'
tor-basic-utils: Add RetryDelay::reset test

See merge request tpo/core/arti!467
2022-04-25 09:25:23 +00:00
Ian Jackson 28c9be1283 Merge branch 'type-skewestimate' into 'main'
fix typo in doc

See merge request tpo/core/arti!469
2022-04-25 09:23:52 +00:00
trinity-1686a b9dd23de91 fix typo in doc 2022-04-25 00:27:29 +02:00
Samanta Navarro 77653608d6 tor-error: Handle integer overflows
If duration addition overflows, then continue with Never.

Caching the AbsRetryTime constructed with duration from supplied
function also reduces the overhead of earliest_absolute.
2022-04-23 13:33:00 +00:00
Samanta Navarro f0bc1b6649 retry-error: Handle integer overflow
In theory n_errors could overflow, which is an error in Rust.
The check is cheap and I have added a test for it.
2022-04-23 13:32:27 +00:00
Samanta Navarro d3b1a93474 tor-basic-utils: Add RetryDelay::reset test 2022-04-23 12:04:15 +00:00
Christian Grigis 349b5497a5
Fix typos bothering rust-nightly pipeline 2022-04-22 19:53:31 +02:00
Christian Grigis 08bce9b6db
Authority: make v3ident public under experimental-api 2022-04-22 19:33:36 +02:00
eta a566f82d40 Merge branch 'config-sub' into 'main'
Replace much handwritten config code with use of derive_builder

See merge request tpo/core/arti!462
2022-04-22 17:15:27 +00:00
Ian Jackson 89824fc7ea arti-client: TorClientConfig: derive TorClientConfigBuilder
Replace handwritten builder struct, accessors, and builder function.
2022-04-22 17:48:03 +01:00
Ian Jackson 6da5c9af5e arti: ArtiConfig: derive ArtiConfigBuilder
Replace handwritten builder struct, accessors, and builder function.
2022-04-22 17:48:03 +01:00
Ian Jackson 79decd4ac8 logfiles: Introduce LogfileListConfigBuilder
In
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/462#note_2797697
we decided not to do this.

However, having looked again at the way the FallbackList works, I
think there is a lot of value in making these two things (and anything
else like them[1]) as similar as possible.

[1] At least PreemptiveCircuitConfig.initial_predicted_ports and
NetworkConfig.authorities need the same treatment, and perhaps also
GuardUsage.restrictions (although there is no
GuardRestrictionBuilder).

In the irc discussion I imagined `LogfilesConfigBuilder` as opposed to
`LogfileConfigBuilder` (differing only in the `s`) which would be bad,
but we can use `List` instead.

We do *not* need to abstract away the validated version of the config.
Providing a type alias helps the derive_builder sub_builder DTRT
without needing special overrides.

I have split this commit so that we can drop it, if we conclude it's
not wanted.
2022-04-22 17:48:03 +01:00
Ian Jackson 33565ea618 logfiles: Adjust LoggingConfigBuilder::file and impl Deserialize
Change LoggingConfigBuilder to contain Vec<LogfileConfigBuilder>,
not Option<Vec<LogfileConfig>>.  That makes it sane to Deserialize.

Replace LoggingConfigBuilder's file(Vec<>) setter with the methods
discussed in
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/462#note_2797697
2022-04-22 17:48:03 +01:00
Ian Jackson 211cb1958e logfiles Rename LogfileConfig::file to files
It's a plural, and that fact is going to be exposed via serde, if it
isn't already.
2022-04-22 17:48:03 +01:00
Ian Jackson 962b6c32e1 fallback list: Introduce and use FallbackListBuilder
Now the network fallbacks configuration wants to Deserialize
a Vec<FallbackDirBuilder>, rather than validated Vec<FallbackDir>.

Methods on FallbackListBuilder are as per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/462#note_2797697
mutatis mutandi for the fact that this struct has only fallbacks in it.
2022-04-22 17:48:03 +01:00
Ian Jackson 61425a96bd fallback list: Move default list into tor-guardmgr
This is where the FallbackList type is.  We are going to want to
provide a builder too, which ought to impl Default.

This means that the default value for the type must be next to the
type.  In any case, it was anomalous that it wasn't.

This commit is pure code motion.
2022-04-22 17:39:58 +01:00
Ian Jackson 91a8bc0c11 impl From<SubfieldBuildError> for ConfigBuildError
We are going to be using sub-field builders.
2022-04-22 16:46:32 +01:00
Ian Jackson 6da7a2e3e2 Use git source for derive_builder for now, for sub_builder feature
This commitid is the current head of my MR branch
  https://github.com/colin-kiegel/rust-derive-builder/pull/253
  https://github.com/ijackson/rust-derive-builder/tree/field-builder
Using the commitid prevents surprises if that branch is updated.

We will require this newer version of derive_builder.  The version
will need to be bumped again later, assuming the upstream MR is merged
and upstream do a release containing the needed changes.

We will need the new version of not only `derive_builder_core` (the
main macro implementation) but also`derive_builder` for a new error
type.
2022-04-21 14:07:28 +01:00
eta 225accd67e Merge branch 'typos' into 'main'
Fix typos

See merge request tpo/core/arti!461
2022-04-20 15:37:33 +00:00
Samanta Navarro ee78bd7f84 Use https instead of http
Keep http in license text.
2022-04-20 11:48:55 +00:00
Samanta Navarro d3031b437b Fix wording in FAQ 2022-04-20 11:48:45 +00:00
Samanta Navarro 142e57b03a Fix typos
Typos found with codespell.
2022-04-20 11:48:43 +00:00
Nick Mathewson ac8d444aa3 Merge branch 'ticket_282' into 'main'
Remove obsolete files from our state directory.

Closes #282

See merge request tpo/core/arti!457
2022-04-14 12:18:30 +00:00
Nick Mathewson 2847a57a1e Fix build with Rust 1.53; we can't use map_while 2022-04-14 07:32:05 -04:00
Ian Jackson b1d375c785 tor-persist::fs::clean: Log warnings for directory read failures 2022-04-14 10:14:03 +01:00