Commit Graph

4688 Commits

Author SHA1 Message Date
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 881f6edd9f Abolish maint/readmes
This is not needed any more
2022-10-12 15:29:04 +01: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
eta 71bbfbab48 Merge branch 'bridge-rename' into 'main'
Rename Bridge to BridgeConfig

Closes #599

See merge request tpo/core/arti!767
2022-10-12 13:52:07 +00:00
Ian Jackson 9004f94443 Merge branch 'bridge-config-example' into 'main'
Add bridges configuration section

See merge request tpo/core/arti!744
2022-10-12 13:18:02 +00: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 d6554e816f Merge branch 'fix_warning_again' into 'main'
Fix a warning that I reintroduced.

See merge request tpo/core/arti!765
2022-10-11 14:05:08 +00: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 34c689cbe8 Merge branch 'one_method' into 'main'
Change multiplicity of ChannelMethod and addresses

Closes #600

See merge request tpo/core/arti!759
2022-10-11 13:20:55 +00:00