Commit Graph

110 Commits

Author SHA1 Message Date
Ian Jackson 42df88d6bf Run maint/add_warning to add lint block everywhere 2023-08-23 10:34:00 +01:00
Nick Mathewson cec6d0ce33 Run add_warnings on all files. 2023-08-04 07:45:04 -04:00
Nick Mathewson 5cc3fe1629 Bump patchlevel versions of crates with trivial changes
These crates have had trivial changes only: typically,
changes to documentation or to clippy warnings.  There's no
good reason to update which version of them other crates depend on,
so we only bump _their_ patchlevels.

```
tor-async-utils
caret
safelog
tor-events
tor-units
tor-rtcompat
tor-rpcbase
tor-llcrypto
tor-protover
tor-bytes
tor-hscrypto
tor-socksproto
tor-cert
tor-cell
tor-consdiff
tor-congestion
arti-rpcserver
arti-testing
arti-bench
arti-config
arti-hyper
```
2023-08-01 11:03:56 -04:00
Nick Mathewson 3acdf102c7 Increment patchlevel versions of crates with minor changes
These crates are at version 0.x.y, so we don't need to distinguish
new-feature changes from other changes:

```
tor-basic-utils
fs-mistrust
tor-error
tor-geoip
tor-checkable
tor-linkspec
tor-netdoc
tor-netdir
tor-persist
tor-ptmgr
tor-hsservice
```

This crate has a breaking change, but only when the semver-breaking
feature `experimental-api` is enabled:

```
tor-config
```

This crate is at version 1.x.y, but has no new public APIs, and
therefore does not need a minor version bump:

```
arti
```
2023-08-01 10:57:55 -04:00
Nick Mathewson 6f2ae59603 Update minor versions on crates that have had breaking changes
These crates had first-order breaking changes:

```
retry-error
tor-keymgr
tor-proto
tor-hsclient
tor-rtmock
```

Additionally, these broke because they re-exposed RetryError:

```
tor-circmgr
```

Additionally, these broke because they may re-expose something from
tor-proto:

```
    arti-client
    tor-chanmgr
    tor-dirclient
    tor-dirmgr
    tor-guardmgr
```

Additionally, these broke for other fiddly reasons:

`tor-ptmgr` implements traits from tor-chanmgr, which has a breaking
change above.

`arti-hyper` exposes types from arti-client in its API.
2023-08-01 10:51:25 -04:00
Dimitris Apostolou 947ddfff0c
Fix typos 2023-07-22 10:10:34 +03:00
Ian Jackson 473447a82e Run maint/add_warning to actually apply new lint allows 2023-07-10 13:49:51 +01:00
Nick Mathewson 4caf86349c Remove explicit allows for missing_panics_docs.
These are no longer needed.
2023-07-06 14:36:13 -04:00
Nick Mathewson 03f9f9987a Run add_warning to remove `missing_panics_doc` deny.
Closes #950.
2023-07-06 14:32:23 -04:00
Nick Mathewson de13a7319b Bump patchlevel versions on crates with smaller changes
Done with the commands below.

The following crates have had various changes, and should get a
patchlevel bump. Since they are pre-1.0, we do not need to
distinguish new APIs from other changes.

```
cargo set-version --bump patch -p arti-client
cargo set-version --bump patch -p safelog
cargo set-version --bump patch -p tor-bytes
cargo set-version --bump patch -p tor-cert
cargo set-version --bump patch -p tor-circmgr
cargo set-version --bump patch -p tor-config
cargo set-version --bump patch -p tor-consdiff
cargo set-version --bump patch -p tor-dirclient
cargo set-version --bump patch -p tor-dirmgr
cargo set-version --bump patch -p tor-error
cargo set-version --bump patch -p tor-hsservice
cargo set-version --bump patch -p tor-linkspec
cargo set-version --bump patch -p tor-llcrypto
cargo set-version --bump patch -p tor-netdir
cargo set-version --bump patch -p tor-netdoc
cargo set-version --bump patch -p tor-proto
cargo set-version --bump patch -p tor-rpcbase
cargo set-version --bump patch -p tor-socksproto
```

This crate has new features, but no new non-experimental Rust APIs.
So even though it is post-1.0, it gets a patchlevel bump.

```
cargo set-version --bump patch -p arti
```
2023-06-30 08:42:21 -04:00
Nick Mathewson 65e81bf0ca Bump minor versions on crates with breaking changes
Done with:
```
cargo set-version --bump minor -p tor-hsclient
cargo set-version --bump minor -p arti-rpcserver
cargo set-version --bump minor -p tor-hscrypto
cargo set-version --bump minor -p tor-cell
```
2023-06-30 08:38:16 -04:00
Nick Mathewson 23c67d92e6 Run "fixup-features". 2023-06-29 17:09:52 -04:00
Ian Jackson 161b9844da lints: Run maint/add_warning to actually apply new lints 2023-06-21 12:15:41 +01:00
Ian Jackson affa5b5e91 Merge branch 'rpcdoc' into 'main'
rpc: Minor docs improvements

See merge request tpo/core/arti!1260
2023-06-20 12:11:49 +00:00
Nick Mathewson 3e704a080c rpc: Fix docs typo 2023-06-20 11:38:31 +00:00
Nick Mathewson a34af0323b Fix compilation afver last suggestion. 2023-06-16 13:24:41 -04:00
Ian Jackson 0e3dbdee8e Apply 1 suggestion(s) to 1 file(s) 2023-06-16 17:07:25 +00:00
Ian Jackson ceaa70f41a rpc: Expand and clarify and cross-reference lock hierarchy 2023-06-16 17:48:59 +01:00
Ian Jackson 0460a4a4d8 rpc: Document relationship between `Connection` and `RpcSession` 2023-06-16 17:48:59 +01:00
Nick Mathewson 6521864a34 rpc: Document and apply lock hierarchy for Mgr/Connection 2023-06-15 12:53:50 -04:00
Nick Mathewson 9e8ad5415e rpc: Give the session-creation function an argument.
This will later let us tell the session-creation function
how the authentication occurred, which will let it decide
what privileges to provide.
2023-06-15 11:50:12 -04:00
Nick Mathewson 2d28402fb7 rpc: revise session initialization a lot.
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.
2023-06-15 11:44:14 -04:00
Nick Mathewson 6da1acadab rpc: Rename Session=>RpcSession 2023-06-15 11:29:57 -04:00
Nick Mathewson 269fab7abe rpc: Expose Session object.
We'll want to move the responsibility for creating Sessions outside
the rpcmgr crate.
2023-06-15 11:28:34 -04:00
Nick Mathewson bd134525fd RPC: rename new_session to new_connection 2023-06-15 11:15:40 -04:00
Nick Mathewson de423f6a36 rpc: switch GlobalId mac to KMAC. 2023-06-14 14:47:13 -04:00
Nick Mathewson 66a72370d1 rpc: connection_id _is_ used: remove a comment to the contrary 2023-06-14 14:46:08 -04:00
Nick Mathewson 789953d800 rpc: revise the relationship between Mgr and Connection
This adds a Weak reference from Connection to Mgr, makes DispatchTable
mutable, and makes a few other changes as discussed between me and
 Diziet the other week.

I bet we are not done tweaking this, but I hope it's a setp forwards.
2023-06-14 14:43:08 -04:00
Nick Mathewson 8166a29746 RPC: Functionality to downcast dyn Object to a dyn Trait.
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.
2023-06-12 13:35:28 -04:00
Nick Mathewson 999f914e03 rpc: make decl_object! responsible for writing impl Object {} blocks. 2023-06-07 14:37:04 -04:00
Nick Mathewson e102a1c943 RPC: Note a possible API change in RpcMgr::new. 2023-06-05 14:46:51 -04:00
Nick Mathewson 3a93c94f4b RPC: Make Session objects get a GlobalId. 2023-06-05 14:46:51 -04:00
Nick Mathewson 27a5074635 RPC: Give out and accept GlobalIds for appropriate objects. 2023-06-05 14:46:51 -04:00
Nick Mathewson 71e98b1a12 RPC: Implement a "global identifier" for non-session-bound IDs
These identifiers are actually only "global" with respect to a given
`RpcMgr`, but they should not be forgeable or reusable across RpcMgr
objects.  We're going to use them so that we have a kind of identifier
for `TorClient`s that we can expose to SOCKS.
2023-06-05 14:46:51 -04:00
Nick Mathewson d6944bf003 rpc: Slightly refactor GenIdx encoding. 2023-06-05 14:45:42 -04:00
Nick Mathewson 545984b095 rpc: Give RpcMgr a registry of connections.
We're going to use this to implement arti#863, which requires that
some RPC objects be globally nameable.
2023-06-05 14:45:42 -04:00
Nick Mathewson 0b2511dd2b rpc: Move Arc::new() to RpcMgr code. 2023-06-05 14:45:42 -04:00
Nick Mathewson daf5ecc153 Bump crate versions in preparation for v1.1.5 release.
Generated with the following commands:

```
cargo set-version --bump minor -p tor-cell
cargo set-version --bump minor -p tor-linkspec
cargo set-version --bump minor -p tor-proto
cargo set-version --bump minor -p tor-netdoc
cargo set-version --bump minor -p tor-circmgr

cargo set-version --bump patch -p tor-cert
cargo set-version --bump patch -p tor-basic-utils
cargo set-version --bump patch -p tor-rpcbase
cargo set-version --bump patch -p tor-llcrypto
cargo set-version --bump patch -p tor-hscrypto
cargo set-version --bump patch -p tor-checkable
cargo set-version --bump patch -p tor-async-utils
cargo set-version --bump patch -p caret
cargo set-version --bump patch -p fs-mistrust
cargo set-version --bump patch -p safelog
cargo set-version --bump patch -p retry-error
cargo set-version --bump patch -p tor-error
cargo set-version --bump patch -p tor-config
cargo set-version --bump patch -p tor-events
cargo set-version --bump patch -p tor-units
cargo set-version --bump patch -p tor-rtcompat
cargo set-version --bump patch -p tor-rtmock
cargo set-version --bump patch -p tor-protover
cargo set-version --bump patch -p tor-bytes
cargo set-version --bump patch -p tor-socksproto
cargo set-version --bump patch -p tor-consdiff
cargo set-version --bump patch -p tor-netdir
cargo set-version --bump patch -p tor-congestion
cargo set-version --bump patch -p tor-persist
cargo set-version --bump patch -p tor-chanmgr
cargo set-version --bump patch -p tor-ptmgr
cargo set-version --bump patch -p tor-guardmgr
cargo set-version --bump patch -p tor-dirclient
cargo set-version --bump patch -p tor-dirmgr
cargo set-version --bump patch -p tor-hsclient
cargo set-version --bump patch -p tor-hsservice
cargo set-version --bump patch -p arti-client
cargo set-version --bump patch -p arti-rpcserver
cargo set-version --bump patch -p arti-config
cargo set-version --bump patch -p arti-hyper
cargo set-version --bump patch -p arti
cargo set-version --bump patch -p arti-bench
cargo set-version --bump patch -p arti-testing
```
2023-06-01 10:03:05 -04:00
Nick Mathewson 8d32e1f65f Run fixup-features script and resolve its complaints. 2023-05-31 08:04:10 -04:00
Nick Mathewson 3d4b9aa1b7 Merge branch 'rpc-auth-and-meta' into 'main'
rpc: authentication and basic handle manipulation

See merge request tpo/core/arti!1200
2023-05-24 14:53:29 +00:00
Nick Mathewson 936387efee rpc: Remove downgrade_owned for now
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.
2023-05-24 10:15:56 -04:00
Nick Mathewson 4a9c6fba7d rpc: Disable auth:get_rpc_protocol for now. 2023-05-24 10:15:56 -04:00
Nick Mathewson 9713e8d305 rpc: Implement functionality to remove objects from a session
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.
2023-05-24 10:15:56 -04:00
Nick Mathewson fef8342be3 rpc: Make the top-level returned object a "session".
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.
2023-05-24 10:15:56 -04:00
Nick Mathewson 45b4845f3a rpc: Remove fake_generational_arena
Now that generation-arena has merged [@diziet's patch] to clarify
their license, we no longer need to disable it.

[@diziet's patch]: https://github.com/fitzgen/generational-arena/pull/56
2023-05-23 13:58:08 -04:00
Nick Mathewson 0993672cb2 rpc: Implement auth:query. 2023-05-23 09:08:32 -04:00
Nick Mathewson 2798dade00 rpc: Implement the auth:get_rpc_protocol method. 2023-05-23 08:58:03 -04:00
Nick Mathewson d745e2d866 rpc: move existing auth code to new module. 2023-05-23 08:46:19 -04:00
Nick Mathewson ef3c049064 Merge branch 'rpc-objectmap' into 'main'
RPC: revise semantics for weak references and object IDs

Closes #848

See merge request tpo/core/arti!1183
2023-05-16 13:30:42 +00:00
Nick Mathewson 1ed2da523a rpc: Split the generational index into two.
This lets us simplify our logic a bit for strong references.
2023-05-16 09:08:25 -04:00