Commit Graph

2841 Commits

Author SHA1 Message Date
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
Nick Mathewson d4f26581c0 Implement BridgeDesc and BridgeDescList.
BridgeDesc is a separate type to make sure that we do not confuse
bridges' descriptors with the descriptors from other routers down
the road.  (Bridges' descriptors need to be used differently, and
treated as more private.)

With this code, BridgerDescList is now just an alias for
`ByRelayIds<BridgeDesc>`, which is pretty keen.
2022-10-04 17:49:32 -04:00
Nick Mathewson 6f0d974cbe tor-netdoc: Add relay ID accessors for RouterDesc.
To implement a reasonable RsaIdentity accessor, we have to
store the RsaIdentity in the RouterDesc, or else we'd have to
recalculate it using SHA1 and DER every time.

The Ed25519 identity is hidden inside the identity cert, but it's
safe to get a reference to it.
2022-10-04 17:49:32 -04:00
Nick Mathewson 6341057129 Temporarily suppress a false positive from nightly.
Nightly rust gives a warning about this "pub use", but the warning
is a false positive.  Since it doesn't seem to be going away in a
hurry, let's suppress it for now.
2022-10-04 16:40:34 -04:00
Nick Mathewson 5a5f96aa37 n_key_set: Fix bugs in API documentation.
For whatever reason, rustdoc didn't like these multiline strings
in `doc` attributes.
2022-10-04 16:05:40 -04:00
Nick Mathewson 11caa46525 tor-linkspec: ByRelayIds<> type to hold a set of HasRelayIds
This is based on the type generated with n_key_set, with a
couple of extra methods to take advantage of RelayId and RelayIdRef.
2022-10-04 16:05:40 -04:00
Nick Mathewson f8382d4978 n_key_set: Wrap "where" clauses in square brackets too.
Otherwise, there is a parsing ambiguity. :(
2022-10-04 16:05:40 -04:00
Nick Mathewson 8475d3ab39 n_key_set: Rename generic parameters on functions.
Previously we used `<T>` in a bunch of places.  But that fails
if you try to declare `T` as a parameter on the structure itself.
2022-10-04 16:05:40 -04:00
Nick Mathewson bf7c0bb2ba n_key_set: Add a try_insert().
I am finding as I use this that I want a variant that can't panic.
2022-10-04 16:05:40 -04:00
Ian Jackson 9705ef3fea Merge branch 'bridge-parse' into 'main'
Parse (and format) bridge lines

See merge request tpo/core/arti!745
2022-10-03 20:13:02 +00:00
Ian Jackson 193d0f7007 pt: bridge line parsing: overhaul errors
Include the offending word in all the applicable errors.
Always print it with {word:?}.

As a consequence, there are no From impls any more and error
generation/conversion is by hand in all cases.

Clarify InvalidPtOrAddr vs InvalidIAddrorPt, and don't make the
attempted parse be a source error for those.

Where we still have source errors, don't print them in Display.
2022-10-03 20:45:54 +01:00
Ian Jackson c920dca9b2 pt: transport ID error: Fix style to remove full stop 2022-10-03 20:45:54 +01:00
Ian Jackson 00fb96650b pt: Check PT key=value syntax
This is not perfect but it at least ensures that our own parsing and
printing code works correctly with all the values we accept.
2022-10-03 20:45:54 +01:00
Ian Jackson b67b5ac536 pt: Make PtTarget::push_setting fallible, and take Into
It has its own error type PtTargetInvalidSetting.

In check_doc_features, adjust suppression to new code.
2022-10-03 20:45:54 +01:00
Ian Jackson a237b80ad8 pt: bridge line parsing: Add commentary 2022-10-03 20:45:54 +01:00
Ian Jackson f6a6fe0d8e pt: Document Bridge line syntax 2022-10-03 20:45:54 +01:00
Ian Jackson 01222dd9e7 pt: PtTransportAddr: change None string to "-"
This is going to appear in config files etc.  We don't want the user
to have to type "<none>" in a bridge line.
2022-10-03 20:45:54 +01:00
Nick Mathewson b08ac01b61 Merge branch 'new-libfuzzer' into 'main'
Upgrade all fuzzers to newer libfuzzer-sys version.

See merge request tpo/core/arti!752
2022-10-03 19:13:09 +00:00
Nick Mathewson 0d985b0def Merge branch 'hostname-validation' into 'main'
Use hostname-validator crate for hostname validation

See merge request tpo/core/arti!739
2022-10-03 19:01:56 +00:00
Nick Mathewson 128fb76c73 Upgrade all fuzzers to newer libfuzzer-sys version. 2022-10-03 14:35:34 -04:00
Nick Mathewson 88a06225b9 Remove semver.md files now that arti 1.0.1 is out. 2022-10-03 14:16:56 -04:00
Nick Mathewson 7402578af4 Merge branch 'multi_keyed_set' into 'main'
Include a HashSet variant that can be keyed on multiple keys.

See merge request tpo/core/arti!747
2022-10-03 18:16:10 +00:00
Nick Mathewson 1329f2c8f3 n_key_set: fix doctest compilation. 2022-10-03 13:31:03 -04:00
Nick Mathewson 8ab2a88923 n_key_set: Update generic syntax
Doing this lets us work with defaults and const generics.
2022-10-03 13:31:01 -04:00
Nick Mathewson 857272bc7a n_key_set: rename map elements.
This prevents an explosion if somebody has a key called "values".
2022-10-03 13:31:01 -04:00
Nick Mathewson 9c08fdb865 n_key_set: Add support for generic lifetimes.
It doesn't work for const generics yet, since they can't be repeated
in quite the same way.
2022-10-03 13:31:01 -04:00
Nick Mathewson 48a15d5627 Tweaks and improvements in documentation.
Most of these were suggested by Ian
2022-10-03 13:31:01 -04:00
Nick Mathewson 4724639d7c Require slab 0.4.4
The `try_remove()` method, which we need, was introduced there.
2022-10-03 13:31:01 -04:00
Nick Mathewson 59f1f7c11d Repair rustdoc.
The previous indentation was making it think that we had rust code
where none existed.
2022-10-03 13:31:01 -04:00
Nick Mathewson 9fd072a4d4 n_key_set: Add a function to check invariant violations
Also, document another invariant.
2022-10-03 13:31:01 -04:00
Nick Mathewson 0dc1573268 n_key_set: Use remove_by_foo to implement insert. 2022-10-03 13:31:01 -04:00
Nick Mathewson e06ae79009 n_key_set: Panic on more invariant and constraint violations. 2022-10-03 13:31:01 -04:00
Nick Mathewson 43fd594819 n_key_set: Remove by_$key_mut.
This can't be used in a consistency-preserving way.
2022-10-03 13:31:01 -04:00
Nick Mathewson 7043df0241 n_key_set: Add flags to keys rather than inferring from Option<T>
Using Option<T> as an alias for T was too clever indeed, and it
meant that our HashMaps were declared with the wrong types.

Putting flags here instead gives us an extension point that we can
use in the future.
2022-10-03 13:31:01 -04:00
Nick Mathewson f0d74db38e n_key_set: Use to_owned to permit &str accessors. 2022-10-03 13:31:01 -04:00
Nick Mathewson 47c9ae0e4b n_key_set: Add some tests, and notes on infelicities. 2022-10-03 13:31:01 -04:00
Nick Mathewson 4e3a390c5b n_key_set: Fix a bug in function access. 2022-10-03 13:31:01 -04:00
Nick Mathewson 0321912ad0 n_key_set: add FromIterator. 2022-10-03 13:30:54 -04:00
Nick Mathewson c2d4b4ed3b Include a HashSet variant that can be keyed on multiple keys.
Every element in the set has up to N keys, each of which may have differnt
types.  No value for any key may correspond to more than one element in
the set.

These properties can be provided, via a macro, for values of N between 1
and $BIG_ENOUGH.

We'll use this to implement a type that holds HasRelayIds.
2022-10-03 13:30:37 -04:00
Nick Mathewson 05868fea7f Merge branch 'socks_client' into 'main'
Implement a SOCKS client handshake

See merge request tpo/core/arti!746
2022-10-03 17:23:24 +00:00
Nick Mathewson f81afe4930 Move generate_* methods in socks client impl. 2022-10-03 12:52:38 -04:00
Nick Mathewson f663f5fdd2 Require no NUL in socks hostname. 2022-10-03 12:52:38 -04:00
Nick Mathewson 41be40694d Tweak "handshake" docs.
Per a suggestion from Diziet, clarify that the socks handshake code
only wants you to drain your buffers when it tells you to.
2022-10-03 12:52:38 -04:00
Nick Mathewson 235bda1210 Add a SocksReply type to capture address/port information.
I don't expect us to need this information much, but we may as well
hang on to it.
2022-10-03 12:52:38 -04:00
Nick Mathewson f12202d707 Make sure that socks4 auth doesn't have any 0 bytes.
Try to do it in constant time, to avoid even the smell of
side-channel attacks.
2022-10-03 12:52:38 -04:00
Nick Mathewson 3ae062911b Tests for socks client handshake.
These tests include a few reference cases, as well as a little
framework to make sure that the client and the proxy implementation
will handshake with one another successfully.
2022-10-03 12:52:38 -04:00
Nick Mathewson cb4e32ddc7 Bug fix: report empty SOCKS4 auth as "no auth".
Previously we would report it as authenticating using the empty
string.
2022-10-03 12:52:38 -04:00
Nick Mathewson dc55272602 Fuzzer code for socks client implementation. 2022-10-03 12:52:38 -04:00
Reylaba 6a6931e2c3 Use hostname-validator crate for hostname validation 2022-10-03 16:47:03 +02:00
Nick Mathewson c1e70b7af4 Bump patchlevels of binary crates.
Since these don't expose any Runtime-based APIs, they don't have
a breaking change.
2022-10-03 10:07:19 -04:00
Nick Mathewson 102e3c221d Bump minor version of tor-rtcompat and most of its dependents
(Since the APIs for the `Schedule::sleep*` functions changed, this
is a breaking change in tor-rtcompat.  Therefore, the Runtime trait
in tor-rtcompat is now a different trait.  Therefore, anything that
uses the Runtime trait in its APIs has also broken.)
2022-10-03 10:01:46 -04:00
Nick Mathewson 388e0cbab5 Bump crates that have had backward compatible API changes. 2022-10-03 09:52:34 -04:00
Nick Mathewson f5389b53e9 Bump crates that have had no API changes. 2022-10-03 09:47:09 -04:00
Nick Mathewson 4b61d778bd Update README.md files. 2022-09-30 15:19:48 -04:00
Nick Mathewson 66ddbee1a4 Upgrade dependencies in preparation for upcoming release 2022-09-30 15:19:32 -04:00
Ian Jackson 5be8830b3f pt: bridge parsing: Add an IPv6 test case 2022-09-30 17:08:14 +01:00
Ian Jackson 47aae0c27a pt: impl Display for Bridge and test it 2022-09-30 17:08:14 +01:00
Ian Jackson 0c9b54c2f0 pt: Provide accessors for PtTarget 2022-09-30 17:08:14 +01:00
Ian Jackson 0dfa69510e implement FromStr for Bridge, and test it 2022-09-30 17:08:14 +01:00
Ian Jackson 4b28c0e120 tor-guardmgr: Introduce pt-client feature
guardmgr needs to know how to parse Bridge lines into Bridge structs
so it needs to know about PTs specifically
2022-09-30 17:08:14 +01:00
Ian Jackson c41ea6e07b pt: Make some more types Eq
I wanted this for testing.  I think it's reasonable to promise this.
2022-09-30 17:08:14 +01:00
Ian Jackson 7bbf7ac161 pt: Provide constructors for PtTarget
Make PtTargetSettings be Default.

No longer wrap it in Arc.  We want to be able to update it here during
construction.  If we want to save memory with copies of the same
bridge line, we should do this for the whole Bridge I think.
2022-09-30 17:08:14 +01:00
Ian Jackson 98f92d870e tor-error::internal: Remove a redundant suppression
Spotted this in passing.
2022-09-30 17:08:14 +01:00
Nick Mathewson 6a04188d59 Work around a new nightly clippy warning
The warning `clippy::bool_to_int_with_if` is meant to shout at you
when you say `if x { 1 } else { 0 }` and instead suggest that you
say `inttype::from(x)`.

I agreed with this for the case in tor-cert, where we are literally
converting a boolean into a flag.

I don't agree with this in tor-netdoc, where we are using a boolean
to decide how many fields to skip in a given document format.  So
for this case, I decided to clean up the code a little by renaming
"skip" to "n_skip", and changing the boolean to use an enum instead.
2022-09-30 09:00:42 -04:00
Nick Mathewson b146dacf1d Mark all bridge and pt features as experimental for now.
Also, document the features.

Closes #588.
2022-09-29 10:59:19 -04:00
Nick Mathewson af99979689 Implement client-side SOCKS handshake 2022-09-28 09:29:56 -04:00
Nick Mathewson d06dcefd7b Make "SocksRequest::new" public.
Also, have it enforce more correctness properties.
2022-09-27 12:38:48 -04:00
Nick Mathewson 4b992cbd89 New ErrorKind::LocalProtocolFailed.
This type is by analogy to `RemoteProtocolFailed`; we'll use it for
cases when the Socks proxy refuses to talk to us.
2022-09-27 12:30:20 -04:00
Ian Jackson 278425321d pt: Reject a pluggable transport named Bridge
https://gitlab.torproject.org/tpo/core/torspec/-/merge_requests/91
2022-09-27 17:30:00 +01:00
Ian Jackson 102a663907 Remove docsrs thing which is in wrong place? 2022-09-27 17:30:00 +01:00
Ian Jackson 9b55cc012e pt: Try to fix docsrs problem 2022-09-27 17:29:38 +01:00
Ian Jackson 3e5be3ddd6 pt: Use PtTransportName in PtTarget 2022-09-27 17:29:38 +01:00
Ian Jackson fdfbdf082a pt: Use PtTransportName in TransportId 2022-09-27 17:29:38 +01:00
Ian Jackson 0dab3e0c08 pt: PtTransportName: Provide TryFrom, into_inner, AsRef
This seems a minimal API for such a thing.
2022-09-27 17:29:38 +01:00
Ian Jackson 9980338a9d pt: tor-linkspec: Shorten some names with use
This repetition was getting repetitive.
2022-09-27 17:29:38 +01:00
Nick Mathewson b08073c2d4 socksproto: Rename SocksHandshake to SocksProxyHandshake.
Retain "SocksHandshake" as a deprecated synonym.

Also, make an (on-by-default) feature for SocksProxyHandshake.

(There is about to be a SocksClientHandshake as well.)
2022-09-27 08:28:47 -04:00
Ian Jackson bee40d3954 pt: Introduce PtTransportName
The config parsing wants this.  Also there are some anomalies in the
types here that ought to be tidied up.
2022-09-27 12:44:23 +01:00
Ian Jackson 85dfe9d1ec Merge branch 'always_safelog_on_console' into 'main'
Enforce SafeLogging on the console.

Closes #553

See merge request tpo/core/arti!742
2022-09-26 16:33:58 +00:00
Nick Mathewson 8ddc1a4b36 Enforce SafeLogging on the console.
Previously we always assumed that the console was ephemeral, and so
we disabled safe logging.  But the console can be piped to journald.
And even if we enforce isatty there's no guarantee that the user
isn't using some kind of terminal that logs to disk or something.

Best just to enable SafeLogging unconditionally.  I've added a note
about where and how we might re-enable this.

Closes #553.
2022-09-26 11:36:18 -04:00
Nick Mathewson 3272c6fb04 Add the necessary APIs for bridge-based circuit construction. 2022-09-26 11:23:21 -04:00
Nick Mathewson 1196e1b680 GuardMgr/DirMgr: Add APIs for bridge descriptor lists 2022-09-26 11:23:21 -04:00
Nick Mathewson 571e7f9556 Make RouterDesc implement Clone and Debug.
Their omission was an oversight.
2022-09-26 11:23:21 -04:00
Nick Mathewson ab5dd6cbc3 GuardMgr: Add TODOs for bridge support.
This covers only the most basic notions of working with bridges:
that we need a separate set of guards, and that they have to
come from the list of known bridges.
2022-09-26 11:23:21 -04:00
Nick Mathewson e097d64417 A basic configuration type for a bridge.
This type goes in tor-guardmgr, since that's where decisions about
circuits' first hops are made.

There are a lot of "todo"s here for us to resolve.
2022-09-26 11:23:21 -04:00
Ian Jackson 0154d82522 Merge branch 'cell-introduce2' into 'main'
Implement Introduce2 tor cell

See merge request tpo/core/arti!736
2022-09-26 12:07:33 +00:00
Nick Mathewson 52ca64fe0d Add a few comments based on review. 2022-09-23 14:08:53 -04:00
Nick Mathewson 4f93eee67b Clarify and combine PtTargetAddr constructors. 2022-09-23 14:08:53 -04:00
Nick Mathewson 141afbbf61 Rename various Transport* types to Pt*.
This clarifies that the types apply to pluggable transports only,
and not (typically) to the default plain-old-TCP transport.
2022-09-23 14:08:53 -04:00
Ian Jackson 9df8ea215a Clarify note on "none" transport ID. 2022-09-23 14:08:36 -04:00
Nick Mathewson e412d7400c Add the skeleton of a tor-ptmgr crate
When complete, this crate will handle launching and using pluggable
transports on demand.
2022-09-23 14:08:24 -04:00
Nick Mathewson bd627c2e15 ChanMgr: new (unimplemented) APIs for pluggable transports 2022-09-23 14:08:24 -04:00
Nick Mathewson cd88e8cb0b Add a HasChanMethods trait, with a bunch of open TODO questions.
We'll need to sort these out as we implement pluggable transports.
2022-09-23 14:08:24 -04:00
Nick Mathewson cf135ad3eb New data types to describe transport targets.
I've tried to name and structure these for consistency, and
comment reasonably well.  We'll still probably want to make changes.
2022-09-23 14:08:24 -04:00
Nick Mathewson b056e69e1b Add TransportTargetAddr as the target address for a PT-using channel
As with `TransportId`, this type only gets complicated when
`pt-client` is enabled: it's meant to stay simple for relays and
non-PT-using clients.
2022-09-23 14:08:24 -04:00
Nick Mathewson 63dbc7b22d Create an API for TransportId 2022-09-23 09:55:33 -04:00
Ian Jackson a773a753b3 Merge branch 'fix-nightly-clippy' into 'main'
Fix nightly clippy

See merge request tpo/core/arti!729
2022-09-22 16:45:52 +00:00
Ian Jackson 10d3fd9e9f Apply 1 suggestion(s) to 1 file(s) 2022-09-22 16:25:08 +00:00
Ian Jackson 3a8bcd6fc6 Merge branch 'channel-usage-doc' into 'main'
Improve docs for ChannelUsage

See merge request tpo/core/arti!737
2022-09-22 13:30:10 +00:00
Ian Jackson 6b7b4896bb Merge branch 'expose-builder' into 'main'
CircMgr: Add an accessor for the CircuitBuilder.

See merge request tpo/core/arti!738
2022-09-22 13:28:04 +00:00
Nick Mathewson 67b88547c5 CircMgr: Add an accessor for the CircuitBuilder.
Without this, actually building circuits manually is a pain.

This API is behind the `experimental-api` feature, and so it does
not require a semver.md entry.
2022-09-22 08:57:34 -04:00
Nick Mathewson 016a362f8b Improve docs for ChannelUsage
Try to clarify more that the ChannelUsage is for describing the
usage for one particular channel request, not for the channel as a
whole.  This is a potentially confusing point, so we should spell it
out completely.
2022-09-22 08:49:32 -04:00
Yuan Lyu 6e5874d15b
Implement Introduce2 tor cell
Reuse the same Introduce inner body implementation
of Introduce1.
2022-09-21 00:34:13 -04:00
Nick Mathewson 3e922e5ede Intoduce1: Use a constant-time check for all-zero RsaIdentity
As a matter of good crypto practice, we shouldn't use
short-circuiting checks to compare keys or key-like objects, since
the amount of time taken by those checks can leak information about
their inputs.

I don't think it's actually _necessary_ to use a constant-time
operation in this case, but let's establish the precedent.

This is a follow-up to !724.
2022-09-20 09:36:49 -04:00
Nick Mathewson 657914f778 Add a new constant-time is_zero() check for RsaIdentity
There are some places in the protocol where we have an all-zero RSA
identity that does not truly represent a key, but rather represents
an absent or unknown key.  For these, it's better to use
`RsaIdentity::is_zero` instead of manually checking for a set of
zero bytes: it expresses the intent better, and ensures that the
operation is constant-time.

I am deliberately not introducing a more general IsZero trait here,
or implementing is_zero for anything else: This is the only one we
seem to need right now.  We can generalize it later if we have to.
2022-09-20 09:13:31 -04:00
Nick Mathewson 7715b9c8d6 Merge branch 'cell-introduce1' into 'main'
Implement onion service Introduce1

See merge request tpo/core/arti!724
2022-09-20 13:02:02 +00:00
trinity-1686a 8e7a904260 fix clippy::needless_borrow 2022-09-10 14:39:47 +02:00
trinity-1686a dcbdd076eb fix clippy::unwrap_used and old TODO for msrv 1.56 2022-09-10 14:37:32 +02:00
trinity-1686a edfd416ba4 enumerate platform with getresuid support 2022-09-10 14:13:26 +02:00
trinity-1686a cb9f085f77 force no inlining on internal_macro_test
it may fix this test when running in release, where the function gets inlined, so its name does not appear in the backtrace
2022-09-09 17:29:59 +02:00
Yuan Lyu 1a3b979ecf
Implement onion service Introduce1 2022-09-08 23:48:56 -04:00
Nick Mathewson a7d9d2ceb1 Add a dbg!() to diagnose #570.
This won't fix anything, but it will let us see what the backtrace
looks like when it fails.
2022-09-08 09:58:05 -04:00
eta d9c140992f Merge branch 'fix-async-std' into 'main'
fix compilation error with async-std

See merge request tpo/core/arti!723
2022-09-07 17:16:28 +00:00
Nick Mathewson 86e479ae13 `TaskSchedule`: give error on `sleep*()` if last handle is dropped
This fixes an busy-loop.

When the last `TaskHandle` on a `TaskSchedule` is dropped, the
schedule is permanently canceled: whatever operation it was
scheduling should no longer be performed.  But our code was broken:
the `sleep()` and `sleep_until_wallclock()` functions don't verify
whether the handles are dropped or not.

This breakage caused an CPU-eating busy-loop in
`sleep_until_wallclock`.

With this patch, we now return a `Result<(), SleepError>` from these
functions.

Fixes #572.
2022-09-07 09:22:38 -04:00
Nick Mathewson a5f704f443 Remove semver.md from arti-1.0.0 2022-09-07 09:17:00 -04:00
trinity-1686a 4c543b570a fix compilation error with async-std 2022-09-06 21:32:20 +02:00
trinity-1686a 5e41e7dad4 document TOR_SKIP_CONTROLPORTTEST=1 for no warning on Tor Browser 2022-09-03 11:29:26 +02:00
Ian Jackson f62e2f48d4 READMEs: Drop stability warning re config
The referenced ticket is closed and I think the top-level caveats
remaining after !717 are sufficient.
2022-09-02 17:29:11 +01:00
Ian Jackson 52d9b8103a READMEs: Run maint/readmes (to update READMEs from lib.rs) 2022-09-02 17:08:08 +01:00
Ian Jackson 1f78b781f1 docs: Move Tor Browser part to arti top-level (rustfmt etc.) 2022-09-02 17:07:42 +01:00
Ian Jackson 6ae54b4623 arti-client README: Say we intend to provide FFI 2022-09-02 17:07:37 +01:00
Ian Jackson bed312bdcf README: Remove caveats from Tor Browser instructions 2022-09-02 17:07:37 +01:00
Ian Jackson 7581a425b3 README: Fix links to Tor Browser 2022-09-02 17:07:34 +01:00
Ian Jackson fc5c7ce55e docs: Move Tor Browser part to arti top-level (syntax fixup) 2022-09-02 17:07:17 +01:00
Ian Jackson b19547e15a docs: Move Tor Browser part to arti top-level (code motion) 2022-09-02 16:58:15 +01:00
Ian Jackson 78d633b940 README: change an NB to Note
https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/717#note_2834307
2022-09-02 16:44:13 +01:00
Ian Jackson c0189e02b7 READMEs: arti-client: Remove caveats and add some xrefs 2022-09-02 14:51:31 +01:00
Ian Jackson d512036549 READMEs: arti (CLI): Remove several caveats, and tidying 2022-09-02 14:51:31 +01:00
Ian Jackson 905aa29a9f Merge branch 'update-notify' into 'main'
update to notify v5.0.0

Closes #454

See merge request tpo/core/arti!679
2022-09-01 16:18:20 +00:00
Nick Mathewson 96875ea208 Bump crate versions in preparation for Arti 1.0.0 release.
Because we want to work more on ensuring that our semver stability
story is solid, we are _not_ bumping arti-client to 1.0.0 right now.

Here are the bumps we _are_ doing.  Crates with "minor" bumps have
had API breaks; crates with "patch" bumps have had new APIs added.

Note that `tor-congestion` is not bumped here: it's a new crate, and
hasn't been published before.

```
tor-basic-utils         minor
fs-mistrust             minor
tor-config              minor
tor-rtcompat            minor
tor-rtmock              minor
tor-llcrypto            patch
tor-bytes               patch
tor-linkspec            minor
tor-cell                minor
tor-proto               minor
tor-netdoc              patch
tor-netdir              minor
tor-persist             patch
tor-chanmgr             minor
tor-guardmgr            minor
tor-circmgr             minor
tor-dirmgr              minor
arti-client             minor
arti-hyper              minor
arti                    major
arti-bench              minor
arti-testing            minor
```
2022-09-01 08:59:49 -04:00
Nick Mathewson b3f989d689 Update patch-versions on crates without API changes.
Since our last round of releases, these crates have had either
trivial changes, or changes that did not affect their APIs.
Therefore we are bumping their versions, but not changing which
versions of them other crates depend on.
2022-09-01 08:45:02 -04:00
Alexander Færøy 276d472739 Fix broken build and tests after arti!700.
This patch fixes a minor build error where we would call
`compact_home()` on Windows instead of `anonymize_home()` on our PathBuf
instance.

Additionally we change how the `arti_conf` path is constructed such that
we join the individual path components to ensure that no "/" ends up
being present on Windows where path's are separated by "\".

See: tpo/core/arti#555.
See: tpo/core/arti!700.
2022-08-31 20:36:01 +02:00
trinity-1686a e1e3f912b3 update to v5.0.0 2022-08-31 19:08:06 +02:00
Nick Mathewson 6406e4db74 Merge branch 'ahf/563-appveyor-test-fix' into 'main'
Shorten the duration needed in preemptive::test::does_not_predict_old_ports.

See merge request tpo/core/arti!708
2022-08-31 17:00:17 +00:00
Nick Mathewson 2b5070640c Merge branch 'rustdoc_fix_20220831' into 'main'
Fix a rustdoc link error.

See merge request tpo/core/arti!711
2022-08-31 16:59:16 +00:00
Nick Mathewson 874ba13501 Fix a rustdoc link error. 2022-08-31 12:24:39 -04:00
Nick Mathewson 2221b66b74 Add test warning exceptions to arti::cfg::test 2022-08-31 11:22:18 -04:00
Nick Mathewson 8b6f4cc69d Update README.md files with "readmes" tool. 2022-08-31 11:08:03 -04:00
Nick Mathewson 77cb5acceb Merge branch 'compact_home_2' into 'main'
Represent the home directory as ${HOME} or %UserProfile%

Closes #555

See merge request tpo/core/arti!700
2022-08-31 13:57:11 +00:00
Nick Mathewson a9f19b0045 Use anonymize_home() when displaying various messages.
Closes #555
2022-08-31 09:38:35 -04:00
Nick Mathewson 7888ca09d2 fs-mistrust: Add a `anonymize_home` extension fn for Path.
This function transforms `/home/nickm/.config` to
`${HOME}/.config/`, so that we can expose the username less in our
logs.
2022-08-31 09:38:09 -04:00
Nick Mathewson 210c8f883c Merge branch 'ahf/557-mistrust-fixes-3' into 'main'
Add AppVeyor config (but do not enable it) and disable a few tests for Windows

See merge request tpo/core/arti!705
2022-08-31 13:25:38 +00:00
Nick Mathewson 8d6a1ea6ec Merge branch 'refactor-anyhow-arti-crate' into 'main'
Remove `anyhow` from `tor-config` crate

See merge request tpo/core/arti!707
2022-08-31 13:14:46 +00:00
Nick Mathewson 60e1a5c400 Merge branch 'upgrade_2022_0830' into 'main'
Upgrade and update dependencies in preparation for release.

See merge request tpo/core/arti!703
2022-08-31 13:06:01 +00:00
Alexander Færøy 3e3a68683c Shorten the duration needed in preemptive::test::does_not_predict_old_ports.
This patch shortens the duration of the `does_not_predict_old_ports`
test in the preemptive module. AppVeyor spawns its VMs/containers per
build, so the `Instant::now()` call returns a value smaller than `60 *
60 + 1` which causes the subtraction to overflow and thus panic.

Thanks to @trinity-1686a for the help here.

See: tpo/core/arti#563.
2022-08-31 14:52:40 +02:00
Nick Mathewson db50d57880 Upgrade serial_test in preparation for release. 2022-08-30 20:09:19 -04:00
Nick Mathewson 79860041fe Upgrade statrs in preparation for release. 2022-08-30 20:09:19 -04:00
Nick Mathewson a07c4124b1 Mark a few APIs as experimental in docs.
For example, see
https://tpo.pages.torproject.net/core/doc/rust/arti/fn.run.html :
this isn't labeled as `experimental-api`, but it should be.

These APIs were found by poking around in the `arti` crate.
2022-08-30 17:48:50 -04:00
Alexander Færøy 5c3456ff88 Comment out docstring as it fails to compile on Windows.
This patch comments out a method call to `trust_group()` as this method
is not available on all platforms that Arti builds on right now and thus
fails to compile there.

I have added a comment that the given call is not available on non-Unix
like platforms.

See: tpo/core/arti#557.
2022-08-30 22:07:44 +02:00
Alexander Færøy a0bf6b1eeb Disable 3 tests in fs-mistrust.
This patch disables `readable_ok()`, `multiple_errors()`, and
`check_contents()` as they all rely on permission issues on groups being
detected properly which is not the case on Windows right now.

See: tpo/core/arti#557.
2022-08-30 22:06:47 +02:00
Ian Jackson e2104e4cce tor-config: DisfavouredKey: Linkify Display 2022-08-30 13:24:06 +01:00
Ian Jackson 71122a61b6 tor-config: DisfavouredKey: Widen applicability of .to_string()
And linkify it.
2022-08-30 13:24:06 +01:00
Alexander Færøy 4c2fd18d35 Add documentation note on `to_string()` usage for DisfavouredKey. 2022-08-30 13:24:06 +01:00
Alexander Færøy 2f6ae1d5a1 Fix Tests on Windows in Configuration Subsystem.
This patch changes our `default_config()` test in `arti/src/cfg.rs` such
that we can define a number of known unrecognized options on different
platforms.

We mark the two keys "storage.permissions.trust_group" and
"storage.permissions.trust_user" as unknown on the Windows platform as
such features is not available using the ordinary Unix UID concept.

This patch also publicly exposes the `tor_config::load::DisfavouredKey`
and `tor_config::load::PathEntry` types and marks them as
non-exhaustive.

See: tpo/core/arti#450.
2022-08-30 13:24:06 +01:00
Ian Jackson 652ada2a4a Merge branch 'sighup' into 'main'
Sighup

See merge request tpo/core/arti!702
2022-08-30 11:59:03 +00:00
Alexander Færøy 8668bd7bc9 Use `expect()` instead of `unwrap()` in `mistrust_build()`.
See: tpo/core/arti#557.
2022-08-29 16:40:00 +02:00
Alexander Færøy d208706280 Refactor the construction of the `Mistrust` type in tests.
This patch refactors how we construct the `Mistrust` type in the tests
found in the fs-mistrust crate such that it is possible to construct an
instance of the `Mistrust` type using a set of operations available via
the `MistrustBuilder`'s methods.

We handle some of the portability issues found while testing this code
on Windows in the convenience function `mistrust_build()` instead of
having duplicated code in multiple test cases.

See: tpo/core/arti#557.
2022-08-29 16:22:57 +02:00
Alexander Færøy 514aaf41b8 Document in link_rel() why we do not support symlinks on Windows.
This patch adds a comment to the `link_rel()` function in fs-mistrust to
explain why we ignore symlink creation on the Windows platform.

See: tpo/core/arti#557.
2022-08-29 15:29:25 +02:00
Arturo Marquez 7d3d24cddf
Remove `anyhow` from `tor-config` crate 2022-08-28 18:07:53 -05:00
trinity-1686a 8510ba534d small refactoring to reduce duplicaiton of config reloading 2022-08-27 14:12:02 +02:00
trinity-1686a 748d5aea48 connect SIGHUP to watch_cfg 2022-08-27 14:12:02 +02:00
Nick Mathewson 7a3fec6fec WIP: listen for sighups and reconfigure? 2022-08-26 15:44:04 -04:00
Alexander Færøy 7b5ee8423b Disable fs-mistrust's simple_cases() unit test on non-Unix.
This patch disables the simple_cases() test on non-Unix platforms and
hides the LinkType type import on non-Unix where we won't be testing
symbolic link features.

See: tpo/core/arti#557.
2022-08-26 21:34:49 +02:00
Nick Mathewson 2c4a176e66 Add functionality to listen for SIGHUPs. 2022-08-26 15:33:56 -04:00
Alexander Færøy c3928bfe6c Fix compilation of tests for Windows.
This patch allows us to compile the fs-mistrust tests on Windows where
the `trust_no_group_id()` method is unavailable.

See: tpo/core/arti#557.
2022-08-26 21:33:40 +02:00
Alexander Færøy fa1b77642f Mark fs-mistrust's link_rel() and link_abs() as Unix-only.
Since we are not going to test symlink creation on Windows we remove
this code from the testing module.

See: tpo/core/arti#557.
2022-08-26 21:32:12 +02:00
Alexander Færøy edec8f3ecd Mark the repeats and looping tests in fs-mistrust as Unix-only.
See: tpo/core/art#557.
2022-08-26 21:30:20 +02:00
Nick Mathewson c1f64144b3 fs-mistrust: Try to handle verbatim prefixes in test.
We have a test that tries to check that our outputs are the same as
those from `std::fs::canonicalize`.  But on Windows, they aren't:
There, `canonicalize` also puts path prefixes into a "Verbatim"
form.

This patch tries to replicate that behavior for the test only.  If
we find that it's unreliable, though, our best bet is probably to
revise or disable this check on Windows, rather than chasing
compatibility with `GetFinalPathNameByHandle`.

Should fix part of #557.
2022-08-26 10:56:32 -04:00
Ian Jackson 3ea05c981d Merge branch 'fs-mistrust-by-component' into 'main'
fs-mistrust: Handle windows prefixes specially.

See merge request tpo/core/arti!698
2022-08-26 14:50:51 +00:00
Ian Jackson ca4ca75ede fs-mistrust: Clarify comment on `stack` 2022-08-26 14:14:40 +00:00
Nick Mathewson 5e7a62dff2 fs-mistrust: Handle windows prefixes specially.
On Windows, paths can have a "prefix", like `C:` or
`\\server\share`.  Attempts to get metadata for these prefixes
appear to fail with `ERROR_INVALID_FUNCTION`, since they are not
files.

This patch teaches fs-mistrust about prefixes on Windows, and tells
it that attempts to find their metadata are allowed to fail.

Doing this may solve part of #557.
2022-08-26 09:43:08 -04:00
Ian Jackson 56fd5ac779 Merge branch 'safelog_more' into 'main'
Apply safelog to more of the things that we log

See merge request tpo/core/arti!693
2022-08-26 13:20:00 +00:00
Nick Mathewson 496a5be749 Merge branch 'clippy' into 'main'
tor-config: tests: Apply standard lint block in sources.rs

See merge request tpo/core/arti!694
2022-08-26 12:56:25 +00:00
Nick Mathewson 2e7028e8e2 Merge branch 'setuid-again' into 'main'
arti: running_as_setuid: fix MacOs build

See merge request tpo/core/arti!697
2022-08-26 11:26:39 +00:00
Ian Jackson 0045b70bc8 Merge branch 'establish-intro-followup' into 'main'
Clean up EstablishIntro cell

See merge request tpo/core/arti!648
2022-08-26 11:21:02 +00:00
Ian Jackson 72bc20c99b arti: running_as_setuid: fix MacOs build
libc::getuid and geteuid are marked unsafe, even though I think they
could be safe.  So the previous code didn't build.
2022-08-26 11:44:05 +01:00
Yuan Lyu 08e55bc9b1
Clean up EstablishIntro cell 2022-08-25 16:45:40 -04:00
Nick Mathewson 88fa24d029 Improve error from bad escapes in a toml config.
Whereas previously we would say:

```
target/debug/arti: error: invalid escape character in string: `Z` at line 9 column 14 in ../../.config/arti/arti.toml
```
we now say:
```
target/debug/arti: error: invalid escape character in string: `Z` at line 9 column 14 in ../../.config/arti/arti.toml   (If you wanted to include a literal \ character, you need to escape it by writing two in a row: \\)
```

The implementation is a bit of a hack, I'm afraid, but I don't think
it's all that bad.

Closes #549.
2022-08-25 15:04:52 -04:00
Ian Jackson 3faf4475cc Bump toml dependency
We need
  60b874308e6792a73cc00517a60bbef60a12e3cc
  Mixed type arrays (#358)
for a test case in tor-config.

While we're here, drop the dupe entry in tor-config.

(In principle we could make this increase only in tor-config's
dev-dependencies, but that seems unnecessarily fiddly.)
2022-08-25 18:41:28 +01:00
Ian Jackson 76066dac81 tor-config Listen: Rename localhost_port_legacy (from _deprecated)
As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/602#note_2830847
2022-08-25 18:41:28 +01:00
Ian Jackson a6d7e38f6d tor-config Listen: Add a note about EADDRINUSE
Prompted by
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/602#note_2830848
2022-08-25 18:41:28 +01:00
Ian Jackson 81bf8d5f4d tor-config; Listen: Return addresses in groups for error behaviour
Prompted by
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/602#note_2830766
2022-08-25 18:41:28 +01:00
Ian Jackson 370330cb57 arti cfg: Provide comprehensive tests for port listening 2022-08-25 18:41:28 +01:00
Ian Jackson 12476bf0d4 arti: cfg: Rename `*_port` to `*_listen` and change the type
This commit largely follows the example for resolve_alternative_specs.

The difference is that there are two fields, so we use a macro to
avoid recapitulating the field names.
2022-08-25 18:41:28 +01:00
Ian Jackson 846fe3d520 tor-config: Provide resolve_alternative_specs 2022-08-25 18:41:28 +01:00
Ian Jackson 3af1f3e712 tor-config: Support tracking deprecated config keys 2022-08-25 18:41:28 +01:00
Ian Jackson 33358379f4 tor-config: Introduce ResolutionResults
This will allow us to handle new kinds of warnigns etc.
2022-08-25 18:41:03 +01:00
Ian Jackson 29a24a9dcb tor-config: Rename UnrecognizedKey to DisfavouredKey
We're going to want the to use the same type for deprecated keys.
2022-08-25 18:40:14 +01:00
Ian Jackson f588268128 tor-config: Provide misc::Listen 2022-08-25 18:40:14 +01:00
Ian Jackson 00c51bf63f tor-config misc tests: Add standard lint suppression block 2022-08-25 18:40:14 +01:00
Nick Mathewson 4696174d68 Merge branch 'default_log_severity' into 'main'
arti: Raise the default console log severity to "info"

See merge request tpo/core/arti!692
2022-08-25 17:13:51 +00:00
Nick Mathewson f9a9921bed arti-client: Treat list of exit ports as sensitive. 2022-08-25 12:03:38 -04:00
Ian Jackson a931ec08bd tor-config: tests: Apply standard lint block in sources.rs
Fixes a spurious clippy warning on nightly, about a dbg!
2022-08-25 16:33:59 +01:00
Nick Mathewson 0452fa67f6 arti: Adjust severity on per-socks-request log.
Also, note why we aren't hiding the addrs that we're listening on
here.
2022-08-25 11:09:38 -04:00
Nick Mathewson e8fcf2b038 arti-client: Downgrade "got a circuit for" message.
This is not interesting to the user, and violates some of our
safe-logging rules (like "Don't log at info for each user request"
and "don't log ports").
2022-08-25 11:05:42 -04:00
Nick Mathewson 0f133de6b9 Downgrade "guard set loaded" messages
These aren't interesting to the user.
2022-08-25 11:03:19 -04:00
Nick Mathewson 0510224820 circmgr: treat usage as sensitive. 2022-08-25 11:02:06 -04:00
Ian Jackson ae5ca43779 tor-config: semver.md: Document change to ConfigurationSource enum 2022-08-25 15:58:29 +01:00
Ian Jackson 2662fd0d71 tor-config source: just ConfigurationSource, not FoundConfigFile
FoundConfigFile existed to hide something that ConfigurationSource now
exposes.
2022-08-25 15:58:29 +01:00
Ian Jackson 9c00ec7da4 tor-config: Replace dir detection with ConfigurationSource enum
As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/682#note_2830860

And subsequent IRC discussion.

Having done the work as per review comments, I don't much like the
result.  It's quite un-ergonomiuc.  If we can't have fs autodetection,
I think syntactic autodetection within sources.rs would be nearly as
nice.

However, I seem to be outvoted.  At least the externally visible
functionality (of an arti binary, say) is reasonably ergonomic.
2022-08-25 15:58:29 +01:00
Ian Jackson e98bdf6004 tor-config: Provide is_syntactically_directory helper function 2022-08-25 15:58:29 +01:00
Ian Jackson a3005d8c0a tor-config: MustRead: Make public
I think this ought to be exhaustive.
2022-08-25 15:58:29 +01:00
Ian Jackson 7c0637ad44 config watch: Fix and reduce debounce interval
The parameter to FileWatcher::new is not a polling time fallback; it
is a "debounce time".  Events are always delayed by at least this
much.

10s is much too long for this.  1s is more appropriate.
2022-08-25 15:58:29 +01:00
Ian Jackson 7d8b3e2f2f config sources: Read arti.d as well as arti.toml
Fixes #474 aka #271
2022-08-25 15:58:29 +01:00
Ian Jackson ba94c4a4fa config sources tests: Test results of directory scan 2022-08-25 15:58:29 +01:00