Commit Graph

302 Commits

Author SHA1 Message Date
Nick Mathewson dc2c00e282 Merge branch 'doc-config-must' into 'main'
tor-config: Document how to reject compiled-out features

Closes #654

See merge request tpo/core/arti!929
2022-12-07 13:20:09 +00:00
Ian Jackson dc3c7651ca tor-config: Document how to reject compiled-out features
Fixes #654
2022-12-06 15:51:43 +00:00
Ian Jackson f3fa77be6f tor-config: Add "particular situations" sections and mention list_builder 2022-12-06 15:51:31 +00:00
Ian Jackson ba338bdf37 tor-config: Update to shellexpand 3.x
This is the new upstream version (published by me, recently).
It has the same MSRV and one breaking change:

The caller who specifies a home dir function for substituting into
strings, must now supply a string, not Path.  Previously shellexpand
would allow the caller to supply non-unicode data, and then simply not
substitute it.  That was an infelicity in the shellexpand API.

Now this infelicity is pushed into our code.  The overall behaviour of
Arti hasn't changed as a result.  And it seems reasonable to me.

shellexpand 3.x also has a module for expanding Paths instead, in
response to requests for this filed as upstream tickets.  We *could*
use that but I am not sanguine about that approach: the Pathness would
spread throughout much of our config and file handling code.

I think we should at the very least postpone trying to work with
invalid-unicode-paths as long as we can.
2022-12-06 15:15:22 +00:00
Ian Jackson 010ffd6ea6 tor-config: home dir handling: fmt pre-patch 2022-12-06 15:11:58 +00:00
Nick Mathewson e0aeda3071 Remove semver.md files now that 1.1.0 is released. 2022-11-30 17:10:29 -05:00
Nick Mathewson 38bef96b99 Bump the minor version of every crate.
We made this job easy this time around: by incrementing our MSRV, we
have forced ourselves to do at least a minor bump everywhere.
2022-11-30 15:10:16 -05:00
Ian Jackson f3c8b0433b tor-basic-utils: list_builder: Use standard test lint block
This gets rid of a spurious warning on nightly about the use of dbg!
2022-11-29 18:41:56 +00:00
Ian Jackson cdc1e574f9 tor-config MultilineListBuilder: Test deserialisation 2022-11-29 17:53:04 +00:00
Ian Jackson 255f3b6bf6 tor-config MultilineListBuilder: Print line number starting at 1, not 0 2022-11-29 17:53:04 +00:00
Ian Jackson ef07c2e99d tor-config list_builder tests: Move Outer up a level
We're going to reuse this.
2022-11-29 17:53:04 +00:00
Ian Jackson 71e81bf7b4 MultilineListBuilder: Use a manual implementation of Deserialize
The error message from `#[serde(untagged)]` would otherwise start to
appear when we try to deserialise unsupported PT configurations, when
compiled with bridge but not PT support.
2022-11-29 16:32:14 +00:00
Nick Mathewson 984bd6012a Merge branch 'reconfig-bridges-bad' into 'main'
Require state ownership when using bridges

Closes #612

See merge request tpo/core/arti!889
2022-11-27 19:30:00 +00:00
Ian Jackson 112e28d88e tor-config: Rename to ReconfigureError::UnsupportedSituation
From Unsupported.  Prompted by
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/889#note_2856873
This was added in this MR.

Also add the missing semver note.
2022-11-24 14:31:03 +00:00
Ian Jackson fa918446ac tor-config: Rename to ConfigBuildError::NoCompileTimeSupport
From Unsupported.  Following one of the suggestions here
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/889#note_2856873

This was added in 2c37116149 which was
not yet in a release so this isn't a semver break.  I have added
the semver note that was omitted in that MR.
2022-11-24 14:30:58 +00:00
Nick Mathewson c0a6fb3e0f Merge branch 'stability' into 'main'
arti-client, tor-config: Remove stability warning from top-level docs

See merge request tpo/core/arti!878
2022-11-23 17:50:01 +00:00
Ian Jackson ecaf8b23b8 tor-guardmgr: Refuse to configure bridges if we don't have the lock
Fixes #612
2022-11-23 13:03:14 +00:00
Ian Jackson 2c37116149 tor-config: introduce ConfigBuildError::Unsupported
And use it in bridge configuration parsing.
2022-11-21 15:46:53 +00:00
Ian Jackson ac4869633a tor-config: ConfigBuildError::within: Introduce add_prefix 2022-11-21 15:46:53 +00:00
Ian Jackson 58710b9635 Make the bridge list in the builder be a list of BridgeConfigBuilder
By changing MultilineListBuilder.
2022-11-21 14:58:24 +00:00
Ian Jackson 2327c7657c tor-basic-utils: list_builder: Introduce DirectDefaultEmptyListBuilderAccessors
This trait can have this ludicrously long name because no-one needs to
import it.
2022-11-21 14:54:39 +00:00
Ian Jackson 0b14b93f76 arti-client, tor-config: Remove stability warning from top-level docs
Ticket #285 is closed and most of this is stable now we think.

(There are still a couple of stability warnings for specific types in
tor-config, which aren't exposed at the arti-client level.)
2022-11-21 12:06:27 +00:00
Nick Mathewson d51162e55b Fix a bunch of "needless borrow" warnings on nightly
It looks like, despite a few false starts, they've got this warning
right; there weren't any false positives.
2022-11-18 10:12:05 -05:00
Nick Mathewson 936920b26e bump rust-version to 1.60 in every crate. 2022-11-10 10:57:33 -05:00
Nick Mathewson 932fe48eaf Run add_warnings. 2022-11-03 11:06:02 -04:00
Nick Mathewson 5786637b4f Fix various typos (using typos tool and hand-inspection) 2022-10-18 15:39:33 -04:00
Ian Jackson f84d8777db cargo fmt to remove blank lines
Apparently cargo fmt doesn't like these, which my perl rune didn't
delete.

This commit is precisely the result of `cargo fmt`.
2022-10-12 15:29:04 +01:00
Ian Jackson d9910dba08 Replace all README copies in src/lib.rs with includes
The feature we want is `#[doc = include_str!("README.md")]`, which is
stable since 1.54 and our MSRV is now 1.56.

This commit is precisely the result of the following Perl rune:
  perl -i~ -0777 -pe 's{(^//!(?!.*\@\@).*\n)+}{#![doc = include_str!("../README.md")]\n}m' crates/*/src/lib.rs
2022-10-12 15:29:03 +01:00
Nick Mathewson 63cd6b0c87 Fix error message 2022-10-12 13:50:29 +01:00
Ian Jackson cb1adb0103 tor-config: Provide MultilineListBuilder
This is what we'll use to parse the `bridges.bridges` config key.
2022-10-12 13:50:29 +01:00
Ian Jackson debfa1f107 tor-config: Remove unneeded braces in an example 2022-10-12 13:50:29 +01:00
Ian Jackson 4a6ac4090c tor-config: Provide BoolOrAuto
We're going to use this for the config item `bridges.enabled`,
but it seems general enough that it ought to go here.
2022-10-12 13:50:29 +01:00
Ian Jackson b766b16e46 tor_config: define_list_builder_helper: Support custom serde
We're going to want something that has the standard list builder
methods at the Rust API, but which has different serialisation.

Sadly the implementation is annoying, because macro_rules makes it
hard to parse a nice input syntax.
2022-10-12 13:50:29 +01:00
Ian Jackson 82ad9eea5f Allow "clippy::single_char_pattern" in tests.
This lint exists for perf reasons, and this is rarely relevant in
tests.

Using double quoted str is generally cognitively less burdensome.
2022-10-12 13:50:29 +01:00
Ian Jackson d6b85b27c4 tor-config: CfgPath: Fix two typos "expaneded" 2022-10-11 11:22:49 +01:00
Nick Mathewson e005d38edb CfgPath: Add support for ${PROGRAM_DIR}.
`${PROGRAM_DIR}` expands to the equivalent of
`std::env::current_exe().parent()`, with appropriate unwrapping and
conversions.

It is expected to be useful for finding the locations of pluggable
transports in some kinds of bundles.

Closes #586.
2022-10-07 09:03:00 -04:00
Nick Mathewson f5389b53e9 Bump crates that have had no API changes. 2022-10-03 09:47:09 -04:00
trinity-1686a 8e7a904260 fix clippy::needless_borrow 2022-09-10 14:39:47 +02:00
Nick Mathewson a5f704f443 Remove semver.md from arti-1.0.0 2022-09-07 09:17:00 -04:00
Nick Mathewson 96875ea208 Bump crate versions in preparation for Arti 1.0.0 release.
Because we want to work more on ensuring that our semver stability
story is solid, we are _not_ bumping arti-client to 1.0.0 right now.

Here are the bumps we _are_ doing.  Crates with "minor" bumps have
had API breaks; crates with "patch" bumps have had new APIs added.

Note that `tor-congestion` is not bumped here: it's a new crate, and
hasn't been published before.

```
tor-basic-utils         minor
fs-mistrust             minor
tor-config              minor
tor-rtcompat            minor
tor-rtmock              minor
tor-llcrypto            patch
tor-bytes               patch
tor-linkspec            minor
tor-cell                minor
tor-proto               minor
tor-netdoc              patch
tor-netdir              minor
tor-persist             patch
tor-chanmgr             minor
tor-guardmgr            minor
tor-circmgr             minor
tor-dirmgr              minor
arti-client             minor
arti-hyper              minor
arti                    major
arti-bench              minor
arti-testing            minor
```
2022-09-01 08:59:49 -04:00
Nick Mathewson 874ba13501 Fix a rustdoc link error. 2022-08-31 12:24:39 -04:00
Nick Mathewson 8d6a1ea6ec Merge branch 'refactor-anyhow-arti-crate' into 'main'
Remove `anyhow` from `tor-config` crate

See merge request tpo/core/arti!707
2022-08-31 13:14:46 +00:00
Ian Jackson e2104e4cce tor-config: DisfavouredKey: Linkify Display 2022-08-30 13:24:06 +01:00
Ian Jackson 71122a61b6 tor-config: DisfavouredKey: Widen applicability of .to_string()
And linkify it.
2022-08-30 13:24:06 +01:00
Alexander Færøy 4c2fd18d35 Add documentation note on `to_string()` usage for DisfavouredKey. 2022-08-30 13:24:06 +01:00
Arturo Marquez 7d3d24cddf
Remove `anyhow` from `tor-config` crate 2022-08-28 18:07:53 -05:00
Nick Mathewson 496a5be749 Merge branch 'clippy' into 'main'
tor-config: tests: Apply standard lint block in sources.rs

See merge request tpo/core/arti!694
2022-08-26 12:56:25 +00:00
Nick Mathewson 88fa24d029 Improve error from bad escapes in a toml config.
Whereas previously we would say:

```
target/debug/arti: error: invalid escape character in string: `Z` at line 9 column 14 in ../../.config/arti/arti.toml
```
we now say:
```
target/debug/arti: error: invalid escape character in string: `Z` at line 9 column 14 in ../../.config/arti/arti.toml   (If you wanted to include a literal \ character, you need to escape it by writing two in a row: \\)
```

The implementation is a bit of a hack, I'm afraid, but I don't think
it's all that bad.

Closes #549.
2022-08-25 15:04:52 -04:00
Ian Jackson 3faf4475cc Bump toml dependency
We need
  60b874308e6792a73cc00517a60bbef60a12e3cc
  Mixed type arrays (#358)
for a test case in tor-config.

While we're here, drop the dupe entry in tor-config.

(In principle we could make this increase only in tor-config's
dev-dependencies, but that seems unnecessarily fiddly.)
2022-08-25 18:41:28 +01:00
Ian Jackson 76066dac81 tor-config Listen: Rename localhost_port_legacy (from _deprecated)
As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/602#note_2830847
2022-08-25 18:41:28 +01:00
Ian Jackson a6d7e38f6d tor-config Listen: Add a note about EADDRINUSE
Prompted by
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/602#note_2830848
2022-08-25 18:41:28 +01:00
Ian Jackson 81bf8d5f4d tor-config; Listen: Return addresses in groups for error behaviour
Prompted by
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/602#note_2830766
2022-08-25 18:41:28 +01:00
Ian Jackson 846fe3d520 tor-config: Provide resolve_alternative_specs 2022-08-25 18:41:28 +01:00
Ian Jackson 3af1f3e712 tor-config: Support tracking deprecated config keys 2022-08-25 18:41:28 +01:00
Ian Jackson 33358379f4 tor-config: Introduce ResolutionResults
This will allow us to handle new kinds of warnigns etc.
2022-08-25 18:41:03 +01:00
Ian Jackson 29a24a9dcb tor-config: Rename UnrecognizedKey to DisfavouredKey
We're going to want the to use the same type for deprecated keys.
2022-08-25 18:40:14 +01:00
Ian Jackson f588268128 tor-config: Provide misc::Listen 2022-08-25 18:40:14 +01:00
Ian Jackson 00c51bf63f tor-config misc tests: Add standard lint suppression block 2022-08-25 18:40:14 +01:00
Ian Jackson a931ec08bd tor-config: tests: Apply standard lint block in sources.rs
Fixes a spurious clippy warning on nightly, about a dbg!
2022-08-25 16:33:59 +01:00
Ian Jackson ae5ca43779 tor-config: semver.md: Document change to ConfigurationSource enum 2022-08-25 15:58:29 +01:00
Ian Jackson 2662fd0d71 tor-config source: just ConfigurationSource, not FoundConfigFile
FoundConfigFile existed to hide something that ConfigurationSource now
exposes.
2022-08-25 15:58:29 +01:00
Ian Jackson 9c00ec7da4 tor-config: Replace dir detection with ConfigurationSource enum
As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/682#note_2830860

And subsequent IRC discussion.

Having done the work as per review comments, I don't much like the
result.  It's quite un-ergonomiuc.  If we can't have fs autodetection,
I think syntactic autodetection within sources.rs would be nearly as
nice.

However, I seem to be outvoted.  At least the externally visible
functionality (of an arti binary, say) is reasonably ergonomic.
2022-08-25 15:58:29 +01:00
Ian Jackson e98bdf6004 tor-config: Provide is_syntactically_directory helper function 2022-08-25 15:58:29 +01:00
Ian Jackson a3005d8c0a tor-config: MustRead: Make public
I think this ought to be exhaustive.
2022-08-25 15:58:29 +01:00
Ian Jackson 7c0637ad44 config watch: Fix and reduce debounce interval
The parameter to FileWatcher::new is not a polling time fallback; it
is a "debounce time".  Events are always delayed by at least this
much.

10s is much too long for this.  1s is more appropriate.
2022-08-25 15:58:29 +01:00
Ian Jackson 7d8b3e2f2f config sources: Read arti.d as well as arti.toml
Fixes #474 aka #271
2022-08-25 15:58:29 +01:00
Ian Jackson ba94c4a4fa config sources tests: Test results of directory scan 2022-08-25 15:58:29 +01:00
Ian Jackson b700816eef config sources tests: Break out sources_nodefaults 2022-08-25 15:58:29 +01:00
Ian Jackson e4fea3e1ea config sources tests: Introduce test of reading directory 2022-08-25 15:58:29 +01:00
Ian Jackson 08767f59d8 config sources: Supporting reading directories 2022-08-25 15:58:29 +01:00
Ian Jackson 7d088cf8df config sources: Introduce scan() and FoundConfigFiles
We're going to need to do config file reading in two phases.

Right now this isn't actually necessary, because the set of files
is fixed since we don't support dynamically scanning directories.
But the new API will be needed in a moment.

Code motion and API changes, but no overall functional change.
Review with `git show -b` may be helpful.

The new API also provides for dealing with directories, but right now
that doesn't happen.
2022-08-25 15:58:29 +01:00
Ian Jackson cd2432474c tor-config sources: Remove some unneeded .to_string() from tests 2022-08-25 15:58:29 +01:00
trinity-1686a 7f939fa480 enable doc_auto_cfg feature on every crate when documenting for docs.rs 2022-08-24 18:22:41 +02:00
Ian Jackson ee2580face tor-config: resolve_option_general: Add semver note 2022-08-23 14:21:13 +01:00
Ian Jackson 0c747b8069 tor-config: resolve_option_general: Add TODO about example 2022-08-23 14:20:49 +01:00
Nick Mathewson 32c14d37bf Fix syntax in doc comment. 2022-08-23 12:59:41 +00:00
Ian Jackson 457c17adb0 tor-config: Provide resolve_option_general, for T: !Default etc.
At one point in this MR I thought I was going to want this for
arti::cfg::ListenConfig (which we don't want to be Default).

In fact ListenConfig is being handled specially, but having written
this function it seemed sensible to keep it.  Since resolve_option
becomes a wrapper for it, the existing tests exercise it.
2022-08-22 16:26:38 +01:00
Ian Jackson d9338293c8 Add semver notes 2022-08-17 10:54:41 +01:00
eta e5396a35c8 Fix typos in comments. 2022-08-17 10:54:41 +01:00
Ian Jackson 2fbc196f8e tor-config: Introduce PaddingLevel
This will be used for controlling channel padding, for now.
2022-08-16 18:38:53 +01:00
Ian Jackson fbe80fd417 tor-config: Introduce ReconfigureError::Bug
Reconfigurations might fail due to internal errors.
2022-08-16 18:37:06 +01:00
Ian Jackson 33e0d67018 Update shellexpand, and switch to non-fork
Now we have bus>1 ownership of the crate name `shellexpand`.  I have
made a release, and retired `shellexpand-fork`.

The new shellexpand release switches to a (quite similarly) unforked
version of `dirs`.
2022-08-05 15:36:47 +01:00
Nick Mathewson 859ae4acd0 Bump patch versions on crates that have new APIs.
Do _not_ bump the dependency versions on crates that have had no
changes since arti 0.0.5, since those crates do not depend on the
new APIs.

```
cargo set-version -p tor-basic-utils   --bump patch
cargo set-version -p tor-llcrypto      --bump patch
git restore crates/tor-checkable
git restore crates/tor-consdiff
git restore crates/tor-rtmock
```
2022-08-01 09:56:29 -04:00
Nick Mathewson 511cb46997 Bump minor version on crates with deps with breaking changes.
This performs the transitive closure of the last operation:
everything that depends on a crate with a breaking change gets the
version which it depends on bumped.

```
cargo set-version -p tor-proto         --bump minor
cargo set-version -p tor-netdoc        --bump minor
cargo set-version -p arti-hyper        --bump minor
cargo set-version -p arti-bench        --bump minor
cargo set-version -p arti-testing      --bump minor
cargo set-version -p tor-config        --bump minor
```
2022-08-01 09:49:13 -04:00
Nick Mathewson f5dcb98f06 Bump minor versions on all crates that have had breaking changes.
Done with these commands:

```
cargo set-version -p fs-mistrust       --bump minor
cargo set-version -p tor-bytes         --bump minor
cargo set-version -p tor-socksproto    --bump minor
cargo set-version -p tor-cert          --bump minor
cargo set-version -p tor-linkspec      --bump minor
cargo set-version -p tor-cell          --bump minor
cargo set-version -p tor-netdir        --bump minor
cargo set-version -p tor-persist       --bump minor
cargo set-version -p tor-chanmgr       --bump minor
cargo set-version -p tor-guardmgr      --bump minor
cargo set-version -p tor-circmgr       --bump minor
cargo set-version -p tor-dirclient     --bump minor
cargo set-version -p tor-dirmgr        --bump minor
cargo set-version -p arti-client       --bump minor
cargo set-version -p arti              --bump minor
```
2022-08-01 09:43:09 -04:00
trinity-1686a eed8032dbd fix nighly clippy 2022-07-23 20:25:33 +02:00
Nick Mathewson 20435aea75 Bump crate and dependency versions.
These were done with the following commands:

```
cargo set-version -p tor-basic-utils   --bump patch
cargo set-version -p fs-mistrust       --bump minor
cargo set-version -p tor-error         --bump patch
cargo set-version -p tor-config        --bump patch
cargo set-version -p tor-units         --bump patch
cargo set-version -p tor-rtcompat      --bump minor
cargo set-version -p tor-llcrypto      --bump patch
cargo set-version -p tor-bytes         --bump minor
cargo set-version -p tor-socksproto    --bump minor
cargo set-version -p tor-cert          --bump minor
cargo set-version -p tor-cell          --bump minor
cargo set-version -p tor-proto         --bump minor
cargo set-version -p tor-netdoc        --bump patch
cargo set-version -p tor-netdir        --bump minor
cargo set-version -p tor-persist       --bump patch
cargo set-version -p tor-chanmgr       --bump minor
cargo set-version -p tor-guardmgr      --bump minor
cargo set-version -p tor-circmgr       --bump patch
cargo set-version -p tor-dirclient     --bump patch
cargo set-version -p tor-dirmgr        --bump minor
cargo set-version -p arti-client       --bump patch
cargo set-version -p arti              --bump minor
cargo set-version -p arti-bench        --bump minor
cargo set-version -p arti-testing      --bump minor
```
2022-06-24 12:00:22 -04:00
Ian Jackson 23c352b96b clippy: Consolidate many lints in maint/add_warning
Found these by disabling the nightly dbg macro special case.  Now, we
have a mechanism for globally adding suppressions to tests, we can use
that instead.
2022-06-24 14:23:38 +01:00
Ian Jackson 589c6e52bb Run maint/add_warning crates/*/src/{lib,main}.rs
Update all lint blocks
2022-06-23 19:15:42 +01:00
Nick Mathewson c39631af27 tor-config: style fixes on CfgPathError. 2022-06-22 08:36:13 -04:00
Nick Mathewson 37cbd38abc tor-config: Don't format source error as part of error message
This is one I missed earlier.
2022-06-22 08:23:33 -04:00
Ian Jackson 90ba8b15de impl_standard_builder: Allow for !Default 2022-06-16 15:42:06 +01:00
Ian Jackson c895057cb9 tor-config: impl_standard_builder: handle contexts with local Result 2022-06-16 15:27:00 +01:00
Ian Jackson baca49e087 config: Suppose that we might extend resolve_option to non-T::Default
As per point 3 in
  https://gitlab.torproject.org/tpo/core/arti/-/issues/488
2022-06-10 14:23:16 +01:00
Ian Jackson 77f33176c3 config: Do not strip_option for journald (and in future)
As per point 1 in
  https://gitlab.torproject.org/tpo/core/arti/-/issues/488
2022-06-10 14:23:13 +01:00
Dimitris Apostolou 8488192ba1
Fix typos 2022-06-05 18:47:51 +03:00
Ian Jackson 9f4fe6a484 tor-config: Fix a doc link
Nightly cargo doc complaints about this.
2022-06-01 15:48:45 +01: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
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
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