Commit Graph

3244 Commits

Author SHA1 Message Date
Nick Mathewson a0e1b3d651 Merge branch 'bridge-addr-2' into 'main'
Separate BridgeAddr and PtTargetAddr

See merge request tpo/core/arti!904
2022-11-30 17:36:50 +00:00
eta 5c2847e1d0 Merge branch 'fix_pt_protocol' into 'main'
Resolve two bugs in our pt-socks implementation

Closes #676

See merge request tpo/core/arti!913
2022-11-30 17:25:31 +00:00
Ian Jackson 8157cf059e Merge branch 'abolish-set-default-transport' into 'main'
Abolish ChanMgr::set_default_transport

See merge request tpo/core/arti!910
2022-11-30 17:05:36 +00:00
Nick Mathewson 4688ee9165 safelog: Apply #[serial] to test_redacted()
Closes #675.
2022-11-30 12:00:17 -05:00
Nick Mathewson e835bd4c4c PT protocol: pt-spec conformance with password field
pt-spec says:
```
      If the encoded argument list is less than 255 bytes in
      length, the "PLEN" field must be set to "1" and the "PASSWD"
      field must contain a single NUL character.
```

This is a very silly thing to say, but some PTs enforce it.

Fixes #676.
2022-11-30 11:53:38 -05:00
Nick Mathewson 475d9af34a connect_via_proxy: Actually send initial handshake.
Our previous code would make a TCP connection to the proxy, then
wait forever for it to say something. Whoops!

Part of a fix for #676.
2022-11-30 11:53:27 -05:00
Ian Jackson fa676ce577 ptmgr todo: Remove dead code allow 2022-11-30 16:42:40 +00:00
Ian Jackson fe33112923 ptmgr: No need for state_dir in PtMgr
This is used exclusively by the reactor.
2022-11-30 16:42:18 +00:00
Ian Jackson 1521f63bf1 ptmgr todo: Tolerate exposing the Vec for now
We may want to change this later, but this API is in a low level
crate, so this isn't a blocker.
2022-11-30 16:40:45 +00:00
Ian Jackson 4afe128189 PT SOCKS tests: add a few more tests 2022-11-30 16:35:04 +00:00
Ian Jackson 596e67f588 PT SOCKS tests: test name that only fits in V4 2022-11-30 16:35:04 +00:00
Nick Mathewson a5cdf88fdc Merge branch 'pt-todo-highlevel' into 'main'
Dispose of all TODO pt-client in arti-*

See merge request tpo/core/arti!909
2022-11-30 16:22:46 +00:00
eta f122b4b1ee Merge branch 'no_empty_select' into 'main'
ptmgr: Do not construct an empty select_all future.

Closes #672 and #670

See merge request tpo/core/arti!907
2022-11-30 16:01:58 +00:00
Ian Jackson ab74506dc9 Abolish ChanMgr::set_default_transport
The comment says
  // TODO pt-client: It's not clear to me that we really need this method.
and empirically, deleting it, and its callee, is fine.
2022-11-30 16:00:31 +00:00
Ian Jackson e068c5c2bc Merge branch 'ptmgr-errs' into 'main'
ptmgr: error fixes

See merge request tpo/core/arti!906
2022-11-30 15:58:26 +00:00
Ian Jackson e6d721c497 arti: transports parsing: Record this as a ticket 2022-11-30 15:56:16 +00:00
Ian Jackson 598f4e2e28 arti: BridgesConfig is evidently not too high up
Since apparently it was possible to write all the other code without
moving it.
2022-11-30 15:51:10 +00:00
Ian Jackson e4ac39e638 bridge config: Add a TODO about a redundant clone 2022-11-30 15:49:34 +00:00
Ian Jackson 429d2c7cb7 bridge config: Rename accessors
As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/904#note_2858480
2022-11-30 15:49:34 +00:00
Ian Jackson 117bee5808 bridge config: Use unreachable, not None.expect
As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/904#note_2858479
2022-11-30 15:49:34 +00:00
Ian Jackson bb6c98bdc1 BridgeAddr tests: dedupe slightly 2022-11-30 15:49:34 +00:00
Ian Jackson 199a6e0754 Separate BridgeAddr and PtTargetAddr
As per
  https://gitlab.torproject.org/tpo/core/arti/-/issues/668#note_2858220

This commit is difficult to split up.

The innards of BridgeAddr and PtTargetAddr are still a bit entangled.
2022-11-30 15:49:34 +00:00
Ian Jackson a74ee097f5 arti: pt mgr spawns the task itself in new 2022-11-30 15:48:31 +00:00
Ian Jackson 455295457f Merge branch 'redaction_fix' into 'main'
Fix a logic error in Redacted.

Closes #671

See merge request tpo/core/arti!905
2022-11-30 15:39:41 +00:00
Nick Mathewson d853fdb5cb ptmgr: Do not construct an empty select_all future.
Closes #670.

Closes #672.
2022-11-30 10:22:09 -05:00
Ian Jackson 1e63a89ce8 ptmgr: change error UnconfiguredTransportDueToConcurrentReconfiguration
Rename it from UnconfiguredTransport.  Change descriptions, kind, and
retry.  Add a TODO.

As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/901#note_2858455
2022-11-30 15:21:49 +00:00
Ian Jackson d705454313 ptmgr: Clarify E::NotAFile
As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/901#note_2858454
2022-11-30 15:21:39 +00:00
Ian Jackson f19d8e0397 ptmgr: Fix kind for E::StatedirCreateFailed
As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/901#note_2858456
2022-11-30 15:21:39 +00:00
Nick Mathewson 80d9248b50 Merge branch 'merge_ptreactor' into 'main'
Merge PtReactor, resolve a few of my comments.

See merge request tpo/core/arti!903
2022-11-30 15:21:13 +00:00
Nick Mathewson f0084e3fd4 Fix a logic error in Redacted.
Previously it was redacting exactly when safelogging was _disabled_,
which obviously isn't correct.

Fixes #671. Regression test included.
2022-11-30 09:07:33 -05:00
Nick Mathewson dacb3eafda ptmgr: report an error if PT transports don't match requested.
(I think this may be impossible now, since we check in ipc.rs, but
IMO it's best to check.)
2022-11-29 20:01:19 -05:00
Nick Mathewson 5f0f5f81b1 arti-client: Try to take ownership of state earlier.
There's no harm in doing this, since we'll try to take ownership of
the state soon as soon as we use it: We just want to try early, so
that we'll get it before we decide that we're using bridges.

Fixes bug #669; bug introduced by !889.
2022-11-29 19:58:42 -05:00
Nick Mathewson fdc49b1fed Register transport in pt reactor even if it has no pending requests 2022-11-29 19:35:38 -05:00
Nick Mathewson 9765fdc2e6 ptmgr: Use anonymize_home when displaying paths in errors 2022-11-29 19:30:50 -05:00
Nick Mathewson f6311c83f7 ptmgr: Use PluggableTransport::identity in logs.
This lets us avoid logging the user's path.
2022-11-29 19:20:44 -05:00
Nick Mathewson bb0749cd42 Centralize the "find an identifier for the pt name" logic in one place. 2022-11-29 19:13:32 -05:00
Nick Mathewson 21e7e52ad5 Merge remote-tracking branch 'eta/ptreactor-v1' into merge_ptreactor
Resolved several conflicts while doing so; mostly with !893 and
!895.
2022-11-29 18:55:49 -05:00
eta 9b4fc50625 tor-ptmgr: add PtReactor
This fleshes out the PtReactor that was previously a stub, making it
actually do reactor-ey things. Note that this is entirely untested, and
might not work at all. Hopefully it does, though.
2022-11-29 20:13:32 +00:00
Nick Mathewson 7ef9dde99c Merge branch 'todos-chanmgr' into 'main'
chanmgr: resolve several remaining "TODO pt-client" issues

See merge request tpo/core/arti!897
2022-11-29 19:31:48 +00:00
Nick Mathewson dc5551114c Merge branch 'list-builder-lint' into 'main'
tor-basic-utils: list_builder: Use standard test lint block

See merge request tpo/core/arti!900
2022-11-29 19:25:07 +00:00
Ian Jackson f3c8b0433b tor-basic-utils: list_builder: Use standard test lint block
This gets rid of a spurious warning on nightly about the use of dbg!
2022-11-29 18:41:56 +00:00
Nick Mathewson bdddb78828 Merge branch 'more-linkspec-tests' into 'main'
Add tests for a bunch of code in tor-linkspec

See merge request tpo/core/arti!867
2022-11-29 18:41:54 +00:00
Nick Mathewson 8cc09c2728 chanmgr: Distinguish failure to connect to proxy from other IO failures 2022-11-29 13:41:35 -05:00
Ian Jackson c3bdb30025 Merge branch 'ptmgr-optional-dep-test' into 'main'
MultilineListBuilder etc.: add serde tests

See merge request tpo/core/arti!899
2022-11-29 18:37:43 +00:00
Ian Jackson b36a23cfd3 Merge branch 'ptmgr-optional-dep' into 'main'
Support building without pluggable transports

Closes #649

See merge request tpo/core/arti!898
2022-11-29 18:26:30 +00:00
Ian Jackson 303fafe81b Merge branch 'll-todo-fixes' into 'main'
Fix and resolve TODO pt-client comments in guardmgr, linkspec.

See merge request tpo/core/arti!896
2022-11-29 18:14:25 +00:00
Ian Jackson cdc1e574f9 tor-config MultilineListBuilder: Test deserialisation 2022-11-29 17:53:04 +00:00
Ian Jackson 255f3b6bf6 tor-config MultilineListBuilder: Print line number starting at 1, not 0 2022-11-29 17:53:04 +00:00
Ian Jackson ef07c2e99d tor-config list_builder tests: Move Outer up a level
We're going to reuse this.
2022-11-29 17:53:04 +00:00
Ian Jackson 211a832f6d Clarify internal error. 2022-11-29 17:22:16 +00:00
Ian Jackson 143b331ef7 arti-client: Make ptmgr actually optional 2022-11-29 16:32:14 +00:00
Ian Jackson 1bd606ab5c guardmgr: Conditionalise DisplayRule::Redacted
This is unused in bridgeless configs.  Fixes a compiler warning.
2022-11-29 16:32:14 +00:00
Ian Jackson c92dcb5f50 arti, arti-client: Conditionalise various things on pt-client 2022-11-29 16:32:14 +00:00
Ian Jackson d05d383fa5 arti cfg tests: Add some more debug output 2022-11-29 16:32:14 +00:00
Ian Jackson 71e81bf7b4 MultilineListBuilder: Use a manual implementation of Deserialize
The error message from `#[serde(untagged)]` would otherwise start to
appear when we try to deserialise unsupported PT configurations, when
compiled with bridge but not PT support.
2022-11-29 16:32:14 +00:00
Nick Mathewson c6aa587dc8 chanmgr: remove a now-stale TODO. 2022-11-29 11:15:36 -05:00
Nick Mathewson 4fff9f9dda chanmgr: Report Pt errors correctly.
We were panicking if the PtMgr gave us an error, which isn't so
good.
2022-11-29 11:10:26 -05:00
Nick Mathewson 6b12c5d1de guardmgr: remove todo about bridge::config::Inner members
We've revised this a few times; now it seems plausible.
2022-11-29 11:03:44 -05:00
Nick Mathewson 0c0f3d1faf guardmgr: Remove now-unneeded #[allow(unnecessary_wraps)] 2022-11-29 11:00:27 -05:00
Nick Mathewson 69744ef8f3 Remove deprecated aliases in tor-linkspec. 2022-11-29 10:56:59 -05:00
Nick Mathewson 75cba2ce80 ptmgr: Refine RetryTime for ChildSpawnFailed. 2022-11-29 10:44:09 -05:00
Nick Mathewson 29ea66ecb9 ptmgr: Rename ClientTransportFailed, document, and correct its RetryTime. 2022-11-29 10:42:26 -05:00
Nick Mathewson d9dc30bc13 ptmgr: Replace StdioUnavailable with a PtError. 2022-11-29 10:36:51 -05:00
Nick Mathewson 7f923b9dfe Rename LocalLoginFailed to ExternalToolFailed. 2022-11-29 10:32:59 -05:00
Nick Mathewson eebfe8300e Document better what LocalProtocolViolation does not cover. 2022-11-29 10:29:54 -05:00
Nick Mathewson f08cfb6567 Merge branch 'ptmgr-cleanup' into 'main'
Post-merge cleanups for PtMgr

Closes #667 and #659

See merge request tpo/core/arti!893
2022-11-29 14:46:55 +00:00
Nick Mathewson 9a17a6a8aa Switch from sha-1 back to sha1.
As near as I can tell, the rust-crypto SHA1 crate was called `sha-1`
for a while because of a conflict with a different SHA1 crate.  Now
they apparently have the `sha1` name back and have deprecated the
`sha-1` name.
2022-11-29 08:24:58 -05:00
eta 3a0f0a909d Spelling fix in arti_client::err 2022-11-29 12:31:50 +00:00
Ian Jackson 8835c1b170 Merge branch 'redacted' into 'main'
Define a "redactable" trait, and use it when logging guard info

Closes #648 and #627

See merge request tpo/core/arti!882
2022-11-29 12:29:48 +00:00
Ian Jackson d78295929b Merge branch 'more_netdoc_tests' into 'main'
tor-netdoc: More tests for routerdesc accessors and parsing.

See merge request tpo/core/arti!870
2022-11-29 11:11:47 +00:00
Nick Mathewson 1f4a385d7d Temporarily make ptmgr required for arti-client :/ 2022-11-28 17:29:32 -05:00
Nick Mathewson 820657b6bc PtMgr: Use a persistent state directory for PT state.
This makes a `pt_state` directory inside .local/share/arti (or the
local equivalent), right next to our existing `state` dir.

Ideally we would use a separate directory for each PT, but we have a
very fuzzy "what is a specific PT" notion.

Closes #667
2022-11-28 17:29:32 -05:00
Nick Mathewson 1a9c4c722b Integrate PtMgr into arti-client.
If support is available at compile-time, then we construct a PtMgr
and register it with the ChanMgr.  We keep a handle to it ourself so
that we can reconfigure it as needed.

Closes #659.
2022-11-28 17:29:32 -05:00
Nick Mathewson 3db0e05b39 Fix ChanMgr APIs for setting PtMgr etc to match what TorClient wants. 2022-11-28 17:29:23 -05:00
Nick Mathewson 3fa86f41a6 Revise the API of "PtMgr::reconfigure"
I prefer that it not take `&mut self`, since PtMgr already has
interior mutability.

I also need it to take `tor_config::Reconfigure` argument, in case
it gains any more smarts about validation in the future.
2022-11-28 17:29:23 -05:00
Nick Mathewson c99017b0d6 ptmgr: Note a TODO issue around TempDir. 2022-11-28 17:29:23 -05:00
Nick Mathewson 4b5be3685f ptmgr: Fill in some error-related code; resolve TODOs. 2022-11-28 17:29:23 -05:00
Nick Mathewson 1fa9296f9c ptmgr: clear up unused_import exceptions. 2022-11-28 17:29:23 -05:00
Nick Mathewson 6bde90ce01 PtMgr: New features section in README.md
Per convention, have a `full` feature.

Also, downgrade the 'TODO pt-client' entries in README::limitations,
since they are not blockers for 1.1.0.
2022-11-28 17:29:23 -05:00
Nick Mathewson 8d0ac9bdc8 ptmgr: Mark PtMessage and next_message as experimental-api.
These are implementation details and we don't want to mark them as
stable.

To do this, I needed to apply some additional options to the example
code's configuration in Cargo.toml.
2022-11-28 17:29:23 -05:00
eta a3c9fc5b1a tor-chanmgr: Introduce the BootstrapReporter API, publicize ChanBuilder
This commit makes the `ChanBuilder` type in `tor-chanmgr` usable by
consumers outside of that crate, like the doc comment for
`ChannelFactory` says you need to be able to do in order to turn your
`TransportHelper` into something useful.

As part of doing this, the `event_sender` its constructor takes needed
to be dealt with, since it was a crate-internal type that came from
inside the `ChanMgr`.

Enter `BootstrapReporter`: an opaque wrapper around that sender, now
provided as an additional argument to
`ChannelFactory::connect_via_transport`. You can now construct a
`ChanBuilder` outside this crate, and it'll still be able to report its
bootstrap status by unwrapping this new type that's threaded through
from the `ChanMgr`. (This was a fair deal of manually threading the type
through all the layers in this crate!)

Note that you cannot implement bootstrap updating using something that
isn't `ChanBuilder` yet due to the type being entirely opaque (but, of
course, we can figure out exactly what API the reporter should have
later, and add that capability in).
2022-11-28 13:52:21 -05:00
eta 3b41c78d6f Draft: Pluggable transport manager
This commit implements `PtMgr`, a pluggable transport manager
responsible for keeping track of spawned PTs and spawning them to
satisfy client requests on demand.

It does this in two parts: the `PtMgr` type exported to the rest of the
code, and the background `PtReactor` that actually does the spawning;
this design ensures that only one attempt to spawn a PT is active at a
time, and will prove useful later for implementing e.g. timeouts.

A few changes were necessary to the rest of the code in order to make
this all work out. Namely:
- `TransportRegistry`'s API didn't make any sense for two reasons:
  - It wasn't feasible for implementors to implement `ChannelFactory`,
    since that'd require constructing a `ChanBuilder` (which requires a
    bootstrap reporting event sender).
  - Treating the PT manager as a registry is over-general; it's only
    necessary for it to spawn pluggable transports, so saddling it with
    other concerns didn't make any sense.
  - (It's possible to get extensibility for arbitrary user customization
    by just letting the user swap in a new `ChannelFactory`, anyway.)
- Therefore, the `PtMgr` implements the new `AbstractPtMgr` trait, which
  is far more narrowly focused; this only exists to solve a dependency
  loop, and is documented as such.
  - This provides a `TransportHelper` instead of a `ChannelFactory`.
2022-11-28 13:52:21 -05:00
Nick Mathewson 5d6044f3fc Rustdoc fix: escape []s. 2022-11-28 09:36:15 -05:00
Nick Mathewson 45c4beff7a Fix up compatibility issues between linkspec tests and other patches 2022-11-28 08:29:33 -05:00
Nick Mathewson 777b6bee3d linkspec: Add some tests for ChannelMethod 2022-11-28 08:20:57 -05:00
Nick Mathewson 60bc179019 linkspec: Tests for PtTargetSettings 2022-11-28 08:19:47 -05:00
Nick Mathewson 119e5f6f75 PtTransportName: Remove unused accessors. 2022-11-28 08:19:47 -05:00
Nick Mathewson d990a23948 linkspec: Add tests for has_any_identity. 2022-11-28 08:19:45 -05:00
Nick Mathewson 145ab3c49b linkspec: Add test for lookup on no-ids. 2022-11-28 08:19:08 -05:00
Nick Mathewson aa72f3d8c8 Add a test for ByRelayIds::remove_by_all_ids 2022-11-28 08:19:08 -05:00
Nick Mathewson a77172e20d safelog: Make MaybeRedacted<T> opaque. 2022-11-28 08:01:53 -05:00
Nick Mathewson cf9f29158f GuardMgr: Treat Guards as sensitive and Bridges as redacted.
This machinery is a bit inelegant, but it is all confined to
be within the GuardMgr crate, so IMO it should be fine for now.
2022-11-28 08:01:53 -05:00
Nick Mathewson c62958c76f Add a default debug_redacted impl to save space. 2022-11-28 08:01:53 -05:00
Nick Mathewson 29f903bdac Display guards in redacted form in guard status messages.
Closes #627, again.

Closes #648.
2022-11-28 08:01:53 -05:00
Nick Mathewson 2aa0ae4016 linkspec: Give a Redacted form for chantarget. 2022-11-28 08:01:50 -05:00
Nick Mathewson 8d36fa9996 llcrypto: Make key id types Redactable. 2022-11-28 08:01:10 -05:00
Nick Mathewson f2c91ef56e safelog: Add a MaybeRedacted wrapper too.
This is super helpful for cases where we want to write two nearly
identical implementations to format a type.
2022-11-28 08:01:10 -05:00
Nick Mathewson f91218c78d safelog: implement Redactable for network addr types. 2022-11-28 08:01:10 -05:00
Nick Mathewson d3f4956728 safelog: Define a "Redactable" trait
A "redactable" object is one that can be _partially_ scrubbed in
sensitive contexts.  This can be very helpful for UX, but is not
risk-free: see comments.
2022-11-28 08:01:10 -05:00
Nick Mathewson 8cf9e2a6a4 Merge branch 'chanmethod-non-exhaustive' into 'main'
Make ChannelMethod non-exhaustive

See merge request tpo/core/arti!891
2022-11-27 19:36:22 +00:00
Nick Mathewson 984bd6012a Merge branch 'reconfig-bridges-bad' into 'main'
Require state ownership when using bridges

Closes #612

See merge request tpo/core/arti!889
2022-11-27 19:30:00 +00:00
trinity-1686a fda17829d5 fix deprecation warnings from rustls 2022-11-26 10:23:05 +01:00
trinity-1686a 0a917a1abc upgrade rustls to 0.20, ignoring all deprecation warnings 2022-11-26 10:23:05 +01:00
Ian Jackson 1a39a0c7e9 Make ChannelMethod non-exhaustive
Enums with variants conditional on cargo features must be
non-exhaustive, because cargo features are supposed to be additive,
meaning that enabling a feature (which might happen due to some random
distant thing) ought not to break things using that enum.

There were surprisingly few places to fix this.
2022-11-24 17:17:36 +00:00
Ian Jackson 04082ab7a9 tor-guardmgr: rustfmt for recent changes
Left unsquashed for ease of review
2022-11-24 14:31:05 +00:00
Ian Jackson ecd0e121a8 tor-guardmgr: NoLock error: add TODO for trying to get lock
As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/889#note_2856874
2022-11-24 14:31:05 +00:00
Ian Jackson 112e28d88e tor-config: Rename to ReconfigureError::UnsupportedSituation
From Unsupported.  Prompted by
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/889#note_2856873
This was added in this MR.

Also add the missing semver note.
2022-11-24 14:31:03 +00:00
Ian Jackson fa918446ac tor-config: Rename to ConfigBuildError::NoCompileTimeSupport
From Unsupported.  Following one of the suggestions here
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/889#note_2856873

This was added in 2c37116149 which was
not yet in a release so this isn't a semver break.  I have added
the semver note that was omitted in that MR.
2022-11-24 14:30:58 +00:00
Ian Jackson 90a1a10b3c Merge branch 'sensitive-error' into 'main'
Scrub channel target information in errors

See merge request tpo/core/arti!890
2022-11-23 20:18:17 +00:00
Ian Jackson dc13c93491 Merge branch 'bdm-dormant' into 'main'
bridge desc mgr: Honour specified dormancy

Closes #630

See merge request tpo/core/arti!861
2022-11-23 20:13:29 +00:00
Ian Jackson 6a39cdfe57 Merge branch 'watch-drop-option' into 'main'
tor-basic-utils: DropNotifyWatchSender: use DropNotifyEofSignallable

See merge request tpo/core/arti!853
2022-11-23 18:55:32 +00:00
Ian Jackson ef5a58e158 tor-dirclient: Replace OwnedChanTarget with LoggedChanTarget in SourceInfo
SourceInfo primarily appears in errors, here and in (indirectly)
tor-dirmgr.

This
 1. Makes the errors smaller
 2. Redacts (currently, scrubs) the chantarget when safe logging is enabled

This commit therefore deals with both tor-dirmgr and tor-dirclient
errors, from the pov of error information that should become sensitive
as part of bridge support.

The error pyaloads directly in tor_dirmgr/src/err.rs don't seem to
contain anything in that category.
2022-11-23 18:28:38 +00:00
Ian Jackson b822e2ebe9 tor-cirmgr: Replace OwnedChanTarget with LoggedChanTarget in errors
This
 1. Makes the errors smaller
 2. Redacts (currently, scrubs) the chantarget when safe logging is enabled

The other error variants in tor-circmgr::Error don't seem to contain
information that should become sensitive as part of bridge support.
2022-11-23 18:28:38 +00:00
Ian Jackson e635383dfb tor-chanmgr: Invent [Box]ChanSensitive for two error payloads
This
 1. Makes the errors smaller (in the case of Io's PtTargetAddr;
    ChannelBuild's addresses are already indirected in a Vec).
 2. Redacts (currently, scrubs) the PtTargetAddr and SocketAddr
    when safe logging is enabled

These are the remaining error variants in tor-chanmgr that contain
information that should become sensitive as part of bridge support.
2022-11-23 18:28:38 +00:00
Ian Jackson 32357b3de7 tor-chanmgr: Replace OwnedChanTarget with LoggedChanTarget in errors
This
 1. Makes the errors smaller
 2. Redacts (currently, scrubs) the chantarget when safe logging is enabled

This commit doesn't treat other should-be-sensitive inforemation in
errors just yet.  That will come in a moment.
2022-11-23 18:28:38 +00:00
Ian Jackson 45a79bf725 tor-linkspec: Provide LoggedChanTarget type alias and utility method
This makes it easy to talk about, and construct, a
BoxSensitive<OwnedChanTarget>, which is what we'll use in errors.
2022-11-23 18:28:38 +00:00
Ian Jackson bbc84bf9f4 safelog: Provide BoxSensitive 2022-11-23 18:28:38 +00:00
Ian Jackson 4f193f1017 safelog: Remove type argument from `impl_display_traits`
We're going to have this same macro implement the same traits for a
second type.  And its function is specific to `Sensitive`, so have it
know that.
2022-11-23 18:28:34 +00:00
Ian Jackson b77fd893a4 safelog: Provide some more accessors
We're about to use `.as_inner()` in a few places, and `.as_ref()` (by
analogy with `Option`) seems obviously necessary.
2022-11-23 18:28:34 +00:00
Ian Jackson 1c085cf401 bridge desc mgr: Add dormancy comment to effective_parallelism
As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/861#note_2856922
2022-11-23 18:20:58 +00:00
Ian Jackson 68acedccfd bridge desc mgr: Test dormancy 2022-11-23 18:20:58 +00:00
Ian Jackson e0c4eed549 bridge desc mgr: Honour specified dormancy
Fixes #630
2022-11-23 18:20:58 +00:00
Ian Jackson a33df9a5f5 bridge desc mgr: Introduce effective_parallelism helper 2022-11-23 18:20:58 +00:00
Ian Jackson 2c98351e2d bridge desc mgr: Move set_dormancy to impl that is for mock too 2022-11-23 18:20:58 +00:00
Nick Mathewson ce0f8f41cb Merge branch 'bridge-config-arc' into 'main'
Make BridgeConfig be Arc, so no Arc<BridgeConfig>

Closes #635

See merge request tpo/core/arti!885
2022-11-23 17:52:26 +00:00
Ian Jackson fbd4b88044 Merge branch 'test-config' into 'main'
tor-guardmgr: Fix visibility of TestConfig with no features enabled

See merge request tpo/core/arti!875
2022-11-23 17:51:05 +00:00
Ian Jackson 4d502bd818 arti-client: Add comment about Option DormantMode
As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/852#note_2854090
(ftaod, that is a different MR to this one)
2022-11-23 17:50:05 +00:00
Ian Jackson c82cda85d6 tor-basic-utils: DropNotifyWatchSender: use DropNotifyEofSignallable
This will help avoid the programmer making the mistake I made here:
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/852#note_2854029
2022-11-23 17:50:05 +00:00
Nick Mathewson c0a6fb3e0f Merge branch 'stability' into 'main'
arti-client, tor-config: Remove stability warning from top-level docs

See merge request tpo/core/arti!878
2022-11-23 17:50:01 +00:00
Ian Jackson 63a799a118 tor-basic-utils: DropNotifyWatchSender test: introduce I
We do want to test this with a non-Option type, but we are going to
have to wrap it up.
2022-11-23 17:50:01 +00:00
Nick Mathewson e25ed00fd1 Merge branch 'remove_deadcode_allow' into 'main'
guardmgr: Remove a now-unneeded "allow(dead_code)"

See merge request tpo/core/arti!862
2022-11-23 17:45:26 +00:00
Nick Mathewson 3f5699b95a ChanMgr: Another attempt to build on CI. 2022-11-23 11:25:15 -05:00
Nick Mathewson 74ebc904e3 ChanMgr: Rename Factory -> CompoundFactory 2022-11-23 11:10:34 -05:00
Nick Mathewson 1249bedbb0 ChanMgr: Fix a few more conditional-compilation issues 2022-11-23 11:10:34 -05:00
Nick Mathewson 2fb36f5585 ChanMgr: Remove Arc aliases. 2022-11-23 11:10:34 -05:00
Nick Mathewson f8e103bb94 Mark set-default-factory API as experimental. 2022-11-23 11:10:34 -05:00
Nick Mathewson c04aa9baed Make ChannelFactory and AbstractPtMgr require Send+Sync 2022-11-23 11:10:34 -05:00
Nick Mathewson bc1de60d6d ChanMgr: Implement functions that replace channel factories.
This commit makes it possible to replace the default channel factory
(used when there is no PtMgr), and to replace the PtMgr.

This is part of #659.
2022-11-23 11:10:34 -05:00
Ian Jackson ecaf8b23b8 tor-guardmgr: Refuse to configure bridges if we don't have the lock
Fixes #612
2022-11-23 13:03:14 +00:00
Ian Jackson c0b297c99c tor-guardmgr: make replace_bridge_config fallible
The error type needs to be convertible to GuardMgrError and also to
ReconfigureError.  Neither of those is right, so we need a new error
type.
2022-11-23 13:00:10 +00:00
Ian Jackson 8cddb0a06a tor-guardmgr: Replace a let _ignore with a typed version
`let _ignore =` isn't great because if the function called is
currently infallible, but becomes fallible, it suppresses the
detection of the error check.

A better pattern is to specify the type of the ignored value.

I'm about to do precisely this, here.

I did a git-grep and `let _ignore =` seems very common.  Let's not
deal with all those now.
2022-11-23 13:00:05 +00:00
Nick Mathewson a688e4afc9 ChanMgr: move the AbstractChanFactory into MgrState.
We will want the freedom to replace this, so it needs to go behind a
lock. We need to be able to Clone it cheaply now, so we're using an
Arc instead of a Box.
2022-11-22 14:41:44 -05:00
Nick Mathewson fc74bb8bb4 Merge branch 'retire_on_guard_cfg_change' into 'main'
CircMgr: retire all circuits if bridge configuration changes.

Closes #650

See merge request tpo/core/arti!880
2022-11-22 19:00:20 +00:00
Nick Mathewson 09092394a8 Merge branch 'main' into 'abstract-pt-mgr'
# Conflicts:
#   crates/tor-chanmgr/src/factory.rs
2022-11-22 18:12:25 +00:00
eta 2f75702cec Replace TransportRegistry with AbstractPtMgr
It doesn't make much sense to have the pluggable transport manager be a
registry, so replace its interface with a more narrowly defined, less generic
version.

Other changes:
- instead of returning a &-reference, it returns an owned Arc, which
  should make the ptmgr easier to implement while allowing efficient
  reuse
- provision for error handling is added, but will probably be revised in
  a future commit pending discussion
- tor-ptmgr code that would generate warnings as a result of this change
  is temporarily removed

This is a split out version of arti!886, intended so work on arti#659
can proceed.
2022-11-22 18:09:06 +00:00
Nick Mathewson f2121101d1 Even more comments explaining circuit cancellation. 2022-11-22 12:53:32 -05:00
Nick Mathewson e7c942c918 Improve notes surrounding circuit cancellation.
It turns out that bug #656 is not a real bug, but it was easy to
overlook the code that prevented it.

Closes #656.
2022-11-22 12:53:32 -05:00
Nick Mathewson c0aa10d409 CircMgr: retire all circuits if bridge configuration changes.
Closes #650.
2022-11-22 12:53:32 -05:00
Ian Jackson ee87097dc1 BridgeConfig: Replace all Arc<BridgeConfig> with BridgeConfig
BridgeConfig is itself an Arc now, so these are redundant.
2022-11-22 15:33:21 +00:00
Ian Jackson 3caf7aafc0 BridgeConfig: Make it be a newtype around Arc<Inner>
This leaves the external API of this type unchanged, but now it's much
smaller and quite cheap to clone.
2022-11-22 15:33:21 +00:00