summaryrefslogtreecommitdiff
path: root/crates/arti-rpcserver/src/session.rs
Commit message (Collapse)AuthorAgeFilesLines
* rpc: Do not allow a connection to be authenticated twiceNick Mathewson2026-03-161-2/+0
| | | | This makes it a little easier to drop unwanted capabilities.
* rpc: Add su capability to RpcSession, and methods to get/drop itNick Mathewson2026-03-161-2/+108
| | | | | (For now, the su capability doesn't actually do anything, and there is no ability to actually have a session start with one.)
* rpcserver: Add a temporary allow for missing docsGabriela Moldovan2025-12-011-0/+1
|
* Switch Cargo.toml files to edition 2024.Nick Mathewson2025-08-071-2/+2
| | | | | | | | | | | | | | First, run ``` git grep -l "^edition =" | xargs perl -i -pe 's/^edition *=.*/edition = "2024"/;' ``` Second, manually verify that all Cargo.toml files have changed, and nothing else has changed. Third, run cargo fmt again.
* rpc: Clean up comments surrounding strong referencesNick Mathewson2025-01-271-1/+0
| | | | They used to be deduplicated, but they haven't been for a while.
* Remove echo structsNeel Chauhan2024-10-251-14/+0
|
* arti-rpcserver: Remove echo_on_sessionNeel Chauhan2024-10-251-12/+0
|
* rpc: Move some object-id-manipulation methods to a new module.Nick Mathewson2024-10-231-50/+0
| | | | | These will have different implementations soon; this is a more logical place for them.
* rpcserver: Wrap InvokeError as internal errorNick Mathewson2024-10-171-3/+4
| | | | | | | | | 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`.
* rpc: clarify documentation and fix typosNick Mathewson2024-10-021-2/+4
| | | | Based on review from @opara.
* Revise RPC documentation to be more informative.Nick Mathewson2024-10-021-5/+30
| | | | | | 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-241-5/+5
| | | | | | | | | | 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: Fix a trivial doc typo.Nick Mathewson2024-08-281-1/+1
|
* 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: Refactor errors part 1: a new RpcMethod trait.Nick Mathewson2024-07-251-6/+3
| | | | | 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
|
* RPC: Use RPC methods instead of the "ClientConnectionTarget" trait.Nick Mathewson2024-06-111-47/+48
| | | | | | | | | | | | 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: Pass around our rpc::Context in an Arc.Nick Mathewson2024-06-101-4/+4
| | | | | | | | Formerly we used a Box. That was okay at first, but now that we want RPC methods to be able to invoke other RPC methods, we don't want the Invocable methods to have to consume the Context. This requires that Context become Sync.
* 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
|