Commit Graph

1723 Commits

Author SHA1 Message Date
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
eta 7b5fad3130 tor-dirmgr/state.rs: remove WriteNetDir, use filters directly
- The only purpose of WriteNetDir was to provide a filter, which isn't
  necessary any more. Refactor to provide the filter directly.
2022-05-10 11:50:07 +01:00
eta 8b0166970e tor-dirmgr/state.rs: use the NetDirChange API instead of WriteNetDir
- GetMicrodescsState now uses the NetDirChange API to propagate netdir
  changes, instead of modifying the netdir directly.
- PendingNetDir was refactored in order to support this use case.
- As a result, the netdir-related methods in WriteNetDir can be removed,
  leaving only the DirFilter for now.
- add_from_cache() no longer takes a store, because nothing uses it.
- (bodge: apply_netdir_changes() was put in a few places missed
  previously)
2022-05-10 11:50:06 +01:00
eta 7a52e77e45 tor-dirmgr/state.rs: add new NetDirChange API, consume it
- The new DirState::get_netdir_change() API lets the state machine
  export a NetDirChange: a request to either replace the current netdir,
  or add microdescs to it.
- bootstrap.rs now consumes this new API, even though nothing implements
  it yet.
- This will let us implement GetMicrodescsState without having to
  directly mutate the netdir. The calling code also handles checking the
  netdir against the circmgr for sufficiency, and updating the consensus
  metadata in the store, meaning the revised GetMicrodescsState will not
  have to perform these tasks.
2022-05-10 11:48:57 +01:00
eta cad815e31d tor-dirmgr/state.rs: feed through additional parameters, use them
- The additional parameters passed to GetConsensusState are now passed
  through all the states, and used as well.
- WriteNetDir doesn't have a now() or config() method any more, since
  the states now get this from the runtime or the config parameters.
- This required modifying the tests to make a mocked runtime and custom
  config directly, instead of using DirRcv for this purpose.
- Additionally, because we don't have to upgrade a weak reference for
  DirState::dl_config(), that function no longer wraps its return value
  in Result.
- (A bunch of the FIXMEs from the previous commit that introduced the
  additional parameters have now been rectified as a result.)
2022-05-10 11:48:56 +01:00
eta f0739e46aa tor-rtcompat: make CompoundRuntime handle SleepProviders properly
Previously, CompoundRuntime would use the default implementations of
SleepProvider::now() and ::wallclock(), instead of using its wrapped
SleepProvider. This mildly embarrassing omission has been rectified.
2022-05-10 11:42:53 +01:00
eta a9bae9adfe tor-dirmgr/state.rs: refactor GetConsensusState::new
- GetConsensusState::new now takes a set of parameters matching what it
  actually needs, instead of just taking a writedir. (It still *does*
  take a writedir, and indeed still uses it for basically everything,
  but that will eventually go away.)
- Its call sites were updated.
  - Some tests now need to take a runtime, and got indented a lot as a
    result.
  - Resetting was made non-functional, because we need to thread through
    the parameters passed to GetConsensusState to all of the other
    states, too. This will happen in a later commit.
2022-05-10 11:42:50 +01:00
eta 62ece0ea21 tor-dirmgr: move DirState to state.rs
- Given that this is effectively an implementation detail, it doesn't
  really make sense to have it be in the crate root...
- (also, we're going to change it a bunch now)
2022-05-10 11:39:32 +01:00
eta 72ea9e3438 tor-dirmgr/bootstrap.rs: refactor fetch_single
- fetch_single now takes what it needs, instead of an Arc<DirMgr<R>>.
- This required refactoring the CANNED_RESPONSE mechanism, given the
  test would otherwise fail due to not having a CircMgr to pass to
  fetch_single.
2022-05-10 11:39:32 +01:00
eta 2fd03564b9 tor-dirmgr: make note_request_* functions standalone
- DirMgr::note_request_outcome and friends are now just standalone
  functions, taking a CircMgr.
2022-05-10 11:39:32 +01:00
eta 8b44569b5f tor-dirmgr/bootstrap.rs: refactor query_into_requests, make it used
- query_into_requests is now called make_requests_for_documents, and
  does the &[DocId] -> DocQuery conversion internally instead.
- DirMgr::make_consensus_request and DirMgr::query_into_requests are now
  gone. The tests use the new functions, as does fetch_multiple.
2022-05-10 11:39:32 +01:00
eta 4a98ed1301 tor-dirmgr: move query_into_requests into bootstrap.rs
- There's no good reason these functions needed to be part of the
  dirmgr, apart from needing a runtime and a store.
- However, we can just add those as arguments and copy them over. This
  commit does that.
2022-05-10 11:39:32 +01:00
eta 13446ac65a tor-dirmgr/bootstrap.rs: refactor load_all -> load_documents_from_store
- Function renamed & docs tidied up a bit
- Function signature now takes what it needs (immutable &dyn Store
  instead of mutex, slice instead of Vec) and nothing more
- DocQuery::load_documents_into was also renamed
  DocQuery::load_from_store_into and given similar treatment
2022-05-10 11:39:32 +01:00
eta 0dfac00842 tor-dirmgr/storage.rs: impl Store for Box<dyn Store>
Annoyingly, Rust doesn't automatically generate this sort of `impl` for
you, and I'd like to reduce the usage of Mutex<DynStore> everywhere else
in favour of either &dyn Store or &mut dyn Store.

(This is for two reasons: firstly, we might have a Store implementation
that doesn't use a mutex as above, or similar refactors; secondly,
passing the raw trait object reference lets us encode mutability into
the function signature, which I believe is quite valuable.)
2022-05-10 11:39:30 +01:00
eta d7f2718a8b tor-dirmgr/lib.rs: move DirMgr::load_documents_into to DocQuery
Move the function out of DirMgr, giving it a new &Mutex<DynStore>
argument instead.
2022-05-10 11:38:00 +01:00
Nick Mathewson 3b0336e841 netdoc: add a new type for Nicknames
Relay nicknames are always between 1 and 19 characters long, and
they're always ASCII: That means that storing them in a [u8;19] will
always be possible, and always use less resources than storing them
in a String.

Fortunately, the tinystr crate already helps us with this kind of
thing.
2022-05-09 15:59:38 -04:00
Nick Mathewson 4262e9d0ec Merge branch 'use-fs-mistrust' 2022-05-09 15:27:25 -04:00
Nick Mathewson 5c33499f28 Loosen checking for readable files within target directories.
If the target directory itself is unreadable by untrusted users,
then its contents can't be read[*] by them regardless of their
permissions.  If the target directory _is_ readable, then _it_ will
be rejected if we are forbidding readable objects.  (And if we
aren't we don't care if the contents are readable.)

A similar argument would apply to writable objects within an
unreadable target directory.  We're not making that argument, since
such contents are likelier to be a mistake.

[*] Unless they're hard-linked; see comments in "Limitations"
section.
2022-05-09 14:40:29 -04:00
Nick Mathewson dcc5a3cfe8 Add a CLI option to disable FS permission checks. 2022-05-09 14:40:29 -04:00
Nick Mathewson 8a62f9ce52 Remove "Mistrust" from the public API of arti-client.
I'm doing this per discussion, so that we can have it be part of the
TorConfig later on, and not break stuff as we change the Mistrust
API to have a builder.

This change, unfortunately, results in a little more internal
complexity and duplicated code in arti and arti-client.  I've marked
those points with TODOs.
2022-05-09 14:40:29 -04:00
Nick Mathewson b0f39abe32 arti: use fs-mistrust to validate configuration file locations. 2022-05-09 14:40:29 -04:00
Nick Mathewson 2938268f34 arti-client: Configure and use fs-mistrust.
This is derived from the environment, not the configuration file: We
might not want to trust the configuration file until we've decided
whether we like its permissions.
2022-05-09 14:40:29 -04:00
Nick Mathewson 20a85061b6 Update tor-dirmgr to use fs-mistrust. 2022-05-09 14:40:29 -04:00
Nick Mathewson 984190b3a3 tor-persist: Use fs-mistrust to verify state file permissions. 2022-05-09 14:40:29 -04:00
Nick Mathewson 8509ffff7a Add new FsPermissions ErrorKind. 2022-05-09 14:40:29 -04:00
Nick Mathewson 14e8243bdc fs-mistrust: add various methods.
This includes:

  * a CachedDir::join method.
  * functions to read and write from provided filenames in a
    CachedDir.
  * a method to tell whether a fs-mistrust error is about bad file
    permissions, or failure to inspect file permissions or some other
    kind of IO problem.
2022-05-09 14:39:49 -04:00
Ian Jackson cc99efb72a NetParams: Document its role as a validated config parameter 2022-05-09 15:35:50 +01:00
Nick Mathewson 7b93091f57 Bump the version of every* crate to 0.3.0
* Except for safelog and fs-mistrust, which are new.
2022-05-06 10:03:15 -04:00
Nick Mathewson 89b38b16c7 Change safelog version to 0.1.0.
(This is okay because we haven't published it yet, or any crate that
uses it.)
2022-05-06 09:59:13 -04:00
Nick Mathewson 9447e69355 Update README.md files (automated). 2022-05-06 09:51:11 -04:00
Nick Mathewson 013bb26040 Merge branch 'derive-builder-fork' into 'main'
Switch to derive_builder_arti_fork

Closes #446

See merge request tpo/core/arti!490
2022-05-06 13:07:51 +00:00
Ian Jackson 030289481f Switch to derive_builder_arti_fork
For reference, the git source for this crate (and the others in its
workspace) currently lives in my personal github account (ijackson).
If this fork turns out to be long-lived and gains features and/or
users, it would be good to move it to a gitlab somewhere.

I have granted Nick crate ownership on the crates.io system.
2022-05-06 13:36:40 +01:00
eta 373934efbf Punctuation fix. 2022-05-06 07:38:16 -04:00
Nick Mathewson b879125668 Disable safe-logging when logging to console. 2022-05-06 07:38:16 -04:00
Nick Mathewson 7e34692a65 arti: add support for safe-logging configuration
Here we add a config option to disable safe logging, and ensure that
safe logging is disabled when we are formatting an error message on
exit (since we assume it's safe to write sensitive info to stderr.)
2022-05-06 07:38:14 -04:00
Nick Mathewson 4679023c39 Apply `sensitive` in some info-level log messages.
This specifically applies the `sensitive` wrapper in the places
where we're logging target addresses at level "info" or higher.
2022-05-06 07:36:50 -04:00
Nick Mathewson 7aacc6e30c Implement a safe-logging facility.
This is a rough first-cut of an API that I think might help us with
keeping limited categories of sensitive information out of our logs.
I'll refine it based on experiences with using it.
2022-05-06 07:36:48 -04:00
eta de2b23642d Merge branch 'typos-20220504' into 'main'
Fix typos (using the typos-cli tool).

See merge request tpo/core/arti!486
2022-05-05 15:55:22 +00:00
Nick Mathewson 62d159e3c4 Derive Clone and Debug for CheckedDir. 2022-05-05 09:47:13 -04:00
Ian Jackson d47e94b459 config derive attrs: Make builders serde, and validated structs not
* Builders additionally derive: Debug, Serialize, Deserialize.

 * Validated structs no longer derive: Serialize, Deserialize
   and all related attributes deleted.

 * As a consequence, all the `#[serde(deny_unknown_fields)]`
   are gone.  That means that right now unknown fields are totally
   ignored.  This is good for compatibility but poor for useability.
   Doing something better here is arti#417, in progress.

 * As a consequence, delete tor_dirmgr::retry::default_parallelism.
   (The default value was already duplicated into a builder attr.)
2022-05-05 10:35:52 +01:00
Ian Jackson 6a39f9d8da serde attributes: A tiny bit of reordering
Having a consistent order will make the nest commit easier to read.
2022-05-05 10:19:29 +01:00
Ian Jackson 2c1282f537 Make LogRotation Serialize
We want to be able to serialise as well as deserialise configurations.
2022-05-05 10:19:29 +01:00
Nick Mathewson fc33fc3efb Fix typos (using the typos-cli tool). 2022-05-04 14:41:50 -04:00
Ian Jackson a334f17262 Merge branch 'socket-addr-list-builder' into 'main'
FallbackDir: orports: Introduce and use VecBuilder

See merge request tpo/core/arti!474
2022-05-04 18:13:45 +00:00
Ian Jackson df2813ed55 list_builder: Add some xrefs about macro_rules limitations
Apropos
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/474#note_2800481
2022-05-04 18:35:33 +01:00
Nick Mathewson cb892116dc Fix typo 2022-05-04 17:34:47 +00:00
Ian Jackson 4ad4cae418 FallbackDir: Use VecBuilder for orports
And drop the ad-hoc orport() method.  This brings FallbackDir's
orports field in line with our list builder API.

The general semver note in "configuation" seems to cover most of this.
2022-05-04 17:18:55 +01:00
Ian Jackson cc394ca9b9 FallbackDir: Do orport validation after autogenerated build
This avoids it having to recapitulate defaulting logic.
2022-05-04 17:18:55 +01:00
Ian Jackson 6791758d0b FallbackDir: Do not consider defaulted-empty orport list to be valid 2022-05-04 17:18:55 +01:00
Ian Jackson 2487a46ef0 list_builder: Provide VecBuilder
This is for lists of plain types (non-builder types).
2022-05-04 17:18:55 +01:00
Ian Jackson 221fe63430 list_builder: Use Educe to derive Default
This allows us to use this with an item builder type which doesn't
impl Default.  (Obviously this only makes sense for items which aren't
actually builders.)
2022-05-04 17:18:05 +01:00
Ian Jackson 578684f290 list_builder: Make helper capable of handling generics
It is Quite Vexing that we have to use [ ] rather than the < > around
the generics, particularly given that we are also using [ ] to signal
"this is arrayish".

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2022-05-04 17:17:46 +01:00
Ian Jackson 0c001ed60e list_builder: Actually honour attributes
The docs were a lie.  $docs_and_attrs was missing from the expander.

And add a note about how any supplied docs are handled.
2022-05-04 17:16:36 +01:00
Ian Jackson 015db3d78d GuardUsage: restrictions: Use list builder
Although these do not appear in the config, it does have a builder.
It seems sensible to get rid of this ad-hoc list manipulation site,
and replace it with our standard list builder API.

define_list_builder_helper requires that the builder element type be
Deserialize.  Currently GuardUsageRestriction is a transparent, public
enum, so we aren't really exposing anything.

We could introduce GuardUsageRestrictionBuilder now, but
since it's not in the config and thereofore only in the public API of
the lower crates, we can definitely put that off.
2022-05-04 16:16:38 +01:00
Ian Jackson 9214eb5db2 tor-dirmgr: make DownloadScheduleBuilder public
This type was returned by the public DownloadSchedule::builder
function.  But the only thing that seems to have noticed that the type
name itself wasn't exported, was rustdoc.  Hmmm.
2022-05-04 13:50:12 +01:00
Nick Mathewson d0330d2c95 Fix typos 2022-05-04 13:50:12 +01:00
Ian Jackson 4bca912715 Change builder list API
The new API is (roughly) as discussed in
  https://gitlab.torproject.org/tpo/core/arti/-/issues/451

This is quite a large commit and it is not convenient to split it up.
It contains the following changes:

 * Redo the list builder and accessor macros implemnetation,
   including docs and tests.

 * Change uses of define_list_config_builder.  In each case:
   - Move the docs about the default value to the containing field.
   - Remove the other docs (which were just recapitulations, and
     are now not needed since the ListBuilder is no longer public).
   - Rewmove or replace `pub` in the define_list_builder_helper call,
     so that the builder is no longer public.
   - Change the main macro call site to use define_list_builder_helper.
   - Add a call to define_list_builder_accessors.

 * Make the module `list_builder` pub so that we have somewhere to
   put the overview documentation.

 * Consequential changes:
   - Change `outer.inner().replace(X)` to `outer.set_inner(X)`
   - Consequential changes to imports (`use` statements).
2022-05-04 13:50:10 +01:00
Ian Jackson 71911d2921 Introduce ThingListBuilder::default_list
This removes a caveat from the API and will be convenient for what is
coming.
2022-05-04 13:48:30 +01:00
Ian Jackson 8ad4735d58 Add dependency on paste crate
The list accessor macro is going to want this.
2022-05-04 13:48:30 +01:00
Ian Jackson ff624f6081 Rename NetworkConfig.fallback_caches
Previously this field was differently named to its serde and to its
accessors.  We are about to introduce a macro_rules macro which will
provide list accessors and we don't want that macro to have a field
renaming feature.

So stop renaming the field.
2022-05-04 13:41:39 +01:00
Ian Jackson f4088a755c Fix config version
This matches Cargo.lock.  I suspect a mismerge in arti!478.
2022-05-04 13:39:18 +01:00
Ian Jackson fbf5e8dcb5 Merge branch 'path' into 'main'
CfgPath overhaul

Closes #449

See merge request tpo/core/arti!478
2022-05-03 17:00:41 +00:00
Ian Jackson 2da84857a5 CfgPath: Test serialisation round-trip with a binary format
Use MessagePack.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2022-05-03 17:42:54 +01:00
Ian Jackson 1e6c6169a8 CfgPath: Make it Serialize
And provide round-trip tests.

As per https://gitlab.torproject.org/tpo/core/arti/-/issues/371
2022-05-03 17:42:54 +01:00
Ian Jackson ed970310e2 CfgPath: Overhaul API
Document that this can contain either a string for expansion, or a
literal PathBuf not for expansion.

Rename the `from_path` method to `new_literal`: a very important
difference is whether it gets expanded - less important than the Rust
type.  Also, now it takes `Into<PathBuf>`, which avoids a needless
clone.

(We don't change the API in `arti-client` because
`&tempfile::Tempdir()` doesn't implement `Into<PathBuf>`, so
`arti-client` has to have some new `as_ref` calls.)

Provide accessors `as_unexpanded_str` and `as_literal_path`.  The
deserialisation already makes this part of the stable API,l so not
pvoding accessors seems just obstructive.  They are useful for tests,
too.

Add tests for the new entrypoints, and for deserialisation of both
variants from TOML (via config, or directly) and JSON.
2022-05-03 17:42:14 +01:00
Ian Jackson ae776392fa CfgPath: Change deserialisaation of Literal variant
We introduce LiteralPath struct, so that a literal path deserialises
from
    some_path = { literal: "actual path string" }

This makes the deserialisation unambiguous.
2022-05-03 17:42:14 +01:00
Ian Jackson a150d53faa config: Enable "toml" feature
arti uses this.  Somehow this seems to be enabled by some other thing
in the crate graph, but I found that adding a similar dependency to
another crate resulted in a `config` which doesn't compile.
2022-05-03 17:42:14 +01:00
Nick Mathewson e46edc21fa Merge branch 'fs-mistrust-v2' into 'main'
Second cut at a fs-mistrust crate.

See merge request tpo/core/arti!468
2022-05-03 14:28:28 +00:00
Nick Mathewson f35b488129 fs-mistrust: write a lot about TOCTOU issues. 2022-05-03 10:03:32 -04:00
Nick Mathewson 2f467245ca fs-mistrust: Rename SecureDir to CheckedDir. 2022-05-03 10:03:32 -04:00
Nick Mathewson 2087dde3a0 fs-mistrust: Add a dangerously_trust_everyone method.
This helps make it possible to use `SecureDir` (name pending) even
when we want to disable permissions checks.  Otherwise, optional
permission checking would require users of this crate to maintain
separate code paths for the "check" and "don't check" cases.
2022-05-03 10:03:32 -04:00
Nick Mathewson 0c01fb97ac fs-mistrust: split check_one into two functions.
This will make a "trust_everyone" easier to implement.
2022-05-03 10:03:32 -04:00
Nick Mathewson ab190d2186 fs-mistrust: Make self-named groups trusted by default. 2022-05-03 10:03:32 -04:00
Nick Mathewson 703ad41265 Work around CI config weirdness.
Some of our builders put root into gid 0, but getgroups() doesn't
actually give any result.
2022-05-03 10:03:32 -04:00
Nick Mathewson 85d7084d95 fs-mistrust: Add code to make a self-named group "trusted".
This required a bit of poking through the `users` crate, to mess
with the user and group dbs.  The original goal was to "trust the
group with the same name as us", but it turned into a bit of a
production, since:

  * We want to take our own name from $USER, assuming that matches
    our uid.  (Otherwise we want to ask getpwuid_r().)
  * We only want to trust the group if we are actually a member of
    that group.
  * We want to cache this information.
  * We want to test this code.
2022-05-03 10:03:32 -04:00
Nick Mathewson c09a613590 fs-mistrust: refactor ResolvePath to avoid temporary changes.
Previously we would temporarily put self.resolved into an invalid
state by adding a path component that might be a symlink.  With this
change, we create a new temporary path object (using Cow to avoid
unnecessary allocations) and only conditionally replace
self.resolved.
2022-05-03 10:03:32 -04:00
Nick Mathewson 8e25954c49 fs-mistrust: clarify and test behavior for ".." past the fs root. 2022-05-03 10:03:32 -04:00
Nick Mathewson c9e17c5aaa Add a must_use (suggested by @diziet). 2022-05-03 10:03:32 -04:00
Nick Mathewson 7254fc60eb fs-mistrust: more examples, documentation. 2022-05-03 10:03:32 -04:00
Nick Mathewson 7f27744ef7 Add a SecureDir API for checked access to directories
The only way to get a SecureDir is by having checked a directory.
Once you have one, it encourages you to open and create files and
directories with the right permissions, and checks them for you.
2022-05-03 10:03:32 -04:00
Nick Mathewson 75633109c2 Add functionality to inspect directory content permissions
Also, explain _why_ this is pretty important.
2022-05-03 10:03:32 -04:00
Nick Mathewson d574afa230 By default, forbid special files. 2022-05-03 10:03:32 -04:00
Nick Mathewson 2042d0934b Support for "create missing directory". 2022-05-03 10:03:32 -04:00
Nick Mathewson 712b46174d Add support for trusted group IDs. 2022-05-03 10:03:32 -04:00
Nick Mathewson c4a6c6d82e Implement support for the Sticky Bit. 2022-05-03 10:03:32 -04:00
Nick Mathewson c4a5a49b55 Second cut at a fs-mistrust crate.
This crate is meant to solve #315 by giving a way to make sure that
a file or directory is only accessible by trusted users.  I've tried
to explain carefully (in comments and documentation) what this crate
is doing and why, under the assumption that it will someday be read
by another person like me who does _not_ live and breathe unix file
permissions.  The crate is still missing some key features, noted in
the TODO section.

It differs from the first version of the crate by taking a more
principled approach to directory checking: it emulates the path
lookup process (reading symlinks and all) one path change at a time,
thus ensuring that we check every directory which could enable
an untrusted user to get to our target file, _or_ which could
enable them to get to any symlink that would get them to the target
file.

The API is also slightly different: It separates the `Mistrust`
object (where you configure what you do or do not trust) from the
`Verifier` (where you set up a check that you want to perform on a
single object).  Verifiers are set up to be a bit ephemeral,
so that it is hard to accidentally declare that _every_ object
is meant to be readable when you only mean that _some_ objects
may be readable.
2022-05-03 10:03:32 -04:00
trinity-1686a d1bd9e209f update tls-api to 0.8.0
and remove corresponding RUSTSEC from ignored list
2022-04-28 17:43:32 +02:00
eta 6f787e1e77 Merge branch 'derive-builder-git-fixup' into 'main'
derive_builder: Use git dep everywhere, rather than cargo patch

See merge request tpo/core/arti!477
2022-04-27 14:31:08 +00:00
Ian Jackson a97ad69855 derive_builder: Use git dep everywhere, rather than cargo patch
The `[patch]` approach causes the tree not to build when used as a
dependency, unless the `[patch]` is replicated into the depending
project.

Instead, replace our `derive_builer =` dependencies with a reference
to a specific git commit:

  perl -i~ -pe 'next unless m/^derive_builder/; s#"(0\.11\.2)"#{ version = "$1", git = "https://github.com/ijackson/rust-derive-builder", rev = "ba0c1a5311bd9f93ddf5f5b8ec2a5f6f03b22fbe" }#' crates/*/Cargo.toml

Note that the commitid has changed.  This is because derive_builder is
in fact a workspace of 4 crates.  3 of them are of interest to arti
itself (the 4th exists only for testing).  So the same "add git
revision" treatment had to be done to the `derive_builder` and
`derive_builder_macro` crates.  Each dependency edge involves a new
commit in the derive_builder workspace, since we can't create a git
commit containing its own commitid.  (We want to use commits, rather
than a branch, so that what we are depending on is actually properly
defined, and not subject to the whims of my personal github
namespace.)

There are no actual code changes in derive_builder.
2022-04-27 14:57:59 +01:00
Samanta Navarro 4b9ecc5680 Fix sentences
The arti crate itself is only used in benchmark and testing crate.
I think this sentence does not belong here.

Also extend retry-error description (from Architecture.md).
2022-04-27 13:53:23 +01:00
Samanta Navarro 1d62d92fb9 Fix spacing 2022-04-27 13:52:43 +01:00
Samanta Navarro c53818d496 Fix grammar and typos 2022-04-27 13:52:13 +01:00
eta 8509dbc920 Merge branch 'upgrade_dependencies' into 'main'
Upgrade various dependencies, now that we are MSRV 1.56

Closes #313 and #334

See merge request tpo/core/arti!476
2022-04-27 12:27:28 +00:00
Nick Mathewson 5484bcc21f Merge branch 'download-schedule' into 'main'
DownloadSchedule: Introduce Builder

See merge request tpo/core/arti!473
2022-04-26 18:47:08 +00:00
Ian Jackson 4a32bcd4d3 Make DownloadScheduleBuilder "alternative" defaults pub(crate)
As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/473#note_2798464
2022-04-26 19:01:20 +01:00
Nick Mathewson 4643e1dd24 Fix typo in message 2022-04-26 17:40:05 +00:00
Nick Mathewson f8dbad941e Bump async_executors to 0.6 2022-04-26 12:16:22 -04:00
Nick Mathewson aaab6f3812 Upgrade to AES 0.8
Now that we require Rust 1.56, we can upgrade to AES 0.8.  This
forces us to have some slight API changes.

We require cipher 0.4.1, not cipher 0.4.0, since 0.4.0 has
compatibility issues with Rust 1.56.
2022-04-26 12:16:22 -04:00
Nick Mathewson 6b5cefcccf Bump to config 0.13 2022-04-26 12:16:22 -04:00
Nick Mathewson fe0e5b4ded Upgrade tracing-journald to 0.3.0 2022-04-26 12:16:22 -04:00
Nick Mathewson 5586f0d039 Upgrade to Postage 0.5.0 2022-04-26 12:16:22 -04:00
Nick Mathewson ae72d21092 Upgrade to rlimit 0.8.3, again.
Now that our MSRV is at 1.56, we can use the latest rlimit.

It has to be 0.8.3 (not "0.8"), since 0.8.2 has compatibility issues
with 1.56.
2022-04-26 12:16:22 -04:00
Ian Jackson 72eaa9fc30 DirMgrConfig: Remove unnecessary accessors
These fields are pub.

Retain two convenience accessor functions that access sub-fields of
network.
2022-04-26 15:32:20 +01:00
Ian Jackson 20d61dd4d4 DirMgrConfig: Rename two fields that contained a _config
This entire struct is config.  This is otiose.
2022-04-26 15:29:33 +01:00
Ian Jackson ed71858123 DownloadSchedule: Rename field to "attempts"
This is actually a number of *attempts* not a number of *retries*.
The setter method was already called "attempts".

This chnages the deserialisation of the config.
2022-04-26 15:16:32 +01:00
Ian Jackson cb303cefb3 DownloadSchedule: Abolish accessors in DownloadScheduleConfig
We can just make the fields pub(crate).
2022-04-26 15:16:32 +01:00
Ian Jackson eb35555330 DownloadSchudule: Have NetworkConfig contain Builders
Use sub_builder.  We must do something special for defaults.

This involves moving the actual default values for retry_bootstrap and
retry_microdescs into config.rs, since they need to access the fields
of the un-built version of the structure.  (An alternative would be to
generate "weak setters" which do not override previous settings, but
derive_builder does not offer to generate them and that seems
overkill.)
2022-04-26 15:16:32 +01:00
Ian Jackson f4a1e34bee DownloadSchedule: Abolish new() method
Instead, everyone should use DownloadScheduleBuilder.

The new() method would in any case be useless in a moment, since we're
going to embed DownloadScheduleBuilder in the NetworkConfig, not
DownloadSchedule.

The call sites in the tests are all about to change again.
2022-04-26 15:16:32 +01:00
Ian Jackson e1d1fe6569 DownloadSchedule: tests: Do not try to set parallelism to 0
The current behaviour is to treat 0 as indicating "use the default",
which is quite strange.  We are going to get rid of that.

The new way will be to reject zero, during
DownloadScheduleBuilder::build, Add a test case for that.
2022-04-26 15:16:03 +01:00
Ian Jackson a720205d35 DownloadSchedule: Provide builder 2022-04-26 15:16:03 +01:00
Nick Mathewson c1ea419477 Merge branch 'main' into 'msrv_1_56'
# Conflicts:
#   crates/tor-config/Cargo.toml
#   crates/tor-dirmgr/src/state.rs
#   doc/semver_status.md
2022-04-26 12:45:16 +00:00
Nick Mathewson ed1f5abe20 Merge branch 'config-sub-list' into 'main'
Introduce macro for ThingListBuilder, and use for AuthorityListBuilder

See merge request tpo/core/arti!471
2022-04-26 12:26:16 +00:00
Ian Jackson c529d6cd06 Merge branch 'abstime-sum' into 'main'
retry-error: Provide AbsRetryTime::from_sub and use it

See merge request tpo/core/arti!470
2022-04-25 18:23:03 +00:00
Ian Jackson 15dd7cbdd3 AbsRetryTime::from_sum: Provide a test case
As requested in
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/470#note_2798015
2022-04-25 18:39:11 +01:00
Ian Jackson 2d9b50540d AbsRetryTime::from_sum: Add missing full stop
As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/470#note_2797945
2022-04-25 18:37:14 +01:00
Ian Jackson e81d215787 list-builder: Provide tests of all methods
Because the macro output is private, if we miss one out of the tests,
it doesn't fail due to dead code :-).
2022-04-25 18:24:28 +01:00
Ian Jackson c71046294b list_builder: Allow the struct to not be pub
Really, we probably don't want any of these not to be pub, but it
triggers "unreachable pub" in my test cases, and making it not pub by
mistake seems not very serious, and likely to be noticed.

Making the struct private in the test cases has the useful effect of
checking that all the methods are tested.
2022-04-25 18:24:06 +01:00
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