Commit Graph

694 Commits

Author SHA1 Message Date
Gabriela Moldovan b289c0fd15 arti-client: Add an Error type for the dummy key manager.
Part of #897
2023-06-20 13:33:51 +01:00
Gabriela Moldovan 95e4021ed8 arti-client, keymgr: Introduce Mistrust settings and enforce FS permissions. 2023-06-20 13:29:10 +01:00
Gabriela Moldovan be5c911ac8 arti-client: Temporarily ignore key store errors.
We currently initialize the `ArtiNativeKeyStore` with a dummy root dir,
so when `ArtiNativeKeyStore` starts validating directories, this code
will start to fail. Let's preemptively ignore any errors coming from
`ArtiNativeKeyStore::new`. This is temporary and will be removed when we
introduce the key store config (and a real default value for the
keystore root dir).
2023-06-20 13:29:10 +01:00
Ian Jackson b34ba70070 arti-client: hs: remove some now-obsolete allows 2023-06-16 16:18:02 +01:00
Ian Jackson f877f37308 arti-client: address: Prefer to throw OnionAddressResolveRequest (fmt) 2023-06-16 16:18:02 +01:00
Ian Jackson d9f1c7195b arti-client: address: Prefer to throw OnionAddressResolveRequest
Reformatting deferred for clarity.
2023-06-16 16:18:02 +01:00
Ian Jackson dafccf93b0 arti-client: hs: Test cases for variously disabling .onion
This test case shows that we return a suboptimal error in some cases.
2023-06-16 16:18:02 +01:00
Ian Jackson 18291cb001 arti-client: Provide ErrorDetailDiscriminants for convenient testing
ErrorDetail isn't PartialEq so we can't assert_eq! it.
But the discriminants will be.
2023-06-16 16:18:02 +01:00
Ian Jackson 0a7ca71e70 arti-client: StreamPrefs::connect_to_onion_services: honour 2023-06-16 16:18:02 +01:00
Ian Jackson 2d112efc0f arti-client: StreamPrefs::connect_to_onion_services: docs
This disposes of the TODO as well.
2023-06-16 16:18:02 +01:00
Ian Jackson c5b655ed45 arti-client: StreamPrefs::connect_to_onion_services: fix cfg 2023-06-16 16:18:02 +01:00
Ian Jackson 21090aa6f0 arti-client: StreamPrefs::connect_to_onion_services: fix name 2023-06-16 16:18:02 +01:00
nate_d1azzz 08b7419138 Added setter method in impl for StreamPrefs
(Taken from tpo/core/arti!1113 and squashed by Ian Jackson, with
conflicting hunk in StreamPrefs struct skipped.

The setter name is wrong, the cfg feature is wrong, there are no
docs, and the TODO is still there.  These will be fixed in a moment.)
2023-06-16 16:18:02 +01:00
Ian Jackson 40dae63b65 arti-client hs: connect_to_onion_services: default to true
This should be enabled by default.  There's still no setter for not,
nor is it honoured - those are separate TODOs.
2023-06-16 16:18:02 +01:00
Ian Jackson ce72588322 arti-client: OnionAddressNotSupported: Change description and kind
Previously this error meant "we haven't written this code yet".
Now, we change it to "you haven't built Arti with this feature".
2023-06-16 16:18:02 +01:00
Ian Jackson 2521b88cd6 arti-client: address: Apply deferred rustfmt churn 2023-06-16 16:18:02 +01:00
Ian Jackson 60cfb09e77 arti-client: address: Plumb StreamPrefs into enforce_config
No functional change yet.  We'll use this shortly.
2023-06-16 16:18:02 +01:00
Ian Jackson bf93519cdd arti-client: address: Move config enforcement
Disposes of two TODOs.
2023-06-16 16:18:02 +01:00
Ian Jackson eb9b0d0d78 arti-client: address: Move config enforcement (pre-fmt)
This will make subsequent commits less noisy to read.
2023-06-16 16:18:02 +01:00
Ian Jackson e95f9e52cc arti-client: address: Disable some tests when HS disabled
These have already been partially/replaced supplemented.
The other test referred to will appear shortly.
2023-06-16 16:18:02 +01:00
Ian Jackson 07d5bc9537 arti-client: Rename hs feature to onion-service-client (cfg lines) 2023-06-16 12:34:53 +01:00
Ian Jackson 8d98982bb2 arti-client: Rename hs feature to onion-service-client
Rationale as per #756.

This is the same name as in the `arti` crate.
2023-06-16 12:34:47 +01:00
Gabriela Moldovan 37e0837cea arti-client: rustfmt 2023-06-15 18:56:48 +01:00
Gabriela Moldovan 94b228a4c6 arti-client: Fix clippy lints.
We need to allow some lints in the dummy key manager because its
implementation needs to mirror that of `tor_keymgr::KeyMgr` (so we can't
apply the API changes suggested by clippy).
2023-06-15 18:43:24 +01:00
Gabriela Moldovan bed1ae6304 arti-client: Use a dummy key manager if the keymgr feature is disabled.
TorClient now only uses the tor_keymgr::KeyMgr implementation if the
keymgr experimental feature is enabled. If the feature is disabled, a
dummy key manager implementation is used.

The new `keymgr` feature depends on `onion-client`, because the key
manager is only used for HS client auth.
2023-06-15 18:16:34 +01:00
Gabriela Moldovan 35879a681f arti-client: Implement From<tor_keymgr::Error> for Error. 2023-06-15 18:16:34 +01:00
Gabriela Moldovan 21d93300eb keymgr, arti-client: KeyMgr should return Ok(None) if the key is not found.
This simplifies usage quite a bit and will enable us to implement a
dummy `KeyMgr`  that doesn't depend on the error types from tor-keymgr
(which will replace the "real" `KeyMgr` if the keymgr feature is
disabled).
2023-06-15 18:16:34 +01:00
Gabriela Moldovan a958b3a91a arti_client: Add TODO about refactoring code around HsClientSecretKeysBuilder. 2023-06-15 18:16:34 +01:00
Gabriela Moldovan eda974cd34 keymgr: Move the HS client and service key specifiers out of tor-keymgr.
The HS `HsClientSpecifier` and `HsClientSecretKeySpecifier` are moved to
`tor-hsclient`. The HS service secret key specifier stubs are moved to
`tor-hsservice`.
2023-06-15 18:16:33 +01:00
Gabriela Moldovan e99ee7ec02 arti-client, keymgr: Initialize KeyMgr with an ArtiNativeKeyStore.
The `KeyMgr` is now initialized with an `ArtiNativeKeyStore` built from
an invalid key store root dir (this is alright for the purposes of this
proof-of-concept, since `ArtiNativeKeyStore::new` won't fail as it
doesn't currently validate the keystore root dir).
2023-06-15 18:15:30 +01:00
Gabriela Moldovan 64c24dca66 keymgr: Introduce ToEncodableKey to simplify lookups.
This means `KeyMgr` users don't need to specify the underlying key type
(e.g. `ed25519::Keypair`) when retrieving keys. Instead, they can just
specify the type required (as long as it implements `ToEncodableKey`),
e.g. `HsClientIntroAuthKeypair`.
2023-06-15 18:15:30 +01:00
Gabriela Moldovan fbed393680 arti-client: Make the client use the KeyMgr.
`TorClient` now uses a `KeyMgr` to retrieve the `HsClientSecretKeys`
client auth keys passed to `get_or_launch_connection`.
2023-06-15 18:15:30 +01:00
Gabriela Moldovan 61f37b1b5c keymgr: Add key manager implementation stub. 2023-06-15 18:15:30 +01:00
trinity-1686a 02a82ad748 make snowflake example feature-gated 2023-06-14 18:13:57 +00:00
Nick Mathewson 47b1083d3a Merge branch 'rpc_pseudomethods_v6' into 'main'
RPC: Functionality to downcast dyn Object to a dyn Trait.

See merge request tpo/core/arti!1225
2023-06-12 18:10:46 +00:00
Nick Mathewson 8166a29746 RPC: Functionality to downcast dyn Object to a dyn Trait.
This is a rather tricky piece of functionality.  It works as
follows.

We introduce a `CastTable` type.  Each `CastTable` tells us how to
downcast `dyn Object` for objects of a single concrete type.
The `Object` type now has a `get_casttable` method that returns
an empty `CastTable` by default.

`CastTable` is, internally, a map from the `TypeId` of the target
dyn Trait reference type to a function
`fn(&dyn Object) -> &dyn Trait`.  These functions are stored as
`Box<dyn Any + ...>`.  (They are Boxed because they may refer to
generic functions, which you can't get a static reference to,
and they're Any because the functions have different types.)

The `decl_object!` macro now implements `get_casttable` as
appropriate.  (The syntax is a bit janky, but that's what we get
for not using derive_adhoc.)  For non-generic types, `get_casttable`
uses a Lazy<CastTable>`. to initialize a CastTable exactly once.
For generic types, it use a `Lazy<RwLock<HashMap<..>>` to
build one CastTable per instantiation of the generic type.

This could probably be optimized a bit more, the yaks could be
shaved in a more scintillating hairstyle, and the syntax for
generic `decl_object` could definitely be improved.
2023-06-12 13:35:28 -04:00
Nick Mathewson b19eb8648f Merge branch 'pt-snowflake' into 'main'
add documentation for configuring snowflake pt

Closes #879 and #875

See merge request tpo/core/arti!1216
2023-06-11 20:59:31 +00:00
trinity-1686a a74bb8d4d8 add a few more comments on PTs 2023-06-09 20:15:25 +02:00
Alexander Færøy ab73cf9e8b Merge branch 'report-trait-doc-fix' into 'main'
Expand arti-client docs to include error reporting section

See merge request tpo/core/arti!1213
2023-06-09 13:12:48 +00:00
trinity-1686a b7fd5a6778 change path to snowflake client 2023-06-08 20:19:59 +02:00
trinity-1686a b3c8004f8d change link for more information on pts 2023-06-08 09:20:07 +02:00
Saksham Mittal 6e97b9df1f
Rephrase error handling to reporting 2023-06-08 10:26:52 +05:30
Saksham Mittal 3f7709f98d
Add error handling section in README 2023-06-08 10:26:52 +05:30
Saksham Mittal 724cab8a28
Add separate example with Report 2023-06-08 10:26:38 +05:30
trinity-1686a 73b0bc3561 remove forgoten debug line 2023-06-08 01:29:33 +02:00
trinity-1686a 9c3c7f4bc3 add anchor to amp-cache link 2023-06-08 00:28:58 +02:00
trinity-1686a 925ac7f9d7 complement general documentation on bridges and pt 2023-06-07 23:59:03 +02:00
trinity-1686a 4632d4ff44 move snowflake example to dedicated file and comment it more 2023-06-07 23:59:03 +02:00
trinity-1686a c528443bf4 add documentation for configuring snowflake pt 2023-06-07 23:59:03 +02:00
Nick Mathewson 999f914e03 rpc: make decl_object! responsible for writing impl Object {} blocks. 2023-06-07 14:37:04 -04:00
Nick Mathewson bdb96b4ac1 hs: Fix a feature name in arti-client
In arti-client it's called "onion-client", not "hs-client".
2023-06-07 08:21:22 -04:00
Nick Mathewson daf5ecc153 Bump crate versions in preparation for v1.1.5 release.
Generated with the following commands:

```
cargo set-version --bump minor -p tor-cell
cargo set-version --bump minor -p tor-linkspec
cargo set-version --bump minor -p tor-proto
cargo set-version --bump minor -p tor-netdoc
cargo set-version --bump minor -p tor-circmgr

cargo set-version --bump patch -p tor-cert
cargo set-version --bump patch -p tor-basic-utils
cargo set-version --bump patch -p tor-rpcbase
cargo set-version --bump patch -p tor-llcrypto
cargo set-version --bump patch -p tor-hscrypto
cargo set-version --bump patch -p tor-checkable
cargo set-version --bump patch -p tor-async-utils
cargo set-version --bump patch -p caret
cargo set-version --bump patch -p fs-mistrust
cargo set-version --bump patch -p safelog
cargo set-version --bump patch -p retry-error
cargo set-version --bump patch -p tor-error
cargo set-version --bump patch -p tor-config
cargo set-version --bump patch -p tor-events
cargo set-version --bump patch -p tor-units
cargo set-version --bump patch -p tor-rtcompat
cargo set-version --bump patch -p tor-rtmock
cargo set-version --bump patch -p tor-protover
cargo set-version --bump patch -p tor-bytes
cargo set-version --bump patch -p tor-socksproto
cargo set-version --bump patch -p tor-consdiff
cargo set-version --bump patch -p tor-netdir
cargo set-version --bump patch -p tor-congestion
cargo set-version --bump patch -p tor-persist
cargo set-version --bump patch -p tor-chanmgr
cargo set-version --bump patch -p tor-ptmgr
cargo set-version --bump patch -p tor-guardmgr
cargo set-version --bump patch -p tor-dirclient
cargo set-version --bump patch -p tor-dirmgr
cargo set-version --bump patch -p tor-hsclient
cargo set-version --bump patch -p tor-hsservice
cargo set-version --bump patch -p arti-client
cargo set-version --bump patch -p arti-rpcserver
cargo set-version --bump patch -p arti-config
cargo set-version --bump patch -p arti-hyper
cargo set-version --bump patch -p arti
cargo set-version --bump patch -p arti-bench
cargo set-version --bump patch -p arti-testing
```
2023-06-01 10:03:05 -04:00
Nick Mathewson ee390c423e Refactor ClientCirc APIs to use Arc<ClientCirc>.
Now ClientCirc is no longer `Clone`, and the things that need it
to be `Clone` instead return and use an Arc<ClientCirc>
We're doing this so that ClientCirc can participate in the RPC
system, and so that its semantics are more obvious.

Closes #846.

Thanks to the type system, this was a much simpler refactoring than
I had feared it would be.
2023-05-16 09:02:09 -04:00
Nick Mathewson 6fa821238d Revise all XXXXs from fixup-features 2023-05-15 11:00:28 -04:00
Nick Mathewson 4b08ef76a0 Run fixup-features _with_ annotations.
This litters our Cargo.toml files with "XXX" entries that we should
fix.
2023-05-15 10:41:32 -04:00
Nick Mathewson e2e125fef7 Reformat Cargo.toml files. 2023-05-15 09:09:43 -04:00
Nick Mathewson 7a5373c110 Run fixup-features --no-annotate for initial Cargo.toml fixes.
This does the following:
  - Gives every crate a `full`.
  - Cause every `full` to depend on `full` from the lower-level
    crates.
  - Makes every feature listed _directly_ in `experimental` depend
    on `__is_experimental`.
2023-05-15 09:07:21 -04:00
Nick Mathewson b38567e34a Mark an initial set of non-additive features. 2023-05-15 08:27:48 -04:00
Nick Mathewson d7ab388faf RPC: Start on plumbing TorClient into our RPC code
Because of #837, we won't be able to work with _every_ TorClient<R>,
so I'm only going to be using TorClient<PreferredRuntime> for now.
2023-05-04 10:35:03 -04:00
Nick Mathewson e845a553f3 Upgrade tracing to 0.1.36.
This is the first version to impl Value for String.

With luck, this will get minimal_versions CI passing.
2023-05-03 11:09:21 -04:00
Nick Mathewson 1904cfc8b9 Increment crate versions.
Because of the errorkind bumps, we're calling this a breaking change
in everything lower-level than `arti`.

Generated with:
```
cargo set-version -p tor-basic-utils --bump minor
cargo set-version -p tor-async-utils --bump minor
cargo set-version -p caret --bump minor
cargo set-version -p fs-mistrust --bump minor
cargo set-version -p safelog --bump minor
cargo set-version -p retry-error --bump minor
cargo set-version -p tor-error --bump minor
cargo set-version -p tor-config --bump minor
cargo set-version -p tor-events --bump minor
cargo set-version -p tor-units --bump minor
cargo set-version -p tor-rtcompat --bump minor
cargo set-version -p tor-rtmock --bump minor
cargo set-version -p tor-rpcbase --bump minor
cargo set-version -p tor-llcrypto --bump minor
cargo set-version -p tor-protover --bump minor
cargo set-version -p tor-bytes --bump minor
cargo set-version -p tor-hscrypto --bump minor
cargo set-version -p tor-socksproto --bump minor
cargo set-version -p tor-checkable --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-proto --bump minor
cargo set-version -p tor-netdoc --bump minor
cargo set-version -p tor-consdiff --bump minor
cargo set-version -p tor-netdir --bump minor
cargo set-version -p tor-congestion --bump minor
cargo set-version -p tor-persist --bump minor
cargo set-version -p tor-chanmgr --bump minor
cargo set-version -p tor-ptmgr --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 tor-hsclient --bump minor
cargo set-version -p tor-hsservice --bump minor
cargo set-version -p arti-client --bump minor
cargo set-version -p arti-rpcserver --bump minor
cargo set-version -p arti-config --bump minor
cargo set-version -p arti-hyper --bump minor

cargo set-version -p arti --bump patch
cargo set-version -p arti-bench --bump patch
cargo set-version -p arti-testing --bump patch
```
2023-05-03 08:31:11 -04:00
Gabriela Moldovan 6cb412558d
arti-client: Only run BridgesConfig doc test if pt-client feature is enabled.
One of the tests run as part of `cargo test -p arti-client` fails
because the `pt-client` feature is not enabled by default:

```
failures:

---- src/config.rs - config::BridgesConfig (line 221) stdout ----
error[E0432]: unresolved import `arti_client::config::pt`
 --> src/config.rs:225:26
  |
7 | use arti_client::config::pt::ManagedTransportConfigBuilder;
  |                          ^^ could not find `pt` in `config`

error[E0599]: no method named `bridges` found for mutable reference `&mut BridgesConfigBuilder` in the current scope
  --> src/config.rs:233:19
   |
15 | builder.bridges().bridges().push(bridge_1);
   |                   ^^^^^^^ private field, not a method

error[E0599]: no function or associated item named `default` found for struct `BridgeConfigBuilder` in the current scope
  --> src/config.rs:236:48
   |
18 | let mut bridge2_builder = BridgeConfigBuilder::default();
   |                                                ^^^^^^^ function or associated item not found in `BridgeConfigBuilder`

error[E0599]: no method named `bridges` found for mutable reference `&mut BridgesConfigBuilder` in the current scope
  --> src/config.rs:247:19
   |
29 | builder.bridges().bridges().push(bridge2_builder);
   |                   ^^^^^^^ private field, not a method

error[E0599]: no method named `transports` found for mutable reference `&mut BridgesConfigBuilder` in the current scope
  --> src/config.rs:255:19
   |
37 | builder.bridges().transports().push(transport);
   |                   ^^^^^^^^^^ method not found in `&mut BridgesConfigBuilder`

error: aborting due to 5 previous errors

Some errors have detailed explanations: E0432, E0599.
For more information about an error, try `rustc --explain E0432`.
Couldn't compile the test.

failures:
    src/config.rs - config::BridgesConfig (line 221)

test result: FAILED. 5 passed; 1 failed; 3 ignored; 0 measured; 0 filtered out; finished in 2.10s
```

This disables the `BridgesConfig` doc test if the `pt-client` feature is not enabled.

Closes #843

Signed-off-by: Gabriela Moldovan <gabi@torproject.org>
2023-05-02 14:10:15 +01:00
Nick Mathewson 104d64589d Increment MSRV to 1.65 in every crate. 2023-04-11 15:31:12 -04:00
Nick Mathewson 9ef115a7fb Patchlevel bumps for crates whose dependencies just changed.
These crates had no changes until just a moment ago. But since
we updated the versions on some of their dependents, they have now
changed themselves.  Thus they get patchlevel bumps.

```
tor-rtmock
tor-protover
tor-socksproto
tor-consdiff
tor-chanmgr
tor-dirclient
tor-hsservice
```
2023-03-31 08:30:14 -04:00
Nick Mathewson e208fb15ad Bump crate versions that have breaking changes
These crates have had breaking changes.  They are pre-1.0, so they get
a minor bump.

```
tor-basic-utils
tor-config
```
2023-03-31 08:28:06 -04:00
Nick Mathewson a81ab391ae Bump patchlevel on crates with non-breaking changes
For these crates, the changes are nontrivial, so we
_do_ bump the versions on which their dependent crates depend.

Fortunately, since they are all pre-1.0, we don't need to
distinguish semver-additions from other changes.  (Except for arti,
which _is_ post-1.0, but gets a patchlevel bump anyway.)

These are unstable crates with breaking changes:

```
tor-hscrypto
tor-hsclient
```

These have new or extended APIs:

```
safelog
tor-bytes
tor-cell
tor-linkspec
tor-llcrypto
tor-proto
tor-cert
arti-client
```

These have new unstable APIs or features:
```
tor-netdoc
tor-circmgr (also broke some unstable APIs)
arti (is post-1.0)
```

These have bugfixes only:
```
caret
tor-dirmgr
```
2023-03-31 08:24:39 -04:00
Alexander Færøy bcb051fea4 Merge branch 'plumb' into 'main'
More plumbing for hs connections

See merge request tpo/core/arti!1098
2023-03-30 16:20:54 +00:00
Ian Jackson 23c7bd9174 Run rustfmt
Apply this churn, which I deferred for ease of review.
2023-03-30 15:58:47 +01:00
Ian Jackson a14d18d295 arti-client: Call HsCircPool::launch_background_tasks
I found that I had the bug where I forgot to call this function, and
reached
   bad_api_usage!("The circuit launcher wasn't initialized")

The possibility of such a bug is a hazard of this API pattern.
2023-03-30 15:58:09 +01:00
Ian Jackson 3ed9dca842 tor-hsconn: Rename ConnError (from HsClientConnError)
The old name was unwieldy and other crates can just as well name it by
the crate scope.
2023-03-30 15:49:07 +01:00
Ian Jackson 255b9cac96 arti-client: When making hs conn, wait for bootstrap
Not doing this was a bug.  The bug was possible because of some code
duplication between the exit and hs paths.  Add a comment about that.
2023-03-30 15:49:07 +01:00
Ian Jackson 926abf3ade tor-client: Pass a netdir for each request
This will be more convenient inside tor-hsclient.  In arti-client,
this mirrors the way TorClient::get_or_launch_exit_circ works.
2023-03-30 15:49:07 +01:00
Nick Mathewson a62affd66e Move functionality from tor_basic_utils to tor_async_utils
This commit is mostly code movement; I'd recommend reviewing it
with git's `--color-moved` option.
2023-03-29 13:57:11 -04:00
Ian Jackson edb3ac26f3 Merge branch 'hspre' into 'main'
Miscellanious tidying up (pursuant to HS client work)

See merge request tpo/core/arti!1086
2023-03-29 09:44:48 +00:00
eta a6fe3803a0 arti-client: add accessors for `Blockage`
Fixes #800.
2023-03-28 19:27:04 +01:00
Ian Jackson b982ee678d Tidy up an unused import warning
Now
  cargo +stable clippy --locked --offline --workspace --all-targets
is clean.
2023-03-28 15:49:45 +01:00
Ian Jackson df8e4dd497 Pass HsCircPool to hsclient connect function, not CircMgr (fmt) 2023-03-28 15:49:45 +01:00
Ian Jackson 9b6be7eaa7 Pass HsCircPool to hsclient connect function, not CircMgr
We separated this out in the circmgr API.  This is what the HS client
needs.  It doesn't want to participate in the general circuit pool.
2023-03-28 15:49:45 +01:00
Nick Mathewson 4af2c2ec33 tor_client: Add some example code for BridgeConfig.
Closes #791
2023-03-24 16:25:10 -04:00
Nick Mathewson 455a7a7109 arti-client: Make TransportConfigListBuilder public.
Without this there's no convenient way to add a transport without
messing with serde/toml.

Found while working on #791
2023-03-24 16:25:10 -04:00
Alexander Færøy 6fae5cc7e9 Merge branch 'upgrade_dirs' into 'main'
Bump to the lastest versions of dirs and directories.

See merge request tpo/core/arti!1072
2023-03-23 16:00:50 +00:00
Ian Jackson b6f5c066b4 Apply deferred rustfmt churn 2023-03-23 11:50:18 +00:00
Ian Jackson 9d7983a6ea arti-client: Include redacted HsId in ObtainHsCircuit error
As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/1071/diffs?commit_id=580fe1118dbbbfa086d11b28e3e26d7c91afe21c#fbd7ab2d6d0a5b515697d4f9f99a42ebd508aa4b_153_165
2023-03-23 11:50:18 +00:00
Ian Jackson 58311571d9 arti-client: Fix wording of docs for TorClient::isolation 2023-03-23 11:50:18 +00:00
Nick Mathewson 8a11e0f6ad arti-client: Strengthen an HS todo 2023-03-23 11:50:18 +00:00
Ian Jackson cb93d1bee7 arti-client: Call tor-hsclient to create HS connections
Obviously this still doesn't work because the actual impl in hsclient
is just a todo!().
2023-03-23 11:50:18 +00:00
Ian Jackson 3d33ad7fdf arti-client: Create an HsClientConnector 2023-03-23 11:50:18 +00:00
Ian Jackson a2aa701eb6 arti-client: Move client stream creation out of match, in connect
We want this part for HS too.
2023-03-23 11:50:14 +00:00
Ian Jackson ca73dcfb31 arti-client: Break out TorClient::isolation(prefs)
We're going to want to reuse this.

Also: rename StreamPrefs::isolation and update the docs, to better
reflect its rather limited functionality.  The new
TorClient::isolation is the only call site.
2023-03-23 11:50:14 +00:00
Nick Mathewson 19cdb239bf Bump to the lastest versions of dirs and directories. 2023-03-22 15:15:42 -04:00
Ian Jackson 8c7224ef36 Discuss in comment why we're not using a newtype for the Strings in Host 2023-03-09 18:09:11 +00:00
Ian Jackson 04d843d846 Classify OnionAddressResolveRequest as NotImplemented
We have a theory about how this ought to work, so it's noit an API
usage error - it's an unimplemented feature.

As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/1060#note_2884757
2023-03-09 18:09:08 +00:00
Ian Jackson 5000d11ac3 Reject invalid hostnames
Reject them both for .onion and for "exit" hostnames

This prevents a `Host` from having an invalid hostname in it.
2023-03-09 18:09:08 +00:00
Ian Jackson 8f8df071bc Fix reference to no-longer-contemplated Host variant
Reported in
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/1060#note_2884755
2023-03-09 18:09:08 +00:00
Ian Jackson 8ead708512 Dummy HsId::from_str on .onion: Return Bug, rather than panicking
Prompted by
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/1060#note_2884754
2023-03-09 18:09:08 +00:00
Ian Jackson 654f6689cf Improve error from HsId parse of "www.B32.onion"
And add some clarity and todos about address errors.
2023-03-09 18:09:08 +00:00
Ian Jackson 0a618cbe84 Avoid arti_client::ErrorDetail::Address for TorAddrError::InvalidHostname
Provide an explicit From impl isntead.
2023-03-09 18:09:06 +00:00
Ian Jackson c198a26bf7 arti-client: Parse .onion addresses and dispatch to client.rs
Now, a Host has a separate variant for `.onion` which is always used,
even when HS is disabled.

Currently it ends in a todo!.
2023-03-09 13:41:12 +00:00
Ian Jackson 4502528d0e arti-client: DoThingInstructions: Make error returns consistent
This is more comprehensible, and will be more convenient.
2023-03-09 13:41:12 +00:00
Ian Jackson c31bc1dafe arti-client: Host: Use Display::fmt rather than write!
write! is less good because the `{}` overwrites stuff like "did the
caller ask for padding".
2023-03-09 13:41:12 +00:00
Nick Mathewson e08c229412 Merge branch 'suffix' into 'main'
Introduce and use ends_with_ignore_ascii_case

See merge request tpo/core/arti!1058
2023-03-08 19:36:28 +00:00
Ian Jackson 198a95c74c Merge branch 'host2' into 'main'
arti-client: Do not send resolve requests for IP addrs to exits

See merge request tpo/core/arti!1057
2023-03-08 19:10:23 +00:00
Ian Jackson f15498bc3f arti-client: Host: Be more explicit about what is allowed in Hostname 2023-03-08 18:48:28 +00:00
Ian Jackson c1ae509ce6 Introduce and use ends_with_ignore_ascii_case
As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/1056#note_2884428
2023-03-08 18:27:42 +00:00
Ian Jackson 939027492e Rustfmt 2023-03-08 18:15:32 +00:00
Ian Jackson 257b761042 Abolish Host::into_string_and_port
When I was trying to add HS support to these layers, I found I could
add a new variant to the `Host` enum but everything would still
compile even though I hadn't written the necessary implementation!

This method is a liability: when using it, one inevitably writes such
latent bugs.
2023-03-08 18:15:32 +00:00
Ian Jackson 5df19bc888 arti-client: Do not send resolve requests for IP addrs to exits
Doing so doesn't seem like a good idea.  It might even be some kind of
leak?

Found because I added a variant to `address::Host` for hidden
services, and noticed that the resolve code still compiled.
2023-03-08 18:15:32 +00:00
Ian Jackson fd42ada54c arti-client addr handling: Introduce StreamInstructions 2023-03-08 18:09:57 +00:00
Ian Jackson 6540f260b5 arti-client: Reject .onion, when we should, without allocating
Use new strip_suffix_ignore_ascii_case
2023-03-08 17:26:47 +00:00
Nick Mathewson f41449d0bd Patchlevel bumps for remaining changed crates.
These crates have had small code changes, but no API additions:

tor-config
tor-socksproto
tor-cert
tor-chanmgr
tor-ptmgr
tor-guardmgr
tor-circmgr
tor-dirclient
tor-dirmgr
arti
tor-hsservice
tor-congestion

These crates have had API extensions:

fs-mistrust
tor-llcrypto
tor-bytes
tor-checkable
tor-linkspec
tor-netdoc
tor-persist
arti-client
2023-02-28 07:13:27 -05:00
Nick Mathewson 4479d52a88 Bump patch-versions for breaking changes in tor-hs{crypto,client}
These are API breaks, but the crates themselves are currently
100% experimental, so there's no need to bump the minor versions
according to our semver rules.
2023-02-28 07:06:15 -05:00
Nick Mathewson 3e257a7cb5 Bump minor versions for significant breaking changes.
This includes tor-cell, tor-proto, and tor-netdir.
2023-02-28 07:05:15 -05:00
Ian Jackson f63c7c48af Rename onion-* cargo features to hs-* in tor-* crates
Fixes #756
2023-02-28 11:10:17 +00:00
eta 85ca3e41b9 Merge branch 'shadykaty-error-hint-v2' into 'main'
Create and use an ErrorHint type to report how to fix a problem.

Closes #579 and #578

See merge request tpo/core/arti!994
2023-02-07 16:32:10 +00:00
Nick Mathewson 8ee04ac203 Merge branch 'logs' into 'main'
Report causes of errors

Closes #680

See merge request tpo/core/arti!997
2023-02-01 18:19:33 +00:00
Nick Mathewson a2b1f20216 Bump minor version of tor-cell.
In !948 we renamed a couple of accessor functions, which is a
breaking change in `tor-cell`'s API.

In retrospect, perhaps we should have deprecated the old names and
added the new ones, so we wouldn't have to break the API.  (This is
the only API break AFAICT since 1.1.0.)
2023-02-01 10:42:58 -05:00
Nick Mathewson 7c1b6a5a81 Bump the patch version of every crate that had API additions
These crates had API or behavior changes that may affect downstream
crates. Fortunately, they're all version 0.x, and don't need minor
bumps for this.
2023-02-01 10:36:29 -05:00
Nick Mathewson 66f594a4b6 Bump the patch-level version of crates with _minor_ changes.
These changes influence behavior, but not effect compatibility.
(If I messed up, and any crate except for `arti` has non-breaking
API changes, that's still fine, since they are all version
0.x.)
2023-02-01 10:23:58 -05:00
Ian Jackson 5c0a7e0127 Use ErrorReport for errors in error! in arti-client 2023-01-30 18:52:32 +00:00
Nick Mathewson b3c963e7fa ErrorHint: Add a note about lowering the permissions hint 2023-01-27 11:56:53 -05:00
Nick Mathewson ae963e3c6b ErrorHint: use anonymize_home 2023-01-27 11:56:53 -05:00
Nick Mathewson 39ad97fdc2 ErrorHint: Implement tryfrom_torpersist 2023-01-27 11:56:53 -05:00
Nick Mathewson 3c82f794c1 ErrorHint: refactor API (part 2)
Change ErrorHint so that, internally, it just holds an enum with a
lightweight reference to whatever parts of the error it needs to
generate a hint.  Then we can move the formatting logic into a
Display function for ErrorHint, and do away with ErrorDetail entirely.
2023-01-27 11:56:53 -05:00
Nick Mathewson b8058c5d02 ErrorHint: refactor API (part 1)
Move the "hint" function into Error, and use Option rather than Result.

(I'm using Option here because it's not really an error case not to have
a hint; we just either have a hint, or we don't.)
2023-01-27 11:56:53 -05:00
Shady Katy cc4c07678a add opaque ErrorHint API, impl ErrorHint from BadPermissions 2023-01-27 11:02:42 -05:00
Nick Mathewson a6dd92843e Allow clippy::unchecked_duration_subtraction in tests
This panics on error, and we're fine with a panic on misbehavior in
tests.
2023-01-27 08:28:02 -05:00
Nick Mathewson bf04641c68 Disable clippy::unlinlined-format-args
This warning kind of snuck up on us! (See #748)  For now, let's
disable it.  (I've cleaned it up in a couple of examples, since
those are meant to be more idiomatic and user-facing.)

Closes #748.
2023-01-27 08:27:47 -05:00
Michael van Straten fa93f6674d made TorClient::set_stream_prefs public 2023-01-18 18:20:59 +01:00
Nick Mathewson 56cb2d2a10 Make a top-level API for connecting to onion services.
Fortunately, it adds very little to the arti-client API surface.
2023-01-12 09:28:58 -05:00
Ian Jackson 125a455bdc test lint blocks: Add many many automatically
This is precisely the result of running the rune in
maint/adhoc-add-lint-blocks.
2022-12-12 18:00:30 +00:00
Ian Jackson 4e74104e70 Merge branch 'spelling-20221206' into 'main'
A few spelling fixes for bridgedescmgr code

See merge request tpo/core/arti!925
2022-12-06 18:25:43 +00:00
Nick Mathewson f204eebf11 arti-client: spelling fix. 2022-12-06 09:08:26 -05:00
eta 16305a6415 Merge branch 'optional-deps-static' into 'main'
make use of 1.60 weak dependancy features

Closes #434

See merge request tpo/core/arti!920
2022-12-05 15:21:55 +00:00
trinity-1686a 39fffd8d03 make use of 1.60 opt dependancy features 2022-11-30 21:24:04 +01: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 598f4e2e28 arti: BridgesConfig is evidently not too high up
Since apparently it was possible to write all the other code without
moving it.
2022-11-30 15:51:10 +00:00
Ian Jackson a74ee097f5 arti: pt mgr spawns the task itself in new 2022-11-30 15:48:31 +00:00
Nick Mathewson 5f0f5f81b1 arti-client: Try to take ownership of state earlier.
There's no harm in doing this, since we'll try to take ownership of
the state soon as soon as we use it: We just want to try early, so
that we'll get it before we decide that we're using bridges.

Fixes bug #669; bug introduced by !889.
2022-11-29 19:58:42 -05:00
Ian Jackson 143b331ef7 arti-client: Make ptmgr actually optional 2022-11-29 16:32:14 +00:00
Ian Jackson c92dcb5f50 arti, arti-client: Conditionalise various things on pt-client 2022-11-29 16:32:14 +00:00
eta 3a0f0a909d Spelling fix in arti_client::err 2022-11-29 12:31:50 +00:00
Nick Mathewson 1f4a385d7d Temporarily make ptmgr required for arti-client :/ 2022-11-28 17:29:32 -05:00
Nick Mathewson 820657b6bc PtMgr: Use a persistent state directory for PT state.
This makes a `pt_state` directory inside .local/share/arti (or the
local equivalent), right next to our existing `state` dir.

Ideally we would use a separate directory for each PT, but we have a
very fuzzy "what is a specific PT" notion.

Closes #667
2022-11-28 17:29:32 -05:00
Nick Mathewson 1a9c4c722b Integrate PtMgr into arti-client.
If support is available at compile-time, then we construct a PtMgr
and register it with the ChanMgr.  We keep a handle to it ourself so
that we can reconfigure it as needed.

Closes #659.
2022-11-28 17:29:32 -05:00
Ian Jackson 6a39cdfe57 Merge branch 'watch-drop-option' into 'main'
tor-basic-utils: DropNotifyWatchSender: use DropNotifyEofSignallable

See merge request tpo/core/arti!853
2022-11-23 18:55:32 +00:00
Ian Jackson 4d502bd818 arti-client: Add comment about Option DormantMode
As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/852#note_2854090
(ftaod, that is a different MR to this one)
2022-11-23 17:50:05 +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 b2607fd8c8 bridge non-support: De-cfg the primary bridge config fields
We now parse the `bridges.enabled` BoolOrAuto, and the
`bridges.bridges` list.

The `bridges.bridges` list is Vec<()> in the builder, and Vec<Void> in
the built config.  Ie, it is simply a count, and vanishes in the built
config.

But this count triggers us to try to call build(), to try to parse
bridges, and to try to set and honour the enablement boolean.

The result is that the type system now ensures that if bridges are
disabled, but specified (either by listing them in the config, or
writing `enabled=true`), we inevitably try to insist that we have a
non-empty Vec<Void>, which is of course impossible.

There will be a test case too for those who think this too abstract a
way to guarantee this property :-).
2022-11-21 16:46:19 +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 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