Commit Graph

2848 Commits

Author SHA1 Message Date
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
Ian Jackson b700816eef config sources tests: Break out sources_nodefaults 2022-08-25 15:58:29 +01:00
Ian Jackson e4fea3e1ea config sources tests: Introduce test of reading directory 2022-08-25 15:58:29 +01:00
Ian Jackson 08767f59d8 config sources: Supporting reading directories 2022-08-25 15:58:29 +01:00
Ian Jackson 7d088cf8df config sources: Introduce scan() and FoundConfigFiles
We're going to need to do config file reading in two phases.

Right now this isn't actually necessary, because the set of files
is fixed since we don't support dynamically scanning directories.
But the new API will be needed in a moment.

Code motion and API changes, but no overall functional change.
Review with `git show -b` may be helpful.

The new API also provides for dealing with directories, but right now
that doesn't happen.
2022-08-25 15:58:29 +01:00
Ian Jackson 2fa75be660 tor-basic-utils: Provide IoErrorExt is_not_a_directory()
We're going to want this functionality, which isn't in the stable
stdlib.
2022-08-25 15:58:29 +01:00
Ian Jackson 587fa5f418 config watch: Provide watch_dir
No call site just yet; that will come shortly.

This requires a bit of reorganisation first.
2022-08-25 15:58:29 +01:00
Ian Jackson 863c66159b config watch: Re-establish watcher on each iteration
This is going to be needed in a moment.
2022-08-25 15:58:29 +01:00
Ian Jackson a7bb3a73b4 config watch: Rescan once on startup
That way if the config changes after we read it initially, but before
we set up the watcher, we will still pick it up.

Fixes #544
2022-08-25 15:58:29 +01:00
Ian Jackson 0f9bf12a7f config watch: Break out prepare_watcher
This is going to become more complicated, and gain another call site.
2022-08-25 15:58:29 +01:00
Ian Jackson 8e86599df4 config watch: Make the mpsc channel part of FileWatcher
The previous approach (inherited from the API of notify) was kind of
odd.

Soon we are going to want to be able to drop the watcher and replace
it.  That really wants the same object to contain all the things that
ought to be dropped together.  (notify's watchers stop generating
events and give EOF on the channel, when dropped.)
2022-08-25 15:58:29 +01:00
Ian Jackson 25b5a53953 config: Do process hardening on reconfigure even if not watching
These blocks were in the wrong order.

Previously, if you tried to turn on process hardening in the config
and then reloaded rather than restarting, it wouldn't take effect.
2022-08-25 15:58:29 +01:00
Ian Jackson cd2432474c tor-config sources: Remove some unneeded .to_string() from tests 2022-08-25 15:58:29 +01:00
Nick Mathewson 920f7a3f53 tor-chanmgr: don't log addresses so much.
We now log connection attempts at debug!, and mark relay target
addresses as sensitive.
2022-08-25 10:54:50 -04:00
Nick Mathewson 8fa1568b02 arti: Raise the default console log severity to "info"
Previously we logged at "debug", but that's not meant to
user-facing.
2022-08-25 09:10:42 -04:00
Ian Jackson 504bba2191 Fix setuid testing for MacOS 2022-08-25 12:21:33 +01:00
Nick Mathewson 679c1c9b6a Merge branch 'no_setuid' into 'main'
arti_client: Refuse to build a client if we are setuid.

See merge request tpo/core/arti!689
2022-08-24 19:47:15 +00:00
Nick Mathewson a8b3e147fe arti_client: Refuse to build a client if we are setuid.
Arti is not designed to be a setuid-safe program.

Part of #523.
2022-08-24 15:23:24 -04:00
trinity-1686a 075ec7557f fix nightly lints 2022-08-24 19:10:12 +02:00
trinity-1686a c7d2b5001c fix test failing due to missing allow_running_as_root 2022-08-24 18:34:02 +02:00
trinity-1686a ca99e9f635 add feature annotation to fields made visible through visible::StructFields 2022-08-24 18:22:41 +02:00
trinity-1686a 426a59b2ba add feature annotation not added by doc_auto_cfg 2022-08-24 18:22:41 +02:00
trinity-1686a 7f939fa480 enable doc_auto_cfg feature on every crate when documenting for docs.rs 2022-08-24 18:22:41 +02:00
Nick Mathewson 187c6b48df Merge branch 'no_root' into 'main'
arti: Do not allow running as root.

See merge request tpo/core/arti!688
2022-08-24 15:21:57 +00:00
Nick Mathewson 25c287636b arti: Do not allow running as root.
This can be overridden with `application.allow_running_as_root`.

Part of #523.
2022-08-24 10:57:03 -04:00
Nick Mathewson 51eb0e6ca2 Merge branch 'test-old-config' into 'main'
Test oldest example configuration file

See merge request tpo/core/arti!684
2022-08-23 14:43:30 +00:00
Ian Jackson ee2580face tor-config: resolve_option_general: Add semver note 2022-08-23 14:21:13 +01:00
Ian Jackson 0c747b8069 tor-config: resolve_option_general: Add TODO about example 2022-08-23 14:20:49 +01:00
Nick Mathewson 32c14d37bf Fix syntax in doc comment. 2022-08-23 12:59:41 +00:00
Ian Jackson 298f6f508c arti cfg: Write down future plans
Mostly cribbed from
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/684#note_2829937
2022-08-23 13:55:48 +01:00
Ian Jackson 457c17adb0 tor-config: Provide resolve_option_general, for T: !Default etc.
At one point in this MR I thought I was going to want this for
arti::cfg::ListenConfig (which we don't want to be Default).

In fact ListenConfig is being handled specially, but having written
this function it seemed sensible to keep it.  Since resolve_option
becomes a wrapper for it, the existing tests exercise it.
2022-08-22 16:26:38 +01:00
Ian Jackson 086cf3701a arti cfg: Test parsing of the oldest config file we still support 2022-08-22 16:26:22 +01:00
Ian Jackson a1cc2578b3 arti cfg: Fix docs about ARTI_EXAMPLE_CONFIG
The defaults are now
2022-08-22 16:26:22 +01:00
Ian Jackson 46d9dadd02 Merge branch 'channel' into 'main'
Channel padding

See merge request tpo/core/arti!657
2022-08-17 10:26:25 +00:00
Ian Jackson d4ce701fa4 channel padding: Only do anything with link protocol 5
Or rather, if we *didn't* negotiate 4, which is too old.

As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/657#note_2828354
2022-08-17 10:54:41 +01:00
Ian Jackson 08a7257fe9 channel padding: Properly advertise link protocol 5
We already actually send and negotiate the padding, since !657,
but we ought to negotiate a protocol version where that's not a
violation!

As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/657#note_2828354
2022-08-17 10:54:41 +01:00
Ian Jackson a0b0eca93e tor-netdoc: if_ito: Add expansion of acronym 2022-08-17 10:54:41 +01:00
Ian Jackson 8339558ba8 channel padding: Move initial config of ChannelPaddingInstructions
Making ChannelPaddingInstructions::default() accurately reflect the
initial state of the reactor's padding timer simplifies the code
somewhat.

(When padding is wanted, parameters are computed and inserted
explicitly, so the only change is that if we start out dormant, we
defer setting the timer parameters until necessary.)

As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/657#note_2827249
2022-08-17 10:54:41 +01:00
Ian Jackson 8a484a26e6 channel padding: Parameters: default_padding replaces Default impl
As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/657#note_2827249
2022-08-17 10:54:41 +01:00
Ian Jackson 3aed28acd4 channel usage: Rename CU::UserTraffic from CU::Exit
As suggested in
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/657#note_2827246
2022-08-17 10:54:41 +01:00
Ian Jackson 24e2c717f0 chanmgr padding: Correct docs for padding_parameters*
Prompted by
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/657#note_2827242

These texts were out of date; one of them still mentioned
`all_zeroes`.
2022-08-17 10:54:41 +01:00
Nick Mathewson cbd759163a Improve comment for ChannelUsage::Exit 2022-08-17 10:54:41 +01:00
Nick Mathewson d44c860355 Fix typo in comment 2022-08-17 10:54:41 +01:00
Ian Jackson c97ea4fce0 tor-chanmgr tests: Fix a minimal-versions failure (actually) 2022-08-17 10:54:41 +01:00
Ian Jackson a892a3ee62 tor-chanmgr tests: Fix a minimal-versions failure 2022-08-17 10:54:41 +01:00
Ian Jackson 074d08bee8 arti: Fix a minimal-versions failure 2022-08-17 10:54:41 +01:00
Ian Jackson d9338293c8 Add semver notes 2022-08-17 10:54:41 +01:00
Ian Jackson 4111c63bd4 channel reactor: Add some commented-out debug for padding 2022-08-17 10:54:41 +01:00
Ian Jackson 46885ac14b channel padding: Correctly always send the timer parameters
Fixes "chanmgr configuration: Avoid sending needless initial update(s)"
2022-08-17 10:54:41 +01:00
Ian Jackson 496563e7cf channel padding: Abolish ARTI_EXPERIMENTAL_CHANNEL_PADDING env var
This was for testing and is no longer needed.
2022-08-17 10:54:41 +01:00
Ian Jackson 299f302f35 channel engage_padding_activities: swap docs to tor0proto
This allow us to make a working cross-reference.
2022-08-17 10:54:41 +01:00
Ian Jackson 88dc816770 channel fake_channel_details: Use precise cfg
As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/657#note_2826169
2022-08-17 10:54:41 +01:00
Ian Jackson 97363ba250 tor-netdir: testnet: construct_custom_netdir_with_params: Fix doc
As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/657#note_2826168
2022-08-17 10:54:41 +01:00
Ian Jackson 52848a41c6 ChannelPaddingInstructions: Update and expand docs 2022-08-17 10:54:41 +01:00
Ian Jackson 2a4fd97229 ChannelPaddingInstructions: Rename `params` field to `insns` 2022-08-17 10:54:41 +01:00
Ian Jackson 949e5395e0 Rename ChannelsParams types to ChannelPaddingInstructions (fmt)
Run rustfmt; no other changes.
2022-08-17 10:54:41 +01:00
Ian Jackson 94dd3361e2 Rename ChannelsParams types to ChannelPaddingInstructions
As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/657#note_2826167

This makes some lines too long; I will run rustfmt in a separate
commit for clarity.
2022-08-17 10:54:41 +01:00
Ian Jackson d1a709f46d chanmgr: Fix typo
Reported here
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/657#note_2826166
2022-08-17 10:54:41 +01:00
Ian Jackson 590e174d3a chanmgr parameterize: Correct doc comment
As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/657#note_2826164
2022-08-17 10:54:41 +01:00
Ian Jackson 2404357282 Rename PaddingParameters::all_zeroes constructor to disabled 2022-08-17 10:54:41 +01:00
Ian Jackson bb2ae00217 chamgr NetParamsExtract: Replace direct nf_ito access
It turns out that the TryFrom was infallible, which wasn't obvious
with the previous code structure.
2022-08-17 10:54:41 +01:00
Ian Jackson 03d8a09c0e Channel: Make mutable() and engage_padding_activities infallible
As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/657#note_2826151

This gets rid of quite some Bug error paths.
2022-08-17 10:54:41 +01:00
Ian Jackson 5db974ef72 Move ChannelUsage from tor_proto to tor_chanmgr
Replace Channel::note_usage with Channel::engage_padding_activities,
which unconditionally causes the channel to (start to) do netflow
padding things.

The condition now lives in chanmgr.

Addresses
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/657#note_2826094
2022-08-17 10:54:41 +01:00
Ian Jackson 49dad4bd13 tor-chanmgr: Expand docs for map::Inner dormancy field
As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/657#note_2826093
2022-08-17 10:54:41 +01:00
Ian Jackson 4cf418f421 tor-cell: PaddingNegotiate::default_reduced
Get rid of unneeded constructor.

We never need to use hardcoded reduced padding parameters during
negotiation cell construction.  If we are using reduced padding
parameters, the layers which decide this have netparams to use.

Prompted by
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/657#note_2826092
2022-08-17 10:54:41 +01:00
Ian Jackson 14c6e17797 tor-cell: PaddingNegotiate::start: take IntegerMilliseconds 2022-08-17 10:54:41 +01:00
Ian Jackson 18827b7fd0 chanmgr padding_parameters: Use Option
The network consensus parameters use (0,0) to mean "no padding"
(which is not the same as (0,0) means in a PADDING_NEGOTIATE cell).

Representing "no padding" this way is actually quite convoluted and
un-Rustic.  Ensure that we convert (0,0) to None, and do the primary
logic in Option.
2022-08-17 10:54:41 +01:00
Ian Jackson bdaee82187 tor-cell: PaddingNegotiate: give better spec xrefs 2022-08-17 10:54:41 +01:00
Ian Jackson 6fdaca8eb9 channel: Clarify (and in some places replace) "frontend" terminology 2022-08-17 10:54:41 +01:00
Ian Jackson 481bf0bbe9 tor-proto channel padding: Document PADDING_NEGOTIATE overwriting
As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/657#note_2825979
2022-08-17 10:54:41 +01:00
Ian Jackson 1104235ee5 chanmgr: padding: Split IEFI into named function
Roughly as suggested in
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/657#note_2826160

IMO this is less clear, because of the way it splits the logic up.
2022-08-17 10:54:41 +01:00
Ian Jackson 58fb118480 chanmgr: NetParamsExtract: extend docs for nf_ito 2022-08-17 10:54:41 +01:00
Ian Jackson 84d8c32543 chanmgr: Get rid of final Result relating to netdir/netparams
No functional change.  (The error tyep was Void.)
2022-08-17 10:54:41 +01:00
Ian Jackson 48fc5d3c39 chanmgr: Use NetDirProvider::params and Arc<dyn..Netparameters>
This gets rid of many Result().  Many parameters are renamed.
Test cases of the now-impossible branch are removed.

Deleting the match from padding_parameters will come in a moment.
I've split off that commit since it has much whitespace noise.
for now, change the error type to Void.
2022-08-17 10:54:41 +01:00
Ian Jackson 3497d8723b chanmgr: Add a TODO for renaming NetDirExtract 2022-08-17 10:54:41 +01:00
Ian Jackson 36e3529e34 chanmgr ChannelUsage: Fix and clarify docs 2022-08-17 10:54:41 +01:00
Ian Jackson e4cd01732f chanmgr set_dormancy: Remove obsolete comment 2022-08-17 10:54:41 +01:00
Ian Jackson b5176a700b chanmgr: Extend doc comments for Dormancy
Prompted by
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/657#note_2825962
2022-08-17 10:54:41 +01:00
eta e5396a35c8 Fix typos in comments. 2022-08-17 10:54:41 +01:00
Ian Jackson 7ed983800d channel padding: Rename low_ms and high_ms
These have the unit in the type.  Putting that in the field name too
is otiose.
2022-08-17 10:54:41 +01:00
Ian Jackson 18a6234101 channel padding: Test through most of the layers 2022-08-17 10:54:41 +01:00
Nick Mathewson bd4204a42e Merge branch 'transient_circmgr_errors' into 'main'
Mark some circuit-building errors as "transient".

Closes #517

See merge request tpo/core/arti!676
2022-08-16 18:33:17 +00:00
Nick Mathewson 8862eb1e34 Additionally, mark the LostUsablityRace error as a "reset". 2022-08-16 14:03:43 -04:00
Nick Mathewson 4c9bf4803c Mark some circuit-building errors as "transient".
A "transient" error is one that does not indicate a true failure,
but rather an _expected_ need to retry.  When we hit one of these,
we do not count it against the total number of permitted failures.

(We do impose a higher limit on "real failures plus transient
failures", though, to prevent infinite loops in the event of a
programming error.

Closes #517.
2022-08-16 14:03:43 -04:00
Ian Jackson e4e06f66ec chanmgr testing: FakeChannel: retain the ChannelsParamsUpdates 2022-08-16 18:43:23 +01:00
Ian Jackson 7ae60c229b tor-proto, testing: Provide accessors for ChannelsParamsUpdates 2022-08-16 18:43:23 +01:00
Ian Jackson 9310ee2930 tor-proto, testing: Provide new_fake_channel
To test the padding control we will want this.
2022-08-16 18:43:23 +01:00
Ian Jackson 182b9775bb tor-proto, testing: Make fake_channel_details available
Now it's not just cfg(test), but feature testing.
2022-08-16 18:43:23 +01:00
Ian Jackson db3fafb0d4 tor-proto: Make "testing" feature that exports some things
We are going to want this for through-the-layers padding control
testing.
2022-08-16 18:43:23 +01:00
Ian Jackson 76403563e5 tor-cell, testing: Provide PaddingNegotiate::from_raw
This allows test cases to describe precisely the contents of the
negotiation cell ought to be generated.
2022-08-16 18:43:23 +01:00
Ian Jackson 2385d43279 tor-netdir, testnet: Provide construct_custom_netdir_with_params
We're going to want this for testing netdirs with padding parameters
that diff ere from the spec's default.
2022-08-16 18:43:23 +01:00
Ian Jackson cd8d41fd2e tor-netdoc: NetParams: impl FromIterator
Otherwise a caller who has a set of parameters must open-code the
loop.
2022-08-16 18:43:23 +01:00
Ian Jackson 50ca64218e channel padding: Send negotiation cells 2022-08-16 18:43:23 +01:00
Ian Jackson 0a1bffb047 tor-proto channel: Make arrangements to send PADDING_NEGOTIATE
This is actually a general facility for inserting locally-generated
cells into the outgoing stream.

It doesn't seem to be possible to do this without adding an additional
condition check to the reactor, since we need to insert it into the
right place in the stream, giving it priority over data, and only
using it up if there was room in the output.

We don't engage this machinery yet, because nothing sets
special_outgoing.
2022-08-16 18:43:23 +01:00