Commit Graph

4952 Commits

Author SHA1 Message Date
Nick Mathewson f14a87e4c8 Merge branch 'todos' into 'main'
tor-hsclient: Dispose of easy todos and remove many allows

See merge request tpo/core/arti!1272
2023-06-21 12:53:16 +00:00
Nick Mathewson 372a72e185 Fix a rustdoc link. 2023-06-21 08:45:25 -04:00
Nick Mathewson 21ff8e8060 Merge branch 'chanmgr-doc-fix' into 'main'
Remove message 'For now, only direct channels are supported' in tor-chanmgr docs

See merge request tpo/core/arti!1273
2023-06-21 12:35:46 +00:00
Nick Mathewson 107fbb05de Merge branch 'geoip-nullity-fromstr' into 'main'
Followups wrt country-code robustness

See merge request tpo/core/arti!1268
2023-06-21 12:32:23 +00:00
Saksham Mittal c3384df00f
Remove message 'For now, only direct channels are supported' in tor-chanmgr docs 2023-06-21 17:29:11 +05:30
Ian Jackson 9a05fbb10d tor-hsclient: Apply deferred clippy churn needed by fmt churn
rustfmt *introduced* this clippy warning.
2023-06-21 12:54:57 +01:00
Ian Jackson fe41d2059e tor-hsclient: Apply deferred rustfmt churn 2023-06-21 12:19:04 +01:00
Ian Jackson 60fc4ef98a tor-hsclient: Drop most allows that are marked for removal 2023-06-21 12:19:04 +01:00
Ian Jackson a57d3067a5 tor-hsclient: Drop a large number of unneeded imports 2023-06-21 12:19:04 +01:00
Ian Jackson ae1f144829 tor-hsclient: Add HSID to some log messages
For the debug!, we can use the unredacted form.  For error!, we use
Sensitive.
2023-06-21 12:19:04 +01:00
Ian Jackson d4b7714926 tor-hsclient: Do Debug the descriptor as part of Data
Empirically, this does not cause the descriptor to be spat out in
normal operation.  And it seems right.
2023-06-21 12:19:04 +01:00
Ian Jackson c94a726664 tor-hsclient: Drop some temporary trace calls
These were added as part of a debugging #885, and are no longer
needed.
2023-06-21 12:19:04 +01:00
Ian Jackson 8267fb4535 tor-hsclient: Drop two eprintlns in production code 2023-06-21 12:19:04 +01:00
Ian Jackson 0845694021 tor-hsclinet: Promote dead code allows to cover all tests
We want to remove the crate-level dead code allows.  The tests are
incomplete and there are multiple todos for that.
2023-06-21 12:19:04 +01:00
Ian Jackson 63ab6fb01c tor-hsclient: Use a formulaic TODO mark for incompleteness of tests 2023-06-21 12:19:04 +01:00
Ian Jackson 5a7ea7067d tor-hsclinet: Add a narrow allow, pending answer to open question
I need to talk to HS expert(s) about when this circuit can be
torn down.
2023-06-21 12:19:04 +01:00
Ian Jackson 9a30c4afce tor-hsclient: Remove unused Context.hs_blind_id_key 2023-06-21 12:19:04 +01:00
Ian Jackson 8f90fe619e tor-hsclient: Add an allow for a deliberately-unused variable 2023-06-21 12:19:04 +01:00
Ian Jackson be3433891f tor-hsclient: Omit some unussed struct fields in patterns
For the arms that have a fixed retry time, or a fixed ErrorKind,
dont't bind the unused inner error.
2023-06-21 12:19:04 +01:00
Ian Jackson 161b9844da lints: Run maint/add_warning to actually apply new lints 2023-06-21 12:15:41 +01:00
Nick Mathewson 8676b27e95 geoip: Add a few more tests. 2023-06-20 16:22:21 -04:00
Nick Mathewson b0342a8ede geoip: Explain in more detail what a CountryCode is to us. 2023-06-20 16:22:21 -04:00
Nick Mathewson f918a86c10 geoip: require that ccs actually are printable ascii.
(There are plenty of strings that convert into 2 bytes of UTF8
without being two ascii characters, and there are plenty of
sequences of two ascii characters that aren't printable.)
2023-06-20 16:22:21 -04:00
Nick Mathewson cf9d902320 geoip: Make ?? a little more bullet-proof
We want to make sure that ?? is always None, never a CountryCode.
2023-06-20 16:22:21 -04:00
gabi-250 db7f46265e Merge branch 'keymgr-refactor-fs-ops' into 'main'
keymgr: Move FS operations out of KeyType impl

See merge request tpo/core/arti!1263
2023-06-20 18:41:33 +00:00
Nick Mathewson f41b1178c5 netdoc: downgrade two accessor-related TODOs 2023-06-20 14:02:04 -04:00
Nick Mathewson 17fab6e913 netdoc: Use derive amplify::Getters for HsDesc accessors.
Closes #909.
2023-06-20 14:00:41 -04:00
Nick Mathewson 8d4ca94e19 Merge branch 'add-tor-geoip' into 'main'
tor-geoip: Add new crate with GeoIP database functionality

See merge request tpo/core/arti!1239
2023-06-20 17:59:15 +00:00
Gabriela Moldovan c40e064b42 keymgr: Fix clippy lints. 2023-06-20 18:54:35 +01:00
Gabriela Moldovan 97350cfe4b keymgr: Address clippy lints and run cargo fmt. 2023-06-20 18:54:35 +01:00
Gabriela Moldovan 2f10b08d41 keymgr: Enforce keystore_dir properties for every key read/written from the keystore. 2023-06-20 18:54:35 +01:00
Gabriela Moldovan 9bfd263f42 keymgr: Update function names and docs to reflect reality.
The functions that handle OpenSSH-formatted keys now no longer read or
write from disk. This commit updates their names and doc strings to stop
suggesting they do.
2023-06-20 18:54:35 +01:00
Gabriela Moldovan abdf854547 keymgr: Move FS operations out of ssh.rs
This moves the filesystem calls from the `ssh` module to
`ArtiNativeKeyStore`. While `ArtiNativeKeyStore` shouldn't be concerning
itself with filesystem operations either, that refactoring will be
tackled separately (see arti#899).
2023-06-20 18:54:35 +01:00
Nick Mathewson a812a486c3 Downgrade every "TODO HS" in tor-hsservice
These are all service-specific, and not client-specific.
2023-06-20 13:30:56 -04:00
eta d5632eacb2 tor-geoip: Add new crate with GeoIP database functionality
- This adds a new crate, `tor-geoip`, which can parse and perform
  lookups in the GeoIP database C-tor already uses (generated by a
  maintenance utility in the C-tor codebase).
- We embed a copy of C-tor's databases with the crate and use
  `include_str!` to ship them with the binary, bloating its size
  somewhat.
  - This does, however, solve the problem of figuring out how to
    distribute these.
  - The plan is to gate this functionality behind a feature flag anyway,
    so the cost should be nil unless explicitly opted into.

Part of tpo/core/onionmasq#47.
2023-06-20 16:57:58 +01:00
Gabriela Moldovan 181638333f keymgr: Create a temporary error type for the key types we don't support yet. 2023-06-20 16:48:36 +01:00
Gabriela Moldovan 0c7e5d1924 keymgr: Create a separate error source for key corruption errors. 2023-06-20 16:48:36 +01:00
Alexander Færøy 2fa8a4e56c Merge branch 'update-keymgr-todo' into 'main'
keymgr: Change "TODO hs" to "TODO HSS".

See merge request tpo/core/arti!1264
2023-06-20 13:42:28 +00:00
Gabriela Moldovan c0762f76f1 keymgr: Fix broken docs. 2023-06-20 13:34:32 +01:00
Gabriela Moldovan 84e05591c7 arti-client: Remove unnecessary #[cfgs(...)].
The `keymgr` module selects one of the key manager implementations
(dummy or "real") and exposes all the APIs we need, so we can remove
all of the cfgs related to the `keymgr` feature from `client.rs`.

Part of #897
2023-06-20 13:33:51 +01:00
Gabriela Moldovan 733a559322 arti-client: Create module exposing one of the key manager APIs.
This moves the key manager API selection (dummy vs "real" impl) into the
`keymgr` module. The module exports the dummy API if the `keymgr`
feature is disabled, and the impl from `tor-keymgr` otherwise.

Part of #897
2023-06-20 13:33:51 +01:00
Gabriela Moldovan 8202be3cfe arti-client: Make some of the dummy KeyMgr impls return an error.
`insert` and `remove` should return an error rather than `Ok(())`, as
`Ok(())` implies the key was stored/removed, which is impossible in the
no-op implementation.
2023-06-20 13:33:51 +01:00
Gabriela Moldovan 02c36dabd7 arti-client: Add more dummy keymgr APIs.
This will help us reduce the number of `#[cfgs(...)]` from `client.rs`

Part of #897
2023-06-20 13:33:51 +01:00
Gabriela Moldovan c7d32dbf4c arti-client: Add a result type for the dummy keymgr impl.
Part of #897
2023-06-20 13:33:51 +01:00
Gabriela Moldovan b289c0fd15 arti-client: Add an Error type for the dummy key manager.
Part of #897
2023-06-20 13:33:51 +01:00
Gabriela Moldovan 95e4021ed8 arti-client, keymgr: Introduce Mistrust settings and enforce FS permissions. 2023-06-20 13:29:10 +01:00
Gabriela Moldovan be5c911ac8 arti-client: Temporarily ignore key store errors.
We currently initialize the `ArtiNativeKeyStore` with a dummy root dir,
so when `ArtiNativeKeyStore` starts validating directories, this code
will start to fail. Let's preemptively ignore any errors coming from
`ArtiNativeKeyStore::new`. This is temporary and will be removed when we
introduce the key store config (and a real default value for the
keystore root dir).
2023-06-20 13:29:10 +01:00
Gabriela Moldovan e8176ac8b5 keymgr: Add TODO about separation of concerns wrt FS operations. 2023-06-20 13:29:10 +01:00
Gabriela Moldovan 6837dbce58 keymgr: Add an error variant for fs_mistrust errors.
This will be useful later, when `KeyMgr` will start validating
permissions and paths.
2023-06-20 13:29:10 +01:00
Gabriela Moldovan 01b43f7f26 keymgr: Add a FsErrorSource to Error::Fs.
In the future, the potential causes of an `Error::Filesystem` error will
include permission errors as well as other errors (not just
`io::Error`s).
2023-06-20 13:29:10 +01:00
Nick Mathewson f24a7d48c0 Merge branch 'circmgr-todos' into 'main'
Resolve several "TODO HS" comments in circmgr.

See merge request tpo/core/arti!1258
2023-06-20 12:13:24 +00: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
gabi-250 602bcc3c47 Typo fixes 2023-06-20 11:47:02 +00:00
Nick Mathewson 3e704a080c rpc: Fix docs typo 2023-06-20 11:38:31 +00:00
Gabriela Moldovan fed726e4ff keymgr: Defer key bundle support until "Basic Service" milestone.
We don't really need "key bundles" for the client keys.
2023-06-20 11:36:04 +01:00
Gabriela Moldovan 0bb7c7f600 keymgr: Change "TODO hs" to "TODO HSS".
We probably don't need to support passphrases for the "Basic Client"
milestone, so let's update this TODO accordingly.
2023-06-20 11:24:03 +01:00
Alexander Færøy f55187e065 Merge branch 'arti-client' into 'main'
Sort out .onion handling in arti-client

See merge request tpo/core/arti!1257
2023-06-19 14:44:55 +00:00
Nick Mathewson c7fa6cb746 Merge branch 'rpc_session_mgt' into 'main'
More work on RPC sessions, connections, and managers

See merge request tpo/core/arti!1254
2023-06-16 18:08:58 +00:00
Nick Mathewson b9500c6f3d Merge branch 'netdoc-todos' into 'main'
Resolve many TODO HS items in tor-netdoc

See merge request tpo/core/arti!1251
2023-06-16 17:31: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 85a046e266 rpc: Cross-reference up from tor-rpcbase re where DispatchTable lives 2023-06-16 17:48:59 +01: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 34fc77081c hsdesc.rs: finally remove "allows".
The last piece here is removing some needless keygen from the
tests.  This causes the test output (using the deterministic PRNG)
to change.
2023-06-16 12:24:05 -04:00
Nick Mathewson 1091918525 netdoc::doc::hsdesc changes to let us downgrade/remove allows 2023-06-16 12:24:05 -04:00
Nick Mathewson f1b90fdfee netdoc: unmark MAC_KEY_LEN as conjectural.
The value here is 32 bytes; I'm adding it to to the specification
as torspec!141
2023-06-16 12:24:05 -04:00
Nick Mathewson d8f7ce510c SharedRandVal: Note that it doesn't have to be Ct. 2023-06-16 12:24:05 -04:00
Nick Mathewson 984d97a38d netdoc: remove a TODO about moving a module to where it already is. 2023-06-16 12:24:05 -04:00
Nick Mathewson 6edcca7df3 netdoc: use ct_lookup for rend descriptor cookie lookup
(I doubt that there is a viable side channel here, but still we
might as well get in the habit of doing these things properly.)
2023-06-16 12:24:05 -04:00
Nick Mathewson 2eba3d213e llcrypto: add another warning to ct_lookup. 2023-06-16 12:24:05 -04:00
Nick Mathewson 25db56777c Lower tor-proto::util::ct::lookup to tor-llcrypto
This is mostly code movement; you may want to review it with
`--color-moved`.

I'm doing this so we can also use the function in netdoc for
looking up hsdesc authentication.
2023-06-16 12:24:05 -04:00
Nick Mathewson a20c3eda6e netdoc: Downgrade an HS todo wrt HS_DESC_AUTH_TYPE 2023-06-16 12:24:05 -04:00
Nick Mathewson 6fb19c00f5 netdoc: downgrade some TODO HS to TODO HSS.
I'm using HSS for hs-service features.
2023-06-16 12:24:05 -04:00
Nick Mathewson 3c824fe302 netdoc::build remove very broken example.
This could never be a full rustdoc test, since rustdoc never
runs tests for private items.   Even if it were a rustdoc test,
it uses a bunch of types that aren't exposed in the right places,
and it invokes nonexistent functions, and it assumes a `self`
that isn't there.

In lieu of writing a new untested test, I've added a note to refer
the developer to where they can find working example code.
2023-06-16 12:24:05 -04:00
Nick Mathewson 7a617a2dbd netdoc: Remove a TODO that we already solved. 2023-06-16 12:23:56 -04:00
Nick Mathewson 072ce9182b hsclient: note that we should check revctr. 2023-06-16 12:23:56 -04:00
Nick Mathewson c2764cf111 tor-cell: Downgrade 2 TODO-HS to TODO-HSS 2023-06-16 12:21:27 -04:00
Nick Mathewson 1691c35392 circmgr: Use a slightly nicer way to pick a circuit from our pool.
This algorithm only looks at circuits until it finds one that
satisfies our needs.  To get a random circuit, it just randomizes
the starting point within the pool.

This optimization may help if we let circuit pools grow large.
2023-06-16 12:14:49 -04:00
Nick Mathewson 686d5cf209 circmgr: Make hspool size dynamic
Previously we'd always try to keep 8 circuits ready.  That doesn't
make sense if we are super-busy.  Instead, if we run out of
circuits, we double the amount that we try to keep ready, and if we
never go under 80% of our target number, we half the number we try
to keep ready.

We limit the rate of change here, to make sure that we aren't
flapping too much or shrinking too aggressively.

This algorithm is still a mite arbitrary, and will need tuning in
the future.
2023-06-16 12:11:49 -04:00
Nick Mathewson 69179c5dfe circmgr::hspool: Move the Mutex into an intermediary Inner struct
This will be helpful as we complexify the pool behavior a bit.
2023-06-16 11:42:38 -04:00
Nick Mathewson 1c470fd483 circmgr: Remove TODOS about retrying.
These functions' documentation already says that they don't retry,
and hsclient appears to be where we are concentrating our retry
efforts.
2023-06-16 11:40:00 -04:00
Ian Jackson b34ba70070 arti-client: hs: remove some now-obsolete allows 2023-06-16 16:18:02 +01:00
Ian Jackson f877f37308 arti-client: address: Prefer to throw OnionAddressResolveRequest (fmt) 2023-06-16 16:18:02 +01:00
Ian Jackson d9f1c7195b arti-client: address: Prefer to throw OnionAddressResolveRequest
Reformatting deferred for clarity.
2023-06-16 16:18:02 +01:00
Ian Jackson dafccf93b0 arti-client: hs: Test cases for variously disabling .onion
This test case shows that we return a suboptimal error in some cases.
2023-06-16 16:18:02 +01:00
Ian Jackson 18291cb001 arti-client: Provide ErrorDetailDiscriminants for convenient testing
ErrorDetail isn't PartialEq so we can't assert_eq! it.
But the discriminants will be.
2023-06-16 16:18:02 +01:00
Ian Jackson 0a7ca71e70 arti-client: StreamPrefs::connect_to_onion_services: honour 2023-06-16 16:18:02 +01:00
Ian Jackson 2d112efc0f arti-client: StreamPrefs::connect_to_onion_services: docs
This disposes of the TODO as well.
2023-06-16 16:18:02 +01:00
Ian Jackson c5b655ed45 arti-client: StreamPrefs::connect_to_onion_services: fix cfg 2023-06-16 16:18:02 +01:00
Ian Jackson 21090aa6f0 arti-client: StreamPrefs::connect_to_onion_services: fix name 2023-06-16 16:18:02 +01:00
nate_d1azzz 08b7419138 Added setter method in impl for StreamPrefs
(Taken from tpo/core/arti!1113 and squashed by Ian Jackson, with
conflicting hunk in StreamPrefs struct skipped.

The setter name is wrong, the cfg feature is wrong, there are no
docs, and the TODO is still there.  These will be fixed in a moment.)
2023-06-16 16:18:02 +01:00
Ian Jackson 40dae63b65 arti-client hs: connect_to_onion_services: default to true
This should be enabled by default.  There's still no setter for not,
nor is it honoured - those are separate TODOs.
2023-06-16 16:18:02 +01:00
Ian Jackson ce72588322 arti-client: OnionAddressNotSupported: Change description and kind
Previously this error meant "we haven't written this code yet".
Now, we change it to "you haven't built Arti with this feature".
2023-06-16 16:18:02 +01:00
Ian Jackson 2521b88cd6 arti-client: address: Apply deferred rustfmt churn 2023-06-16 16:18:02 +01:00
Ian Jackson 60cfb09e77 arti-client: address: Plumb StreamPrefs into enforce_config
No functional change yet.  We'll use this shortly.
2023-06-16 16:18:02 +01:00
Ian Jackson bf93519cdd arti-client: address: Move config enforcement
Disposes of two TODOs.
2023-06-16 16:18:02 +01:00
Ian Jackson eb9b0d0d78 arti-client: address: Move config enforcement (pre-fmt)
This will make subsequent commits less noisy to read.
2023-06-16 16:18:02 +01:00
Ian Jackson e95f9e52cc arti-client: address: Disable some tests when HS disabled
These have already been partially/replaced supplemented.
The other test referred to will appear shortly.
2023-06-16 16:18:02 +01:00
Ian Jackson e5d53091cf Merge branch 'hs-naming-arti' into 'main'
arti-*: Rename hs feature to onion-service-client

See merge request tpo/core/arti!1039
2023-06-16 13:22:25 +00:00
Nick Mathewson 672062113e cirmgr: remove a dead-code exception. 2023-06-16 08:45:49 -04:00
Nick Mathewson 5196363d36 Merge branch 'insert' into 'main'
rpc: Make CastTable::insert be more type-safe

See merge request tpo/core/arti!1253
2023-06-16 12:20:14 +00:00
Ian Jackson 07d5bc9537 arti-client: Rename hs feature to onion-service-client (cfg lines) 2023-06-16 12:34:53 +01:00
Ian Jackson 8d98982bb2 arti-client: Rename hs feature to onion-service-client
Rationale as per #756.

This is the same name as in the `arti` crate.
2023-06-16 12:34:47 +01:00
Gabriela Moldovan 37e0837cea arti-client: rustfmt 2023-06-15 18:56:48 +01:00
Gabriela Moldovan 94b228a4c6 arti-client: Fix clippy lints.
We need to allow some lints in the dummy key manager because its
implementation needs to mirror that of `tor_keymgr::KeyMgr` (so we can't
apply the API changes suggested by clippy).
2023-06-15 18:43:24 +01:00
Gabriela Moldovan ec9200c50f keymgr: Add Diziet's notes about storing public keys in the key store. 2023-06-15 18:16:34 +01:00
Gabriela Moldovan bed1ae6304 arti-client: Use a dummy key manager if the keymgr feature is disabled.
TorClient now only uses the tor_keymgr::KeyMgr implementation if the
keymgr experimental feature is enabled. If the feature is disabled, a
dummy key manager implementation is used.

The new `keymgr` feature depends on `onion-client`, because the key
manager is only used for HS client auth.
2023-06-15 18:16:34 +01:00
Gabriela Moldovan 35879a681f arti-client: Implement From<tor_keymgr::Error> for Error. 2023-06-15 18:16:34 +01:00
Gabriela Moldovan 21d93300eb keymgr, arti-client: KeyMgr should return Ok(None) if the key is not found.
This simplifies usage quite a bit and will enable us to implement a
dummy `KeyMgr`  that doesn't depend on the error types from tor-keymgr
(which will replace the "real" `KeyMgr` if the keymgr feature is
disabled).
2023-06-15 18:16:34 +01:00
Gabriela Moldovan 60e2b51f3d keymgr: Add TODO regarding KeyStore rename. 2023-06-15 18:16:34 +01:00
Gabriela Moldovan 0525193d99 keymgr: Add TODO about KeyType refactorings. 2023-06-15 18:16:34 +01:00
Gabriela Moldovan 97ba27aedb keymgr: Add the key type to the `arti_extension`. 2023-06-15 18:16:34 +01:00
Gabriela Moldovan a958b3a91a arti_client: Add TODO about refactoring code around HsClientSecretKeysBuilder. 2023-06-15 18:16:34 +01:00
Gabriela Moldovan 15122a8e10 keymgr: Add TODO regarding some error refactorings. 2023-06-15 18:16:34 +01:00
Gabriela Moldovan eda974cd34 keymgr: Move the HS client and service key specifiers out of tor-keymgr.
The HS `HsClientSpecifier` and `HsClientSecretKeySpecifier` are moved to
`tor-hsclient`. The HS service secret key specifier stubs are moved to
`tor-hsservice`.
2023-06-15 18:16:33 +01:00
Gabriela Moldovan 0828597a2e keymgr: Expand the TODOs regarding HS service key specifiers.
Signed-off-by: Gabriela Moldovan <gabi@torproject.org>
2023-06-15 18:15:30 +01:00
Gabriela Moldovan e0ded457ba keymgr: Expand HsClientSpecifier docs, add TODO about refactoring.
Signed-off-by: Gabriela Moldovan <gabi@torproject.org>
2023-06-15 18:15:30 +01:00
Gabriela Moldovan e99ee7ec02 arti-client, keymgr: Initialize KeyMgr with an ArtiNativeKeyStore.
The `KeyMgr` is now initialized with an `ArtiNativeKeyStore` built from
an invalid key store root dir (this is alright for the purposes of this
proof-of-concept, since `ArtiNativeKeyStore::new` won't fail as it
doesn't currently validate the keystore root dir).
2023-06-15 18:15:30 +01:00
Gabriela Moldovan 64c24dca66 keymgr: Introduce ToEncodableKey to simplify lookups.
This means `KeyMgr` users don't need to specify the underlying key type
(e.g. `ed25519::Keypair`) when retrieving keys. Instead, they can just
specify the type required (as long as it implements `ToEncodableKey`),
e.g. `HsClientIntroAuthKeypair`.
2023-06-15 18:15:30 +01:00
Gabriela Moldovan fbed393680 arti-client: Make the client use the KeyMgr.
`TorClient` now uses a `KeyMgr` to retrieve the `HsClientSecretKeys`
client auth keys passed to `get_or_launch_connection`.
2023-06-15 18:15:30 +01:00
Gabriela Moldovan 61f37b1b5c keymgr: Add key manager implementation stub. 2023-06-15 18:15:30 +01:00
Gabriela Moldovan 17ae752a0b keymgr: Implement `SshKeyType::read_ssh_format_erased` for `KeyType`.
This adds a proof-of-concept `SshKeyType::read_ssh_format_erased`
implementation for `KeyType`. The implementation decodes an OpenSSH key
and converts it to one of the key types used internally by Arti. The
value returned is type-erased, and will be downscast later down the line
by the `KeyMgr` (note: `KeyMgr` doesn't exist yet).

The `SshKeyType::write_ssh_format` will be implemented once these APIs
are a bit more stable.
2023-06-15 18:15:30 +01:00
Gabriela Moldovan a2d0ee63cc keymgr: Add ArtiNativeKeyStore implementation skeleton.
This adds implementation stubs for `ArtiNativeKeyStore`, and introduces
the traits needed to make the `KeyStore` APIs work.
2023-06-15 18:15:30 +01:00
Gabriela Moldovan d133c8b0a6 hsclient: Change builder error return type to ConfigBuildError.
It's not perfectly clear what this error type should be, so let's use
`ConfigBuildError` for now (it makes things easier in `arti-client`, as
we already have an `ErrorDetail` for it).
2023-06-15 18:15:30 +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
Ian Jackson a1934e7102 tor-hsclient: Make Untried a {}-less unit
Suggested here
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/1247#note_2912642

It's unlikely this will grow any content, so fine.
2023-06-15 16:43:45 +01:00
gabi-250 7e601fba01 tor-hsclient: Insert a blank line 2023-06-15 16:43:45 +01:00
gabi-250 d99434d06b tor-hsclient: Docs improvements. 2023-06-15 16:43:45 +01:00
Ian Jackson 856269f7a7 tor-hsclient: Remove two done TODOs 2023-06-15 16:43:45 +01:00
Ian Jackson 731cc9ed44 tor-hsclient: provide intro_index accessor for FailedAttemptError (xref)
Add a cross-reference to docs arising from MR comments in !1246.
2023-06-15 16:43:45 +01:00
Ian Jackson 2dfa00f379 tor-hsclient: Actually store our IPT experiences 2023-06-15 16:43:45 +01:00
Ian Jackson f5a895b33f tor-hsclient: intro_rend_connect: bind `outcome`
This will be used in a moment.
2023-06-15 16:43:45 +01:00
Ian Jackson 4f4f753b6a tor-hsclient: Actually choose which intro points to use
Right now this just always chooses randomly because nothing stores
anything in the HashMap.
2023-06-15 16:43:45 +01:00
Ian Jackson 65d7d499d7 tor-hsclient: Introduce RelayIdForExperience
Wrap this up in a newtype so we don't accidentally use it for anything
else.  Provide two constructors, one for storing and one for lookups.
2023-06-15 16:43:45 +01:00
Ian Jackson 397c4fb01f tor-hsclient: Add random sort key to UsableIpt 2023-06-15 16:43:45 +01:00
Ian Jackson 279afeefc2 tor-hsclient: provide intro_index accessor for FailedAttemptError 2023-06-15 16:43:45 +01:00
Ian Jackson dac7a45ea8 tor-error: Introduce `LooseCmpRetryTime`
Having a newtype for this kind of thing is considerably more
convenient.  I'm going to use this in a moment.
2023-06-15 16:43:45 +01: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
Ian Jackson 1710ce54f4 rpc: Remove some verbiage about 'static, and demo that it's OK without
It's now not actually possible to write code that doesn't work, even
if `Tr` *isn't* 'static, because of the bounds on `CastTable::insert`.

I tried to produce a non-working setup with a non-static `Simple`, but
you can't implement `Object` for such a thing.  Removing 'static from
Object would stop the downcasts from Any to Object working.

Prior to the new typesafe insert, this change
  - let f: fn(&dyn $crate::Object) -> &(dyn $traitname + 'static) = |self_| {
  + let f: fn(&dyn $crate::Object) -> &(dyn $traitname) = |self_| {
would result in a runtime crash.  Now it results in a compiler error.
2023-06-15 12:07:11 +01:00
Ian Jackson 0eedf0e254 rpc: Give the name `O` to "the type associated with this CastTable"
This was locally bound to `S` in one place.  Bind and use it throughout.
Since this is an RPC object, `O` is a better name.

In each item, use the description once and thereafter just the name.
2023-06-15 12:03:53 +01:00
Ian Jackson 2228751a00 rpc: Add Simple test case for CastTable 2023-06-15 12:03:53 +01:00
Ian Jackson 54b364cdcf rpc: Move boxing from macro to CastTable::insert (formatting) 2023-06-15 12:03:53 +01:00
Ian Jackson 890a7b52be rpc: Move boxing from macro to CastTable::insert 2023-06-15 11:32:32 +01:00
Ian Jackson 8452fe11cf rpc: Make CastTable::insert be more type-safe
This checks the Requirements.
2023-06-15 11:13:26 +01: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
Ian Jackson a156e60780 Merge branch 'pt-snowflake-fix' into 'main'
make snowflake example feature-gated

See merge request tpo/core/arti!1249
2023-06-14 18:13:57 +00:00
trinity-1686a 02a82ad748 make snowflake example feature-gated 2023-06-14 18:13:57 +00:00
Ian Jackson d277f6729d tor-hsclient: InvalidTarget::ImpossibleRelayIds is RetryTime::Never
As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/1246#note_2912105
2023-06-14 17:26:05 +01:00
Nick Mathewson 46a89ffb14 tor-hsclient: Correction to HasRetryTime for InvalidTarget doc 2023-06-14 17:26:05 +01:00
Ian Jackson c99207b60e tor-hsclient: Add doc for HasKind for FailedAttemptError
There is a cross-reference here to code (`IptSortKey`) in another
branch that I haven't made an MR for yet.
2023-06-14 17:26:05 +01:00
Ian Jackson d5bf90c33e tor-hsclient: Add docs and comments about HasRetryTime for InvalidTarget 2023-06-14 17:26:05 +01:00
Ian Jackson 3e8590c2b5 tor-cell: HasRetryTime for IntroduceAckStatus: Confirm re CANT_RELAY (fmt)
rustdoc insisted on misindenting this before, and now it insists on
un-mis-indenting it.
2023-06-14 17:26:05 +01:00
Ian Jackson fb4e33fbdf tor-cell: HasRetryTime for IntroduceAckStatus: Confirm re CANT_RELAY
Remove this todo as per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/1246#note_2912104
2023-06-14 17:26:05 +01:00
Ian Jackson bfcddd4e59 tor-cell: Add a doc comment for impl tor_error::HasRetryTime for IntroduceAckStatus 2023-06-14 17:26:05 +01:00
Nick Mathewson f32b8cfaa2 netdoc::build: remove or narrow `allow`s. 2023-06-14 11:26:05 -04:00
Ian Jackson ea678ffa22 tor-hsclient: impl HasRetryTime for FailedAttemptError 2023-06-14 15:17:54 +01:00
Ian Jackson c4944de996 tor-hsclient: impl HasRetryTime for InvalidTarget 2023-06-14 15:16:31 +01:00
Ian Jackson f98c7df12e tor-cell: impl HasRetryTime for IntroduceAckStatus 2023-06-14 15:16:31 +01:00
Nick Mathewson ab56dcf145 Merge branch 'tor-cell-todos' into 'main'
Resolve most TODO HS comments in tor-cell

See merge request tpo/core/arti!1245
2023-06-13 22:30:50 +00:00
gabi-250 677148d077 Merge branch 'hscrypto-todos' into 'main'
hscrypto: Resolve all but one TODO HS comment.

See merge request tpo/core/arti!1244
2023-06-13 18:40:59 +00:00
Nick Mathewson 0912496dbb cell: Downgrade a couple more TODO HS comments. 2023-06-13 13:57:57 -04:00
Ian Jackson d843aaa3b2 Merge branch '20_byte_sendme_digest' into 'main'
proto: Make sure that auth tags are truncated to 20 bytes

See merge request tpo/core/arti!1242
2023-06-13 17:05:27 +00:00
Nick Mathewson 589fefd581 cell: Remove relaycell::restrict
This module didn't have anything in it; nonetheless, removing it
does count as an API break since it was public.
2023-06-13 13:04:16 -04:00
Nick Mathewson 6a6164a360 cell: Remove some TODOs
Yes, we still will need more accessors for onion services, but we
can add them as we find the need.
2023-06-13 12:58:22 -04:00
Nick Mathewson 0f3724322d cell: remove/localize "allow(dead-code)" 2023-06-13 12:50:09 -04:00
gabi-250 a931c7e5d9 Merge branch 'hs' into 'main'
tor-hsclient: Finish(?) plumbing up first cut of HS client connection

See merge request tpo/core/arti!1240
2023-06-13 16:47:19 +00:00
Nick Mathewson 0add7df458 hscrypto: fix TODOs in time-period code.
* Return a more informative error type (instead of Option)
* Check that time periods are an integer number of seconds
* Decide not to change the semantics of an argument.
2023-06-13 12:39:52 -04:00
Nick Mathewson 0a4dac0fa0 hscrypto: remove compatibility note about time periods.
We updated and clarified the spec in arti!107, and noted the
remaining infelicities in proposal 342.
2023-06-13 12:20:12 -04:00
Nick Mathewson 44ced7dbd3 hscrypto: write a README 2023-06-13 12:15:04 -04:00
Nick Mathewson 848793da5a hscrypto: note that hs_mac is not a good choice for new protocols 2023-06-13 12:11:38 -04:00
Nick Mathewson 7a82285984 hscrypto: comment out an unused key type.
(I'm not removing it entirely since maybe we _should_ use it, and
maybe we _will_ as we do services.  I've added a TODO HS for
removing it or using it, and removed the TODO HS at the head of
pk.rs about making sure that all the key types in the module really
belong there.)
2023-06-13 12:01:12 -04:00
Nick Mathewson 9888c4422d hscrypto: Remove a TODO about extending an internal macro. 2023-06-13 11:53:29 -04:00
Ian Jackson cc7fd57511 Merge branch 'hs3' into 'main'
tor-hsclient: Plumb some needed values through etc.

See merge request tpo/core/arti!1238
2023-06-13 15:53:01 +00:00
Nick Mathewson 670c73a159 hscrypto: Remove a TODO about implementing ErrorKind.
I think it isn't actually a great idea for HsIdParseError to
implement ErrorKind, since the actual ErrorKind would depend
entirely on where the problematic ID came from.
2023-06-13 11:50:53 -04:00
Nick Mathewson 9311a8da5b hscrypto: clarify and downgrade TODOs about blinding secrets 2023-06-13 11:48:54 -04:00
Ian Jackson bfaf0bba6f tor-hsclient: Add some more debugging 2023-06-13 16:14:57 +01:00
Ian Jackson e123ade035 tor-hsclient: Return the circuit 2023-06-13 16:14:57 +01:00
Ian Jackson 57ba35dfe0 tor-hsclient: Conduct the INTRODUCE1 exchange 2023-06-13 16:14:57 +01:00
Ian Jackson ab11a2042f tor-hsclient: Remove an already-done TODO
Since !1238 we do pass the handshake_state along.
2023-06-13 16:14:57 +01:00
Ian Jackson f76b6eb614 tor-cell: IntroduceAck: Add .success() function to give a Result
The type is a bit odd but this is a result of the underlying protocol.
I don't feel like inventing `IntroduceAckSuccess` that contains only
the extensions.
2023-06-13 16:14:57 +01:00
Ian Jackson 0c10a9554b tor-hsclient: Rename some errors for greater consistency 2023-06-13 16:14:57 +01:00
Ian Jackson d98405d1e0 tor-hsclient: Reorder timeout errors to be "less interesting"
If something *other* than a timeout went wrong, then that is less
expected so more interesting.
2023-06-13 16:14:57 +01:00
Nick Mathewson c79ed2b31b tor-hsclient: Improve proto_oneshot docs 2023-06-13 16:14:06 +01:00
Ian Jackson b1ac10203a tor-hsclient: Pass handshake_state to complete_handcshake (fmt) 2023-06-13 16:14:03 +01:00
Ian Jackson 6810881f38 tor-hsclient: Pass handshake_state to complete_handcshake
Pass Introduced to complete_handshake.  The lack of this was a slip.
Add handshake_state to Introduced, and use it.
2023-06-13 16:13:57 +01:00
Nick Mathewson 40840b1f3a proto: Make sure that auth tags are truncated to 20 bytes
Onion service hops (pointlessly) use SHA3-256 for their
authentication, but they truncate it to 20 bytes (assuming I'm
reading the C right.)

See torspec#204 for clarification here.
2023-06-13 11:04:23 -04:00
Ian Jackson 85273a7646 tor-hsclient: Add a missing doc
Requested in !1228 but overlooked
2023-06-13 13:22:27 +01:00
Ian Jackson 01259a560b tor-hsclient: Introduce proto_oneshot, to help with message handling (fmt) 2023-06-13 13:22:27 +01:00
Ian Jackson 0dcf872e3a tor-hsclient: Introduce proto_oneshot, to help with message handling
This gets rid of a lot of repeated `oneshot::<...<Result, ...>>` and
a bit of repeated functional code, etc.
2023-06-13 13:22:27 +01:00
Ian Jackson 1587c06790 tor-hsclient: (try to) receive the RENDEZVOUS2 message 2023-06-13 13:00:19 +01:00
Ian Jackson 5d49660e0a RPC: Suppress a warning to do with RPC and SOCKS
Fixes `cargo check`
2023-06-13 12:11:23 +01:00
Ian Jackson 880095356e tor-hsclient: Fix a botched doc comment 2023-06-13 12:00:56 +01:00
Ian Jackson 78de0d279c Merge branch 'msg_in_handler' into 'main'
proto: Convert MsgHandler API to expect a message, not a cell.

Closes #887

See merge request tpo/core/arti!1236
2023-06-13 10:57:01 +00:00
Nick Mathewson beecf3c92c proto: Convert MsgHandler API to expect a message, not a cell.
Closes #887.
2023-06-12 14:55:26 -04:00
Nick Mathewson 47b1083d3a Merge branch 'rpc_pseudomethods_v6' into 'main'
RPC: Functionality to downcast dyn Object to a dyn Trait.

See merge request tpo/core/arti!1225
2023-06-12 18:10:46 +00:00
gabi-250 5480035f51 Merge branch 'desc-validation-err-doc' into 'main'
tor-error: Document another potential cause for OnionServiceDescriptorValidationFailed.

See merge request tpo/core/arti!1215
2023-06-12 18:03:06 +00: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
Gabriela Moldovan 44fca4c2ca
tor-error: Clarify what we mean by "hostile".
Signed-off-by: Gabriela Moldovan <gabi@torproject.org>
2023-06-12 18:25:50 +01:00
Gabriela Moldovan de8ca98900
tor-error: Document another potential cause for OnionServiceDescriptorValidationFailed.
Signed-off-by: Gabriela Moldovan <gabi@torproject.org>
2023-06-12 18:25:46 +01:00
Nick Mathewson 255d74ac3c hsclient: fill in a lot more introduce/rendezvous logic.
This code tries to fill in some TODO HS code, replacing it with a
lot more code with a bunch more TODO HS comments.  Hopefully the
expansions of the new TODO HS comments should be simpler.
2023-06-12 13:15:59 -04:00
Nick Mathewson 2c8e3b22b5 cell: Add an accessor for the body of a Rendezvous2. 2023-06-12 13:15:59 -04:00
Nick Mathewson f78c5a5a42 proto: Add a commment about a problem in my hs_ntor plans.
I am pretty sure that C tor works around this somehow; we should
figure out how!
2023-06-12 13:15:59 -04:00
Nick Mathewson c38ba16a81 proto: code movement and reindentation in hs_ntor 2023-06-12 13:15:59 -04:00
Nick Mathewson 7255b122d7 proto: Remove now-unused hs_ntor APIs 2023-06-12 13:15:59 -04:00
Nick Mathewson bb6115103a proto: refactor hs_ntor to reuse state.
We want the ability to send the same handshake request in parallel
on multiple introduce circuits.  This implies encoding the client
handshake more than once.

(Sadly we can't _actually_ do this in the protocol as it stands,
since the onion service can use a separate KP_hss_ntor for each
introduction point; I'll add a comment to that effect later.)
2023-06-12 13:15:59 -04:00
Nick Mathewson edfb3642e0 hsclient: receive rendezvous2 messages too. 2023-06-12 13:15:59 -04:00
Nick Mathewson 32d54c857e hsclient: Move the body of the msg handler into a new function 2023-06-12 13:15:59 -04:00
Nick Mathewson e948116bc7 hsclient: Add a second oneshot to Rendezvous msghandler
On a client's circuit to the rendezvous point, we need to first wait
for an `RENDEZVOUS_ESTABLISHED` message, and then for a
`RENDEZVOUS2` message.
2023-06-12 13:15:59 -04:00
Nick Mathewson 796dc4457b hsclient: use hs-client feature in tor-proto. 2023-06-12 13:15:59 -04:00
Nick Mathewson ac90cb7500 Upgrade async-trait requirement to 1.54
We need the fix from [82d69902], which first appeared in async-trait
version 1.54.  (Technically we only need this fix in tor-hsclient,
but we may as well update our minimal async-trait version everywhere.)

[82d69902]: 82d6990253
2023-06-12 13:15:59 -04:00
Nick Mathewson 3b93cdb2dd Merge branch 'redactable_relayids' into 'main'
Implement Redactable for RelayIds, and other improvements

Closes #882

See merge request tpo/core/arti!1233
2023-06-12 16:06:11 +00:00
Nick Mathewson ddea524849 linkspec: cleanup usage; change std::fmt to fmt. 2023-06-12 11:39:45 -04:00
Nick Mathewson 345808322d Merge branch 'circuit_send_message_fixes' into 'main'
Correct documentation and API on ClientCirc::send_control_message

Closes #885 and #881

See merge request tpo/core/arti!1232
2023-06-12 14:14:32 +00:00
Ian Jackson da78c53e20 Merge branch 'arc_hsdirs_in_netdir' into 'main'
netdir: Wrap HsDir an Arc<>

Closes #883

See merge request tpo/core/arti!1234
2023-06-12 13:56:44 +00:00
Ian Jackson 4ee4de2d0a Apply 1 suggestion(s) to 1 file(s) 2023-06-12 13:49:18 +00:00
Nick Mathewson b19eb8648f Merge branch 'pt-snowflake' into 'main'
add documentation for configuring snowflake pt

Closes #879 and #875

See merge request tpo/core/arti!1216
2023-06-11 20:59:31 +00:00
Nick Mathewson 0313ca9f62 netdir: Wrap HsDir an Arc<>
This change reduces the cost of cloning a `NetDir`.  It's fine
since–although we replace the HsDir once–we never modify it once it
exists.

Closes #883.
2023-06-09 16:08:57 -04:00
Nick Mathewson a542a3e93f RelayId: Display the ID type on redacted identities.
Formerly we would display just the first characters of the identity,
without telling you what kind of ID it was.
2023-06-09 16:03:56 -04:00
Nick Mathewson a6ce079d4a linkspec: implement Display/Redacted on RelayIds 2023-06-09 16:03:56 -04:00
Nick Mathewson 979a2bd6a0 linkspec: Implement HasRelayIds::display_relay_ids(). 2023-06-09 15:50:25 -04:00
Nick Mathewson c76fbff125 proto: Have send_control_message take an AnyRelayMsg.
When we break the 1:1 relationship of message and cell, we'll want
this API to take messages, not cells.

This API is experimental, so we don't need to call it a semver
break.

Closes #881.
2023-06-09 15:28:01 -04:00
Nick Mathewson 58babcb756 proto: Correct the docs on send_control_message
Formerly we said that it would not return until the handler
was uninstalled.  This is incorrect: it returns as soon as the
message is sent and the handler installed.

Closes #885.
2023-06-09 15:22:15 -04:00
trinity-1686a a74bb8d4d8 add a few more comments on PTs 2023-06-09 20:15:25 +02:00
Ian Jackson 7231042343 tor-hsclient: Use send_control_message properly (fmt)
This re-indents the body of the trapping IEFE.
2023-06-09 17:47:35 +01:00
Ian Jackson e4a3498f28 tor-hsclient: Use send_control_message properly
The comment was entirely wrong.  send_control_message returns as soon
as the message has been enqueued.  So we actually *need* to wait for
the oneshot.

Also, given that a circuit collapse doesn't give us a real error, we
plumb the error through the oneshot.  Introduce an IEFE to capture the
error from the decoding.
2023-06-09 17:45:50 +01:00
Ian Jackson 8d71ceef9a tor-hsclient: Obtain reply_tx earlier
No functional change other than to error cases.

Will fit better with code to come in a moment.
2023-06-09 17:45:41 +01:00
Ian Jackson 27b76ffa3c tor-hsclient: Break out handle_proto_error
We're going to want to reuse this.
2023-06-09 17:45:29 +01:00
Ian Jackson c9cc76addb tor-hsclient: Add TODO for broken send_control_message use 2023-06-09 17:36:48 +01:00
Ian Jackson 9240ae55ba tor-hsclient: Discuss circuit parallelisation in sad case
Apropose
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/1228#note_2910588
2023-06-09 17:36:48 +01:00
Ian Jackson 5cc1323752 tor-hsclient: Add a TODO to retain the NetDir less long 2023-06-09 17:36:48 +01:00
Ian Jackson a9a59186fa tor-hsclient: Add some trace! temporarily
With this I see this:

    2023-06-09T12:26:27.698815Z DEBUG tor_hsclient::connect: hs conn to duckduckgogg42xjoc72x3sjasowoarfbgcmvfimaftt6twagswzczad.onion: RPT $36acd600bc8ea6c2800434778909ce3d83621358: sending ESTABLISH_RENDEZVOUS
    2023-06-09T12:26:27.699144Z TRACE tor_proto::circuit::reactor: Circ 1.0: reactor received SendMsgAndInstallHandler { msg: RelayCell { streamid: StreamId(0), msg: EstablishRendezvous(EstablishRendezvous { cookie: RendCookie(CtByteArray([220, 39, 37, 30, 37, 108, 111, 23, 127, 220, 50, 108, 161, 109, 229, 235, 110, 88, 233, 38])) }) }, sender: Sender { complete: false } }
    2023-06-09T12:26:27.699238Z TRACE tor_guardmgr: Received report of guard status guard_id=FirstHopId(Guard(Default, GuardId(RelayIds { ed_identity: Some(Ed25519Identity { 6lORxW93KRbhHFPNG0g+oBkXZbRnpwBzyfDcta7ed/M }), rsa_identity: Some(RsaIdentity { $f0c9c07d1b7c6fc8547f52cac1015b4a79e2ac1a }) }))) status=Success
    2023-06-09T12:26:27.699429Z TRACE tor_hsclient::connect: SEND CONTROL MESSAGE RETURNED
    2023-06-09T12:26:27.699966Z  INFO tor_guardmgr:💂 We have found that guard [scrubbed] is usable.
    2023-06-09T12:26:27.700030Z TRACE tor_guardmgr:💂 Guard status changed. guard_id=GuardId(RelayIds { ed_identity: Some(Ed25519Identity { 6lORxW93KRbhHFPNG0g+oBkXZbRnpwBzyfDcta7ed/M }), rsa_identity: Some(RsaIdentity { $f0c9c07d1b7c6fc8547f52cac1015b4a79e2ac1a }) }) old=Untried new=Reachable
    2023-06-09T12:26:27.700607Z TRACE tor_guardmgr: Known usability status guard_id=FirstHopId(Guard(Default, GuardId(RelayIds { ed_identity: Some(Ed25519Identity { 6lORxW93KRbhHFPNG0g+oBkXZbRnpwBzyfDcta7ed/M }), rsa_identity: Some(RsaIdentity { $f0c9c07d1b7c6fc8547f52cac1015b4a79e2ac1a }) }))) usable=true
    2023-06-09T12:26:27.701481Z DEBUG arti_client::status: 45%: connecting successfully; directory is fetching authority certificates (8/8)
    2023-06-09T12:26:27.765193Z TRACE tor_proto::circuit::reactor: Circ 1.0: handling cell: Relay(Relay { body: .. })
    2023-06-09T12:26:27.765284Z TRACE tor_proto::circuit::reactor: Circ 1.0: Received meta-cell UnparsedRelayCell { body: [39, 0, 0, 0  [[[ eldied -iwj ]]]] }
    2023-06-09T12:26:27.765352Z TRACE tor_hsclient::connect: SENDING VIA ONESHOT
    2023-06-09T12:26:27.765363Z TRACE tor_hsclient::connect: SENDING VIA ONESHOT DONE
    2023-06-09T12:26:27.765367Z TRACE tor_proto::circuit::reactor: Circ 1.0: meta handler completed with result: Ok(UninstallHandler)
    2023-06-09T12:26:29.588045Z DEBUG tor_hsclient::connect: hs conn to duckduckgogg42xjoc72x3sjasowoarfbgcmvfimaftt6twagswzczad.onion: attempt failed: error: internal error (bug) at /volatile/rustcargo/Rustup/Arti/arti/crates/tor-hsclient/src/connect.rs:725:28: RENDEZVOUS_ESTABLISHED not sent yet

This seems to suggest that send_control_message is returning sooner
than expected.
2023-06-09 17:36:48 +01:00
Ian Jackson 7be005b05d tor-hsclient: Add a lot of debug! (fmt) 2023-06-09 17:36:48 +01:00
Ian Jackson 2a34f69c88 tor-hsclient: Add a lot of debug! 2023-06-09 17:36:48 +01:00
Ian Jackson 57f295cc21 safelog: Provide Redacted.as_inner() and .as_ref()
Just like for Sensitive.
2023-06-09 17:36:48 +01:00
Ian Jackson c679e8706a tor-hsclient: Add missing `#[source]` annotation for `Failure` error
Without this, the printed errors are very bland.
2023-06-09 17:36:48 +01:00
Ian Jackson 16d58d641e tor-hsclient: Discuss gold-plated handling of RENDEZVOUS_ESTABLISHED 2023-06-09 17:36:48 +01:00
Ian Jackson 1fb4c1eb2a tor-hsclient: Check RENDEZVOUS_ESTABLISHED *after* it should exist
Bugfix, without which this code wouldn't work.

Reported in
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/1228#note_2910293
2023-06-09 17:36:48 +01:00
Ian Jackson 180f1dcb47 tor-hsclient: Discuss performance and circuit build serialisation 2023-06-09 17:36:48 +01:00
Ian Jackson 4b94b63081 tor-hsclient: Add TODO about trying multiple IPTs in parallel 2023-06-09 17:36:48 +01:00
Ian Jackson a4755e2e46 tor-hsclient: Expand TODO about IPT selection to mention randomness 2023-06-09 17:36:48 +01:00
Ian Jackson 2f838dce15 tor-hsclient: tuning parameters: TODO about getting from the netdir
As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/1228#note_2910286

Not thinking about this right now, but it seems like a reasonable
suggestion.
2023-06-09 17:36:48 +01:00
Ian Jackson 00d5978999 tor-hsclient: Add vacuous doc comments
As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/1228#note_2910284
2023-06-09 17:36:48 +01:00
Ian Jackson b2faf02170 tor-hsclient: Add a TODO for changing RendPtIdentityForError 2023-06-09 17:36:48 +01:00
Ian Jackson bcbe66f636 tor-hsclient: Improve description of `Context`
Be more specific about precisely what it's the context for, and its
lifetime.
2023-06-09 17:36:48 +01:00
Ian Jackson 4e2321086f tor-hsclient: Correct InvalidTarget error
Remove TODO comment; instead, replace with a comment about future use
for HS server side, inspired by
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/1228/diffs?commit_id=ecfd39507c4e8d52788f4599d6275cab3b4a2a5f#c0123bb2f6b9a9ca50fa45886b667580a7dc951e_79_82

Do not implment `tor_error::HasKind`; the true kind depends on where
the bad information came from, which the calling code will understand.
As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/1228/diffs?commit_id=d63ad3ab041460bf85defb99b31d6ebe075a0eb1#c0123bb2f6b9a9ca50fa45886b667580a7dc951e_101_110
2023-06-09 17:36:48 +01:00
Ian Jackson 742462deae tor-hsclient: mocks: Fix new code to use mockable ClientCirc 2023-06-09 17:36:48 +01:00
Ian Jackson 6c377cdeec tor-hsclient: mocks: Make MockableClientCirc be Debug 2023-06-09 17:36:48 +01:00
Ian Jackson cead8e2716 tor-hsclient: mocks: Provide send_control_message
We were able to get as far as we have, merely because all the new code
uses just Arc<ClientCirc> rather than the mockable version.

We want to change that, so we need to mock this function too.
2023-06-09 17:36:48 +01:00
Ian Jackson 8e5814c683 tor-hsclient: Call the mock with the result circuit 2023-06-09 17:36:48 +01:00
Ian Jackson 90a48f5b52 tor-hsclient: Define representation of intro point experience data
This is the data structure for recording IPT outcomes and, later,
selecting a good IPT to try for a new connection.
2023-06-09 17:36:48 +01:00
Ian Jackson c2952a5b20 tor-hsclient: Implement rendezvous setup, and retry framework
This contains code to:

 * Iterate over introduction points
 * Make multiple attempts to connect
 * Apply timeouts to the various phases of each attempt
 * Establish a rendezvous point
 * Represent errors that occur during the above

It provides places to add:

 * Implementation of the INTRODUCE1/INTRODUCE_ACK handshake
 * Reception of RENDEZVOUS2 and actual end-to-end circuit establishment
 * Recording of the outcome of connection attempts via particular IPTs
 * Using previous IPT outcome information for selecting IPTs to try
 * Tests of the new code (although more mocking will probably be needed)

Much of this code works with a fixed type ClientCirc rather than going via
the Mockable traits.  That is wrong, and it will be fixed later.
2023-06-09 17:36:48 +01:00
Ian Jackson 4827ce8548 tor-error: Extend applicability of RemoteNetworkTimeout
We're going to use this for rendezvous completion timeout, which could
be due to basically anything.
2023-06-09 17:36:48 +01:00
Ian Jackson f194819b9e tor-hsclient: errors: Introduce IntroPtIndex
We're going to want to report about rendezvous points in errors.

We'll do this by printing the "number" of the intro point in the descriptor.
2023-06-09 17:36:48 +01:00
Ian Jackson f40b21304d tor-hsclient: errors: Introduce RendPtIdentityForError
We're going to want to report about rendezvous points in errors.
We'll be using this.  And we'll want to convert it from a Relay.
2023-06-09 17:36:48 +01:00
Ian Jackson cfbd318132 tor-hsclient: Allow dead code for now
The dead code warnings are a nuisance while this file is half-written.
2023-06-09 17:36:48 +01:00
Ian Jackson 02b10a147c tor-hsclient: Mocks: Add get_or_launch_client_rend to mock pool
This has the wrong return type at the moment.
2023-06-09 17:36:48 +01:00
Ian Jackson 5bf917650a tor-hsclient: Mock trait: use actual HsCircPool in non-mock impl
The impl was in terms of itself.  Sadly, nothing warns about this bug.
2023-06-09 17:36:48 +01:00
Ian Jackson 9d22ce9f8a tor-hsclient: impl HasKind for InvalidTarget: ..DescriptorValidationFailed
This basically always means we couldn't cope with the descriptor.

We need to extend the description of OnionServiceDescriptorValidationFailed
2023-06-09 17:36:48 +01:00
Ian Jackson 33c90e5b72 tor-error: Introduce define_asref_dyn_std_error and use it
This factors out an ad-hoc AsRef impl.  We're going to want to reuse
this for another error type.
2023-06-09 17:36:48 +01:00
Ian Jackson f2f76f4f31 tor-hsclient: Have descriptor_ensure take only &mut data.desc
It returns a borrow (so whatever is passed remains borrowed) and the
next phase is going to need to perhaps mutate other parts of data, so
we must pass only what is needed.
2023-06-09 17:36:48 +01:00
Ian Jackson ccc9a35afe tor-hsclient: Move &mut Data out of Context, and pass &Context (fmt) 2023-06-09 17:36:48 +01:00
Ian Jackson 62f3981d27 tor-hsclient: Move &mut Data out of Context, and pass &Context
Now Context can be usefully shared, across different
threads/tasks/functions, so long as only one of them needs to modify
`Data`.
2023-06-09 17:36:48 +01:00
Ian Jackson 065ba51f93 tor-hsclient: export InvalidTarget
It's going to appear in our public errors.
2023-06-09 17:36:48 +01:00
Ian Jackson cbce8697b6 tor-hsclient: Add a TODO for InvalidTarget error 2023-06-09 17:36:48 +01:00
Alexander Færøy ab73cf9e8b Merge branch 'report-trait-doc-fix' into 'main'
Expand arti-client docs to include error reporting section

See merge request tpo/core/arti!1213
2023-06-09 13:12:48 +00:00
Alexander Færøy f48789f494 Merge branch 'warning' into 'main'
Fix a silly clippy warning

See merge request tpo/core/arti!1226
2023-06-09 12:25:04 +00:00
Ian Jackson a50016b3da tor-hscrypto: implement Rng.gen() for RendCookie 2023-06-09 12:24:24 +01:00
Ian Jackson dc95c7874a tor-hscrypto: Break out REND_COOKIE_LEN
We need to reuse this.
2023-06-09 12:24:19 +01:00
trinity-1686a b7fd5a6778 change path to snowflake client 2023-06-08 20:19:59 +02:00
Ian Jackson e35cd4f115 Fix a silly clippy warning
Fixes
  nailing-cargo +stable clippy -p tor-hsclient --all-features --all-targets
2023-06-08 15:29:06 +01:00
Alexander Færøy 174332640d Merge branch 'hsclient-feature' into 'main'
hs: Fix a feature name in arti-client

See merge request tpo/core/arti!1222
2023-06-08 14:15:06 +00:00
Ian Jackson de995c1164 Expand docs for NetDirProvider
Apropos a question that arose on IRC, to which I felt the answer
wasn't 100% unambiguous.

Also, reference the usual implementation (it can't be a link because
it's an upward reference).
2023-06-08 10:47:29 +01:00
trinity-1686a b3c8004f8d change link for more information on pts 2023-06-08 09:20:07 +02:00
Saksham Mittal 6e97b9df1f
Rephrase error handling to reporting 2023-06-08 10:26:52 +05:30
Saksham Mittal 3f7709f98d
Add error handling section in README 2023-06-08 10:26:52 +05:30
Saksham Mittal 724cab8a28
Add separate example with Report 2023-06-08 10:26:38 +05:30
trinity-1686a 73b0bc3561 remove forgoten debug line 2023-06-08 01:29:33 +02:00
trinity-1686a 9c3c7f4bc3 add anchor to amp-cache link 2023-06-08 00:28:58 +02:00
trinity-1686a 925ac7f9d7 complement general documentation on bridges and pt 2023-06-07 23:59:03 +02:00
trinity-1686a 4632d4ff44 move snowflake example to dedicated file and comment it more 2023-06-07 23:59:03 +02:00
trinity-1686a c528443bf4 add documentation for configuring snowflake pt 2023-06-07 23:59:03 +02:00
Nick Mathewson 999f914e03 rpc: make decl_object! responsible for writing impl Object {} blocks. 2023-06-07 14:37:04 -04:00
Nick Mathewson 924dbf7d8f Merge branch 'ipt_to_circtarget' into 'main'
Construct a CircTarget from an IntroPointDesc.

See merge request tpo/core/arti!1221
2023-06-07 12:35:26 +00:00
Nick Mathewson bdb96b4ac1 hs: Fix a feature name in arti-client
In arti-client it's called "onion-client", not "hs-client".
2023-06-07 08:21:22 -04:00
Nick Mathewson 618ed48cea hsclient: Create a CircTarget from an IntroPointDesc.
The main body of this function is written so that we can later use
it to create a CircTarget from an INTRODUCE2 message.
2023-06-07 07:55:45 -04:00
Alexander Færøy 2877140075 Merge branch 'access' into 'main'
hsdesc docs: Provide some accessors

See merge request tpo/core/arti!1220
2023-06-06 17:54:12 +00:00
Nick Mathewson 205b6d176c netdir, netdoc: Add accessors for protocol version status.
The consensus includes a listing for clients and for relays,
saying which protocol versions are _required_ for participation on
the network, and which versions are _recommended_.  We have been
parsing this, but not yet exposing it.

This commit adds accessors to expose it, since we'll need that in
order to create CircTargets for introduction points and rendezvous
points.
2023-06-06 09:06:01 -04:00
Nick Mathewson e7ebb31009 Merge branch 'remove_arrayref' into 'main'
Remove use of arrayref

Closes #872

See merge request tpo/core/arti!1214
2023-06-06 00:37:31 +00:00
Nick Mathewson 362a1f8ac1 arti: Interpret socks request to mean "lookup an RPC session"
The actual decoding here is just a placeholder.  The important part
is that we can get either a (SessionId, StreamId) tuple out of the
request, or we treat it as part of an isolation token.

This commit has a few TODOs for additional things that we'll need
in order to build out our design.
2023-06-05 14:47:38 -04:00
Nick Mathewson 291c739003 arti: Move SOCKS code for building StreamPrefs and getting a TorClient. 2023-06-05 14:46:51 -04:00
Nick Mathewson 05e9bc199b arti: Add an alias in the SOCKS code for per-conn isolatino info.
This enables some small simplifications.
2023-06-05 14:46:51 -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 9f51bcb0be RPC: tell the `arti` SOCKS code about an RpcMgr object.
It will use this to find which TorClient to use when opening a
stream.
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 b7feb034a9 RPC: Let objects declare that they need a GlobalId. 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
Ian Jackson 9a30d76ea6 hsdesc: Add minimal set of accessors for HsDesc and IntroPointDesc 2023-06-05 19:33:31 +01:00
Ian Jackson 8382927080 hsdesc docs: Don't imply that a thing has been done, which hasn't yet 2023-06-05 19:20:45 +01:00
Ian Jackson fa324f76de hsdesc docs: Use the definite article
These are (I hope) the only key matching the description.  If they're
not, the description needs to be expanded.
2023-06-05 19:20:13 +01:00
Ian Jackson 660726b2f0 tor-circmgr: send_control_message: Add reference to MR discussion 2023-06-05 13:54:49 +01:00
Ian Jackson bfe575bc64 tor-circmgr: send_control_message: Change a rename proposal
As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/1218#note_2908119
2023-06-05 13:51:01 +01:00
Ian Jackson 9b36697282 tor-circmgr: send_control_message: Fix reference to circuit 2023-06-05 13:50:51 +01:00
Ian Jackson e35d4e6a46 tor-circmgr: send_control_message: API change proposal
I am hoping we can merge this as a "TODO (Diziet)",  even though I
think it may be controversial.  Ie merging this doesn't represent a
decision to do as I suggest.
2023-06-05 13:19:58 +01:00
Ian Jackson eecbf85b4c tor-circmgr: Propose to rename `MetaCellDisposition::UninstallHandler` 2023-06-05 13:19:58 +01:00
Ian Jackson a9ff778ba5 tor-circmgr: send_control_message: Clarify some corner cases
Also, no longer talk about handlers being "installed".  That's not
something that's exposed by this API.

And, say that `send_control_message` can be called again only
after *`send_control_message`* returns, not when `handle_msg` has
returned `UinstallHandler`.  IMO this makes more sense.

Explain that we can't maintain a continuous watch while holding a
conversation with the peer.  (This is surely an API bug.)
2023-06-05 13:19:58 +01:00
Nick Mathewson 469f62a983 Remove semver.md files from 1.1.5 2023-06-01 14:08:24 -04:00
Ian Jackson 254d4c93a7 Merge branch 'bump-versions-v115' into 'main'
Bump crate versions in preparation for v1.1.5 release.

See merge request tpo/core/arti!1211
2023-06-01 17:32:41 +00:00
Nick Mathewson 0bf44b1393 tor-cell: remove use of arrayref
Closes #872
2023-06-01 11:14:48 -04:00
Nick Mathewson dfcbd7d4ee tor-llcrypto: remove use of arrayref 2023-06-01 10:50:25 -04:00
Nick Mathewson 744d32d554 tor-netdoc: remove use of arrayref. 2023-06-01 10:36:35 -04:00
Nick Mathewson 46d2a768a1 tor-proto: Remove use of arrayref. 2023-06-01 10:32:00 -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
Tor CI Release 3aef515135 fallbackdir: Update list generated on June 01, 2023
Signed-off-by: Tor CI Release <no-email@torproject.org>
2023-06-01 09:41:28 -04:00
Nick Mathewson 8d32e1f65f Run fixup-features script and resolve its complaints. 2023-05-31 08:04:10 -04:00
Nick Mathewson 244ec5dce2 tor-bytes: Remove use of arrayref
Part of #872: Now that const generics are in, we have better ways to
express converting slices into array-references.
2023-05-25 14:48:57 -04:00
Nick Mathewson 6703f3d52a Merge branch 'stream_ctrl' into 'main'
Experimental new stream-ctrl feature

Closes #847

See merge request tpo/core/arti!1198
2023-05-24 20:01:40 +00:00
Nick Mathewson e4758a754e Add "TODO RPC" notes around DataStreamCtrl per review. 2023-05-24 15:25:33 -04:00
Nick Mathewson a397ca77d9 proto: Add stream-status functionality to DataStreamCtrl.
There are some weaknesses and problems here; see TODO notes.
2023-05-24 15:25:33 -04:00
Ian Jackson 14b7fae113 Merge branch 'virtual_conditional' into 'main'
proto: Make PathEntry::Virtual feature-conditional.

See merge request tpo/core/arti!1201
2023-05-24 14:57:24 +00: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 7178ab85eb Merge branch 'real_generational_arena' into 'main'
rpc: Use the real generational-arena crate

See merge request tpo/core/arti!1203
2023-05-24 14:50:20 +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 15a8644bf7 rpc: fix documentation for methods in Context. 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 24d67594d7 cell: Make EstablishRendezvous contain a RendCookie. 2023-05-23 13:33:07 -04:00
Nick Mathewson 278e2fea79 Merge branch 'socks-read-fix' into 'main'
Fix a local-only CPU DoS bug.

Closes #861

See merge request tpo/core/arti!1196
2023-05-23 15:28:00 +00:00
Nick Mathewson 03c81ae5aa proto: Make PathEntry::Virtual feature-conditional.
This fixes a warning when building tor-proto without the
`rpc-common` feature.
2023-05-23 10:59:37 -04:00
Nick Mathewson 03cb91012d Fix a local-only CPU DoS bug.
Previously, there was a bug in the way that our code used our SOCKS
implementations.  If the buffer used for a SOCKS handshake became full
without completing the handshake, then rather than expanding the buffer
or closing the connection, our code would keep trying to read into the
zero-byte slice available in the full buffer forever, in a tight loop.

We're classifying this as a LOW-severity issue, since it is only
exploitable by pluggable transports (which are trusted) and by
local applications with access to the SOCKS port.

Closes #861.

Fixes TROVE-2023-001.

Reported-By: Jakob Lell <jakob AT srlabs DOT de>
2023-05-23 10:48:27 -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
Ian Jackson 5ba7f31c1d tor-hsclient: Mockable: Do concrete calls with UFCS
Method dispatch rules mean that if the receiver type of the actual
function changes, `self.call()` can turn into a purely-recursive call
which overflows the stack.

Async Rust doesn't have the usual warning for this situation :-(.

UFCS is clumsier but doesn't have that problem because it involves
much less magical dispatch.  Instead of generating a recursive call
which overflows the stack, it fails to compile.
2023-05-23 12:47:33 +01:00
Ian Jackson 79b9a26df0 tor-hsclient: Fix MockableClientCirc for ClientCirc changes
ClientCirc::begin_dir_stream now takes Arc<Self>.  Method resolution
rules mean that this code would just recurse, leading to a stack
overflow.
2023-05-23 12:47:33 +01:00
Nick Mathewson 0df0cf4250 proto: Create a `DataStreamCtrl` type.
The idea here is that we want to make DataStream visible to the
RPC system without requiring that the RPC session hold the
DataStream itself (or the Reader, or the Writer).  We could solve
this problem by making _all_ the state in the DataStream shared,
but that would introduce unnecessary extra locking in our critical
path.

Instead we're creating the notion of a "control handle" that lets
you manage and observe a stream without actually owning the stream.

Right now the only supported functionality is asking for the
stream's circuit.

Part of #847
2023-05-22 11:27:44 -04:00
Ian Jackson 1fc1c269c3 Fix a docs reference to refer to HsClientIntroAuthKeypair
Fixes warning from
  cargo -o doc --document-private-items --all-features --workspace

This was evidentlhy overlooked during recent replacement of unescorted
private keys in the code.
2023-05-22 14:30:16 +01:00
Nick Mathewson 0765412fc8 proto: Add a new experimental stream-ctrl feature.
(It doesn't do anything yet. It may eventually become always-on.
But for now let's make this API optional.  Part of #847)
2023-05-22 09:07:03 -04:00
Nick Mathewson b55a3ade33 tor-proto: Move a comment in Cargo.toml 2023-05-22 09:04:44 -04:00
Nick Mathewson 9848155f59 Upgrade notify dependency to 6.0 2023-05-22 07:54:10 -04:00
Nick Mathewson a179d10ad4 Upgrade async-compression dependency to 0.4.0. 2023-05-22 07:52:18 -04:00
Nick Mathewson 16c992ecd3 Upgrade memmap2 dependency to 0.6.1. 2023-05-22 07:51:22 -04:00
Nick Mathewson 512455da96 Upgrade serde_with dependency to 3.0.0 2023-05-22 07:49:58 -04:00
Nick Mathewson df9ff46b80 tor-rtcompat: Say default-features with a dash, not an underscore.
(`cargo-upgrade` warns about this.)
2023-05-22 07:49:28 -04:00
Ian Jackson 26af92ca10 Merge branch 'clippy-nightly' into 'main'
Fix a few warnings from clippy nightly

See merge request tpo/core/arti!1193
2023-05-22 10:49:10 +00:00
Nick Mathewson 4b9d6b255e Merge branch 'escorted_25519_secrets' into 'main'
Refactor code not to use unescorted ed25519 secrets

Closes #798

See merge request tpo/core/arti!1192
2023-05-18 18:48:05 +00:00
Nick Mathewson 9773633a84 hscrypto: Remove an incorrect comment.
(It said that we want to deprecate all unescorted secret keys; in
fact, only unescorted EdDSA secrets are bad.)
2023-05-18 14:18:53 -04:00
Nick Mathewson 82801d9963 netdoc, hsclient: Update remaining ed25519::SecretKey users
Fortunately, these are all in experimental code.

Closes #798
2023-05-18 14:18:53 -04:00
Nick Mathewson 66c06ecc9c hscrypto: Replace ed25519 secret keys with keypairs
Part of #798: We no longer use unescorted ed25519 secret keys.
2023-05-18 14:18:53 -04:00
Nick Mathewson f333c9029a Merge branch 'virtual_hop' into 'main'
tor-proto: Add support for extending circuits through virtual hops.

Closes #726

See merge request tpo/core/arti!1191
2023-05-18 17:14:01 +00:00
Nick Mathewson e8e40e66f6 chanmgr: fix a unit-default warning from clippy nightly.
I could also have stopped using `::default()` to construct this
(testing-only) object, but I think it makes more sense to turn it
into a non-unit object.
2023-05-18 12:57:57 -04:00
Nick Mathewson 41863bd622 guardmgr, netdir: fix some needless-mut warnings
Found by clippy nightly
2023-05-18 12:54:55 -04:00
Nick Mathewson 45571b3ec7 guardmgr: suppress a clippy-nightly warning.
I don't love this change, but apparently we are trying for
"consistency".
2023-05-18 12:52:19 -04:00
Nick Mathewson 6f80caed9d proto: Explain "virtual" hops better.
Based on text from @diziet
2023-05-18 12:40:02 -04:00
Nick Mathewson 0230e7bccc proto: Try to improve the documentation in crypto/cell.rs 2023-05-18 12:40:02 -04:00
Nick Mathewson 3b7a20ef4c proto: Allow circuit Paths to represent virtual hops.
Sadly, this adds a few more `TODO HS` entries, but I think we can
clean them up later after a bit of discussion.
2023-05-18 12:40:02 -04:00
Nick Mathewson 663f25d44c proto: Implement Circuit::extend_virtual.
There are a few new TODO hs comments, though, and an XXXX I'll need
to fix up in the next commit.

Implements #726.
2023-05-18 12:40:02 -04:00
Nick Mathewson b9a848a7ac tor-proto: Code to construct crypto layers for virtual hops.
This is fairly straightforward, thanks to our existing design work
on this code.
2023-05-18 12:40:02 -04:00
eta 4665835ee8 tor-guardmgr, tor-proto: minor logging tweaks
- We make the tor-guardmgr "We have found that {} is usable" line
  include the word "guard", otherwise it doesn't appear very useful to a
  user in safe logging mode, since the guard gets replaced with
  [scrubbed].
- The "Actually got an end cell..." message is downgraded to DEBUG.
2023-05-18 16:04:11 +01:00
Nick Mathewson dcec7ca2dc llcrypto: Don't take or return "unescorted" ed25519 keys.
Per #798, we want to make sure that we never pass around an
`ed25519::SecretKey`; only an `ed25519::Keypair` (or
`ExpandedKeypair`).  This is because, when you're computing an
ed25519 signature, you have to use the public key as one of your
inputs, and if you ever use a mismatched public key you are
vulnerable to a nonce reuse attack.

(For more info see
https://moderncrypto.org/mail-archive/curves/2020/001012.html )
2023-05-18 11:00:43 -04:00
Nick Mathewson 2ffb200a77 llcrypto: Add an `ed25519::ExpandedKeypair` type.
This is like an `ed25519::Keypair`, except that instead of a
`SecretKey` it contains an `ExpandedSecretKey`.

We'll be using this to implement #798, where we impose a rule that
there must be no "unescorted" ed25519 secret keys.
2023-05-18 10:56:43 -04:00
Nick Mathewson a8b6f19552 Merge branch 'hs_handshake' into 'main'
Clean up hs_ntor.rs, add test vectors generated by C tor, and fix some bugs

Closes #865

See merge request tpo/core/arti!1189
2023-05-18 13:25:07 +00:00
Nick Mathewson 07e2ed0e5c cell: Make Introduce2::new testing-only.
We never want to create one of these from its parts except when we
are testing it; we only want to forward an Introduce1 message with a
new command on it.
2023-05-17 16:22:35 -04:00
Nick Mathewson c3c44cea67 cell: Record the text of an INTRODUCE2 header
We'll need to store this so that it can later on be used to complete
the hs_ntor handshake.
2023-05-17 16:22:35 -04:00
Nick Mathewson d008c385d5 hs_ntor: several documentation cleanups. 2023-05-17 16:18:55 -04:00
Nick Mathewson 954b41dcf1 hs_ntor: make encrypt_and_mac take a typed public key
This is still not the most beautiful interface, but it'll do for now.
2023-05-17 16:18:55 -04:00
Nick Mathewson 50ce084d64 hs_ntor: remove the last lingering AsRef<[u8]> 2023-05-17 16:18:55 -04:00
Nick Mathewson a6fd8fb347 hs_ntor: Add a test vector case extracted from C tor. 2023-05-17 16:18:55 -04:00
Nick Mathewson 20d6c4b247 hs_ntor: Calculate MAC on introduce1 message correctly.
There were two bugs here that made the behavior unlike that of C
tor: we had swapped the MAC inputs, and we had forgotten to include
the public key X in the input.
2023-05-17 16:18:55 -04:00
Nick Mathewson 1f665d1144 hs_ntor: Make internal no-rng variants of the handshake functions.
We'll want these so we can implement some test vectors.
2023-05-17 16:18:55 -04:00
Nick Mathewson ceaeb61168 hs_ntor: Move extra data outside of the "input" fields.
I think that these Input structs had been defined so that we could
use hs_ntor interchangeably with other handshakes.  The trouble is,
though, that it doesn't really work like any other handshakes we
have.
2023-05-17 16:18:55 -04:00
Nick Mathewson 54665c2b65 hs_ntor: Use MAC implementation from tor-hscrypto
Note that some of the invocations for this function seem to put the
key and the message in a questionable order.  But that's a thing to
figure out later, while debugging.
2023-05-17 16:18:55 -04:00
Nick Mathewson c8ad9450c2 hs_ntor: Use correct PK types from tor_hscrypto. 2023-05-17 16:18:55 -04:00
Nick Mathewson 9d5dd813c0 hs_ntor: Use Subcredential type from tor-hscrypto 2023-05-17 16:18:55 -04:00
Nick Mathewson a6ad49b22b cell: extract introduce headers into a new type.
We'll want this because our hs_ntor handshake requires access to an
encoded version of the header independent from the actual encrypted
message.

part of #866.
2023-05-17 11:06:28 -04:00
gabi-250 ac0eb05a07 Merge branch 'info-to-warn' into 'main'
Change log levels of messages from INFO to others

Closes #854

See merge request tpo/core/arti!1172
2023-05-17 12:41:26 +00:00
Saksham Mittal e9dff1c0d7
Change log level to debug and warn for certain appropriate situations
This commit changes certain log messages to debug for recoverable errors
and a warn if all such attempts fail, in order to not clutter up the
info messages that end users get to see.
2023-05-17 17:28:22 +05:30
gabi-250 fb8bc19b9b Merge branch 'arc_circ' into 'main'
Refactor ClientCirc APIs to use Arc<ClientCirc>.

Closes #846

See merge request tpo/core/arti!1187
2023-05-17 09:47:19 +00:00
Nick Mathewson b84f122aab Merge branch 'ticket_759' into 'main'
tor-cert: Replace the KeyUnknownCert::check_key API

Closes #759

See merge request tpo/core/arti!1184
2023-05-16 22:23:17 +00:00
Nick Mathewson dfa19998e2 Merge branch 'resolve_relay' into 'main'
netdir: New function to check consistency of a HasRelayIds

Closes #855

See merge request tpo/core/arti!1186
2023-05-16 22:12:29 +00:00
Nick Mathewson 9d54c7973b Deprecate check_key, and refactor its logic into the new functions.
Closes #759
2023-05-16 17:53:15 -04:00
Nick Mathewson 56c6e4345b Replace usage of KeyUnknownCert::check_key. 2023-05-16 17:53:15 -04:00
Nick Mathewson eb356323bd tor-cert: Add new functions to replace KeyUnknownCert::check_key.
These should have a cleaner API than check_key, and be easier to
understand.

Part of #759
2023-05-16 17:53:15 -04:00
Nick Mathewson 4a779807e8 netdir: New function to check consistency of a HasRelayIds
This function will be used to look up a relay by a set of LinkSpecs
given from an incoming HsDesc or INTRODUCE2 message.  It differs
from other "lookup relay by IDs" functions in that it needs to be
able to return "here's a relay", "couldn't found a relay", or
"learned that this relay is impossible."

Closes #855: This is the only new API needed for ChanTarget
validation, I think.
2023-05-16 17:45:21 -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
Nick Mathewson ee390c423e Refactor ClientCirc APIs to use Arc<ClientCirc>.
Now ClientCirc is no longer `Clone`, and the things that need it
to be `Clone` instead return and use an Arc<ClientCirc>
We're doing this so that ClientCirc can participate in the RPC
system, and so that its semantics are more obvious.

Closes #846.

Thanks to the type system, this was a much simpler refactoring than
I had feared it would be.
2023-05-16 09:02:09 -04:00
Nick Mathewson 2e1115acc3 rpc: Change the formatting of object IDs
We want each ID to have a unique form every time it is given out,
so that you can't use ID==ID to check whether Object==Object.  (See
discussions leading to #848.)

We'd also like the form of object IDs to be a little annoying to
analyze, to discourage people from writing programs that depends on
their particular format.  (We are reserving the right to change the
format whenever we want.)

We _don't_ want to use any cryptography here (yet), lest somebody
think that this is an actual security mechanism.  (This isn't for
security; it's for encouraging developers to treat IDs as opaque.)

With that in mind, we now lightly obfuscate our generational indices
before returning them.
2023-05-15 15:59:58 -04:00
Nick Mathewson 8531ed2dad rpc: rename GenIdx::into/try_from implementations
These are about to become nondeterministic-ish and probably shouldn't
use the Into/TryFrom traits.
2023-05-15 15:26:58 -04:00
Nick Mathewson 0d207028ce rpc: do not deduplicate strong object ids
Per discussion referenced at #848, we want each operation that
returns a strong object ID to return a new, distinct strong ID.

Note that we no longer need to put strong and weak references in the
same arena; we can clean this code up a lot down the road.
2023-05-15 15:26:53 -04:00
Nick Mathewson c9819455e1 rpc: Repair an error in our ObjectId encoding.
Now we generate object IDs that we can parse.  This is about to be
obsolete once we change how we generate objects and their IDs for #848,
but we may as well start from a working state.
2023-05-15 13:48:47 -04:00
Nick Mathewson 6fa821238d Revise all XXXXs from fixup-features 2023-05-15 11:00:28 -04:00
Nick Mathewson 4b08ef76a0 Run fixup-features _with_ annotations.
This litters our Cargo.toml files with "XXX" entries that we should
fix.
2023-05-15 10:41:32 -04:00
Nick Mathewson e2e125fef7 Reformat Cargo.toml files. 2023-05-15 09:09:43 -04:00
Nick Mathewson 7a5373c110 Run fixup-features --no-annotate for initial Cargo.toml fixes.
This does the following:
  - Gives every crate a `full`.
  - Cause every `full` to depend on `full` from the lower-level
    crates.
  - Makes every feature listed _directly_ in `experimental` depend
    on `__is_experimental`.
2023-05-15 09:07:21 -04:00
Nick Mathewson 0109dd09d4 Merge branch 'better-fixup-features' into 'main'
Revise fixup-features to be closer to something we can use

See merge request tpo/core/arti!1180
2023-05-15 13:04:34 +00:00
Nick Mathewson b38567e34a Mark an initial set of non-additive features. 2023-05-15 08:27:48 -04:00
Nick Mathewson bfda3082d4 Use non-deprecated *Secret::random_from_rng.
The `new` function is deprecated in x25519-dalek 2.0.0-rc.2
2023-05-13 16:52:23 -04:00
Nick Mathewson bedc47afe7 llcrypto: upgrade x25519-dalek.
This upgrades us to 2.0.0-rc.2, which is the latest in the
not-quite-done-yet 2.0 series.

The only code change that's absolutely needed is opting into the
static_secrets feature.
2023-05-13 16:46:47 -04:00
Gabriela Moldovan c4def3cfca
tor-basic-utils: Add unbounded range (..) test.
Signed-off-by: Gabriela Moldovan <gabi@torproject.org>
2023-05-13 12:49:10 +01:00
Gabriela Moldovan ef53c4235d
tor-basic-utils: Update combinatorial test to randomly choose an open or closed bound.
Signed-off-by: Gabriela Moldovan <gabi@torproject.org>
2023-05-13 12:49:06 +01:00
Gabriela Moldovan 27ae57e543
tor-basic-utils: Add rangebounds test with time ranges.
Signed-off-by: Gabriela Moldovan <gabi@torproject.org>
2023-05-13 12:49:03 +01:00
Gabriela Moldovan 9d4db38d4d
tor-basic-utils: Assert witness is not part of the intersection.
Signed-off-by: Gabriela Moldovan <gabi@torproject.org>
2023-05-13 12:48:59 +01:00
Gabriela Moldovan 18c78c3ad3
tor-basic-utils: Log the ranges/intersection on assertion failure.
Signed-off-by: Gabriela Moldovan <gabi@torproject.org>
2023-05-13 12:48:56 +01:00
Gabriela Moldovan f9c6cc11bb
netdoc: Use the RangeBoundsExt impl of TimerangeBound.
We can now get rid of the standalone `intersect_bounds` function.

Signed-off-by: Gabriela Moldovan <gabi@torproject.org>
2023-05-13 12:48:52 +01:00
Gabriela Moldovan 094287e677
tor-checkable: Implement RangeBounds for TimerangeBound.
By implementing `RangeBounds` for `TimerangeBound`, we get
`RangeBoundsExt` for free. This will enable `parse_decrypt_validate` to
easily compute the intersection of the `TimerangeBound`s its layers.

Signed-off-by: Gabriela Moldovan <gabi@torproject.org>
2023-05-13 12:48:49 +01:00
Gabriela Moldovan 11c39b5657
tor-basic-utils: Add a helper function to deduplicate test code.
Signed-off-by: Gabriela Moldovan <gabi@torproject.org>
2023-05-13 12:48:44 +01:00
Gabriela Moldovan 872f5da4b2
tor-basic-utils: Add RangeBoundsExt trait.
Signed-off-by: Gabriela Moldovan <gabi@torproject.org>
2023-05-13 12:48:41 +01:00
Gabriela Moldovan 6992427596
hsclient: descriptor_ensure no longer wraps the descriptor in TimerangeBound.
`descriptor_fetch_attempt` now returns a `TimerangeBound<HsDesc>` (and
so does `parse_descript_validate`).

Signed-off-by: Gabriela Moldovan <gabi@torproject.org>
2023-05-13 12:48:37 +01:00
Gabriela Moldovan 9dbf162c90
netdoc: Do not consume EncryptedHsDesc when decrypting.
`parse_decrypt_validate` will need to "peek" inside an encrypted
descriptor (before validating it) to extract the `TimerangeBound` of the
inner layer. This is needed to compute the intersection of the
`TimerangeBound`s of both layers.

Signed-off-by: Gabriela Moldovan <gabi@torproject.org>
2023-05-13 12:48:23 +01:00
Gabriela Moldovan 92e0b6a029
hsclient: Compute HsDesc validity time from the TimerangeBounds of its layers.
This makes `descriptor_ensure` refetch the descriptor if either of its
layers (inner or outer) expires.

Signed-off-by: Gabriela Moldovan <gabi@torproject.org>
2023-05-13 12:48:20 +01:00
Gabriela Moldovan 919790c632
tor-checkable: Add a way to compute the intersection of 2 RangeBounds.
This will be used for computing the final `TimerangeBound` of a `HsDesc`
from the `TimerangeBound`s of its inner and outer layers.

Signed-off-by: Gabriela Moldovan <gabi@torproject.org>
2023-05-13 12:48:16 +01:00
Gabriela Moldovan 88ea5032f4
hsclient: Build cached descriptor TimerangeBounds from descriptor lifetime.
This makes `descriptor_ensure` refetch the descriptor if it has been
cached for longer than `descriptor-lifetime` minutes.

Signed-off-by: Gabriela Moldovan <gabi@torproject.org>
2023-05-13 12:48:13 +01:00
Gabriela Moldovan 7dfa25db35
hsclient: Rename import alias to reflect new name.
A `NetdocErrorKind` is a `NEK` rather than a `PEK`.

Signed-off-by: Gabriela Moldovan <gabi@torproject.org>
2023-05-11 18:46:04 +01:00
Gabriela Moldovan 0422893373
netdoc: Rename parse_error_kind() to netdoc_error_kind().
`ParseErrorKind` was renamed to `NetdocErrorKind`, so we need to
rename this acccessor too.

Signed-off-by: Gabriela Moldovan <gabi@torproject.org>
2023-05-11 18:39:40 +01:00
gabi-250 35f9196a6d Merge branch 'nightly-warnings-20230511' into 'main'
Fix a few warnings from rust nightly

See merge request tpo/core/arti!1178
2023-05-11 13:17:56 +00:00
Nick Mathewson ca96b77b15 Merge branch 'hs-linkspec-work-v2' into 'main'
Second take on linkspec manipulation code needed by onion services

Closes #794

See merge request tpo/core/arti!1177
2023-05-11 13:16:13 +00:00
Nick Mathewson 0f9b45fe82 arti-testing: remove some needless ::default()s
This fixes a warning from nightly clippy.  I don't care for this
warning, but fixing it is easier than adding a version-conditional
warning exception.
2023-05-11 08:39:12 -04:00
Nick Mathewson c1fea9a67f dirmgr: remove a needless .borrow()
This fixes a warning from nightly clippy.
2023-05-11 08:38:42 -04:00
Nick Mathewson 78fb64387d chanmgr: remove a needless mut.
This fixes a warning from nightly clippy.
2023-05-11 08:38:06 -04:00
Nick Mathewson 164717e196 linkspec::verbatim: wrapper to give a CircTarget a new set of LinkSpecs 2023-05-11 08:31:53 -04:00
Nick Mathewson 88e9976556 Add linkspec::decode to convert linkspecs to an OwnedChanTarget
Relays and onion service services/clients will both need this.

I'm marking this experimental for now; we should stabilize it before
we release onion services.
2023-05-11 08:31:53 -04:00
Nick Mathewson 7ce808b75b Change CircTarget::linkspecs() to return an encoded list.
If we didn't do this, we would need to transfrom
`EncodedLinkSpec`s into a `LinkSpec::Unrecognized`, which is not
semantically right.  What's more, every user of this API wants to
consume encoded link specifiers, so encoding them early saves a
little effort.
2023-05-10 12:30:32 -04:00
Nick Mathewson a86aff8399 linkspec: Make LinkSpecType public.
This lets us check the type of an `EncodedLinkSpec` as well, and
lets us remove an interface that took a raw u8.
2023-05-10 12:19:37 -04:00
Nick Mathewson 4e5d7cecca linkspec: define conversion functions for EncodedLinkSpec
This commit adds functions to convert between LinkSpec and
EncodedLinkSpec, and refactors their read/write implementations a
bit to avoid code duplication.
2023-05-10 11:40:40 -04:00
Nick Mathewson 02785ca650 Rename UnparsedLinkSpec => EncodedLinkSpec 2023-05-10 11:23:39 -04:00
Nick Mathewson 1442763f3d hspool: Accept any T:CircTarget.
Previously, we only accepted an OwnedCircTarget, which would have
kept us from getting a circuit that was aimed at a specialized
CircTarget that gave us LinkSpecs in a raw order.
2023-05-10 11:00:57 -04:00
Nick Mathewson d26da331be test_linkspecs: tidy order of linkspecs
This is pure code movement.
2023-05-10 11:00:57 -04:00
Nick Mathewson e919ade062 Move responsibility for linkspec sorting to CircTarget.
This change is necessary so that we can build Extend2 messages
that have their LinkSpecs appear in a verbatim order as provided
in an INTRODUCE2 message or in a HS descriptor.
2023-05-10 11:00:57 -04:00
Gabriela Moldovan 410ca23d2d
netdoc: Remove experimental-api gate from parse_decrypt_validate.
`parse_decrypt_validate` was marked as experimental because it was
unclear if the newly added `BadTimeBound` error kind belongs in
`ParseErrorKind`. However, we have since renamed `ParseErrorKind` to
`NetdocErrorKind` and decided to keep the new variant, so this API
doesn't need to be experimental anymore.

Closes arti #852

Signed-off-by: Gabriela Moldovan <gabi@torproject.org>
2023-05-10 15:53:54 +01:00
Gabriela Moldovan 099b2315b0
netdoc: Rename `ParseError{Kind, Source}` to `NetdocError{Kind, Source}`.
`ParseErrorSource` was originally meant to represent a parsing error,
this enum has since gained some variants that aren't really parsing
related (`Signature`, `CertSignature`, `UntimelyDescriptor`).

Since this error type is now used for general-purpose netdoc errors,
let's rename `ParseError{Kind, Source}` to `NetdocError{Kind, Source}`.

Signed-off-by: Gabriela Moldovan <gabi@torproject.org>
2023-05-10 15:52:28 +01:00
Alexander Færøy 24051b1d1a Merge branch 'ticket_839' into 'main'
Downgrade and clarify message about dir replacment time.

Closes #839

See merge request tpo/core/arti!1171
2023-05-09 13:14:11 +00:00
Alexander Færøy 867663f2e5 Merge branch 'print-stati-feature' into 'main'
print both static sqlite/tls when 'static' feature is used

See merge request tpo/core/arti!1169
2023-05-09 13:12:51 +00:00
Nick Mathewson e6aa947c45 Downgrade and clarify message about dir replacment time.
Closes #839
2023-05-08 14:01:19 -04:00
trinity-1686a fe68f0a119 fix a couple clippy lints 2023-05-08 18:01:28 +02:00
trinity-1686a a8fd2d390e update rustls to 0.21 2023-05-08 18:01:00 +02:00
trinity-1686a 7d50a34a3a update rsa to 0.9.x 2023-05-08 17:24:23 +02:00
trinity-1686a f390440bbf print both static sqlite/tls when 'static' feature is used 2023-05-08 16:59:35 +02:00
Gabriela Moldovan 6b9e37e07c
tor-netdir: Shuffle the list of HS dirs used for downloading descriptors.
We'll probably need the hsdir list to be shuffled deterministically for
testing purposes (this might be desirable, for example, when we write a
test for HS descriptor download retries).

Signed-off-by: Gabriela Moldovan <gabi@torproject.org>
2023-05-04 17:53:58 +01:00
Nick Mathewson da185223c0 objmap: move types to top of file. 2023-05-04 10:37:27 -04:00
Nick Mathewson 7918904b99 Note/clean more TODOs in objmap. 2023-05-04 10:37:27 -04:00
Nick Mathewson 6fb5d08103 RPC: Make the "client" return optional. 2023-05-04 10:37:27 -04:00
Nick Mathewson 0e3fa38c03 RPC: Make "Weak" and "Strong" entries separate.
Now there can be one of each, since we want references and handles
to be conceptually separate.

(The alternative would be to say that an operation either "returns a
handle" or "returns a reference (which may become a handle) unless a
handle already exists.")
2023-05-04 10:37:27 -04:00
Nick Mathewson 7f59d7dae5 Temporarily replace generational-arena with a fake version.
This fake version is completely silly, but it will do the job until
we figure out our MPL2 concerns.
2023-05-04 10:37:27 -04:00
Nick Mathewson 54dabdbd0c RPC: make arti-rpcserver require the arti-client/rpc feature 2023-05-04 10:37:25 -04:00
Nick Mathewson b807e834a3 RPC: Rename session.rs to connection.rs 2023-05-04 10:35:05 -04:00
Nick Mathewson 7845f04908 RPC: rename Session to Connection.
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.
2023-05-04 10:35:05 -04:00
Nick Mathewson 94df123932 RPC: Make authentication return a TorClient.
(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.)
2023-05-04 10:35:05 -04:00
Nick Mathewson 475da9b802 Add a generational arena for object mapping for RPC.
See the comments on `TypedAddr` for some explanations about
why this is so tricky.  Thanks to @diziet for helping me figure
this out.
2023-05-04 10:35:05 -04:00
Nick Mathewson 9be9ddb902 RPC: Add "register" methods to RequestContext. 2023-05-04 10:35:05 -04:00
Nick Mathewson d7ab388faf RPC: Start on plumbing TorClient into our RPC code
Because of #837, we won't be able to work with _every_ TorClient<R>,
so I'm only going to be using TorClient<PreferredRuntime> for now.
2023-05-04 10:35:03 -04:00
Nick Mathewson 879a453212 RPC: Move the "listen" part of the RPC listener code to `arti`.
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.
2023-05-04 10:30:40 -04:00
Nick Mathewson 25398b5a3b rpc: Make an RpcMgr type to own the DispatchTable.
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
2023-05-04 10:22:27 -04:00
Gabriela Moldovan f6456d469d
tor-error: Add a TODO regarding HS desc parsing errors.
Signed-off-by: Gabriela Moldovan <gabi@torproject.org>
2023-05-03 17:25:36 +01:00
Gabriela Moldovan b168fd36de
hscrypto: Add comment about impl that will be removed after we address #798.
Signed-off-by: Gabriela Moldovan <gabi@torproject.org>
2023-05-03 17:25:32 +01:00
Gabriela Moldovan c2cb96a623
Clarify what the new ErrorKinds mean.
Signed-off-by: Gabriela Moldovan <gabi@torproject.org>
2023-05-03 17:25:29 +01:00
Gabriela Moldovan 30983c764f
tor-netdir: Update tests to parse the descriptor, make test consensus lifetime configurable.
Signed-off-by: Gabriela Moldovan <gabi@torproject.org>
2023-05-03 17:25:25 +01:00
Gabriela Moldovan c6fccbbb01
hsclient: Use a real HsDesc instead of an unparsed string.
Signed-off-by: Gabriela Moldovan <gabi@torproject.org>
2023-05-03 17:25:21 +01:00
Gabriela Moldovan 18cb1671c4
hscrypto: Add From impl for deriving KP_hsc_desc_enc out of KS_hsc_desc_enc.
The `HsClientSecretKeys` stored in the HS client connection context only
have the secret keys. Certain APIs (such as `HsDesc::parse`) expect a
keypair (both `HsClientDescEncKey` and `HsClientDescEncSecretKey`). This
`From` impl makes it possible to get a `HsClientDescEncKey` out of
`HsClientDescEncSecretKey`.

Signed-off-by: Gabriela Moldovan <gabi@torproject.org>
2023-05-03 17:25:17 +01:00
Nick Mathewson 02a0afbae4 Merge branch 'more_dir_logging' into 'main'
Lots more dirmgr log messages

Closes #803

See merge request tpo/core/arti!1163
2023-05-03 15:39:13 +00:00
Nick Mathewson e845a553f3 Upgrade tracing to 0.1.36.
This is the first version to impl Value for String.

With luck, this will get minimal_versions CI passing.
2023-05-03 11:09:21 -04:00
Nick Mathewson a7612ecdf8 DirMgr: More logs in top-level bootstrapping code.
Closes #803, I hope.
2023-05-03 11:08:19 -04:00
Nick Mathewson 8151fa504f DirMgr: more trace!() logs and information in download/load functions.
My goal here is to make sure that we can't confuse
one download operation and another, and that we actually know
what's going on.  Previously, not all state transitions or
attempts to fetch information actually corresponded to a log.
2023-05-03 11:08:19 -04:00
Nick Mathewson b2486bba1e DirMgr: Log at trace! when starting a new "AttemptId". 2023-05-03 11:08:19 -04:00
gabi-250 2c2d9e9425 Merge branch 'hsdesc-parse-decrypt-validate' into 'main'
netdoc: Add a convenience method for HS descriptor parsing.

Closes #809

See merge request tpo/core/arti!1152
2023-05-03 14:34:42 +00:00
Nick Mathewson c65b52e552 Remove semver.md files. 2023-05-03 08:33:20 -04:00
Nick Mathewson 1904cfc8b9 Increment crate versions.
Because of the errorkind bumps, we're calling this a breaking change
in everything lower-level than `arti`.

Generated with:
```
cargo set-version -p tor-basic-utils --bump minor
cargo set-version -p tor-async-utils --bump minor
cargo set-version -p caret --bump minor
cargo set-version -p fs-mistrust --bump minor
cargo set-version -p safelog --bump minor
cargo set-version -p retry-error --bump minor
cargo set-version -p tor-error --bump minor
cargo set-version -p tor-config --bump minor
cargo set-version -p tor-events --bump minor
cargo set-version -p tor-units --bump minor
cargo set-version -p tor-rtcompat --bump minor
cargo set-version -p tor-rtmock --bump minor
cargo set-version -p tor-rpcbase --bump minor
cargo set-version -p tor-llcrypto --bump minor
cargo set-version -p tor-protover --bump minor
cargo set-version -p tor-bytes --bump minor
cargo set-version -p tor-hscrypto --bump minor
cargo set-version -p tor-socksproto --bump minor
cargo set-version -p tor-checkable --bump minor
cargo set-version -p tor-cert --bump minor
cargo set-version -p tor-linkspec --bump minor
cargo set-version -p tor-cell --bump minor
cargo set-version -p tor-proto --bump minor
cargo set-version -p tor-netdoc --bump minor
cargo set-version -p tor-consdiff --bump minor
cargo set-version -p tor-netdir --bump minor
cargo set-version -p tor-congestion --bump minor
cargo set-version -p tor-persist --bump minor
cargo set-version -p tor-chanmgr --bump minor
cargo set-version -p tor-ptmgr --bump minor
cargo set-version -p tor-guardmgr --bump minor
cargo set-version -p tor-circmgr --bump minor
cargo set-version -p tor-dirclient --bump minor
cargo set-version -p tor-dirmgr --bump minor
cargo set-version -p tor-hsclient --bump minor
cargo set-version -p tor-hsservice --bump minor
cargo set-version -p arti-client --bump minor
cargo set-version -p arti-rpcserver --bump minor
cargo set-version -p arti-config --bump minor
cargo set-version -p arti-hyper --bump minor

cargo set-version -p arti --bump patch
cargo set-version -p arti-bench --bump patch
cargo set-version -p arti-testing --bump patch
```
2023-05-03 08:31:11 -04:00
Alexander Færøy 5ff19678fe Merge branch 'relayid' into 'main'
RelayId: Remove some duplication and relax a lifetime

See merge request tpo/core/arti!1156
2023-05-02 17:55:07 +00:00
Gabriela Moldovan dfc22beddf
netdoc: Mark parse_decrypt_validate as experimental.
Signed-off-by: Gabriela Moldovan <gabi@torproject.org>
2023-05-02 17:18:53 +01:00
Gabriela Moldovan 6cb412558d
arti-client: Only run BridgesConfig doc test if pt-client feature is enabled.
One of the tests run as part of `cargo test -p arti-client` fails
because the `pt-client` feature is not enabled by default:

```
failures:

---- src/config.rs - config::BridgesConfig (line 221) stdout ----
error[E0432]: unresolved import `arti_client::config::pt`
 --> src/config.rs:225:26
  |
7 | use arti_client::config::pt::ManagedTransportConfigBuilder;
  |                          ^^ could not find `pt` in `config`

error[E0599]: no method named `bridges` found for mutable reference `&mut BridgesConfigBuilder` in the current scope
  --> src/config.rs:233:19
   |
15 | builder.bridges().bridges().push(bridge_1);
   |                   ^^^^^^^ private field, not a method

error[E0599]: no function or associated item named `default` found for struct `BridgeConfigBuilder` in the current scope
  --> src/config.rs:236:48
   |
18 | let mut bridge2_builder = BridgeConfigBuilder::default();
   |                                                ^^^^^^^ function or associated item not found in `BridgeConfigBuilder`

error[E0599]: no method named `bridges` found for mutable reference `&mut BridgesConfigBuilder` in the current scope
  --> src/config.rs:247:19
   |
29 | builder.bridges().bridges().push(bridge2_builder);
   |                   ^^^^^^^ private field, not a method

error[E0599]: no method named `transports` found for mutable reference `&mut BridgesConfigBuilder` in the current scope
  --> src/config.rs:255:19
   |
37 | builder.bridges().transports().push(transport);
   |                   ^^^^^^^^^^ method not found in `&mut BridgesConfigBuilder`

error: aborting due to 5 previous errors

Some errors have detailed explanations: E0432, E0599.
For more information about an error, try `rustc --explain E0432`.
Couldn't compile the test.

failures:
    src/config.rs - config::BridgesConfig (line 221)

test result: FAILED. 5 passed; 1 failed; 3 ignored; 0 measured; 0 filtered out; finished in 2.10s
```

This disables the `BridgesConfig` doc test if the `pt-client` feature is not enabled.

Closes #843

Signed-off-by: Gabriela Moldovan <gabi@torproject.org>
2023-05-02 14:10:15 +01:00
Nick Mathewson 56b99075f6 Upgrade to serial_test 2.0.0 2023-04-28 10:35:54 -06:00
Ian Jackson c0aa600179 RelayId: implement id_type and as_bytes in terms of RelayIdRef
This eliminates some duplicated code.
2023-04-27 20:39:03 +01:00
Ian Jackson 58a0803667 RelayIdRef: as_bytes: Doesn't borrow from self
This borrows from the contained key, but not from self.

This will allow us to implement RelayId::as_bytes in terms of
RelayIdRef::as_bytes.
2023-04-27 20:39:03 +01:00
Ian Jackson 4b03795915 RelayId: impl Display in terms of RelayIdRef
This removes a duplicated copy of the format strings.
2023-04-27 20:37:36 +01:00
Gabriela Moldovan b967749325
netdoc: Document how to extract an `HsDesc` out of an `UncheckedEncryptedHsDesc`.
This adds an example to the `HsDesc::parse` docs. The constants from the
example are lifted from the `parse_desc_good` test.

Signed-off-by: Gabriela Moldovan <gabi@torproject.org>
2023-04-25 18:15:56 +01:00
Gabriela Moldovan 8f4e876924
netdoc: Add a convenience method for HS descriptor parsing.
This adds the `HsDesc::parse_decrypt_validate` method, which parses,
decrypts, and validates HS descriptors.

Closes #809

Signed-off-by: Gabriela Moldovan <gabi@torproject.org>
2023-04-25 18:15:53 +01:00
Nick Mathewson dc187c8fb8 Bump our own memchr dependency to 2.5
This appears to be necessary for getting "minimal-versions" to be
happy with memchr dependencies between reges and async-compression.
2023-04-22 09:41:47 -04:00
Nick Mathewson 7c1f45a514 RPC: Log all internal errors. 2023-04-19 12:38:26 -04:00
Nick Mathewson ffcbd8fe88 rpc: Simplify and clarify SendUpdateError. 2023-04-19 12:38:26 -04:00
Nick Mathewson accd3d858f Arti: Add ability to remember the list of methods names.
Right now, this lets us say whether the method was unrecognized or
whether the parameter type was incorrect.

We'll use this to enforce correct method names later on.

(I have to add another `inventory` here, since the `typetag`
maintainer does not want to expose this functionality: see
https://github.com/dtolnay/typetag/issues/57#issuecomment-1506106290
)
2023-04-19 12:38:26 -04:00
Nick Mathewson e6092e99ea rpc: New syntax for method declaration
Now you just declare your function `my_func` with the right types,
and invoke `rpc_invoke_fn!{ my_func(ObjType, MethodType); }`
2023-04-19 12:38:26 -04:00
Nick Mathewson a415b0e2d2 rpc: impl From<SendUpdateError> for RpcError. 2023-04-19 12:38:26 -04:00
Nick Mathewson f33aefd76c rpcserver: Use with_fn. 2023-04-19 12:38:26 -04:00
Nick Mathewson 6f6a4d073e rpcbase: Use with_fn. 2023-04-19 12:38:26 -04:00
Nick Mathewson 8a8c800c99 async-utils: Add a SinkExt with a with_fn
(This function behaves as `futures::sink::SinkExt::with`, except
that the function that it takes does not return a future.)
2023-04-19 12:38:26 -04:00
Nick Mathewson d54154e520 async-utils: rename sinkext to prepare_send 2023-04-19 12:38:26 -04:00
Nick Mathewson 5cd5e6a3f8 async-utils: rename SinkExt to SinkPrepareExt 2023-04-19 12:38:26 -04:00
Nick Mathewson 80a13ff898 rpc: Minor tweaks to get a sink to compile. 2023-04-19 12:38:26 -04:00
Nick Mathewson 0503f7bd4b rpc: Use Method types to determine type of method outputs, updates.
This lets us do much less in our rpc_invoke_fn functions.
2023-04-19 12:38:26 -04:00
Nick Mathewson 7dcfb02c22 rpc: Split Method into DynMethod and Method
Now `Method` has an Output and Update associated type, and
`decl_method` can do a little more.
2023-04-19 12:38:26 -04:00
Alexander Færøy 1faa97c645 Merge branch 'post_1145' into 'main'
Followups from !1145

See merge request tpo/core/arti!1146
2023-04-18 16:03:48 +00:00
Ian Jackson 219153a541 Merge branch 'rpc_refactoring_v2' into 'main'
A few RPC refactorings

Closes #817 and #824

See merge request tpo/core/arti!1144
2023-04-18 16:00:05 +00:00
Ian Jackson 6c720962a8 Merge branch 'fix_802_core' into 'main'
DirMgr: Detect that directory state is ready if it begins with all MDs

Closes #802

See merge request tpo/core/arti!1126
2023-04-18 15:34:08 +00:00
Nick Mathewson 543e089b82 netdoc: Document that particular bit values for flags are not part of our API. 2023-04-17 17:09:58 -04:00
Nick Mathewson 11945e8b4e netstatus: re-number routerstatus flags to go in order.
Otherwise there is too much risk of accidentally adding in another
1<<12 when we meant to add a 1<<13.

(It would be neat to have an alternative to bitflags here that would
auto-number our bitflags for us.)
2023-04-17 16:50:08 -04:00
Nick Mathewson 3985700216 netdir: more documentation on MIDDLE_ONLY flag.
Clarify that it isn't anything that most users will need to check.
2023-04-17 16:48:15 -04:00
juga eee1dbee7a netdoc: Add MiddleOnly flag to RelayFlags
Closes #833
2023-04-17 09:53:04 +00:00
Nick Mathewson 5a2c38a134 rpc: simplify API by always providing a sink.
Previously we have two places where we had to do "make a `Drain` sink
if updates aren't wanted"; now there's only one.
2023-04-16 08:46:42 -04:00
Nick Mathewson 83f5dc4888 rpc: Ensure well-ordering of responses.
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.
2023-04-16 08:46:42 -04:00
Nick Mathewson 58ad91cbf5 rpc: Wire updates into rpc invoke functions again.
Now that the sink is not part of the context, RPC functions that are
able to send an update have to declare an `impl Sink` as their
fourth argument.  This syntax is not final.

Part of #824.
2023-04-16 08:46:42 -04:00
Nick Mathewson 3b9fc60763 rpc: Move update sink out of context.
Now the update sink is its own boxed object.  It is not yet passed
to the invoke functions that want it.
2023-04-16 08:46:41 -04:00
Nick Mathewson c51f44aa0b rpcserver: Fix a couple of broken rustdoc links 2023-04-16 08:39:52 -04:00
gabi-250 31b6c9243d Merge branch 'use_secmem_proc_03' into 'main'
Update our secmem_proc dependency to 0.3.0

Closes #664

See merge request tpo/core/arti!1138
2023-04-13 14:26:06 +00:00
gabi-250 da790e4b78 Merge branch 'misc_upgrades' into 'main'
Upgrade a couple more dependencies

See merge request tpo/core/arti!1139
2023-04-13 14:25:13 +00:00
Nick Mathewson cf00fd8e8a Merge branch 'rpc_conformance' into 'main'
RPC: Terminology and error-handling conformance

Closes #826 and #825

See merge request tpo/core/arti!1136
2023-04-13 13:45:40 +00:00
Nick Mathewson 8dd65dcd5f rpc, spec: Document current ObjectError, RequestError behavior as correct. 2023-04-13 09:03:52 -04:00
Nick Mathewson ea77f959fb rpc: Change `id=<SYNTAX>` to "no id".
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.
2023-04-13 09:03:52 -04:00
Nick Mathewson 5041b51498 rpc: Require that errors are RpcError.
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.
2023-04-13 09:03:52 -04:00
Nick Mathewson 4efb423947 Upgrade our hex-literal dependency 2023-04-13 07:51:26 -04:00
Nick Mathewson 50d95964d1 Upgrade our num_enum dependency. 2023-04-13 07:50:11 -04:00
Nick Mathewson 6e83139fc7 Update our secmem_proc dependency to 0.3.0
(This wasn't possible before we updated our MSRV to 1.65.)

Closes #664.
2023-04-13 07:41:46 -04:00
Nick Mathewson 767c91557e rpc: Improve error reporting for invalid requests
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.
2023-04-12 16:21:34 -04:00
Nick Mathewson 739561b2cb rpcbase: Use correct error codes, and add tests.
Well, mostly correct.  Our current serde implementation doesn't
tell us much about what went wrong with the object, so we can't
tell why we couldn't convert it into a Request.

Also, our output for the data field is not as the spec says:
we should bring them into conformance.

Part of #825.
2023-04-12 13:32:15 -04:00
Nick Mathewson e37b017342 tor-error: Add ErrorKinds for RPC errors.
These are experimental for now so that we can change them without
breaking semver.
2023-04-12 13:30:24 -04:00
Ian Jackson 1d2514a06e Merge branch 'ticket_785' into 'main'
ExitPath: Add an explanation of WeightRole::Exit on non-exit circs

Closes #785

See merge request tpo/core/arti!1135
2023-04-12 17:00:36 +00:00
Ian Jackson 835480e98f Merge branch 'remove-hsdesc-todo' into 'main'
Remove misleading TODO.

See merge request tpo/core/arti!1130
2023-04-12 16:52:59 +00:00
Nick Mathewson 2e017d3575 tor-rpcbase: Create error kinds properly.
The field is called "kinds", it is a list, and it holds strings
beginning with "arti:".
2023-04-12 12:27:16 -04:00
Nick Mathewson 6bdfc5740f arti-rpcserver: Be careful about saying "result".
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.
2023-04-12 12:08:53 -04:00
Nick Mathewson 4d82bf4b98 arti-rpcserver: Rename Authentication{Method => Scheme}. 2023-04-12 11:53:50 -04:00
Nick Mathewson 4327276922 arti-rpcserver: rename cmd to method. 2023-04-12 11:51:48 -04:00
Nick Mathewson b2b0a0dd83 arti-rpcserver: rename command to method. 2023-04-12 11:51:37 -04:00
Nick Mathewson 193253a158 tor-rpcbase: rename cmd to method everywhere. 2023-04-12 11:45:30 -04:00
Nick Mathewson 224b919835 tor-rpcbase: Rename cmd.rs to method.rs. 2023-04-12 11:26:12 -04:00
Nick Mathewson c5b70224b2 tor-rpcbase: Rename and rephrase "command" to "method" 2023-04-12 11:25:03 -04:00
Nick Mathewson 2efdcd38ff ExitPath: Add an explanation of WeightRole::Exit on non-exit circs
In one case, we use WeightRole::Exit on circuits that can't
actually be used to exit.  This commit adds a comment to explain
why, so that we don't wonder about it in the future, and we have
some indication of whether it's still appropriate.

Closes #785
2023-04-12 09:50:16 -04:00
Neel Chauhan be78062bb6 s/BridgeDescManager/BridgeDescMgr/g in codebase 2023-04-12 05:49:11 -07:00
Nick Mathewson 8e6848b965 rpc: Try to fix rustdoc errors. 2023-04-12 08:02:30 -04:00
Nick Mathewson 44fbd87208 rpc: Use empty structs in test code. 2023-04-12 07:35:07 -04:00
Nick Mathewson 9a5f319a84 Rename tor-rpccmd to tor-rpcbase. 2023-04-12 07:34:57 -04:00
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