summaryrefslogtreecommitdiff
path: root/crates/arti-rpcserver/src/session.rs
Commit message (Collapse)AuthorAgeFilesLines
* RPC: Require an Error type in methods.Nick Mathewson2024-05-161-0/+3
| | | | | | | | This is needed so that we can cast special methods' return types properly. I wish I could make this optional, but Rust doesn't allow defaulting an associated type.
* RPC: Use RPC method names in a consistent format.Nick Mathewson2024-05-141-2/+2
| | | | | Specifically, we want a single colon, and we want our method names to be in snake_case.
* RPC: Add a trait that can be the target of SOCKS requestsNick Mathewson2024-05-121-6/+55
| | | | | | | | | | | | (These will later become objects that can receive any application request, once we have HTTP connect.) For now, Session and TorClient implement this trait; but soon there will be a new type to hold on to the created DataStreamCtrl. There are some XXXXs here, marking code that is too ugly to live. I should fix it before I merge this branch.
* RPC: Un-parameterize RpcSession.Nick Mathewson2024-05-091-29/+43
| | | | | | | Instead, add a trait so that we can hold TorClient<R> and invoke only the methods on it that we need. This is a partial revert of 47f012829d3381fd896c6b6f20961fbfe2f40f6d.
* rpc: Teach RpcSession to expose and isolate clients.Nick Mathewson2024-05-091-1/+39
|
* Make RpcSession parameterized.Nick Mathewson2024-05-091-17/+18
| | | | | | This change allows it to hold a TorClient<R> that isn't type-erased. We'll use this for cases when we need to get the client directly and call functions on it.
* RPC: Implement methods to get and watch client bootstrap status.Nick Mathewson2024-05-061-3/+0
|
* RPC: Remove method and object type from macros.Nick Mathewson2024-04-221-2/+2
| | | | | These are no longer needed, since they are inferred from the types of the functions.
* rpc: Move deftly attributes into an `rpc` namespace.Nick Mathewson2024-04-111-3/+3
|
* Globally rename rpc_invoke_fn to static_rpc_invoke_fnNick Mathewson2024-04-081-2/+2
| | | | | | | | This will be called _static_ to make it clear that it registers the method statically, so you don't need to install it at runtime. After a bit more work, there will be a separate macro that declares an installer function.
* Refactor: remove existence of HasConstTypeId_ as a traitNick Mathewson2024-04-081-3/+3
| | | | | | | | | We don't actually need this to be a trait; we just need methods and objects to have a `CONST_TYPE_ID_` if they want to participate in the inventory-based method registry. Removing this trait makes it much simpler to declare methods and objects.
* Port many of the macros in tor-rpcbase to use derive-deftly.Nick Mathewson2024-04-041-5/+12
| | | | | | This simplifies our implementation logic in a few places, and simplifies our invocation syntax greatly. There are a few infelicities, noted in `TODO RPC` comments.
* rpc: Fix docs typoNick Mathewson2023-06-201-1/+1
|
* rpc: Document relationship between `Connection` and `RpcSession`Ian Jackson2023-06-161-1/+11
|
* rpc: revise session initialization a lot.Nick Mathewson2023-06-151-8/+4
| | | | | | | | | | | | | | Formerly, every time we wanted to launch a new connection, we had to give the RpcMgr a TorClient. The connection would hold that TorClient until a session was authenticated, and then would wrap it in a Session and put it in the object map. Now, the RpcMgr holds a Box<dyn Fn()...> that knows how to create Sessions. When a connection is authenticated, it asks the Mgr to make it a new session. This lets us make it clearer that the TorClient simply can't be given out until the connection is authenticated. Later, it will let us create more types of Session objects under more complicated rules.
* rpc: Rename Session=>RpcSessionNick Mathewson2023-06-151-7/+7
|
* rpc: Expose Session object.Nick Mathewson2023-06-151-3/+12
| | | | | We'll want to move the responsibility for creating Sessions outside the rpcmgr crate.
* RPC: Functionality to downcast dyn Object to a dyn Trait.Nick Mathewson2023-06-121-8/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* rpc: make decl_object! responsible for writing impl Object {} blocks.Nick Mathewson2023-06-071-1/+1
|
* RPC: Make Session objects get a GlobalId.Nick Mathewson2023-06-051-1/+7
|
* rpc: Remove downgrade_owned for nowNick Mathewson2023-05-241-15/+0
| | | | | | | Rationale: Our weak-vs-strong design is a bit confused at the moment due to concerns about deduplication and capability semantics. It's not clear that a general "change strong to weak" method is compatible with what we want to provide.
* rpc: Implement functionality to remove objects from a sessionNick Mathewson2023-05-241-0/+55
| | | | | | | | | | | I've made doing some design choices here: * Reserving "rpc" as a prefix for post-authentication functionality that is not arti-specific. * Declaring these to be methods on the session rather than methods on the objects themselves. There's a problem with defining an API to drop a weak reference; see comment in code.
* rpc: Make the top-level returned object a "session".Nick Mathewson2023-05-241-0/+52
| | | | | | This will make it easier to change the semantics of what exactly we return, whether it has to be/contain a client, whether you can use it to look up all the live objects, &etc.
* RPC: Rename session.rs to connection.rsNick Mathewson2023-05-041-494/+0
|
* RPC: rename Session to Connection.Nick Mathewson2023-05-041-41/+44
| | | | | | | 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.
* RPC: Make authentication return a TorClient.Nick Mathewson2023-05-041-50/+62
| | | | | | (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.)
* RPC: Add "register" methods to RequestContext.Nick Mathewson2023-05-041-0/+8
|
* RPC: Move the "listen" part of the RPC listener code to `arti`.Nick Mathewson2023-05-041-2/+25
| | | | | | | | | 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.
* rpc: Make an RpcMgr type to own the DispatchTable.Nick Mathewson2023-05-041-10/+7
| | | | | | | | | 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
* RPC: Log all internal errors.Nick Mathewson2023-04-191-1/+6
|
* rpcserver: Use with_fn.Nick Mathewson2023-04-191-12/+7
|
* rpc: Use Method types to determine type of method outputs, updates.Nick Mathewson2023-04-191-17/+39
| | | | This lets us do much less in our rpc_invoke_fn functions.
* rpc: Split Method into DynMethod and MethodNick Mathewson2023-04-191-7/+11
| | | | | Now `Method` has an Output and Update associated type, and `decl_method` can do a little more.
* rpc: simplify API by always providing a sink.Nick Mathewson2023-04-161-7/+6
| | | | | Previously we have two places where we had to do "make a `Drain` sink if updates aren't wanted"; now there's only one.
* rpc: Ensure well-ordering of responses.Nick Mathewson2023-04-161-60/+88
| | | | | | | | | | | | 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.
* rpc: Move update sink out of context.Nick Mathewson2023-04-161-101/+25
| | | | | Now the update sink is its own boxed object. It is not yet passed to the invoke functions that want it.
* rpc: Change `id=<SYNTAX>` to "no id".Nick Mathewson2023-04-131-5/+8
| | | | | | | 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.
* rpc: Require that errors are RpcError.Nick Mathewson2023-04-131-2/+16
| | | | | | 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.
* rpc: Improve error reporting for invalid requestsNick Mathewson2023-04-121-12/+34
| | | | | | | | | | | | | | | | 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.
* arti-rpcserver: Be careful about saying "result".Nick Mathewson2023-04-121-1/+1
| | | | | | 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.
* arti-rpcserver: Rename Authentication{Method => Scheme}.Nick Mathewson2023-04-121-7/+7
|
* arti-rpcserver: rename cmd to method.Nick Mathewson2023-04-121-2/+2
|
* arti-rpcserver: rename command to method.Nick Mathewson2023-04-121-11/+11
|
* tor-rpcbase: Rename and rephrase "command" to "method"Nick Mathewson2023-04-121-4/+4
|
* Rename tor-rpccmd to tor-rpcbase.Nick Mathewson2023-04-121-1/+1
|
* rpc: Make AuthenticationMethod an enum.Nick Mathewson2023-04-121-13/+20
|
* rpc: Reify and expose DispatchTable.Nick Mathewson2023-04-121-1/+9
|
* rpc: Use Pin<Box<Stream/Sink>> for run_loopNick Mathewson2023-04-121-9/+15
|
* rpc: Import Pin/Context/Poll.Nick Mathewson2023-04-121-29/+13
| | | | | (Except for one case where we are using crate::Context and task::Context at the same time.)
* rpc: Document our intended read-blocking behavior.Nick Mathewson2023-04-121-0/+4
|