Commit Graph

3909 Commits

Author SHA1 Message Date
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
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