Commit Graph

4104 Commits

Author SHA1 Message Date
trinity-1686a 7d50a34a3a update rsa to 0.9.x 2023-05-08 17:24:23 +02:00
trinity-1686a f390440bbf print both static sqlite/tls when 'static' feature is used 2023-05-08 16:59:35 +02:00
Gabriela Moldovan 6b9e37e07c
tor-netdir: Shuffle the list of HS dirs used for downloading descriptors.
We'll probably need the hsdir list to be shuffled deterministically for
testing purposes (this might be desirable, for example, when we write a
test for HS descriptor download retries).

Signed-off-by: Gabriela Moldovan <gabi@torproject.org>
2023-05-04 17:53:58 +01:00
Nick Mathewson da185223c0 objmap: move types to top of file. 2023-05-04 10:37:27 -04:00
Nick Mathewson 7918904b99 Note/clean more TODOs in objmap. 2023-05-04 10:37:27 -04:00
Nick Mathewson 6fb5d08103 RPC: Make the "client" return optional. 2023-05-04 10:37:27 -04:00
Nick Mathewson 0e3fa38c03 RPC: Make "Weak" and "Strong" entries separate.
Now there can be one of each, since we want references and handles
to be conceptually separate.

(The alternative would be to say that an operation either "returns a
handle" or "returns a reference (which may become a handle) unless a
handle already exists.")
2023-05-04 10:37:27 -04:00
Nick Mathewson 7f59d7dae5 Temporarily replace generational-arena with a fake version.
This fake version is completely silly, but it will do the job until
we figure out our MPL2 concerns.
2023-05-04 10:37:27 -04:00
Nick Mathewson 54dabdbd0c RPC: make arti-rpcserver require the arti-client/rpc feature 2023-05-04 10:37:25 -04:00
Nick Mathewson b807e834a3 RPC: Rename session.rs to connection.rs 2023-05-04 10:35:05 -04:00
Nick Mathewson 7845f04908 RPC: rename Session to Connection.
To me, "Session" suggests that we're authenticated, when we are
not necessarily authenticated.  Also, we may eventually want to have
some kind of persistent session object; if we do, then we'll want
Connections to be separate.
2023-05-04 10:35:05 -04:00
Nick Mathewson 94df123932 RPC: Make authentication return a TorClient.
(This is the correct capabilities-based behavior. For now it will only
work if the TorClient uses a PreferredRuntime, but with luck we will
find a solution for #837 soon.)
2023-05-04 10:35:05 -04:00
Nick Mathewson 475da9b802 Add a generational arena for object mapping for RPC.
See the comments on `TypedAddr` for some explanations about
why this is so tricky.  Thanks to @diziet for helping me figure
this out.
2023-05-04 10:35:05 -04:00
Nick Mathewson 9be9ddb902 RPC: Add "register" methods to RequestContext. 2023-05-04 10:35:05 -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 879a453212 RPC: Move the "listen" part of the RPC listener code to `arti`.
Now there's a module in `arti` that runs the loop for an RPC
listener.  The part of the old `listener` module that made
the framed connections is now part of the `Session` object.

There is now yet another a temporary location for the pipe; we
should pick something better.  At least now it's configurable.
2023-05-04 10:30:40 -04:00
Nick Mathewson 25398b5a3b rpc: Make an RpcMgr type to own the DispatchTable.
In the future, this will probably hold more data as well, like a
TorClient and some configuration info.

The TorClient will present an issue; I've made comments about that.

Closes #820
2023-05-04 10:22:27 -04:00
Gabriela Moldovan f6456d469d
tor-error: Add a TODO regarding HS desc parsing errors.
Signed-off-by: Gabriela Moldovan <gabi@torproject.org>
2023-05-03 17:25:36 +01:00
Gabriela Moldovan b168fd36de
hscrypto: Add comment about impl that will be removed after we address #798.
Signed-off-by: Gabriela Moldovan <gabi@torproject.org>
2023-05-03 17:25:32 +01:00
Gabriela Moldovan c2cb96a623
Clarify what the new ErrorKinds mean.
Signed-off-by: Gabriela Moldovan <gabi@torproject.org>
2023-05-03 17:25:29 +01:00
Gabriela Moldovan 30983c764f
tor-netdir: Update tests to parse the descriptor, make test consensus lifetime configurable.
Signed-off-by: Gabriela Moldovan <gabi@torproject.org>
2023-05-03 17:25:25 +01:00
Gabriela Moldovan c6fccbbb01
hsclient: Use a real HsDesc instead of an unparsed string.
Signed-off-by: Gabriela Moldovan <gabi@torproject.org>
2023-05-03 17:25:21 +01:00
Gabriela Moldovan 18cb1671c4
hscrypto: Add From impl for deriving KP_hsc_desc_enc out of KS_hsc_desc_enc.
The `HsClientSecretKeys` stored in the HS client connection context only
have the secret keys. Certain APIs (such as `HsDesc::parse`) expect a
keypair (both `HsClientDescEncKey` and `HsClientDescEncSecretKey`). This
`From` impl makes it possible to get a `HsClientDescEncKey` out of
`HsClientDescEncSecretKey`.

Signed-off-by: Gabriela Moldovan <gabi@torproject.org>
2023-05-03 17:25:17 +01:00
Nick Mathewson 02a0afbae4 Merge branch 'more_dir_logging' into 'main'
Lots more dirmgr log messages

Closes #803

See merge request tpo/core/arti!1163
2023-05-03 15:39:13 +00: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 a7612ecdf8 DirMgr: More logs in top-level bootstrapping code.
Closes #803, I hope.
2023-05-03 11:08:19 -04:00
Nick Mathewson 8151fa504f DirMgr: more trace!() logs and information in download/load functions.
My goal here is to make sure that we can't confuse
one download operation and another, and that we actually know
what's going on.  Previously, not all state transitions or
attempts to fetch information actually corresponded to a log.
2023-05-03 11:08:19 -04:00
Nick Mathewson b2486bba1e DirMgr: Log at trace! when starting a new "AttemptId". 2023-05-03 11:08:19 -04:00
gabi-250 2c2d9e9425 Merge branch 'hsdesc-parse-decrypt-validate' into 'main'
netdoc: Add a convenience method for HS descriptor parsing.

Closes #809

See merge request tpo/core/arti!1152
2023-05-03 14:34:42 +00:00
Nick Mathewson c65b52e552 Remove semver.md files. 2023-05-03 08:33:20 -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
Alexander Færøy 5ff19678fe Merge branch 'relayid' into 'main'
RelayId: Remove some duplication and relax a lifetime

See merge request tpo/core/arti!1156
2023-05-02 17:55:07 +00:00
Gabriela Moldovan dfc22beddf
netdoc: Mark parse_decrypt_validate as experimental.
Signed-off-by: Gabriela Moldovan <gabi@torproject.org>
2023-05-02 17:18:53 +01: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 56b99075f6 Upgrade to serial_test 2.0.0 2023-04-28 10:35:54 -06:00
Ian Jackson c0aa600179 RelayId: implement id_type and as_bytes in terms of RelayIdRef
This eliminates some duplicated code.
2023-04-27 20:39:03 +01:00
Ian Jackson 58a0803667 RelayIdRef: as_bytes: Doesn't borrow from self
This borrows from the contained key, but not from self.

This will allow us to implement RelayId::as_bytes in terms of
RelayIdRef::as_bytes.
2023-04-27 20:39:03 +01:00
Ian Jackson 4b03795915 RelayId: impl Display in terms of RelayIdRef
This removes a duplicated copy of the format strings.
2023-04-27 20:37:36 +01:00
Gabriela Moldovan b967749325
netdoc: Document how to extract an `HsDesc` out of an `UncheckedEncryptedHsDesc`.
This adds an example to the `HsDesc::parse` docs. The constants from the
example are lifted from the `parse_desc_good` test.

Signed-off-by: Gabriela Moldovan <gabi@torproject.org>
2023-04-25 18:15:56 +01:00
Gabriela Moldovan 8f4e876924
netdoc: Add a convenience method for HS descriptor parsing.
This adds the `HsDesc::parse_decrypt_validate` method, which parses,
decrypts, and validates HS descriptors.

Closes #809

Signed-off-by: Gabriela Moldovan <gabi@torproject.org>
2023-04-25 18:15:53 +01:00
Nick Mathewson dc187c8fb8 Bump our own memchr dependency to 2.5
This appears to be necessary for getting "minimal-versions" to be
happy with memchr dependencies between reges and async-compression.
2023-04-22 09:41:47 -04:00
Nick Mathewson 7c1f45a514 RPC: Log all internal errors. 2023-04-19 12:38:26 -04:00
Nick Mathewson ffcbd8fe88 rpc: Simplify and clarify SendUpdateError. 2023-04-19 12:38:26 -04:00
Nick Mathewson accd3d858f Arti: Add ability to remember the list of methods names.
Right now, this lets us say whether the method was unrecognized or
whether the parameter type was incorrect.

We'll use this to enforce correct method names later on.

(I have to add another `inventory` here, since the `typetag`
maintainer does not want to expose this functionality: see
https://github.com/dtolnay/typetag/issues/57#issuecomment-1506106290
)
2023-04-19 12:38:26 -04:00
Nick Mathewson e6092e99ea rpc: New syntax for method declaration
Now you just declare your function `my_func` with the right types,
and invoke `rpc_invoke_fn!{ my_func(ObjType, MethodType); }`
2023-04-19 12:38:26 -04:00
Nick Mathewson a415b0e2d2 rpc: impl From<SendUpdateError> for RpcError. 2023-04-19 12:38:26 -04:00
Nick Mathewson f33aefd76c rpcserver: Use with_fn. 2023-04-19 12:38:26 -04:00
Nick Mathewson 6f6a4d073e rpcbase: Use with_fn. 2023-04-19 12:38:26 -04:00
Nick Mathewson 8a8c800c99 async-utils: Add a SinkExt with a with_fn
(This function behaves as `futures::sink::SinkExt::with`, except
that the function that it takes does not return a future.)
2023-04-19 12:38:26 -04:00
Nick Mathewson d54154e520 async-utils: rename sinkext to prepare_send 2023-04-19 12:38:26 -04:00
Nick Mathewson 5cd5e6a3f8 async-utils: rename SinkExt to SinkPrepareExt 2023-04-19 12:38:26 -04:00
Nick Mathewson 80a13ff898 rpc: Minor tweaks to get a sink to compile. 2023-04-19 12:38:26 -04:00
Nick Mathewson 0503f7bd4b rpc: Use Method types to determine type of method outputs, updates.
This lets us do much less in our rpc_invoke_fn functions.
2023-04-19 12:38:26 -04:00
Nick Mathewson 7dcfb02c22 rpc: Split Method into DynMethod and Method
Now `Method` has an Output and Update associated type, and
`decl_method` can do a little more.
2023-04-19 12:38:26 -04:00
Alexander Færøy 1faa97c645 Merge branch 'post_1145' into 'main'
Followups from !1145

See merge request tpo/core/arti!1146
2023-04-18 16:03:48 +00:00
Ian Jackson 219153a541 Merge branch 'rpc_refactoring_v2' into 'main'
A few RPC refactorings

Closes #817 and #824

See merge request tpo/core/arti!1144
2023-04-18 16:00:05 +00:00
Ian Jackson 6c720962a8 Merge branch 'fix_802_core' into 'main'
DirMgr: Detect that directory state is ready if it begins with all MDs

Closes #802

See merge request tpo/core/arti!1126
2023-04-18 15:34:08 +00:00
Nick Mathewson 543e089b82 netdoc: Document that particular bit values for flags are not part of our API. 2023-04-17 17:09:58 -04:00
Nick Mathewson 11945e8b4e netstatus: re-number routerstatus flags to go in order.
Otherwise there is too much risk of accidentally adding in another
1<<12 when we meant to add a 1<<13.

(It would be neat to have an alternative to bitflags here that would
auto-number our bitflags for us.)
2023-04-17 16:50:08 -04:00
Nick Mathewson 3985700216 netdir: more documentation on MIDDLE_ONLY flag.
Clarify that it isn't anything that most users will need to check.
2023-04-17 16:48:15 -04:00
juga eee1dbee7a netdoc: Add MiddleOnly flag to RelayFlags
Closes #833
2023-04-17 09:53:04 +00:00
Nick Mathewson 5a2c38a134 rpc: simplify API by always providing a sink.
Previously we have two places where we had to do "make a `Drain` sink
if updates aren't wanted"; now there's only one.
2023-04-16 08:46:42 -04:00
Nick Mathewson 83f5dc4888 rpc: Ensure well-ordering of responses.
Previously the main loop received updates via a `mpsc::channel`, and
final responses via a `futures::unordered`.  This could lead to
final responses being transmitted to the user before the updates
were all flushed.

Now all of the responses are sent to the main loop via the same channel,
and they can't get out-of-sequence.

Closes #817 and (IMO) simplifies the code a bit.
2023-04-16 08:46:42 -04:00
Nick Mathewson 58ad91cbf5 rpc: Wire updates into rpc invoke functions again.
Now that the sink is not part of the context, RPC functions that are
able to send an update have to declare an `impl Sink` as their
fourth argument.  This syntax is not final.

Part of #824.
2023-04-16 08:46:42 -04:00
Nick Mathewson 3b9fc60763 rpc: Move update sink out of context.
Now the update sink is its own boxed object.  It is not yet passed
to the invoke functions that want it.
2023-04-16 08:46:41 -04:00
Nick Mathewson c51f44aa0b rpcserver: Fix a couple of broken rustdoc links 2023-04-16 08:39:52 -04:00
gabi-250 31b6c9243d Merge branch 'use_secmem_proc_03' into 'main'
Update our secmem_proc dependency to 0.3.0

Closes #664

See merge request tpo/core/arti!1138
2023-04-13 14:26:06 +00:00
gabi-250 da790e4b78 Merge branch 'misc_upgrades' into 'main'
Upgrade a couple more dependencies

See merge request tpo/core/arti!1139
2023-04-13 14:25:13 +00:00
Nick Mathewson cf00fd8e8a Merge branch 'rpc_conformance' into 'main'
RPC: Terminology and error-handling conformance

Closes #826 and #825

See merge request tpo/core/arti!1136
2023-04-13 13:45:40 +00:00
Nick Mathewson 8dd65dcd5f rpc, spec: Document current ObjectError, RequestError behavior as correct. 2023-04-13 09:03:52 -04:00
Nick Mathewson ea77f959fb rpc: Change `id=<SYNTAX>` to "no id".
Now instead of hoping that buggy clients will detect a magic `id`,
we can simply tell them that they will get no `id` at all.  If they
can't handle that case, no major harm is done: the connection will
get closed anyway.
2023-04-13 09:03:52 -04:00
Nick Mathewson 5041b51498 rpc: Require that errors are RpcError.
Since we're serializing everything in this format, let's enforce it.
With this change, we can no longer cram arbitrary junk into an
RPC error, so we have to clean up our handling of cancelled requests.
2023-04-13 09:03:52 -04:00
Nick Mathewson 4efb423947 Upgrade our hex-literal dependency 2023-04-13 07:51:26 -04:00
Nick Mathewson 50d95964d1 Upgrade our num_enum dependency. 2023-04-13 07:50:11 -04:00
Nick Mathewson 6e83139fc7 Update our secmem_proc dependency to 0.3.0
(This wasn't possible before we updated our MSRV to 1.65.)

Closes #664.
2023-04-13 07:41:46 -04:00
Nick Mathewson 767c91557e rpc: Improve error reporting for invalid requests
This is a bit big, but it's not that _complicated_.

The idea here is that we use serde's "untagged" enum facility
when parsing our `Request`s, such that if parsing as a `Request`
fails, we parse as an `InvalidRequest` and try to report
what the problem was exactly.

This lets us determine the ID of a request (if it had one),
so we can report that ID in our error message.  We can also
recover from a much broader variety of errors.

We now also conform with the spec reporting errors about
completely wrong json, requests without IDs, and so on.
2023-04-12 16:21:34 -04:00
Nick Mathewson 739561b2cb rpcbase: Use correct error codes, and add tests.
Well, mostly correct.  Our current serde implementation doesn't
tell us much about what went wrong with the object, so we can't
tell why we couldn't convert it into a Request.

Also, our output for the data field is not as the spec says:
we should bring them into conformance.

Part of #825.
2023-04-12 13:32:15 -04:00
Nick Mathewson e37b017342 tor-error: Add ErrorKinds for RPC errors.
These are experimental for now so that we can change them without
breaking semver.
2023-04-12 13:30:24 -04:00
Ian Jackson 1d2514a06e Merge branch 'ticket_785' into 'main'
ExitPath: Add an explanation of WeightRole::Exit on non-exit circs

Closes #785

See merge request tpo/core/arti!1135
2023-04-12 17:00:36 +00:00
Ian Jackson 835480e98f Merge branch 'remove-hsdesc-todo' into 'main'
Remove misleading TODO.

See merge request tpo/core/arti!1130
2023-04-12 16:52:59 +00:00
Nick Mathewson 2e017d3575 tor-rpcbase: Create error kinds properly.
The field is called "kinds", it is a list, and it holds strings
beginning with "arti:".
2023-04-12 12:27:16 -04:00
Nick Mathewson 6bdfc5740f arti-rpcserver: Be careful about saying "result".
Even though json-rpc uses "result" to mean "a successful return value
from a method", we can't: Rust's `Result` type is so pervasive
that confusion would be inevitable.
2023-04-12 12:08:53 -04:00
Nick Mathewson 4d82bf4b98 arti-rpcserver: Rename Authentication{Method => Scheme}. 2023-04-12 11:53:50 -04:00
Nick Mathewson 4327276922 arti-rpcserver: rename cmd to method. 2023-04-12 11:51:48 -04:00
Nick Mathewson b2b0a0dd83 arti-rpcserver: rename command to method. 2023-04-12 11:51:37 -04:00
Nick Mathewson 193253a158 tor-rpcbase: rename cmd to method everywhere. 2023-04-12 11:45:30 -04:00
Nick Mathewson 224b919835 tor-rpcbase: Rename cmd.rs to method.rs. 2023-04-12 11:26:12 -04:00
Nick Mathewson c5b70224b2 tor-rpcbase: Rename and rephrase "command" to "method" 2023-04-12 11:25:03 -04:00
Nick Mathewson 2efdcd38ff ExitPath: Add an explanation of WeightRole::Exit on non-exit circs
In one case, we use WeightRole::Exit on circuits that can't
actually be used to exit.  This commit adds a comment to explain
why, so that we don't wonder about it in the future, and we have
some indication of whether it's still appropriate.

Closes #785
2023-04-12 09:50:16 -04:00
Neel Chauhan be78062bb6 s/BridgeDescManager/BridgeDescMgr/g in codebase 2023-04-12 05:49:11 -07:00
Nick Mathewson 8e6848b965 rpc: Try to fix rustdoc errors. 2023-04-12 08:02:30 -04:00
Nick Mathewson 44fbd87208 rpc: Use empty structs in test code. 2023-04-12 07:35:07 -04:00
Nick Mathewson 9a5f319a84 Rename tor-rpccmd to tor-rpcbase. 2023-04-12 07:34:57 -04:00
Nick Mathewson 5979272cc4 rpc: Make AuthenticationMethod an enum. 2023-04-12 07:34:57 -04:00
Nick Mathewson 0eb15ae592 rpc: Reify and expose DispatchTable. 2023-04-12 07:34:57 -04:00
Nick Mathewson ec247856fb rpc: Change ConstTypeId_ to be a function that gets called
We now _use_ the function pointers rather than comparing them; this
lets us drop our Eq/PartialEq/Hash implementations for
`ConstTypeId_` and instead just use `TypeId`s once we're in run-time
code.
2023-04-12 07:34:57 -04:00
Nick Mathewson a02a200ccd rpc: Use Pin<Box<Stream/Sink>> for run_loop 2023-04-12 07:34:57 -04:00
Nick Mathewson 3ad5d2f6ea rpc: Import Pin/Context/Poll.
(Except for one case where we are using crate::Context and
task::Context at the same time.)
2023-04-12 07:34:57 -04:00
Nick Mathewson 8845309125 rpc: Document our intended read-blocking behavior. 2023-04-12 07:34:57 -04:00
Nick Mathewson ed1cbce13a rpc: Switch JsonLinesEncoder to have Default, not new. 2023-04-12 07:34:57 -04:00
Nick Mathewson 03937e35b2 rpc: Rename BoxedResponseBody => ResponseBody 2023-04-12 07:34:57 -04:00
Nick Mathewson 07bb57a4c2 rpc: Remove anyhow dependency 2023-04-12 07:34:57 -04:00
Nick Mathewson 06b2180907 rpc: Add a demonstration feature to "arti"
It's experimental, and tokio-only.  To enable it, build with
the "rpc" feature turned on, and connect to
`~/.arti-rpc-TESTING/PIPE`.  (`nc -U` worked for me)

I'll add some instructions.
2023-04-12 07:34:57 -04:00
Nick Mathewson 074dd704f4 Reformat arti/Cargo.toml
(This is what my editor wants to do to it.)
2023-04-12 07:34:57 -04:00
Nick Mathewson ff68a5f02a rpc: Add standard warnings to arti-rpcserver 2023-04-12 07:34:57 -04:00
Nick Mathewson b024fe5596 rpc: Add an authentication step.
Per our design, every connection starts out unauthenticated, and
needs one authenticate command to become authenticated.

Right now the only authentication type is "This is a unix named
socket where everybody who can connect has permission."
2023-04-12 07:34:57 -04:00
Nick Mathewson f9de7929c1 RPC: add a temporary "listen" function.
It requires tokio, it's unix-only, and makes some unfortunate
shortcuts.  Probably good enough for initial testing.
2023-04-12 07:34:57 -04:00
Nick Mathewson 3e64cab62d rpc: Declare a trivial Echo command that works on a session. 2023-04-12 07:34:57 -04:00
Nick Mathewson 41cba18899 rpc: Wire up arti-rpcserver to use tor-rpccmd. 2023-04-12 07:34:57 -04:00
Nick Mathewson 5a41ac34d5 rpc: temporary converion functions for some error types. 2023-04-12 07:34:57 -04:00
Nick Mathewson 0cba074786 rpc: Make all object lookup fns return LookupError. 2023-04-12 07:34:57 -04:00
Nick Mathewson 74706683c7 rpc: Try refactoring the context type to _be_ a Sink.
This lets us avoid async_trait in tor-rpccmd, and makes us use a
Box<>.  I think we might actually get an even smarter type later on,
but we will need to play with this for a while too.
2023-04-12 07:34:57 -04:00
Nick Mathewson 7a81f4b01b tor-rpccmd: Apply standard warnings and make them pass. 2023-04-12 07:34:57 -04:00
Nick Mathewson 154accc05a rpc: Make a real test for our dispatch logic. 2023-04-12 07:34:57 -04:00
Nick Mathewson 5a2c9d7da1 rpc: Remove type mangling from rpc_invoke_fn!
Now the user has to say that the fn takes an
Arc<>, a Box<>, and an Arc<dyn>.  Previously, they had to pretend
that it didn't.
2023-04-12 07:34:57 -04:00
Nick Mathewson dce9c530ec rpc: Add an RpcError type.
This could have been a trait instead, but I don't know whether
that's smart or not.  There is a lot of opportunity for refactoring
here.
2023-04-12 07:34:57 -04:00
Nick Mathewson dec23c1cf6 rpc: Make invoke return a Result of erased_serde::Serialize
This will let the actual RPC functions return any Result type that
we can serialize.
2023-04-12 07:34:57 -04:00
Nick Mathewson 83b908aa3e rpc: Add Update functionality to rpc::Context.
I'm not sure about these APIs at all!  They force us to use
`async_trait` for `tor_rpccmd::Context`, which bothers me. Should we
just have a function that returns
`Option<Box<dyn Sink<Item=X, Error=Y>>` or something?  If so,
what's the correct Y?
2023-04-12 07:34:57 -04:00
Nick Mathewson 3fbcead7dc rpc: do a better job of hiding impl_const_type_id! 2023-04-12 07:34:57 -04:00
Nick Mathewson e26d9452dc RPC: Initial implementation of a multiple-argument dispatch
This code uses some kludges (discussed with Ian previously and
hopefully well documented here) to get a type-identifier for each
type in a const context.  It then defines a macro to declare a
type-erased versions of a concrete implementation functions, and
register those implementations to be called later.

We will probably want to tweak a bunch of this code as we move ahead.
2023-04-12 07:34:57 -04:00
Nick Mathewson a4660a4e09 Start on a lower-level tor-rpccmd crate.
This crate will hold the backend pieces of RPC interaction that
different parts of Arti get to implement.
2023-04-12 07:34:57 -04:00
Nick Mathewson 6e3f3b4dfc rpc: Add a Session object and an interaction loop. 2023-04-12 07:34:57 -04:00
Nick Mathewson 5247486cfc rpc: Add asynchronous_codec wrapper for jsonlines. 2023-04-12 07:34:57 -04:00
Nick Mathewson a662fb1296 rpc: Add a cancellable future type.
Ordinarily you can cancel a future just by dropping it, but we'll
want the ability to cancel futures that we no longer own (because we
gave them to a `FuturesUnordered`).
2023-04-12 07:34:57 -04:00
Nick Mathewson 0779d405cf rpc: Implement json message types for serde. 2023-04-12 07:34:57 -04:00
Nick Mathewson 3f269449cb tor-proto: Be explicit about an into().
This is a workaround for an issue that I'm about to encounter
somewhere in our pile of dependencies as I add arti-rpcserver, and
somehow make serde_json visible in this test code thereby, making
the PartialEq method resolution ambiguous.
2023-04-12 07:34:57 -04:00
Ian Jackson 3caa8e61e9 tor-hsclient: Add an allow to this incomplete code
Fixes CI warning.
2023-04-12 11:50:27 +01:00
Ian Jackson d566502fc3 Apply ProtocolViolation renaming to hs connector code
!1121 renamed *ProtocolFailed to *ProtocolViolation.
!1118 introduced a new reference to a *ProtocolFailed

I rebased !1118 onto main and enabled automerge.  That tested the tip
of !1118.  I assume a similar thing happened to !1121.

The possibility of such regressions is a property of our workflow.
It's rather surprising it doesn't happen more often.
2023-04-12 10:40:29 +01:00
Ian Jackson b6533b31aa Merge branch 'msrv-1.65' into 'main'
Increase Arti MSRV to 1.65

Closes #815

See merge request tpo/core/arti!1131
2023-04-12 09:34:05 +00:00
Nick Mathewson c596ded74a Merge branch 'bug804' into 'main'
s/ProtocolFailed/ProtocolViolation/g where possible

Closes #804

See merge request tpo/core/arti!1121
2023-04-11 21:33:25 +00:00
Nick Mathewson e26445b1b0 Use bool::then_some() as appropriate
Now that we require a version of Rust that allows
`b.then_some(v)`, clippy complains about our use of
`b.then(|| v)`.
2023-04-11 15:32:32 -04:00
Nick Mathewson 104d64589d Increment MSRV to 1.65 in every crate. 2023-04-11 15:31:12 -04:00
Ian Jackson b8b02b38f1 Merge branch 'hs' into 'main'
Download HS descriptors

See merge request tpo/core/arti!1118
2023-04-11 19:19:48 +00:00
Gabriela Moldovan 631a1e1a86
Remove misleading TODO.
The `superencrypted` blob is, in fact, followed by a newline.

See [core/torspec!122].

[core/torspec!122]: https://gitlab.torproject.org/tpo/core/torspec/-/merge_requests/122

Signed-off-by: Gabriela Moldovan <gabi@torproject.org>
2023-04-11 19:44:50 +01:00
Ian Jackson 24efbf4df7 tor-netdoc: Tidy up and fix some broken intra-doc links
1. Abbreviate the link text, and don't have it contain `crate`
   which is not really great in docs.

2. Use `super::` for the link target, to find the right thing.
   (`crate` doesn't seem to work in rustdoc, perhaps deliberately,
   although the error messages are ridiculous and claim the
   nonexistence of intermediate modules.)

3. Wrap the lines a bit more.
2023-04-11 19:31:10 +01:00
Ian Jackson 23c56db111 tor-netdir: Fix capitalisation of a doc link
Fixes a rustdoc warning.
2023-04-11 19:31:10 +01:00
Ian Jackson df3e8242ea tor-netdir: Fix link to hs_time_period function
Fixes a rustdoc warning.
2023-04-11 19:31:10 +01:00
Ian Jackson 7f51394e6e impl_debug_hex: Fix syntax error in usage template
Corrects the doc and fixes a rustdoc warning.
2023-04-11 19:31:10 +01:00
Ian Jackson 592252ae0a hs connect: Improve a todo and refer to #813 2023-04-11 19:14:01 +01:00
Ian Jackson 26d3bf67e9 hs connect: Add TODOs re improving tests
Aa per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/1118#note_2894467
2023-04-11 19:14:01 +01:00
Ian Jackson db457de99b hs connect: Add TODO re multiple parallel hsdir requests 2023-04-11 19:14:01 +01:00
Ian Jackson 7198afa153 hs connect: Improve docs for descriptor_ensure 2023-04-11 19:14:01 +01:00
Ian Jackson b78240131f hs connect: Clarify clientness of Context 2023-04-11 19:14:01 +01:00
Ian Jackson 54bec0bf8d hs connect tests: check that we asked exactly one relay 2023-04-11 19:14:01 +01:00
Ian Jackson 2ac87a6690 hs connect tests: derive Default for MocksGlobal, and use it 2023-04-11 19:14:01 +01:00
Ian Jackson f5a5743468 hs connect: Test descriptor download 2023-04-11 19:14:01 +01:00
Ian Jackson be98cb890d hs connect: Do circuitry etc. via mocks trait
This doesn't change the text of the functional code, but now the
methods are indirected via the Mock* traits.
2023-04-11 19:14:01 +01:00
Ian Jackson e6b8752d98 hs dirs: Initial cut at descriptor downloading
There are many TODOs here.  Some are questions; some are
straightforward and can be done in followups.

With this code, I am able to reach the eprintln! and todo! with
  curl --socks5-hostname localhost:9150 https://duckduckgogg42xjoc72x3sjasowoarfbgcmvfimaftt6twagswzczad.onion/
2023-04-11 19:14:01 +01:00
Ian Jackson 99bc97118f hs desc: Record a Timebound<HsDesc> (but not really for now)
We have a local alias of `HsDesc = String` which needs to be got rid
of.

But, right now the alternative would be to implement all the code for
signature checking and decryption of an `HsDesc`, before we can make a
test case for the downloader part.
2023-04-11 19:14:01 +01:00
Ian Jackson bb5b2be5f1 hs connect: Introduce Context
This will be convenient as the common context for the descriptor
download work, and also for testing.
2023-04-11 19:14:01 +01:00