Commit Graph

4048 Commits

Author SHA1 Message Date
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
Ian Jackson 565b063a52 hs dirs: Note a thing we don't implement yet
We'll add this later, about here.
2023-04-11 19:14:01 +01:00
Ian Jackson d8ed32b321 hs dirs: Implement spread_fetch (fmt) 2023-04-11 19:14:01 +01:00
Ian Jackson 95125d9e72 hs dirs: Implement spread_fetch 2023-04-11 19:14:01 +01:00
Ian Jackson 3ea8f3b7e0 hs dirs: Fix wrong ignored variable name
This is the HsDirIndex, not the Hs[Blind]Id.
2023-04-11 19:14:01 +01:00
Ian Jackson a3945ad3c6 hs dirs: Replicas are 1-indexed 2023-04-11 19:14:01 +01:00
Ian Jackson a1241bca43 tor-netdir: Make an import more precise
With this
  cargo +stable clippy --locked --offline -p tor-netdir --features=hs-client --all-targets

I got this:

64 | use {hsdir_params::HsDirParams, hsdir_ring::HsDirRing, itertools::chain, std::iter};
   |                                                        ^^^^^^^^^^^^^^^^
   |
   = note: `#[warn(unused_imports)]` on by default
2023-04-11 19:14:01 +01:00
Ian Jackson 9c3ccaefb2 Merge branch 'correct_osx_config' into 'main'
arti: Explain correct location of OSX config.

See merge request tpo/core/arti!1125
2023-04-11 15:35:53 +00:00
Nick Mathewson ba4b43aa8c Add a semver entry for !1112. 2023-04-10 14:38:51 -04:00
tranna 51b5ba6681 Use an Enum for the description request 2023-04-10 18:37:45 +00:00
Nick Mathewson f61fd9609a DirMgr: Detect that directory state is ready if it begins with all MDs
Previously, we'd only call PendingNetDir::upgrade_if_necesessary
when adding a microdescriptor.  But if it began already having all
of its descriptors (because we found them in the cache), we wouldn't
actually upgrade it to a PendingNetDir::Yielding, which would make
it unusable, and would make us schedule its reset time too far
in the future.

Fixes #802.
2023-04-10 11:33:58 -04:00
Nick Mathewson 6e05eb36a2 arti: Explain correct location of OSX config. 2023-04-10 11:25:26 -04:00
Neel Chauhan 5d61ff04d1 s/ProtocolFailed/ProtocolViolation/g where possible 2023-04-08 07:47:28 -07:00
Nick Mathewson d12e2422b3 linkspec: Add a missing ; in tests. 2023-04-06 10:27:35 -04:00
Nick Mathewson fdd28d9319 dirclient: fix an "unused import" warning. 2023-04-06 10:26:58 -04:00
Nick Mathewson 9dbfaf5f9b guardmgr: update feature behavior wrt testing and pts. 2023-04-06 10:26:20 -04:00
Nick Mathewson 2f231b2ea0 circmgr: make "testing" depend on guardmgr/testing 2023-04-06 10:24:32 -04:00
Nick Mathewson 43e1128cdf circmgr: Mark a number of internal APIs as hs-only.
This resolves a few dead-code warnings.

Closes #801.
2023-04-06 09:05:12 -04:00
Nick Mathewson c22cf483ff circmgr: Expand an incomplete comment in exitpath.rs 2023-04-06 08:59:41 -04:00
Nick Mathewson 465ad963c4 Merge branch 'rw' into 'main'
tor-async-utils: Introduce JoinReadWrite

See merge request tpo/core/arti!1115
2023-04-06 12:28:54 +00:00
Ian Jackson 11d0c4c6fb Merge branch 'error' into 'main'
tor-error: Introduce ErrorKind::TorDirectoryBroken

See merge request tpo/core/arti!1117
2023-04-06 10:43:52 +00:00
Ian Jackson bf9a7826de tor-error: Rename ErrorKind::TorDirectoryUsable (from ...Broken)
As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/1117#note_2893986

(Not going to squash this as it has a semantic conflict with !1118, so
needs a little special handling there.)
2023-04-06 11:06:18 +01:00
Ian Jackson 4bf42c951c JoinReadWrite: Minor docs improvements. 2023-04-06 11:02:27 +01:00
Ian Jackson fbf1a6d8d4 JoinReadWrite: Move the example to the struct
This makes it more prominent on the rustdoc page.
2023-04-06 11:02:03 +01:00
Ian Jackson 2c87219a01 JoinReadWrite: Discuss using .reunite() or .unsplit()
As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/1115#note_2894238

And move the "This is the converse" comment to somewhere it actually
appears in public docs.  The module-level docs only appear with
--document-private-items because the modules themselves are private.
2023-04-06 10:58:39 +01:00
Ian Jackson 0e8384bcb4 tor-error: Introduce ErrorKind::TorDirectoryBroken
We will use this for a lack of HS directories.  (These aren't chosen
according to any local restrictions, so the problems with EK::NoPath
and EK::NoExit don't arise.)
2023-04-05 15:11:17 +01:00
Ian Jackson dfceb50f69 tor-netdir: testnet: Make all non-guard non-exits be hsdirs 2023-04-05 15:10:07 +01:00
Ian Jackson c29cb6ac2b tor-circmgr: HsCircKind: derive Eq 2023-04-05 15:10:07 +01:00
Ian Jackson 10f19eaf56 tor-async-utils: Introduce JoinReadWrite
I wanted one of these for a test stream.  Unaccountably neither
the futures crate, nor tokio, seem to have one!
2023-04-05 13:34:25 +01:00
Ian Jackson 11dc265325 Merge branch 'netdoc' into 'main'
tor-netdoc: Expose some test data (and fix feature builds)

See merge request tpo/core/arti!1106
2023-04-05 10:36:08 +00:00
Ian Jackson 38805f53b2 tor-netdoc: Expose test data under new "testing" feature flag 2023-04-05 11:02:36 +01:00
Ian Jackson 646e291f96 tor-netdoc: Fix feature builds
Fixes
  cargo +stable test --locked --offline F -p tor-netdoc
  cargo +stable clippy -p tor-netdoc F --all-targets
for values of F including
  --all-features
  --features=hs-client
  --features=hs-common
  --features=hs-service
  (nothing)
2023-04-05 11:02:33 +01:00
Ian Jackson 173b577069 Merge branch 'req' into 'main'
tor-dirclient: Provide HsDescDownloadRequest

See merge request tpo/core/arti!1097
2023-04-04 16:15:37 +00:00
Nick Mathewson 559aed002f Merge branch 'x25519' into 'main'
tor-llcrypto: Pin x25519-dalek version, bump our crate version

Closes #807

See merge request tpo/core/arti!1108
2023-04-04 12:51:39 +00:00
Ian Jackson ed594b5a6f tor-llcrypto: Pin x25519-dalek version, bump our crate version
Fixes #807
2023-04-04 11:59:54 +01:00
gabi-250 d1553e884b Merge branch 'timerange' into 'main'
Ergonomic improvements to TimerangeBound

See merge request tpo/core/arti!1105
2023-04-03 17:35:42 +00:00
gabi-250 fd13a26a00 tor-dirclient: Add a comment about 50 x 1024 2023-04-03 17:32:48 +01:00
Ian Jackson 91b3b79fed tor-dirclient: Add test case for HsDescDownloadRequest
I couldn't find a test vector in C Tor.  This test case was generated
from the code here.

I'm fairly sure it's right since I managed to get my descriptor
downloader to work.  (That's not an MR yet, but uses this code.)
2023-04-03 17:32:48 +01:00
Ian Jackson 4a754ae76a tor-dirclient: Provide HsDescDownloadRequest
In my tests this seems to do the right thing, but I'm getting 404s.
I'm not sure if actually this URL is wrong.
2023-04-03 17:32:48 +01:00
Ian Jackson e85f974934 TimerangeBound: Provide .as_ref() and .as_deref() 2023-04-03 15:54:13 +01:00
Ian Jackson 456eb2f3df TimerangeBound: derive Debug and Clone, and Eq/PartialEq in tests 2023-04-03 15:50:32 +01:00
Nick Mathewson 289007ef96 Merge branch 'debug-hex' into 'main'
Debug two types as compact hex strings

See merge request tpo/core/arti!1104
2023-04-03 12:31:27 +00:00
Ian Jackson 14cc805929 Merge branch 'hserror' into 'main'
tor-error: Errors for hidden services

See merge request tpo/core/arti!1099
2023-03-31 18:16:45 +00:00
Ian Jackson aafdf755c0 Debug as hex strings for HsBlindId and HsDirIndex 2023-03-31 19:10:17 +01:00
Ian Jackson 9de3c1e307 tor-basic-utils: Provide impl_debug_hex 2023-03-31 19:10:06 +01:00
Ian Jackson c5f6b2e3a5 tor-error: Add missing footnote
I C&P this from tor-dirmgr, and missed this part.
2023-03-31 18:45:40 +01:00
gabi-250 11a70925fd Fix duplicated licence in Cargo.toml 2023-03-31 17:44:30 +00:00
Ian Jackson 8a045af479 Merge branch 'netdir' into 'main'
tor-netdir: API changes to support hsconn hsdir fetch

See merge request tpo/core/arti!1094
2023-03-31 17:12:42 +00:00
Ian Jackson 3e22e881f3 tor-error: Add OnionServiceNotRunning error
We'll want this later.  Define it now, though, since we've discussed
it here
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/1099#note_2892020
2023-03-31 18:01:36 +01:00
Ian Jackson 68e5711684 tor-error: Put OnionService errors behind a new experimental-api feature 2023-03-31 17:57:24 +01:00
Ian Jackson 307af3714f tor-error: Document cargo feature 2023-03-31 17:56:32 +01:00
Ian Jackson c6a10387e3 tor-error: Errors for hidden services
So far these are just the errors that occur during descriptor
fetch. There will be more later as we have more code in tor-hsconn.

This is very user-facing; use the "onion service" terminology.
2023-03-31 17:53:40 +01:00
Gabriela Moldovan 3d0bf0d6ab
Generate a new KP_hss_desc_enc keypair for each new descriptor.
Previously, to build descriptors for hidden services with client auth
enabled, in addition to the list of authorized clients, users of
`HsDescBuilder` were required to also provide a descriptor encryption
keypair and a descriptor cookie. This was potentially dangerous and/or
error-prone, because the ephemeral encryption key and the descriptor
cookie are expected to be randomly generated and unique for each
descriptor.

This change makes `ClientAuth` private to the `hsdesc::build` module and
updates `HsDescBuilder` to build `ClientAuth`s internally. Users now
only need to provide the list of authorized client public keys.

Signed-off-by: Gabriela Moldovan <gabi@torproject.org>
2023-03-31 15:04:30 +01:00
Gabriela Moldovan 94a4d2ea43
Remove unnecessary test constant.
It's not really needed, it can just be generated at (test) runtime.

Signed-off-by: Gabriela Moldovan <gabi@torproject.org>
2023-03-31 15:04:26 +01:00
Gabriela Moldovan cd66781577
Add an encode-decode test for descriptors with client auth.
This adds a test for an `encode -> decode -> encode` flow for a hidden
service descriptor with client authorization enabled.

Signed-off-by: Gabriela Moldovan <gabi@torproject.org>
2023-03-31 15:04:23 +01:00
Gabriela Moldovan 8aa930a645
Use constants instead of magic numbers.
Signed-off-by: Gabriela Moldovan <gabi@torproject.org>
2023-03-31 15:04:19 +01:00
Gabriela Moldovan 2d9d16aabc
Stop requiring the caller to supply `AuthClient`s.
`AuthClient`s were originally meant to represent parsed `auth-client`
lines. In !1070, this struct was repurposed for representing individual
authorized clients in the HS descriptor encoder. However, hidden
services will likely use a list of public keys to represent the
authorized clients rather than a list of `AuthClient`s, as the
information from an `AuthClient` (`client_id`, `iv`, `encrypted_cookie`)
likely won't be immediately available to the hidden service.

This change updates the HS descriptor encoder to represent authorized
clients as a list of `curve25519::PublicKey`s. As such, it is now the
responsibility of the encoder to create the `client_id`, `iv`, and
`encrypted_cookie` using the available keys, the unencrypted descriptor
cookie, and HS subcredential.

Signed-off-by: Gabriela Moldovan <gabi@torproject.org>
2023-03-31 15:04:15 +01:00