summaryrefslogtreecommitdiff
path: root/crates/arti-rpcserver/src
Commit message (Collapse)AuthorAgeFilesLines
* Remove echo structsNeel Chauhan2024-10-251-14/+0
|
* arti-rpcserver: Remove echo_on_sessionNeel Chauhan2024-10-251-12/+0
|
* rpc: Tweak release_owned to give an error on second removal of "connection".Nick Mathewson2024-10-231-16/+20
|
* rpc: Use a const for the "connection" object ID.Nick Mathewson2024-10-231-2/+9
|
* rpc: Simplify method-dispatch-bypass logic a bitNick Mathewson2024-10-232-9/+2
| | | | | | | | | | | | | | | This commit removes the separate function for asking whether to bypass the dispatch code. Instead, it gives the "invoke with bypass" function an error to return when no dispatch is warranted, and moves the whole responsibility for method dispatch or non-dispatch back into tor-rpcbase. I had to add an ObjectId argument to `invoke_rpc_method` to make this work, but that's probably a good thing. Additionally, this commit tweaks the derive-deftly macro to prevent you from asking for dispatch bypass on special methods, where it isn't implemented (and doesn't really make sense).
* rpc: Add support for dropping the special "connection" object ID.Nick Mathewson2024-10-231-9/+19
|
* rpc: Move "rpc:release" to be a method on the rpc object.Nick Mathewson2024-10-231-24/+24
| | | | | | | Now, instead of telling the session or the connection to drop the object ID, we tell the object ID to go away. Closes #1663.
* rpcserver: detect and use methods that bypass method dispatch.Nick Mathewson2024-10-231-3/+8
|
* rpc: Remove unimplemented rpc:downgrade method for now.Nick Mathewson2024-10-231-9/+0
| | | | | If and when we implement this, it will likely be different; arti#868 has some thoughts on the implications.
* rpc: Move some object-id-manipulation methods to a new module.Nick Mathewson2024-10-233-50/+63
| | | | | These will have different implementations soon; this is a more logical place for them.
* Merge branch 'arti-rpcserver-comment' into 'main'wesleyac2024-10-211-1/+1
|\ | | | | | | | | Fix typo in arti-rpcserver auth.rs comment See merge request tpo/core/arti!2558
| * Fix typo in arti-rpcserver auth.rs commentNeel Chauhan2024-10-181-1/+1
| |
* | rpc: List missing required features in error dataNick Mathewson2024-10-171-5/+7
| | | | | | | | | | | | | | | | | | | | Our spec says that when the RPC client has said "I require you to have feature X" and we don't have it, we need to include the feature(s) we don't have in an `rpc:unsupported_features` field of our error. Also, add an integration test for this behavior. Closes #1662
* | Remove Rpc* variants from tor_error::ErrorKindNick Mathewson2024-10-173-21/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | These are not regular ErrorKinds, since they can never occur in an error that's meant to be returned from a Rust API like `arti-client`. Instead, they only exist for errors returned from RpcError. (I can't find the place where we discussed this previously, but the rationale is that if an ErrorKind never makes sense in response to something that the user does from Rust, we should never have that be an ErrorKind. The fact that the removed kinds do not actually appear outside the RPC system suggests that this is reasonable.)
* | rpcserver: Wrap InvokeError as internal errorNick Mathewson2024-10-172-6/+8
|/ | | | | | | | | I'm about to remove HasKind from InvokeError, which would otherwise break this code. These errors are all in fact internal errors, since in this context they can only stem from incorrectly formed calls to `invoke_special_method`.
* Merge branch 'mq-prevent' into 'main'Ian Jackson2024-10-151-2/+5
|\ | | | | | | | | | | | | Use clippy to prevent non-mq use of mpsc::channel Closes #1659 See merge request tpo/core/arti!2536
| * Use mpsc_channel_no_memquota in the RPC system (adding a TODO)Ian Jackson2024-10-151-2/+5
| | | | | | | | | | We need to decide whether RPC will participate in memquota. Perhaps it should. But that's for the future.
* | Replace _ => panic!() elsewhereIan Jackson2024-10-151-1/+1
|/
* arti-rpcserver: minimal handling for request.meta.requireNick Mathewson2024-10-072-2/+30
| | | | | | | | | | We have defined a forward-compatibility mechanism for the RPC system, where a request may list one or more required "features", and if any feature is absent, the request will fail. Since no "features" are currently implemented, this code does the bare minimum to implement this mechanism, by rejecting every request with a nonempty "require" field.
* arti-rpcserver: Correctly handle rpc.meta without `updates`Nick Mathewson2024-10-071-0/+1
| | | | | The `update` field in request.meta is optional, so we should allow it to default to `false` when it is absent.
* rpcserver: Remove TODO about optionality of paramsNick Mathewson2024-10-071-3/+0
| | | | | | | The spec no longer says that `params` is optional, so we can remove the TODO about making it optional. Closes #1665.
* rpc: clarify documentation and fix typosNick Mathewson2024-10-022-3/+6
| | | | Based on review from @opara.
* Revise RPC documentation to be more informative.Nick Mathewson2024-10-024-13/+73
| | | | | | Previous documentation was more-or-less meant for the Arti developer only. This new documentation is intended for actual users of RPC functionality. It's meant to be extracted with `maint/rpc-doc-tool`.
* rpc: Rename SingletonId to SingleIdResponseNick Mathewson2024-09-242-8/+8
| | | | | | | | | | Calling it "singleton" might have suggested that it was using the [singleton pattern](https://en.wikipedia.org/wiki/Singleton_pattern), which it isn't. (Renaming done with rust-analyzer and double-checked with `git grep`.) Closes #1585.
* rpcserver: Split a few long lines.Nick Mathewson2024-09-161-5/+10
|
* rpcserver: move is_connection_close detection into run_loop.Nick Mathewson2024-09-161-6/+10
| | | | | | I've used an `async{ expr }.await` pattern, to make sure that _every_ error returned by the `loop{select!{}}` construct is actually transformed.
* rpcserver: Add an extra level of braces.Nick Mathewson2024-09-161-50/+52
| | | | (This will make the next commit easier to read.)
* rpcserver: Apply documentation suggestion.Nick Mathewson2024-09-161-0/+2
|
* rpcserver: Use a struct to enforce explicit ContinueNick Mathewson2024-09-161-2/+10
| | | | Per suggestion from @diziet.
* rpc: Simplify simplified close logic even furtherNick Mathewson2024-09-162-35/+38
| | | | | | Instead of classifying errors and complicating our behavior _early_ in our loop, instead we just decide whether an error indicates an EOF immediately before we return it.
* rpc: Simplify close logic even further.Nick Mathewson2024-09-161-6/+4
| | | | | | Make it more clear than the previous match statement that once we get an Err() from request_stream.next(), we aren't going to continue the loop.
* rpc: Simplify handling of fatal Json read errors.Nick Mathewson2024-09-163-44/+33
| | | | | | | | | | | | | | | | | | | | Previously, after determining that an error on an RPC connection was fatal, we would: 1. Determine whether it was a "clean" close or one that needed to be logged. 2. In exactly one case (specifically, when the inbound Json stream contained a Value that was not an Object) , we would send back a message to the client. 3. Exit the connection with Ok() or Err(e). We no longer do step "2" above. Additionally, we document: - Why it's important to exit immediately on syntax errors. - A better way to tolerate non-Object Json Values, if we decide someday to do so. Closes #1591.
* rpc: More specificity surrounding SOCKS-rpc integrationNick Mathewson2024-09-091-1/+8
|
* extract tor_async_utils::oneshot into ::oneshot-fused-workaroundJim Newsome2024-08-281-1/+1
| | | | | | | | | | | | | | Having this in the `tor-async-utils` crate prevents us from doing both of the following without introducing a circular dependency: * using it in `tor-rtmock` (which we currently do, particularly in tests). * using `tor-rtmock` to test things in `tor-async-utils`. We don't do this yet, but it is generally sensible to do so. In particular we want to move the `stream_peak` module there, which is currently tested with `tor-rtmock`. Moving this into its own crate avoids this circular dependency.
* rpcserver: Fix a trivial doc typo.Nick Mathewson2024-08-281-1/+1
|
* rpcserver: Use slotmap-careful instead of generational-arena.Nick Mathewson2024-08-142-34/+37
| | | | | | | | | Unlike generational-arena, slotmap is maintained. Unlike slotmap, slotmap-careful should never be able to reuse the same key for two different objects. Closes #1282.
* Merge branch 'rpc-connection-error' into 'main'Nick Mathewson2024-08-131-16/+66
|\ | | | | | | | | | | | | rpcserver: use more sophisticated handling for ConnectionError. Closes #1517 See merge request tpo/core/arti!2335
| * rpcserver: use more sophisticated handling for ConnectionError.Nick Mathewson2024-08-121-16/+66
| | | | | | | | | | | | | | | | | | | | | | | | In general, we don't want to return a ConnectionError for a simple EOF condition; we only want to report an error when there's an actual failure. Also, it's a good idea to capture the actual error return conditions that we get from aynchronous_codecs, rather than throwing them away as we did before. Closes #1517.
* | Unstable RPC method to dump method information.Nick Mathewson2024-08-121-1/+41
|/
* Mark a struct as allowed-to-be-unused.Nick Mathewson2024-07-281-0/+1
| | | | | (This will either become used later, or we will remove it; the TODO RPC will remind us.)
* rpc: Rename the error codes for something like consistency.Nick Mathewson2024-07-253-4/+4
|
* rpc: Remove RpcError data field and use ReportNick Mathewson2024-07-251-1/+1
| | | | | | | | | | | | Per discussion, this field isn't really specified in a way that lets us fill it sensibly at the moment. So for now, we're going to just omit it. Additionally, we said that we'd Report on our errors; this branch changes the implementation of RpcError to do that. Question: Will the blanket implementation for Into<RpcError> make it harder to re-add a Data field later on if we want to do so?
* rpc: Refactor errors part 1: a new RpcMethod trait.Nick Mathewson2024-07-254-14/+7
| | | | | It is no longer necessary to say, for every RPC method, that its error type is RpcError.
* Several typo fixes from GabiNick Mathewson2024-06-111-2/+1
|
* Un-indent a block.Nick Mathewson2024-06-111-42/+39
|
* RPC: Use RPC methods instead of the "ClientConnectionTarget" trait.Nick Mathewson2024-06-112-91/+113
| | | | | | | | | | | | On its own, this might not seem like a huge improvement, but it will later let us implement these RPC methods for types that can't reasonably implement ClientConnectionTarget. It also serves as a proof of concept that special-method invocation can actually work, so that we can build things like this in cases where introducing a trait isn't practical. Closes #1427
* rpc: Make RpcMgr::lookup_object return context along with object.Nick Mathewson2024-06-101-6/+12
| | | | The context will make it possible to invoke rpc methods.
* Implement rpc::Context on Connection directlyNick Mathewson2024-06-101-25/+7
| | | | | | | | | | | This lets us get rid of a now-spurious `RequestContext` wrapper type and an extra layer of indirection; it will also make it easier to treat a Connection _as_ a context, so that we can have a context in the socks-rpc interface code. This patch removes a TODO about "treading carefully" when we make this change. When I added that TODO, I had misremembered some implementation details of the RPC object system.
* rpc: allow Connection::lookup_object to take &selfNick Mathewson2024-06-101-7/+16
| | | | This will allow us to implement rpc::Context on Connection directly.
* rpc: Make the connection type always-Arc.Nick Mathewson2024-06-102-5/+5
|