Commit Graph

3244 Commits

Author SHA1 Message Date
Ian Jackson 63c463944d arti-client: Store a handle to the DirMgrStore in TorClient
We'll need this shortly.
2022-11-15 12:08:21 +00:00
Ian Jackson 647610f2f9 arti-client: Store a handle to the guardmgr in TorClient
We'll need this shortly.
2022-11-15 12:08:20 +00:00
Nick Mathewson 79a09ae379 Merge branch 'make_bridges_work' into 'main'
Bugfix: preserve active_set when loading guards

See merge request tpo/core/arti!848
2022-11-14 19:40:26 +00:00
Nick Mathewson 2f5f066d85 Merge branch 'report_missing_descs' into 'main'
GuardMgr: Update desired bridge descs from 'update' function.

Closes #622

See merge request tpo/core/arti!847
2022-11-14 19:15:12 +00:00
Nick Mathewson ec2e432bee Preserve active_set when loading guards. 2022-11-14 13:50:59 -05:00
Nick Mathewson 92115aa366 GuardMgr: Update desired bridge descs from 'update' function.
There are some new TODOs here for us to think about, but I think
this will give us something to test.
2022-11-14 13:36:10 -05:00
Nick Mathewson 0f4c7a477a GuardSet: Add a method to report which bridge descs we want. 2022-11-14 13:36:10 -05:00
Ian Jackson b41becec56 Merge branch 'guardmgr' into 'main'
Move guardmgr creation to arti-client, rather than within circmgr

See merge request tpo/core/arti!850
2022-11-14 17:01:31 +00:00
Ian Jackson 58fc19dc8d Merge branch 'store3' into 'main'
dirmgr: Expopse DirMgrStore

See merge request tpo/core/arti!851
2022-11-14 17:01:10 +00:00
Ian Jackson 7efbc600c0 Merge branch 'bdm-dormant' into 'main'
bridge descriptor dormancy: Define an enum and semantics

See merge request tpo/core/arti!845
2022-11-14 17:00:40 +00:00
Ian Jackson ed4006c87c Move GuardMgr::new call to arti_client::TorClient (fmt)
rustfmt only, broken out to ease review.
2022-11-14 15:52:30 +00:00
Ian Jackson 525c452e77 Move GuardMgr::new call to arti_client::TorClient
Having this done within circmgr was irregular - most of our other key
buildup functions are done in TorClient::create_inner.

It is also inconvenient, as it buries the guardmgr within the circmgr.
2022-11-14 15:50:07 +00:00
Ian Jackson 92939439a6 dirmgr Store: Have constructors take DirMgrStore
Now the Store is constructed by arti_client, solving the problem
described here
  https://gitlab.torproject.org/tpo/core/arti/-/issues/631#note_2853665
but in a different way.
2022-11-14 15:48:17 +00:00
Ian Jackson 5e16c55f9e dirmgr Store: Introduce DirMgrStore and use for BridgeDescMgr (fmt)
rustfmt only, broken out to ease review.
2022-11-14 15:48:17 +00:00
Ian Jackson cf362f9806 dirmgr Store: Introduce DirMgrStore and use for BridgeDescMgr
We are going to change DirMgr's constructors to also take a DirMgrStore.
2022-11-14 15:48:17 +00:00
Ian Jackson d9f231e099 dirmgr Store: Abolish redundant trait impl 2022-11-14 15:47:04 +00:00
Ian Jackson 527ab06376 dirmgr Store: Use `**` syntax and deref to trait objects
This will allow us to get rid of a needless trait impl.
2022-11-14 15:47:04 +00:00
Ian Jackson bf7d45b7b9 dirmgr Store: Move Send and 'static bounds to Store trait
This seems tidier to me.

(It saved a lot of typing when I was trying to make some complicated
pub supertrait with sealed private supertrait, but apparently not
now.)
2022-11-14 15:33:58 +00:00
arnabanimesh 91be995588 Fix Windows shortcut target 2022-11-13 16:05:24 +00:00
Ian Jackson 9ecda958a4 Document Clone semantics of GuardMgr and DirMgr 2022-11-11 16:55:56 +00:00
Ian Jackson 9a979cf2c4 cfg-ify an import 2022-11-11 16:54:01 +00:00
Ian Jackson c6234428e3 bridge descriptor dormancy: Accept the dormancy value
But right now, don't do anything with it.  That will come in a future MR.
2022-11-11 15:34:35 +00:00
Ian Jackson eeb6d52678 bridge descriptor dormancy: Add a TODO for this enum 2022-11-11 15:26:42 +00:00
eta b1cc1e2065 Merge branch 'workaround_545' into 'main'
Temporarily disable it_cancels_delayed_firings.

See merge request tpo/core/arti!846
2022-11-11 11:16:33 +00:00
Nick Mathewson 9c9f9bbd25 Merge branch 'guardmgr-todo-misc' into 'main'
Resolve most "TODO pt-client" comments in GuardMgr

See merge request tpo/core/arti!840
2022-11-10 17:50:34 +00:00
Nick Mathewson b91f7d61b3 GuardMgr: Explain why we timestamp BridgeSets as we do. 2022-11-10 12:11:28 -05:00
Nick Mathewson f5a5e310a8 GuardMgr: Downgrade a pt-client TODO about an internal API 2022-11-10 12:11:28 -05:00
Nick Mathewson 8cf04d2a38 GuardMgr Document why a BridgeSet has trivial weight thresholds.
This is the only way I could find in which parameter interpretation
differs between bridge guards and relay guards; with it documented,
I can remove a TODO about identifying such ways.
2022-11-10 12:11:28 -05:00
Nick Mathewson 01def7cf86 GuardMgr: once more, fix our n_primary_dir_info check.
Have the check only apply to non-bridge universes, and explain why
in a bunch more comments.
2022-11-10 12:11:28 -05:00
Nick Mathewson 11e83d8069 GuardMgr: remove redundant call to extend_sample_as_needed
Previously we would call extend_sample_as_needed in only two places,
one of which called the other unconditionally.  That's obviously not
necessary.

I've selected just one of them (`update_guardset_internal`) since it
fits better with the theme if that function.  I've added comments
explaining what is going on.

This commit also introduces a yes/no enum for "were any guards added
while extending this set". Formerly we had a boolean, but it got
passed around so many times that I think its intent became obscure.
2022-11-10 12:11:28 -05:00
Nick Mathewson 1d4db04e4e GuardMgr: rename n_primary_without_dir_info
What this function actually does is return the number of primary
guards whose presence (by identity) is ambiguous in a current
universe.  The new name and documentation should help avoid
confusion.

The method's old name had led me astray when identifying whether it
should apply to bridges in one case.  This commit also removes the
corresponding `TODO pt-client`.
2022-11-10 12:11:28 -05:00
Nick Mathewson 1ad45f164e Remove TODO to rename for_circuit_usage in favor of #623 2022-11-10 12:11:28 -05:00
Nick Mathewson b8792307ac GuardMgr: Remove TODO to move `mod bridge` to another crate
The code seems happy enough here for now.
2022-11-10 12:11:28 -05:00
Nick Mathewson 942dfc8487 Resolve todo!()s and TODOs around BridgeRelay::HasAddrs.
Also, add a bunch of reminders around these implementations that
`HasAddrs` returns all the address associated with you for GeoIp or
family purposes, even if they are _not_ ones that we should actually
contact you at.
2022-11-10 12:11:28 -05:00
Nick Mathewson dcfb4d0956 RouterDesc: Add an or_ports method. 2022-11-10 12:11:28 -05:00
Nick Mathewson 71510fbd96 Temporarily disable it_cancels_delayed_firings.
This test is timing-dependent in a way that seems to fail on heavily
loaded CI machines. See #545.
2022-11-10 11:58:35 -05:00
Nick Mathewson e5c26a123f Actually, require rsa 0.7.1.
rsa 0.7.0 has been yanked.
2022-11-10 11:26:35 -05:00
Nick Mathewson 0a1141db32 tor-persist: use map_while
It was introduced in Rust 1.57.
2022-11-10 11:04:20 -05:00
Nick Mathewson 06e4e91614 Remove allow() for a false-positive warn on Rust 1.56. 2022-11-10 11:04:20 -05:00
Nick Mathewson e19ff0ec21 Upgrade rsa to 0.7. Closes #613. 2022-11-10 11:04:20 -05:00
Nick Mathewson 34ae02e75f Upgrade to serde_with 2, phf 0.11. Closes #526. 2022-11-10 11:04:18 -05:00
Nick Mathewson 2c13a78c57 Upgrade to tinystr 0.7. Closes #591. 2022-11-10 10:57:33 -05:00
Nick Mathewson 936920b26e bump rust-version to 1.60 in every crate. 2022-11-10 10:57:33 -05:00
Ian Jackson eacb5dc2e3 bridge descriptor dormancy: Define an enum and semantics
This is part of #630.
2022-11-10 15:17:36 +00:00
Nick Mathewson d9788c16b3 Merge branch 'bridge-error' into 'main'
Use ErrorKind::TorAccessFailed for misbehaving bridges

See merge request tpo/core/arti!842
2022-11-10 13:50:47 +00:00
Nick Mathewson 3c29dfd99d Merge branch 'bdm-process-doc-test' into 'main'
bridge descs: Add tests for process_document

See merge request tpo/core/arti!841
2022-11-10 13:50:23 +00:00
Nick Mathewson 6454896d95 Merge branch 'bdm-params' into 'main'
Remove TODO re BridgeDescDownloadConfig defaults

See merge request tpo/core/arti!839
2022-11-10 13:49:54 +00:00
trinity-1686a 614cf34284 Check more targets 2022-11-10 13:34:17 +00:00
Ian Jackson 42dd5d7746 bridge desc: Drop a done TODO
We have a separate BridgeDescMgr, rather than reusing DirMgr, so we
will not be implementing BridgeDescProvider for DirMgr.
2022-11-08 18:54:31 +00:00
Ian Jackson 8fbff3a27f Use ErrorKind::TorAccessFailed for misbehaving bridges
(Use semantic linefeed for the doc comment.)
2022-11-08 18:52:57 +00:00
Ian Jackson d808f70a13 bridge descs: Add tests for process_document 2022-11-08 18:42:34 +00:00
Ian Jackson f1f4ca56a8 Remove TODO re BridgeDescDownloadConfig defaults 2022-11-08 17:34:25 +00:00
Ian Jackson 05cad7c0eb bridge desc: todo re config: weaken and reference a new ticket 2022-11-08 17:34:13 +00:00
Ian Jackson 4f893648b8 Merge branch 'clap-v3' into 'main'
Upgrade to clap 3

Closes #616

See merge request tpo/core/arti!830
2022-11-08 17:11:04 +00:00
Nick Mathewson 9dcfc2bb65 GuardMgr: Docs for BridgeDescProvider 2022-11-08 11:35:35 -05:00
Nick Mathewson 91cfd7ea4a GuardMgr: Remove a TODO pt-client comment.
The BridgeSet type does not necessarily need further changes... and
if it gets them, it won't be because of this comment.
2022-11-08 11:35:35 -05:00
Ian Jackson 8efcfb64af Merge branch 'misc-todo-ptclient' into 'main'
Downgrade and/or remove a few misc "TODO pt-client" comments

See merge request tpo/core/arti!838
2022-11-08 16:21:30 +00:00
Nick Mathewson ec9e9c86e7 Merge branch 'store' into 'main'
Persistently cache bridge descriptors

Closes #619

See merge request tpo/core/arti!831
2022-11-08 15:10:21 +00:00
Ian Jackson 46286dddd4 Merge branch 'todo-ptclient-linkspec-1' into 'main'
Resolve `TODO pt-client` entries in linkspec

See merge request tpo/core/arti!836
2022-11-08 15:01:02 +00:00
Ian Jackson ea369e8385 bridge descs: Rename BridgeDescMgr from BridgeDescManager
This is more consistent with our naming elsewhere.

Suggested-by: Nick Mathewson <nickm@torproject.org>
2022-11-08 14:40:28 +00:00
eta 53f62eb8be Merge branch 'store-yak-misc' into 'main'
Small misc yaks for bridge descriptor persistence

See merge request tpo/core/arti!828
2022-11-08 14:28:14 +00:00
Nick Mathewson 3bcb85bd59 Merge branch 'guards_as_bridges_part4' into 'main'
GuardMgr: Almost finish wiring Bridges in as a guard substitute

See merge request tpo/core/arti!832
2022-11-08 13:48:27 +00:00
Nick Mathewson 6b422b1c4d circmgr: downgrade TODO pt-client comments
These are structure-internal things we can solve later, if ever.
2022-11-08 08:31:59 -05:00
Nick Mathewson c99976fabc ChanMgr: downgrade and remove a few TODO-ptclient comments
renamings are now #623.  Code movement can happen later.
2022-11-08 08:27:19 -05:00
Ian Jackson d9d9cdeac9 bridge descs: Apply sensitive() to bridge identity in error log msg 2022-11-08 13:19:42 +00:00
Nick Mathewson ada3acf6b8 Try to explain exactly what lookup_bridge_circ_target does 2022-11-08 08:10:15 -05:00
Nick Mathewson 0fd41a7faf GuardMgr: Try to explain what is going on with update()
This explanation is slightly complicated by the fact that I think
that one of the calls to update_guardset_internal() is possibly
unnecessary, and that one of the calls that it makes is potentially
ill-advised.

I'm not going to make those changes right now, however, because they
are potentially a little destabilizing.
2022-11-08 08:10:15 -05:00
Nick Mathewson 6591842458 Refactor configured_bridges
Now it is an Option, and is set to None if bridges aren't enabled.

This simplifies `replace_bridge_config` a bit, and forces us to
check for `None` in a few more places.
2022-11-08 08:10:15 -05:00
Nick Mathewson 2a5b4d21e3 GuardMgr: Document that providers should only be installed once.
Enforce this with assert!() and a documented panics section.
2022-11-08 08:10:15 -05:00
Nick Mathewson 9fda8d17c4 GuardMgr: Fix build with bridge-client disabled. 2022-11-08 08:10:15 -05:00
Nick Mathewson 6bcce19655 GuardMgr: Remove no-longer-relevant `TODO pt-client` comments
Also remove a bunch of now-unnecessary `allow(dead_code)`
annotations.
2022-11-08 08:10:15 -05:00
Nick Mathewson 1418ec13a8 GuardMgr: Rename an error variant 2022-11-08 08:10:15 -05:00
Nick Mathewson 3943c6cd1e GuardMgr: Spelling fixes and normalizations. 2022-11-08 08:10:15 -05:00
Nick Mathewson 3f3d82ee48 GuardMgr: do not use fallbacks when in bridge mode. 2022-11-08 08:10:15 -05:00
Nick Mathewson 5c3bb3d7e1 GuardMgr: When possible, return a FirstHop that can be a CircTarget
We do this by checking the FirstHops we're about to return, and when
they correspond to bridges, looking up an appropriate BridgeRelay
in the current BridgeSet (if we can).
2022-11-08 08:10:15 -05:00
Nick Mathewson 25d7924832 GuardMgr: Refactor UniverseRef to contains Arcs.
We already _have_ these Arc<>s whenever we construct a UniverseRef,
so there's no real point in using &refs and making these so
hard to construct.
2022-11-08 08:10:15 -05:00
Nick Mathewson 7fa08140cf GuardMgr: Remove an outdated "Limitations" comment.
Found while grepping for NetDir.
2022-11-08 08:10:15 -05:00
Nick Mathewson e1ef939ebd GuardMgr: do not block netdir if we are using bridges
The `GuardMgr` code has functionality to tell the DirMgr "Hey,
don't switch to the new NetDir yet: we still need more guard
information!"  But we never want to do that if we're selecting
bridges, since they don't come from the NetDir.
2022-11-08 08:10:15 -05:00
Nick Mathewson 1a4fbb2c3f GuardMgr: Add UniverseType to make code more explicit.
Instead of duplicating the logic about which guard sample uses which
universe, we explicitly ask it, and then use that universe.  This
will avoid trouble if/when we introduce more samples.
2022-11-08 08:10:15 -05:00
Nick Mathewson d395ae75a5 GuardMgr: Launch a background task to keep the list of bridge
descriptors updated as appropriate.
2022-11-08 08:10:15 -05:00
Nick Mathewson e93ee14270 GuardMgr: Exit keep-netdir-updated task early if GuardMgr disappears. 2022-11-08 08:10:15 -05:00
Nick Mathewson 697a355a21 GuardMgr: Pass correct universe to "Bridges" `GuardSet`.
This can probably be done in a simpler way, but for the moment I
would prefer to try to minimize the amount of code I'm changing
here.
2022-11-08 08:10:15 -05:00
Nick Mathewson f4149cd133 GuardMgr: Change BridgeSet, BridgeRelay to use more references
This will match our needs better and help avoid some `Arc<>`s.

It will be especially helpful for avoiding `Arc`s we don't
actually have.
2022-11-08 08:10:15 -05:00
Nick Mathewson 51a98883c8 GuardMgr: Store bridge configuration.
I'm using an Arc<[]> here though I think that there's a chance
that a simple Vec<> would suffice. Since it's an internal type,
nothing will break if we change it later.

Also, we now switch into and out of the Bridges guard sample
as needed.  However, that selection is not (yet) built from the
list of bridges.  That will come soon.
2022-11-08 08:10:15 -05:00
Nick Mathewson 188b9c0f86 GuardMgr: Remove duplicate code in set_filter 2022-11-08 08:10:15 -05:00
Nick Mathewson 04bcf69749 GuardMgr: Clarify intent with update_active_set.
Also fix its behavior when using bridges.
2022-11-08 08:10:15 -05:00
Nick Mathewson ad47b28f2f GuardMgr: Split `update_internal` into two functions.
The first part changes which guard set is active based on based on
the parameters, which always come from a NetDir; the second changes
the contents of the active guard set, based on a Universe.
2022-11-08 08:10:15 -05:00
Nick Mathewson 95a95076a7 Refactor external guardmgr APIs: Stop taking NetDir arguments.
These arguments were used only for legacy (testing) purposes; the
tests now use `TestNetDirProvider`.  This lets us simplify our
internal logic for passing a `NetDir` to our samples, and prepare
for having a `BridgeSet` to pass there instead.

This is a breaking change to `guardmgr` and `circmgr`.
2022-11-08 08:10:15 -05:00
Nick Mathewson 339bd8bde0 Mock implementation of a NetDirProvider for testing.
I'm about to remove the old testing APIs from GurdMgr that took in a
NetDir in each function: adding this will make that possible.
2022-11-08 08:10:15 -05:00
Nick Mathewson 6b94bc5e4c Add an accessor for the latest BridgeDescList. 2022-11-08 08:10:15 -05:00
Nick Mathewson faf51702ac Implement GuardMgr::install_bridge_desc_provider 2022-11-08 08:10:15 -05:00
Nick Mathewson 5cb9e1987e Require Send+Sync for BridgeDescProvider
We require these for NetDirProvider, so this shouldn't be a big reach.
2022-11-08 08:10:11 -05:00
Ian Jackson 93a150229a sqlite cache: Document reasoning about timestamps
As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/831#note_2851764
2022-11-08 13:00:51 +00:00
Nick Mathewson 897bac680f linkspec: Rename "maybe rename this?" TODOs in favor of #623 2022-11-07 12:27:50 -05:00
Nick Mathewson f5364065f3 PtTargetSettings: Enforce correctness at lower level.
This resolves a number of TODOs.
2022-11-07 12:21:22 -05:00
Nick Mathewson 06972f171d Remove a blank line 2022-11-07 12:19:02 -05:00
Nick Mathewson bc28793166 Downgrade TODO on chan_method
This is not something we need to solve for 1.1.0 (and it might not
need to be solved ever).
2022-11-07 11:49:49 -05:00
Nick Mathewson d448809e49 Merge branch 'hilev_spelling' into 'main'
Spelling fixes and normalizations on some high-level crates

See merge request tpo/core/arti!835
2022-11-07 15:48:06 +00:00
Nick Mathewson b423a40478 Remove TODO about third ChannelMethod variant.
We didn't find a use for this.
2022-11-07 10:39:13 -05:00
Nick Mathewson e832a90c4b Remove TODO about inlining PtTargetSettings.
Since there are (or soon will be) parsing restrictions on this type,
we don't want to inline it as a simple Vec.
2022-11-07 10:36:20 -05:00
Nick Mathewson b295518a42 Spelling fixes and normalizations on some high-level crates 2022-11-07 10:21:58 -05:00
Ian Jackson 85035c7c5a bridge desc: Make BridgeDescProvider DynClone
This allows the use of Box<dyn BridgeDescProvider> in callers,
since Box<dyn BridgeDescProvider> is now Clone.
2022-11-07 11:56:41 +00:00
Dimitris Apostolou 9c7d1802f5
Fix typos 2022-11-06 06:51:58 +02:00
Ian Jackson 5b66a5e199 bridge desc tests: Test caching and if-modified-since 2022-11-04 19:08:32 +00:00
Ian Jackson 78f7916a88 bridge desc tests: Break out queues_are_empty helper 2022-11-04 19:08:32 +00:00
Ian Jackson 40c21b7d19 bridge desc tests: Provide a sqlite connection
The current test case doesn't use this.
2022-11-04 19:08:32 +00:00
Ian Jackson 636bff3193 bridge desc: Implement storage functions at the DB layer 2022-11-04 19:08:32 +00:00
Ian Jackson 6bb2eb9902 bridge desc: Make Downloaded be Debug 2022-11-04 19:08:32 +00:00
Ian Jackson 5bc1d40a2b bridge desc: Implement cache reuse logic and if-modified-since
This introduces the new API functions to Store.
But currently they are all no-ops.
So all this machinery doesn't actually do anything.

Also, it changes the API to the mockable downloader, to allow it to
support if-modified-since.  So this isn't used either.  But it is more
convenient to do this all at once in BridgeDescManager, since care
needs to be taken about the intraction between if-modified-since and
the persistent cache.
2022-11-04 19:08:32 +00:00
Ian Jackson 279a169031 bridge desc: Rename one more variable to text 2022-11-04 19:02:23 +00:00
Ian Jackson eaaa61a8e2 bridge desc: Catch panics in the download functionality 2022-11-04 19:02:23 +00:00
Ian Jackson 3f3f27193c bridge desc: Provide a Store to the bridge desc manager
We use the one in the dirmgr.  That means that our constructor now has
to take a dirmgr.  And, the dirmgr must have a circmgr.

This is all rather odd, TBH.

Add .. to the binding of the return values from setup, as
future-proofing.

The tests now need to provide a Store too.  Make the sqlite::new_empty
function pub(crate) so we can use it.

We must retain the _db_tmp_dir, since when it goes away the tmp
directory is deleted and the db goes readonly.
2022-11-04 19:02:23 +00:00
Ian Jackson 1fa9dd62b3 bridge desc tests: Apply tracing_test::traced_test
This lets us see the log messages.  They look fine, as it happens.
2022-11-04 19:02:23 +00:00
Ian Jackson 9424b0970d tor-dirmgr: impl AsRef<dyn Error> for Error
This allows use with tor_error::Report.
2022-11-04 19:01:24 +00:00
Ian Jackson f3957a50b6 tor-netdoc: RouterDesc: Add published accessor
The bridge descriptor manager is going to want this.
2022-11-04 19:01:24 +00:00
Ian Jackson dcdd8053b4 dirmgr: Make store be in an Arc
This will let us share it with the bridge descriptor manager.
(As discussed with Nick.)
2022-11-04 19:01:24 +00:00
Ian Jackson 9a285ec4ad dirmgr sqlite store: Improve schema updates
* Centralise applying the schema updates, in a closure
 * Make the schema update SQL texts be in an array so we can loop
 * Make the version update statement generic, not cloned-and-hacked

This will make it possible to add another schema version without
error-prone conditions etc.
2022-11-04 19:01:24 +00:00
Gabriel de Perthuis 21a3808684 Upgrade to clap 3: replace deprecated functions
Also replace Arg::takes_value with Arg::action to configure flags
that don't take parameters vs options that do.

This makes it easy to upgrade to clap 4.

Tested deprecations with:

    cargo check --workspace --all-features --features clap/deprecated
2022-11-04 19:28:40 +01:00
Gabriel de Perthuis bc08ea48f7 Upgrade to clap 3 with minimal changes
This removes the last cargo audit override (for the unmaintained
ansi_term).

Don't mark options as required when they have default values:
see <https://github.com/clap-rs/clap/pull/3793>.
2022-11-04 19:28:38 +01:00
Ian Jackson bf563f3bdf bridgedesc: Rename "text" from "output"
This was confusing, because it's the output of the donwload, but
nowhere near the output of the whole process.  And it's going to
become even less so.
2022-11-03 19:00:47 +00:00
Ian Jackson 17ceae724e bridgedesc: Make process_document into a free function
It deserves this treatment, I think.
2022-11-03 18:59:50 +00:00
Ian Jackson c7a7ce5c20 bridgedesc: Introduce Downloaded
This gives names to things and makes things clearer, and this will be
even more true in a moemnt.
2022-11-03 18:59:50 +00:00
Ian Jackson d2b31f7796 bridgedesc: download: Break out process_document
We're going to want to reuse this for handling cached stuff.
2022-11-03 18:57:40 +00:00
Ian Jackson 6fbf3059cd bridgedesc: Prepare Mockable trait for if-modified-since 2022-11-03 18:57:40 +00:00
Nick Mathewson 7d079ade3b Merge branch 'warning' into 'main'
tor-guardmgr: use imported WeightThreshold in one place

See merge request tpo/core/arti!825
2022-11-03 16:25:37 +00:00
Ian Jackson 7d6f5d5eab guardmgr config: Provide bridge information to new and reconfigure 2022-11-03 15:48:07 +00:00
Ian Jackson aa375e2e09 tor-guardmgr: use imported WeightThreshold in one place
Without this, an unused import warning is generated when building
without features.
2022-11-03 15:44:32 +00:00
Ian Jackson 5bc3934fb4 bridges config: Provide uninhabited placeholder
This will avoid having to make bridge-related trait features in
GuardMgr conditional, which would be non-additive.
2022-11-03 15:43:41 +00:00
Ian Jackson 3dde9f8a05 bridges config: Check that bridges aren't enabled with no bridges
This is the validation which is called for by the documentation.
2022-11-03 15:43:41 +00:00
Ian Jackson 6c64be06a6 guardmgr config: Introduce and require new GuardMgrConfig trait
It doesn't seem to me like it makes sense to provide the backward
compatibility here.
2022-11-03 15:43:41 +00:00
Ian Jackson f50da3efa1 define_accessor_trait: Allow specification of other items 2022-11-03 15:43:41 +00:00
Ian Jackson 64de9f74be define_accessor_trait: Allow specification of supertraits 2022-11-03 15:43:41 +00:00
Ian Jackson 2bfce54959 guardmgr config: Pass fallback list from config by reference
This does involve additional cloning.  However, soon it will mean that
we can pass the whole `TorClientConfig` by reference.
2022-11-03 15:43:41 +00:00
Nick Mathewson 1179c39859 Suppress two clippy::large_enum_variant warnings
These are newly present on 1.65.  We can address them later.
2022-11-03 11:09:51 -04:00
Nick Mathewson 932fe48eaf Run add_warnings. 2022-11-03 11:06:02 -04:00
eta c77cecd5b3 Merge branch 'edition-2021' into 'main'
set all crate edition to 2021

See merge request tpo/core/arti!822
2022-11-03 14:39:24 +00:00
Ian Jackson 70b420adf8 bridge descriptors tests: Fix flaky test 2022-11-03 11:46:20 +00:00
Ian Jackson daf7eac60a bridge descriptors tests: Test set_bridges more thoroughly (fix)
The RetryDelays are being triggered for the 2nd time here, so their
timeouts can be longer.  We must bump the sleep to make sure we don't
have a flaky test.
2022-11-03 11:37:30 +00:00
Ian Jackson 7a99601721 bridge descriptors: logging: Log addition and removal (fmt)
Worsify formatting as demanded by rustfmt.
2022-11-03 11:37:30 +00:00
Ian Jackson 269808336e bridge descriptors: logging: Log addition and removal
This involves breaking the calls to `new_bridges.remove` into a helper
that does the logging.
2022-11-03 11:37:30 +00:00
Ian Jackson 17c766fde4 bridge descriptors: logging: Log download start and outcome 2022-11-03 11:37:30 +00:00
Ian Jackson 1ccd9db9af bridge descriptors tests: Test set_bridges more thoroughly
Prior to the previous commit, set_bridges would malfunction if there
were bridges which where (i) in current (ii) in queued or running
(iii) in the new bridge set.

This test failed then and passes now.
2022-11-03 11:37:30 +00:00
Ian Jackson 4a830e1ac2 bridge descriptors: Rewrite set_bridges
This was fundamentally confused and irregular.  Now it is more
regular: it does the same things to all the elements of Tracked,
and a simple filtering on current.

This fixes a bug, for which I'm about to add a test case.
2022-11-03 11:37:30 +00:00
Ian Jackson 0571674a64 bridge descriptors tests: Add another couple of test cases 2022-11-03 11:37:30 +00:00
Ian Jackson 6db3403820 bridge descriptors tests: stream_drain_ready returns event count
We'll use this in a moment.
2022-11-03 11:37:30 +00:00
Ian Jackson 53c1cf0c6d bridge descriptors tests: Break out bad_bridge helper function 2022-11-03 11:37:30 +00:00
Ian Jackson 42b1b08fdf bridge descriptors: Change default max_refetch
As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/820#note_2850269
2022-11-03 11:37:30 +00:00
Ian Jackson 2ae8a52371 bridge descriptors: Add clarification about bridge states 2022-11-03 11:37:30 +00:00
Ian Jackson ad39873782 bridge descriptors: Improve and fix docs for consider_launching 2022-11-03 11:37:30 +00:00
Ian Jackson d44bc1d0f8 bridge descriptors: Add comments where StateGuard is dropped 2022-11-03 11:37:30 +00:00
Ian Jackson 54e51cdba5 bridge descriptors: Document `changed` and `earliest_timeout` Options 2022-11-03 11:37:30 +00:00
Ian Jackson fb4ffb76fd bridge descriptors: Document updates argument to timeout_task 2022-11-03 11:37:30 +00:00
Ian Jackson 48f48841e1 Require derive_more 0.99.3
0.99.[012] have a bug https://github.com/JelteF/derive_more/issues/114
which makes the Deref derive for bridgedesc::StateGuard not work
and therefore breaks minimal-versions CI.

It seems simpler to require the newer version everywhere.
2022-11-03 11:37:23 +00:00
Ian Jackson 8eb7c731a2 bridge descriptors: Tests 2022-11-03 11:37:05 +00:00
Ian Jackson 3a185d61df bridge descriptors: Provide a consistency check function
This is really part of the tests, but I put it here so that it can be
compiled-in if someone wants it during debugging.
2022-11-03 11:37:05 +00:00
Ian Jackson 51b4588cc0 bridge descriptors: Provide an implementation of BridgeDescProvider
Tests will come in a moment.
2022-11-03 11:37:05 +00:00
Ian Jackson 0fb535ba28 tor-dirclient: Response: Provide into_output_string
This is the missing one of the full set.  It turns out that I wanted
this rather than the non-consuming output_string.
2022-11-03 11:37:05 +00:00
Ian Jackson 42f9651b8e Copy tor-netdoc/testdata/routerdesc1.txt into tor-dirmgr
This seems better than having tor_netdoc export a `#[cfg(test)]`
public constant.
2022-11-03 11:37:05 +00:00
Nick Mathewson 66f34ee774 Merge branch 'guards_as_bridges_part3' into 'main'
GuardMgr: decouple NetDir from guards and sample code.

See merge request tpo/core/arti!815
2022-11-02 12:41:03 +00:00
Nick Mathewson c2ed381c99 Refactor CandidateStatus API to simplify code in descs.
This removes some duplication.
2022-11-02 08:07:32 -04:00
Nick Mathewson fc0c12510a GuardMgr: Fix and improve comments based on review. 2022-11-02 08:07:32 -04:00
Nick Mathewson 6828178dec guardmgr: fix rustdoc references. 2022-11-02 08:07:32 -04:00
Nick Mathewson 08473872ab guardmgr: Refactor candidate info; add `full_dir_info`
Previously we always set `dir_info_missing` to `false` for new
guards, since new guards could only be taken from ones that were
present in the NetDir.  But for bridges, we don't download their
info until _after_ we have chosen them as guards.
2022-11-02 08:07:11 -04:00
Nick Mathewson 5867318a35 guardmgr: Implement Universe for bridges.
Now we can use a group of bridges as the basis for a sample of
guards.
2022-11-02 08:06:43 -04:00
Nick Mathewson 79dade342a guardmgr: Universe API should look up by ChanTarget
This will be necessary for bridges.
2022-11-02 08:06:43 -04:00
Nick Mathewson 82e9a57012 guardmgr: take sampled guards from Universe.
This is a trickier case, since we have to deal with weights.
2022-11-02 08:06:43 -04:00
Nick Mathewson 7733146c8c guardmgr: Continue porting porting code to use Universe.
Two more simple cases that can use Universe instead of Netdir.
2022-11-02 08:06:20 -04:00
Nick Mathewson fbcacea993 guardmgr: Begin to decouple guards from NetDir.
In this and the upcoming commits I'll be changing how guards related
to `NetDir` and to `Relay`.  Previously, a guard could only come
from (or be updated from) a `Relay` in a `NetDir`.  Soon it will be
able to be built from a bridge as well.

To do this, I'm defining a `Universe` trait (name negotiable) that
represents a set of things that may be guards.  I'm going to
continue extending its functionality until there are no more
methods in guard.rs or sample.rs that take `NetDir`.

This commit removes most of the usage of `NetDir` and `Relay` in
`guard.rs`.
2022-11-02 08:05:51 -04:00
Nick Mathewson b5f498021d guardmgr: Rename microdescriptor_missing to dir_info_missing 2022-11-02 07:59:56 -04:00
Nick Mathewson 39ea0518ee guardmgr: Allow guards to be constructed from any ChanTarget. 2022-11-02 07:59:56 -04:00
Nick Mathewson 1cb6ea1e77 guardmgr: Include PtTarget in guards.
Use a vector, since we may (someday) want to allow a Guard to have
multiple PtTargets.
2022-11-02 07:59:56 -04:00
Ian Jackson 0489d2d4be Merge branch 'notify' into 'main'
refactor config reload triggering

Closes #562

See merge request tpo/core/arti!819
2022-11-01 13:31:17 +00:00
trinity-1686a c487de6c46 debounce reload cfg events 2022-11-01 13:42:05 +01:00
trinity-1686a d29f38603d set all crate edition to 2021 2022-11-01 00:17:33 +01:00
trinity-1686a ce886e209f rename unused field 2022-10-30 12:36:13 +01:00
trinity-1686a 5cf2933d33 update some strings 2022-10-30 12:31:07 +01:00
trinity-1686a 5abddfb579 use iife so we can try! instead of custom error handling 2022-10-30 12:31:07 +01:00
trinity-1686a 66c08c967e refactor so events always indicate reload 2022-10-30 12:31:07 +01:00
trinity-1686a 749746a609 depends less on notify types 2022-10-30 12:31:07 +01:00
trinity-1686a e6e064ac8a remove unused dependancies 2022-10-29 13:29:55 +02:00
Nick Mathewson 29c46d08b5 Merge branch 'guards_as_bridges_part2' into 'main'
Use ByRelayIds to hold guards in GuardSet

See merge request tpo/core/arti!808
2022-10-27 21:09:47 +00:00
Nick Mathewson 557a07677e guardmgr: Rename and clarify of non-persistent-state copy fns
These will need a bigger overhaul: see #612 and #611.
2022-10-27 16:40:35 -04:00
Ian Jackson 4f171acaf7 Clarify fix_consistency 2022-10-27 16:40:35 -04:00
Ian Jackson 7180079112 Clarify what it means to be "an identity" for a primary guard. 2022-10-27 16:40:35 -04:00
Ian Jackson 15d464a929 tor-guardmgr: Add big doc comment about guard id handling 2022-10-27 16:40:35 -04:00
Ian Jackson 4a59d384b6 tor-dirmgr: impl Default for FlagPublisher 2022-10-27 15:57:57 +01:00
Ian Jackson 94325cd456 tor-dirmgr: impl FlagEvent for BridgeDescEvent 2022-10-27 15:57:57 +01:00
Ian Jackson 26a7aa9aa6 BridgeDescProvider: Make BridgeDescEvent repr(u16) and derive traits
This will enable us to impl FlagEvent for it.
2022-10-27 15:57:54 +01:00
Ian Jackson a56efbfdf0 impl Hash for BridgeConfig and various PT information
The bridge descriptor manager wants to index data structures by the
BridgeConfig.
2022-10-27 15:57:54 +01:00
Ian Jackson a89daba1c8 tor-guardmgr: bridges: export BridgeDescError at toplevel 2022-10-27 15:57:54 +01:00
eta 84a2624401 Merge branch 'fuzz_ptmgr_ipc' into 'main'
ptmgr: Add a fuzzer for ptmessage.

See merge request tpo/core/arti!814
2022-10-27 14:51:35 +00:00
eta b3d8f3b5ee Merge branch 'simpler_quote_skipping' into 'main'
ptmgr::ipc: Try an alternate approach to initial quotes.

See merge request tpo/core/arti!813
2022-10-27 14:50:56 +00:00
Ian Jackson 9796d615f8 tor-basic-utils: Provide an implementation of BinaryHeap::retain
This is currently nightly-only and is blocked on an unresolved API
question:
  https://github.com/rust-lang/rust/issues/71503
2022-10-27 10:46:03 +01:00
Ian Jackson a59fef00e9 tor-checkable: Make TimerangeBound::dangerously* non-experimental
I want one of these for the bridge descriptor downloader, and they
seem reasonable to me.
2022-10-27 10:46:03 +01:00
Nick Mathewson 9f73ddd440 Merge branch 'assert_maxlen' into 'main'
tor-cell: Assert data length in Data cells

See merge request tpo/core/arti!800
2022-10-27 01:46:21 +00:00
Nick Mathewson 42fefe021d ptmgr: Add a fuzzer for ptmessage. 2022-10-26 16:59:48 -04:00
Nick Mathewson cb7eb3b00d ptmgr::ipc: Try an alternate approach to initial quotes.
This lets us use `chars()` rather than `char_indices()`.
2022-10-26 14:49:24 -04:00
Nick Mathewson a8b96534be Merge branch 'dirclient-yaks' into 'main'
Misc minor changes to tor-dirclient, for descriptor downloading

See merge request tpo/core/arti!810
2022-10-26 18:43:15 +00:00
eta a118a639ed tor-ptmgr/ipc: First cut of pluggable transport spawning
The new `ipc` module inside `tor-ptmgr` implements the Pluggable
Transport Specification version 1 (`pt-spec.txt`,
https://gitlab.torproject.org/tpo/core/torspec/-/blob/main/pt-spec.txt).

This enables module users to spawn pluggable transport binaries inside a
child process asynchronously, and receive structured information about
how to connect to the transports provided by said binaries.

Internally, this is structured as a pure set of serialisers and
deserialisers for the protocol in the specification (in the form of
environment variables, and the PT's stdout), a wrapper to run the PT
binary and enable accessing its output asynchronously, and a user-facing
wrapper that handles ensuring all the requested transports launched
properly.

The included `run-pt` example is an exceedingly minimal wrapper program
that was useful in testing. More tests can and should be added in a
further MR.

closes arti#394; part of arti#69
2022-10-26 16:07:30 +01:00
Ian Jackson d0492ba189 Merge branch 'redundant_allocation' into 'main'
tor-bytes: Avoid redundant allocation

See merge request tpo/core/arti!806
2022-10-26 09:43:13 +00:00
Ian Jackson a04becf8b4 Merge branch 'flag-event' into 'main'
FlagEvent trait: Implement using macros

See merge request tpo/core/arti!804
2022-10-25 19:16:45 +00:00
Ian Jackson 79a6b4d94f tor-dirclient: impl HasKind for RequestFailedError 2022-10-25 20:12:56 +01:00
Ian Jackson 0b046ad4fb tor-dirclient: Promise that download only gives RequestFailed 2022-10-25 20:12:56 +01:00
Ian Jackson b68f7af79b tor-dirclient::DirResponse: provide output_string
This gives callers a nice error type with source and everything.
2022-10-25 20:12:56 +01:00
Ian Jackson 897e472e60 tor-dirclient: Provide RoutersOwnDescRequest
This will be used for bridges' descriptors.
2022-10-25 20:12:56 +01:00
Ian Jackson 9c9d82f6b8 Fix clippy false positive 2022-10-25 19:42:41 +01:00
Nick Mathewson 20016df6fa guardmgr: Use new ambiguity-tolerant contains in state handling
This has subtleties; the comments try to explain them.
2022-10-25 11:15:53 -04:00
Nick Mathewson d65c351b33 guard sample: Change semantics of `contains` to handle ambiguity.
This is necessary for the (somewhat undesirable) lookup_ids function
to return an ID that the dirmgr can actually use to report successes
and failures.

As noted, lookup_ids will create problems down the road when we
implement relays. We should refactor it out before then.
2022-10-25 11:15:53 -04:00
Nick Mathewson 28f2e2997e Replace contains_relay with can_add_relay().
To see if we can add a relay as a guard, we need a conservative
test: any IDs in common with the given relay prevent us from adding
it.
2022-10-25 11:15:53 -04:00
Nick Mathewson 3a994c32dc Convert guard samples to use ByRelayIds.
This required a number of changes, which I've tried to document.
I've taken a conservative approach to modification, and I'm not
using any of the by_*_mut() functions (yet).  For cases which
potentially modify the whole set, I'm using into_values() and
collect() to ensure that it's re-indexed correctly, even though the
identities don't change.

I introduce some "TODO pt-client" comments here which I will resolve
in the next commit(s).
2022-10-25 11:15:53 -04:00
Ian Jackson f7e5892e40 BridgeDescEvent: Change the sole variant to SomethingChanged
And explain what this all means.
2022-10-25 15:32:56 +01:00
Emil Engler 362d822ee4
tor-bytes: Avoid redundant allocation
See c489e1d911
2022-10-25 16:24:42 +02:00
Nick Mathewson 8528d61a78 impl HasRelayIds for GuardId. 2022-10-25 09:23:28 -04:00
Nick Mathewson 7d313a12bc ByRelayIds: Add additional accessor functions.
These are the ones that turned out to be necessary while converting
guard samples to use ByRelayIds.
2022-10-25 09:23:28 -04:00
Nick Mathewson ac71bb0ef1 linkspec: add HasRelayIds::has_any_identity. 2022-10-25 09:23:28 -04:00
Nick Mathewson 49ffb1cf4b Merge branch 'safe_u16_conversion' into 'main'
tor-cell: Consistent and secure conversion to u16

See merge request tpo/core/arti!803
2022-10-25 13:17:55 +00:00
Nick Mathewson 49f0521904 Merge branch 'rename_for_to_from' into 'main'
tor-cell: Rename for_client and for_relay

See merge request tpo/core/arti!793
2022-10-25 11:53:57 +00:00
Nick Mathewson 303727081b Merge branch 'feat/add-semvermd-tor-cell' into 'main'
Add semver.md in tor-cell for MR#793

See merge request tpo/core/arti!798
2022-10-25 11:53:48 +00:00
breezykermo f177f8a02b Add semver.md in tor-cell for MR#793 2022-10-25 11:53:48 +00:00
eta 378a4999ad Merge branch 'fix_typos' into 'main'
tor-cell: Fix typos in msg.rs

See merge request tpo/core/arti!802
2022-10-25 10:36:07 +00:00
eta 26ff63f985 Merge branch 'explain_magic' into 'main'
tor-cell: Add comment explaing Data::MAXLEN

See merge request tpo/core/arti!801
2022-10-25 10:35:56 +00:00
Ian Jackson 9a175ee323 FlagEvent trait: Implement using macros
The explicit list of variant names, that needs to be kept in sync, and
is a test failure semver break hazard, is now gone.

All the necessary code is now generated automatically, and cannot be
wrong.

I want this because I find myself wanting to add a second
implementation of FlagEvent, for another type.
2022-10-25 10:33:28 +01:00
Ian Jackson f2a08a15cd tor-error: Tidy up use of thiserror::Error
1. Import it, as we do elsewhere, and use that import.
2. Use thiserror to generate the Display impl, rather than
   derive_more, as we do for errors elsewhere.

(tor_error still needs derive_more::Display for ErrorKind.)
2022-10-24 19:38:46 +01:00
Ian Jackson d7783dd956 tor-error: Rename truncated module to misc
This has no external API change, but makes space for other
miscellaneous errors to arrive later.
2022-10-24 19:38:46 +01:00
Nick Mathewson 40ec12b0cb Merge branch 'guards_as_bridges_part1' into 'main'
Allow GuardMgr to expose bridges as guards (part 1)

See merge request tpo/core/arti!785
2022-10-24 13:30:02 +00:00
Nick Mathewson c4263543d4 circmgr: More NOTEs and TODO pt-clients. 2022-10-24 08:59:12 -04:00
Nick Mathewson d7672a13d5 linkspec: specify sort order for HasRelayIds. 2022-10-24 08:59:12 -04:00
Nick Mathewson 103c88dd95 Circmgr: construct paths using either Relay or OwnedCircTarget
Previously we could only use Relay for this case, which won't work
any more: a Bridge is not a `tor_netdir::Relay`.  Instead we allow
the GuardMgr to give us something that knows how to convert itself
into an OwnedCircTarget.

This change required a far amount of follow-on revisions and
refactoring, but it should all be internal to the path-building
logic.
2022-10-24 08:59:12 -04:00
Nick Mathewson 47cd5c97da netdir: Expose addrs-in-same-subnets calculation from SubnetConfig
Previously this was a private method only visible from Relay, but now
we can use it on any two HasAddrs objects.
2022-10-24 08:59:12 -04:00
Nick Mathewson 1195c40a99 linkspec: Remove now-useless declared_peer_addr
The singleton variation here is almost never what we want.
2022-10-24 08:59:12 -04:00
Nick Mathewson bb117a4bd4 guardmgr: Refactor the interior of FirstHop.
Now it contains either an `OwnedChanTarget` or an `OwnedCircTarget`,
which will let `GuardMgr` return bridges that can be used to make
circuits.

As part of this change, it was necessary to revise some
address-modification functions that applied to filters and
`OwnedChanTarget`.  Now they do the smart thing, and remove only the
address that are in the `ChanMethod`.  This means that the addresses
from HasAddrs are still accurate about which addresses the relay
"has".
2022-10-24 08:59:12 -04:00
Emil Engler 05cad9f6d7
tor-cell: Add comment explaing Data::MAXLEN
This commit adds a comment explaining composition of the magic number
"11" found in the assignment of the Data::MAXLEN constant.
2022-10-24 14:46:32 +02:00
Emil Engler cc8b9e446f
tor-cell: Fix typos in msg.rs 2022-10-24 14:45:48 +02:00
Emil Engler c42a55d515
tor-cell: Consistent and secure conversion to u16
This commit improves the overflow protection of one call to
Vec::write_u16(), by replacing the cast conversion from self.sig.len()
with a call to u16::try_from(), like it is already done in the rest of
the accompanying function.
2022-10-24 14:40:51 +02:00
Nick Mathewson b5e96c3414 Merge branch 'by_ids_mutate' into 'main'
Add two ways to change entries in an n_key_set

See merge request tpo/core/arti!797
2022-10-24 12:36:30 +00:00
Nick Mathewson 15ac14a5d9 n_key_set: clean up some wide lines 2022-10-24 08:08:56 -04:00
Nick Mathewson ef1c0cd282 n_key_set: Re-insert by_foo_mut() accessors, but make them unsafe. 2022-10-24 08:04:02 -04:00
Nick Mathewson d648446201 Fix some litter in a doc comment. 2022-10-24 07:59:42 -04:00
Nick Mathewson 24e62d3197 n_key_set: Add ability to modify entries in the map.
The keys can change: if they do, then the entry is removed from its
previous position and inserted at the new one, possibly displacing
others.
2022-10-24 07:58:45 -04:00
Emil Engler fb2195b0cf
tor-cell: Assert data length in Data cells
This commit adds a `debug_assert!` macro into the `new_unchecked()`
function of the Data cell. Beside this, it also fixes a misleading
comment regarding that limit.
2022-10-24 13:33:24 +02:00
eta b031616b5f Merge branch 'fix_typos' into 'main'
tor-cell: Fix typos in msg.rs

See merge request tpo/core/arti!788
2022-10-21 20:21:28 +00:00
eta 533ff7bda2 Merge branch 'remove_redundant' into 'main'
tor-cell: Remove redundant match clauses

See merge request tpo/core/arti!792
2022-10-21 20:17:37 +00:00
eta 81525c345a Merge branch 'concrete_comments' into 'main'
tor-cell: Make historical comments more concrete

See merge request tpo/core/arti!787
2022-10-21 20:16:27 +00:00
eta 15d8ee715a Merge branch 'circmgr' into 'main'
tor-circmgr make get_or_launch_dir_specific depend on specific-relay feature

See merge request tpo/core/arti!795
2022-10-21 20:14:44 +00:00
Ian Jackson a4e65d38e1 Merge branch 'no_redundant_copy' into 'main'
tor-cell: Avoid redundant pointer copy

See merge request tpo/core/arti!791
2022-10-21 17:51:25 +00:00
Ian Jackson 0924fb3623 tor-guardmgr: descs: Make BridgeDescError DynClone 2022-10-21 16:22:17 +01:00
Ian Jackson f4ec3e6cec tor-guardmgr: descs: Make BridgeDescError into a trait 2022-10-21 16:22:13 +01:00
Ian Jackson 77ddddb1f8 tor-error: make HasRetryTime object-safe
We could in the future provide a version of abs_retry_time which took
an &dyn closure if that turns out to be wanted.

I think this isn't a semver break because trait implementors are
allowed to relax bounds.
2022-10-21 16:08:48 +01:00
Ian Jackson a30e42a740 tor-circmgr: Make get_or_launch_dir_specific feature-specific 2022-10-21 15:19:18 +01:00
Ian Jackson 6806180ce1 tor-circmgr: Rename get_or_launch_dir_specific from _bridge
DirSpecificTarget in the usage was renamed apropos an MR comment but
this function name was overlooked.
2022-10-21 15:19:18 +01:00
Ian Jackson 2ccf8a1b5b tor-chanmgr: Suppress an unused imports warning for `use super::*`
If pt-client is disabled, there are in fact no tests, so the module is
empty.  But we would always want `use super::*` here.
2022-10-21 15:19:05 +01:00
Ian Jackson aa3cd7a97c tor-circmgr README: Add experimental features boilerplate 2022-10-21 15:18:41 +01:00
Ian Jackson ea7f31b357 tor-circmgr README: Remove "Limitations"
This doesn't make sense now we've released Arti 1.0.  The version
number is enough I think.
2022-10-21 15:18:41 +01:00
Ian Jackson f68591b923 tor-dirmgr README: Remove some redundant/duplicated headings 2022-10-21 15:18:41 +01:00
Nick Mathewson fa1d2f453a guardmgr: Hold FallbackDir in fallback::set::Entry
This resolves an old TODO, and will simplify our work a little.
2022-10-21 09:21:43 -04:00
Nick Mathewson 00f887db70 linkspec: Add compare-by-relay-ids function to HasRelayIds 2022-10-21 09:21:43 -04:00
Nick Mathewson 19fdf196d8 guardmgr: Add bridges sample, encode sample ID in FirstHopId.
The most important part of this commit is to make sure that each
`FirstHopId` includes the `GuardSetSelector` from which the guard
was selected.  Doing this lets us be certain that when we report
that a guard has succeeded or failed, we're reporting it in the
right context.

Additionally, this commit uses strum to make an iterator over the
samples, so that we can make sure that our "for each sample" code is
robust against future changes, and we don't miss the bridge sample.
2022-10-21 09:21:43 -04:00
Nick Mathewson fe6ac2d9ed Merge branch 'whoops_unused_imports' into 'main'
Oops: Mark some imports as pt-client only.

See merge request tpo/core/arti!794
2022-10-21 13:15:22 +00:00
Nick Mathewson e0c1928ea0 Merge branch 'matrix-features' into 'main'
add checks for many feature combinations

Closes #303

See merge request tpo/core/arti!775
2022-10-21 12:57:36 +00:00
Nick Mathewson 1e4b1f6433 Oops: Mark some imports as pt-client only.
This causes CI problems, and is entirely my fault.
2022-10-21 08:32:02 -04:00
Nick Mathewson a12667e077 Merge branch 'no_redundant_allocation' into 'main'
tor-cell: Avoid redundant allocation

See merge request tpo/core/arti!790
2022-10-21 12:18:49 +00:00
Emil Engler 169ed860c2
tor-cell: Avoid redundant pointer copy
This commit changes an iteration by copying a u16 (which is 2 bytes)
instead of a pointer address, which is most likely 8 bytes on most
machines.
2022-10-21 13:26:00 +02:00
Emil Engler c489e1d911
tor-cell: Avoid redundant allocation
This commit changes the way how a vector with a known sized gets
allocated, by using Vec::with_capacity() instead of Vec::new().
It will eventually avoid an allocation of more memory than required.
2022-10-21 13:25:26 +02:00
Emil Engler e5429a2891
tor-cell: Rename for_client and for_relay
This commit renames the for_client and for_relay functions to
from_client and from_relay respectively, in order to indicate their
origin, as the term "for" is more likely to indicate a destination,
which is not true in that situation.
2022-10-21 13:21:52 +02:00
Emil Engler 17759799f1
tor-cell: Remove redundant match clauses
This commit removes two redundant match clauses inside the
take_one_netinfo_addr function found inside msg.rs.
2022-10-21 13:17:43 +02:00
Emil Engler f423721cc3
tor-cell: Rename fixed_len to fixed_len_handshake
This commit renames the fixed_len! macro to fixed_len_handshake!, in
order to indicate, that this macro is only suited for cells with
commands related to handshaking.
2022-10-21 13:14:50 +02:00
Emil Engler 247cc37290
tor-cell: Fix typos in msg.rs 2022-10-21 13:10:30 +02:00
Emil Engler 7e04de6d96
tor-cell: Make historical comments more concrete
This commit extends comments that make references to historical protocol
versions of Tor, by adding the concrete protocol version numbers.
2022-10-21 12:59:26 +02:00
Ian Jackson db2ce541fb Merge branch 'dirclient-errors' into 'main'
Make DirResponse API not an error handling footgun

See merge request tpo/core/arti!782
2022-10-20 17:30:01 +00:00
Nick Mathewson f23adcd4c8 Merge branch 'pt-serde' into 'main'
serde support for PtTarget

See merge request tpo/core/arti!780
2022-10-20 17:13:19 +00:00
Nick Mathewson 608153cd93 Merge branch 'connect-via-proxy' into 'main'
Implement a TransportHelper to connect via a SOCKS-based pluggable transport

See merge request tpo/core/arti!776
2022-10-20 16:44:58 +00:00
Nick Mathewson 34aa352d16 Implement serde for PtTarget and its members.
This will let us remember bridges that use pluggable transports.
2022-10-20 12:37:41 -04:00
Nick Mathewson bc09a3fe65 Inline now-needless variant constructors for PtTargetAddr 2022-10-20 12:37:41 -04:00
Nick Mathewson 95b03dc96f Remove a now-needless `allow(dead_code)` 2022-10-20 12:37:41 -04:00
Nick Mathewson d8f9a79c4f linkspec: Always expose PT-related types.
The `PtTarget` type and its contents (`TransportName`,
`PtTargetAddr`, `PtSettings`) are now unconditionally compiled and
exposed.  This will allow us to serialize and deserialize them in
our guard-state files even when we have been built without explicit
PT support.

The `pt-client` feature controls whether `TransportName` is a
variant of `TransportId`, and whether `PtTarget` is a variant of
`ChanMethod`: this in turn means that we'll still have simpler
binary code and smaller structures when we're building without PT
support (which is what we wanted when we initially made these types
conditional).
2022-10-20 12:37:40 -04:00
Ian Jackson 7b2a0fbcb1 tor-dirclient: Provide fallible DirResponse::output and into_output 2022-10-20 17:24:53 +01:00
Ian Jackson da3351ad49 tor-dirclient: Make DirResponse be Clone
I want this for testing.  It seems friendly to provide it, though.
2022-10-20 17:24:53 +01:00
Ian Jackson b3675c76dc tor-dirclient: Introduce RequestError:HttpStatus 2022-10-20 17:24:53 +01:00
Ian Jackson e8d662ed7c tor-dirclient: Make RequestFailed its own error type (rustfmt)
Split off to assist review.
2022-10-20 17:24:53 +01:00
Ian Jackson d9375b2b8d tor-dirclient: Make RequestFailed its own error type
We're going to have functions on Response that fail by returning only
one of these.

Sadly this diff is quite noisy.
2022-10-20 17:24:53 +01:00
Ian Jackson 3b1af05851 tor-dirclient Response: Rename output methods
These don't check errors and are therefore quite hazardous.
I'm going to introduce a more cooked version in a moment.
2022-10-20 17:24:50 +01:00
Ian Jackson 803131c1ea Merge branch 'bridge-internal-apis' into 'main'
Use BridgeConfig to identify bridges in two places

See merge request tpo/core/arti!781
2022-10-20 16:14:14 +00:00
Ian Jackson 9c7ea41322 impl ChanTarget etc. for BridgeConfig 2022-10-20 14:16:34 +01:00
Ian Jackson 6193bed788 impl HasAddrs for PtChannelAddr and ChannelMethod 2022-10-20 14:16:34 +01:00
Ian Jackson c93500e14c tor-linkspec: impl From<&ChanTarget> for OwnedChanTarget
This lets us write functions which can either take an existing
owned OwnedChanTarget, or copy out of some other kind of ChanTarget
passed by reference.
2022-10-20 13:29:07 +01:00
Ian Jackson ef5e60c879 circmgr: Plumbing for direct to target directory circuits
The target is identified by Into<OwnedChanTarget>.
We introduce corresponding TargetCircUsage and SupportedCircUsage.
2022-10-20 13:28:30 +01:00
Ian Jackson 11c61a3d7f bridge descriptors: Change types of the descriptor cache
Now keyed by Arc<BridgeConfig>, and the values can be errors.

Currently there is no implementation so there can't be any errors,
but the error enum will become nonempty.
2022-10-20 13:28:23 +01:00
Nick Mathewson 05913f9720 transport: Escape = signs in keys only.
This is a compromise between C tor (never escapes = signs) and the
spec (calls for escaping all = signs).  In C tor there is no way to
actually construct a key with an = sign in it, so this difference
should be undetectable.
2022-10-20 08:11:05 -04:00
Nick Mathewson 40b9b57884 Clarify comment on ExternalProxyPlugin. 2022-10-20 08:11:05 -04:00
Nick Mathewson 27f53f241d transport: rename "ExtraneousData" to "UnexpectedData" 2022-10-20 08:11:05 -04:00
Nick Mathewson f39157f8c3 chanmgr: Add the code necessary to use SOCKS PTs via a TransportHelper
This is mostly a matter of encoding parameters in the format used
for socks authentication.
2022-10-20 08:11:00 -04:00
Nick Mathewson 50b65b217d chanmgr: Begin a socks-client implementation.
This code is _not_ conditional, since we want to support running
with a proxy even if we don't support pluggable transports.

We may eventually want to refactor this into a new create.
2022-10-20 08:09:18 -04:00
Nick Mathewson dcf27f2457 socksproto: Make a method conditional. 2022-10-20 08:09:18 -04:00
Nick Mathewson d1e70d9479 socksproto: impl Clone for Error. 2022-10-20 08:09:18 -04:00
Ian Jackson a5eba71edd HasAddrs: Make it clear that the set of addresses can be empty
Eg, a PT bridge may not have an address.
2022-10-20 12:47:50 +01:00
Nick Mathewson 2845ee24bf fix a couple of spelling errors in guardmgr 2022-10-19 07:49:39 -04:00
Nick Mathewson 5786637b4f Fix various typos (using typos tool and hand-inspection) 2022-10-18 15:39:33 -04:00
Nick Mathewson 3975d0db7e linkspec: Fix typo in error messages. 2022-10-18 15:01:54 -04:00
Nick Mathewson 06132d9f35 chanmgr: Add an error case if a final_attempt neither succeeds or fails
This can happen in weird corner cases, so it's probably best to
report it rather than having an "internal error."
2022-10-18 11:49:21 -04:00
Nick Mathewson 4b0c28014d Refactor flow control in get_or_launch.
Now, instead of duplicate checks in various cases, we simply go
through the loop one last time.

This allows us to simplify some of our other logic around here.
2022-10-18 11:49:21 -04:00
Nick Mathewson e0bd6111a8 chanmgr: Split get_or_launch into sub-functions.
This function had grown huge and hard to reason about.  Before I
make it even worse, let's split it up.
2022-10-18 11:49:21 -04:00
Nick Mathewson 710be8d4c6 chanmgr: Refactor choose_action code into its own function. 2022-10-18 11:49:21 -04:00
Nick Mathewson 8f4ff7014a Clarify a comment about the desired structure of ChanMgr 2022-10-18 11:49:21 -04:00
Nick Mathewson c0bca7213c Comments to explain effects of return in closure. 2022-10-18 11:49:21 -04:00
Nick Mathewson c802d39b80 chanmgr: Remove "Ident" from AbstractChannel
Thanks to our previous changes, we no longer need this type, or the
methods that access it.
2022-10-18 11:49:21 -04:00
Nick Mathewson c78bacce86 chanmgr: replace the HashMap<> with a ByRelayIds.
This is necessary so that we can look up channels (open and pending)
by all of the Ids that we know about them.

The operations needed here are pretty complex: to get them right,
I've replaced most of the accessors on the inner `ChannelMap` with a
function that holds the lock while another `FnOnce` is called.  This
still gets us the invariant that we can't accidentally await while
holding the lock on the `ChannelMap`.

I've removed the tests for the accessors that are no longer there.

There are some subtleties here.  Now that we have more than one kind
of Id, it's possible to have a partial match.  I've tried to explain
all these cases in the comments.
}
2022-10-18 11:49:21 -04:00
Nick Mathewson 61a33da0ff proto: Make Channel::reparameterize take &self.
Even though channels are practically changeable, they use locks
internally so that you don't need a `&mut Channel` to send or
receive traffic.  It makes sense for reparameterizing the channel to
also use a &self reference.

I'll need this so that I can store channels in an `ByRelayIds<>`
set, and still invoke their reparameterize methods.
2022-10-18 11:49:21 -04:00
Nick Mathewson 735100455d chanmgr: Add identities to pending state in map.
This will let us migrate from `HashMap<Ed25519Identity, Entry>` to
`ByRelayIds<Entry>`.
2022-10-18 11:49:21 -04:00
Nick Mathewson e51fdbfb1b chanmgr: Require HasRelayIds for AbstractChannel::BuildSpec
This is mostly a testing only change for now too, but soon I'll use
it to deal with the fact that we need to know the IDs to actually
build a channel at all.
2022-10-18 11:49:21 -04:00
Nick Mathewson 71db8ebc2e chanmgr: Require HasRelayIds for AbstractChannel.
This is mostly a testing-only change for now, but soon I'll use it
so we can have IdMap for our channel map.
2022-10-18 11:49:21 -04:00
Nick Mathewson e94cff26e2 chanmgr: Remove the Poisoned state from the map type.
The `ByRelayIds` type doesn't have a type equivalent to
`hash_map::Entry`, since it's a set type rather than a map
type. Therefore, the only plausible way to do entry mutation will
be to remove the old entry and insert a new one.  And so, we no
longer need a "poisoned" state.
2022-10-18 11:49:21 -04:00
Nick Mathewson 96493f427d proto: Implement HasRelayIds for Channel. 2022-10-18 11:49:21 -04:00
Nick Mathewson a46e8af605 linkspec: Add ByRelayIds::remove_exact.
We need a function to remove an entry if it appears with _exactly_
the same relay Ids, but not otherwise.  This method will do that.
2022-10-18 11:49:21 -04:00
Nick Mathewson 0c8a5a1fa4 linkspec: Add an "all_overlapping" accessor to ByRelayIds.
Also, add a few tests for this and the other accessors.

We'll need this accessor to find whether we have any channels to
_any_ of the identities that we're trying to connect to.
2022-10-18 11:49:21 -04:00
trinity-1686a 3200870079 fix doc-feature synchro 2022-10-16 21:02:10 +02:00
trinity-1686a 53016a005b add test for many features
and fix issue compiling tor-rtcompat with on ssl runtime
2022-10-16 21:02:10 +02:00
Nick Mathewson 522907ac9a Write more tests for RelayId and RelayIdRef. 2022-10-15 10:38:08 -04:00
Nick Mathewson 8e2ce9de1d Write tests for RelayIdSet. 2022-10-15 10:06:02 -04:00
Nick Mathewson ae07909a02 Fix deserialize impl for RelayId.
We need to handle String, not just str, since some deserializers
have to handle escapes and generate new strings.

Found while writing tests; fixes #605.
2022-10-15 10:04:37 -04:00
Nick Mathewson ddc5b63a19 linkspec: impl Hash for RelayIdRef 2022-10-15 09:57:45 -04:00
Nick Mathewson 31528202c5 chanmgr: Edit comments, fix docs 2022-10-13 10:32:02 -04:00
Nick Mathewson 913d5b68ec chanmgr: Remove RegistryAsFactory.
Since there is no longer a blanket implementation of ChannelFactory
for TransportHelper, we no longer need a separate type here.
2022-10-13 10:15:05 -04:00
Nick Mathewson fe2d44d10a ChanMgr: Reorganize factory, builder, transport code.
There is no actual code change here: just movement.
2022-10-13 10:09:52 -04:00
Nick Mathewson 8f267ba166 Fix some rustdoc errors.
In addition to the usual "You named that method wrong!" errors, we
have a new rustdoc error that complains about bogus "HTML tags" that
are actually unquoted usage of types like `Result<Foo>`.
2022-10-13 09:08:46 -04:00
Nick Mathewson 85284ef847 Merge branch 'factory_redux' into 'main'
chanmgr: Build and use chanmgr factory APIs

See merge request tpo/core/arti!769
2022-10-13 12:58:28 +00:00
Nick Mathewson 7b58126706 Flatten TimeoutChannelFactory into ChannelBuilder. 2022-10-13 08:36:05 -04:00
Nick Mathewson 69b64a2795 chanmgr: clean up some TODO pt-client items and documentation. 2022-10-13 08:36:05 -04:00
Nick Mathewson d759489530 Allow multiple ChannelBuilders to share a ChanMgrEventSender. 2022-10-13 08:36:05 -04:00
Nick Mathewson 6b587b25e1 chanmgr: Use ChannelFactory via a Box<dyn<ChannelFactory>>.
This will prepare for supporting multiple different ChannelFactory
implementations.
2022-10-13 08:36:05 -04:00
Nick Mathewson 15108be5ce chanmgr: Move Timeout functionality into a decorator object. 2022-10-13 08:36:05 -04:00
Nick Mathewson e21ac24c77 Have ChannelBuilder use TransportHelper.
This lets us build channels using different TransportHelpers,
including the (new) default TransportHelper, which just uses the old
connect_to_one() code.
2022-10-13 08:36:05 -04:00
Nick Mathewson b4cc98b21b Merge branch 'readmes' into 'main'
Abolish maint/readme and use doc include

Closes #603

See merge request tpo/core/arti!768
2022-10-12 15:16:18 +00:00
Ian Jackson f84d8777db cargo fmt to remove blank lines
Apparently cargo fmt doesn't like these, which my perl rune didn't
delete.

This commit is precisely the result of `cargo fmt`.
2022-10-12 15:29:04 +01:00
Ian Jackson d9910dba08 Replace all README copies in src/lib.rs with includes
The feature we want is `#[doc = include_str!("README.md")]`, which is
stable since 1.54 and our MSRV is now 1.56.

This commit is precisely the result of the following Perl rune:
  perl -i~ -0777 -pe 's{(^//!(?!.*\@\@).*\n)+}{#![doc = include_str!("../README.md")]\n}m' crates/*/src/lib.rs
2022-10-12 15:29:03 +01:00
Ian Jackson 13654d7cd2 README doctests: fix tor-rtmock 2022-10-12 15:27:14 +01:00
Ian Jackson af07e17b45 README doctests: fix safelog
Add some dummy definitions that support the example.
2022-10-12 15:27:02 +01:00
Ian Jackson 99f4511f1e README doctests: fix fs-mistrust
Add fn main wrappers to allow use of ?.

Add ,no-run to test cases that fail due to accessing the filesystem.
2022-10-12 15:26:52 +01:00
Ian Jackson 03a6141865 README doctests: fix arti-client
Add ,ignore to ignore three shell runes.
2022-10-12 15:26:18 +01:00
Nick Mathewson 4d25049473 Implement ChannelFactory for (a wrapper of) TransportRegistry.
This will let us just have ChanMgr take a `dyn ChannelFactory`.
2022-10-12 10:15:00 -04:00
Nick Mathewson 28caae68d1 chanmgr: Clean up async-ness on factory types.
The traits that launch connections need to be async; the traits that
don't, shouldn't be async.

Additionally, we need a few more "Sync" annotations here for the
futures to work.
2022-10-12 10:15:00 -04:00
Nick Mathewson a106d97503 Rename mgr::ChannelFactory to mgr::AbstractChannelFactory
This is an internal type (distinct from factory::ChannelFactory)
that we use to make the code in `tor_chanmgr::mgr` agnostic about
what a channel actually is, and how it is actually launched.

Therefore, I'm renaming it and giving better documentation in a
couple of places, to prevent confusion.
2022-10-12 10:15:00 -04:00
Nick Mathewson 5da9596a04 Add several accessors to ChannelMethod.
* Get `TransportId`
 * Get the target address (of any type)
 * Ask, "is this a direct connection"?
2022-10-12 10:15:00 -04:00
Ian Jackson ac1c0bf8fb README doctests: fix arti-client
Add ,ignore to ignore three examples that don't actually compile.

cargo readme would add these annotations to lib.rs, but the doc
include doesn't do stuff like that.  pandoc seems to still render the
result just fine.
2022-10-12 14:56:37 +01:00
Ian Jackson 19de971775 struct BridgeConfig: Rename from Bridge
Fixes #599
2022-10-12 13:54:25 +01:00
Ian Jackson 029a11c833 struct Bridge: add ref to ticket 2022-10-12 13:51:52 +01:00
Ian Jackson b8b885fcf5 cfg tests: bridges: Document test case assumptions 2022-10-12 13:50:29 +01:00
Ian Jackson d1a84d9693 cfg tests: bridges: Remove now-redundant block { } 2022-10-12 13:50:29 +01:00
Ian Jackson 78d143c940 cfg test: bridges: Test all three feature cases
This demonstrates that:

 * !bridge-client: uncommenting nondefault bridge config generates
   urecognized config key warnings (but the config is still accepted)(

 * bridge-client, !pt-client: uncommenting nondefault bridges generates
   error due to attempting to use a PT.  If that's filtered out,
   everything is fine.

 * pt-client: Everything is good (as before).
2022-10-12 13:50:29 +01:00
Ian Jackson f0120534a2 cfg tests: bridges: Prepare for more comprehensive testing
* Introduce filter_examples and resolve_examples helpers,
  which will become more complex in a moment.

* Move the API test into a { } block to minimise subsequent diff.
  It's going to become conditional.

* In subsequent comparisons, use the parsed version, since
  the API built one might not exist.

No overall functional change.
2022-10-12 13:50:29 +01:00
Ian Jackson 7378a00a28 cfg tests: Make ExampleSectionLines::resolve fallible 2022-10-12 13:50:29 +01:00
Nick Mathewson fcea69bceb Fix comment typo. 2022-10-12 13:50:29 +01:00
Nick Mathewson 63cd6b0c87 Fix error message 2022-10-12 13:50:29 +01:00
Ian Jackson 2fb052404d bridge config: Clarify that examples are nonfunctional 2022-10-12 13:50:29 +01:00
Ian Jackson a1b76bc04f bridges: Test configuration 2022-10-12 13:50:29 +01:00
Ian Jackson 3c33108a85 pt and bridges: Parse configuration 2022-10-12 13:50:29 +01:00
Ian Jackson df2b10ea77 config exhaust checking: Feature-limit some of the tests 2022-10-12 13:50:29 +01:00
Ian Jackson cb1adb0103 tor-config: Provide MultilineListBuilder
This is what we'll use to parse the `bridges.bridges` config key.
2022-10-12 13:50:29 +01:00
Ian Jackson f9e841841a tor-guardmgr: Export BridgeParseError from toplevel
Callers could `use` it as `tor_guardmgr::config::BridgeParseError` but
it seems unecessary to force them to.
2022-10-12 13:50:29 +01:00
Ian Jackson debfa1f107 tor-config: Remove unneeded braces in an example 2022-10-12 13:50:29 +01:00
Ian Jackson 4a6ac4090c tor-config: Provide BoolOrAuto
We're going to use this for the config item `bridges.enabled`,
but it seems general enough that it ought to go here.
2022-10-12 13:50:29 +01:00
Ian Jackson b766b16e46 tor_config: define_list_builder_helper: Support custom serde
We're going to want something that has the standard list builder
methods at the Rust API, but which has different serialisation.

Sadly the implementation is annoying, because macro_rules makes it
hard to parse a nice input syntax.
2022-10-12 13:50:29 +01:00
Ian Jackson ffcc548163 Add pt-client and bridge-client features to arti and arti-client 2022-10-12 13:50:29 +01:00
Ian Jackson 4b1dea9d33 bridges config example: Add much more example syntax 2022-10-12 13:50:29 +01:00
Ian Jackson 86364e6f0a bridges config example: Add bridges section to example config
This is precisely the text from the original version of !744.

There is no implementation yet, so we must add a entry to the
exception list in the tests.
2022-10-12 13:50:29 +01:00
Ian Jackson 136e511390 config exhaust checking: Allow for whole sections
Section headings appear uncommented in the file, so if we have a
whole section which is completely unrecognized (ie, an entry with no
`.`, it will be spotted when we parse the not-uncommented file too.

Right now there aren't any but there will be in a moment.
2022-10-12 13:50:29 +01:00
Ian Jackson 9ec657d632 config exhaust checking: Allow for options only unrecognized in new 2022-10-12 13:50:29 +01:00
Ian Jackson a32a590886 config exhaust checking: Move unrecognized lists earlier
It turns out that we will need these even for uncommented parsing.
2022-10-12 13:50:29 +01:00
Ian Jackson 7393ea6dd4 arti config exhaust checking: Improve message, add comment
I had a failure that was confusing to me, and I wrote it...
2022-10-12 13:50:29 +01:00
Ian Jackson 82ad9eea5f Allow "clippy::single_char_pattern" in tests.
This lint exists for perf reasons, and this is rarely relevant in
tests.

Using double quoted str is generally cognitively less burdensome.
2022-10-12 13:50:29 +01:00
eta 0b588bb855 Merge branch 'typo' into 'main'
tor-config: CfgPath: Fix two typos "expaneded"

See merge request tpo/core/arti!764
2022-10-11 16:25:18 +00:00
eta e0698ef661 Merge branch 'disable_rtt_test' into 'main'
Disable rtt_test_vectors test on non-Linux platforms

See merge request tpo/core/arti!766
2022-10-11 14:46:29 +00:00
Nick Mathewson 34587ef192 Disable rtt_test_vectors test on non-Linux platforms
This test depends on `Duration` having a granularity of 1
nanosecond, which is not the case on OSX, and is probably not the
case on other places too.

We can re-enable this once we have a set of test vectors that use
more realistic RTTs, and a set of testing code that tolerates some
divergence.

Temporary solution for #574.
2022-10-11 10:18:04 -04:00
Nick Mathewson 0cb7b030b3 Fix a warning that I reintroduced.
It looks like this got fixed, but my branch for !759 reintroduced it
by refactoring.
2022-10-11 09:38:04 -04:00
Nick Mathewson 74d4c73d09 Change multiplicity of ChannelMethod and addresses
Now each `ChanTarget` has at most one `ChannelMethod`, and only
`Direct` `ChannelMethods` can have multiple addresses.

Closes #600.
2022-10-11 08:53:31 -04:00
Ian Jackson 171c4208a7 Make some things precisely conditional
I think this is quite an inconvenient way to be carrying on.

Maybe we should disable all dead code warnings unless all features are
also enabled, and just let the compiler get rid of unused stuff later.
2022-10-11 12:22:50 +01:00
Ian Jackson 85464bc770 tor-guardmgr: Fix build without pt-client feature 2022-10-11 12:22:46 +01:00
Ian Jackson 32126f2089 Allow two useless pattern matches that are going to be not useless 2022-10-11 12:22:46 +01:00
Ian Jackson d6b85b27c4 tor-config: CfgPath: Fix two typos "expaneded" 2022-10-11 11:22:49 +01:00
Ian Jackson 19d33d207d Merge branch 'progdir' into 'main'
CfgPath: Add support for ${PROGRAM_DIR}.

Closes #586

See merge request tpo/core/arti!760
2022-10-11 10:20:06 +00:00
eta fc5629cc1c Make cargo-sort stop complaining 2022-10-10 11:57:08 +01:00
EliTheCoder 16430ff54a Fixed grammar mistake 2022-10-08 02:06:09 +00:00
Nick Mathewson e005d38edb CfgPath: Add support for ${PROGRAM_DIR}.
`${PROGRAM_DIR}` expands to the equivalent of
`std::env::current_exe().parent()`, with appropriate unwrapping and
conversions.

It is expected to be useful for finding the locations of pluggable
transports in some kinds of bundles.

Closes #586.
2022-10-07 09:03:00 -04:00
Nick Mathewson c41305d110 tor-cell fuzzer: test more features. 2022-10-06 15:48:45 -04:00
Nick Mathewson 22b14066f0 Clarify limits on socket address from ChannelMethod 2022-10-06 15:13:05 -04:00
Nick Mathewson 95a5393cd8 Move two users of HasAddrs to HasChannelMethods
All the other users of HasAddrs are correct.
2022-10-06 15:13:05 -04:00
Nick Mathewson 299ebd729d tor-linkspec: Remove the old OwnedFoo::new() functions
These are now builders.
2022-10-06 15:13:05 -04:00
Nick Mathewson 34c9178feb tor-proto: Preserve the ChannelMethod, not the SocketAddr 2022-10-06 15:13:05 -04:00
Nick Mathewson f8dc4f8b06 ChannelMethod: Add method to access the (optional) SocketAddr 2022-10-06 15:13:05 -04:00
Nick Mathewson b84224feb4 Add builders for OwnedChanTarget/OwnedCircTarget
This will become the preferred way to make one of these objects, and
insulate us against future API changes.
2022-10-06 15:13:05 -04:00
Nick Mathewson ce09b7c96f Begin revising HasAddr and its relationship to ChanTarget
HasAddr used to mean "Here are addresses that I have, at which I can
be contacted."  But "Where (and how) can I be contacted?" is now a
question for HasChannelMethod to answer.

(We still need to have "HasAddr", though, so we can answer things
like "what country is this relay in" and "are these relays in the
same /8?")

So this commit introduces:
  * A new trait for adding an implementation of HasChannelMethod in
    terms of HasAddr.
  * A requirement on ChanTarget that it needs to implement
    HasChannelMethod.

There is some temporary breakage here, marked with "TODO pt-client",
that I'll fix later in this branch.
2022-10-06 15:13:05 -04:00
Nick Mathewson 1d70bf4ddd Merge branch 'bridge_containers' into 'main'
Start implementing more data structures to hold Bridge descriptors.

See merge request tpo/core/arti!755
2022-10-06 17:16:44 +00:00
Nick Mathewson 3f419f7f65 Extend some comments about bridge descriptors 2022-10-06 12:56:28 -04:00
eta 92c5b386ac Merge branch 'workaround_589' into 'main'
Temporarily suppress a false positive from nightly.

See merge request tpo/core/arti!754
2022-10-06 14:15:23 +00:00
trinity-1686a f230cb5c03 remove manual limitation of coredump size
it's already disabled by secmem_proc
2022-10-05 18:32:16 +02:00
trinity-1686a 2b8b775dfc feature-gate some functions requiring PreferredRuntime 2022-10-05 12:54:04 +02:00
Nick Mathewson fac975ddfb Add a temporary HasAddrs for BridgeRelay
See comment for an explanation of the next issue here.
2022-10-04 17:53:40 -04:00
Nick Mathewson 23b3b0553f BridgeRelay: Implement more traits.
Also add a BridgeRelayWithDesc type (name tbd) to guarantee that
a bridge relay really does have a known descriptor before you
try to build a circuit with it.
2022-10-04 17:49:32 -04:00
Nick Mathewson acb6288621 netdoc: Add accessors for protocols and ntor key.
These are needed to actually be able to build circuits through
a bridge.
2022-10-04 17:49:32 -04:00
Nick Mathewson d9e3d38bd6 Start on a new BridgeRelay type.
This is the one we'll actually use to connect to bridges. It
has a `Bridge` line, and an optional `BridgeDesc`.

Maybe this will turn into a `BridgeRelay<'a>` by analogy to `Relay`
some time; I'm not sure.
2022-10-04 17:49:32 -04:00
Nick Mathewson 013b9bff1b Implement HasRelayIds for Bridge. 2022-10-04 17:49:32 -04:00