Commit Graph

2378 Commits

Author SHA1 Message Date
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
Ian Jackson 67072de75c channel padding: Send padding iff required
Now all the information is plumbed to the right place, and we can
actually decide if we're sending padding.

Additionally, we conditionalise sending timing parameters on whether
padding is actually enabled, so in dormant mode we do not generate
updates (broadcast to all channels) just to reconfigure unused timing
parameters.
2022-08-16 18:43:23 +01:00
Ian Jackson d8972e2cde chanmgr configuration: Avoid sending needless initial update(s)
Change ChannelsParams::initial_update to compare fields with their
default values, and, if they're the same as the default, not to
include them in the returned update.

And if that update is then empty, return None.

The overall effect is to avoid the call to chan.reparameterize if
we're using the builtin default parameters, which is usual.
2022-08-16 18:43:23 +01:00
Ian Jackson ede2510695 chanmgr configuration: Initialise correctly
This arranges that the ChannelsParams we have retain, and which we
send to every newly created channel, actually has the right
parameters, even if they're not the default.
2022-08-16 18:43:23 +01:00
Ian Jackson 76314b41f6 chanmgr configuration: Break out parameterize
We're going to want to call this at startup as well as during
reconfigurations.

Code motion.
2022-08-16 18:43:23 +01:00
Ian Jackson 1694296327 chanmgr configuration: Hadle lack of a NetDir
Now that the code that actually handles the netdir information can
cope with its lack, we can change the types of the various netdir
parameters and get rid of the foolish Bugs.
2022-08-16 18:43:23 +01:00
Ian Jackson fbcc609c17 chanmgr padding: Support reduced and disabled padding (prep)
Now we actually honour the configuration variable.

However, when it is set to None, we lack proper handling.  This will
be done bh turning None into 0,0 and then treating that as disabled.
There is a TODO for that.

Note that we *still* don't actually do or negotiate padding.
2022-08-16 18:43:23 +01:00
Ian Jackson 1688b5ef2a chanmgr padding: Fix low vs high comparison
Whoops.  This bug was completely masked by the fact that we don't
actually enable padding yet.
2022-08-16 18:43:23 +01:00
Ian Jackson 0b140effc6 chanmgr: Break out padding_parameters fn
Move some logic out of reconfigure_general into what was
update_padding_parameters_from_netdir, and rename that function.

We're going to want to call this twice, shortly...

* Move out the PaddingParametersBuilder
* Have it handle missing netdir, though we currently always pass Ok
* Have it handle the error cases

It still ignores the config for now.

No overall functional change.

"git show -b" may be a useful way to review the changes in what
becomes "padding_parameters".
2022-08-16 18:43:23 +01:00
Ian Jackson 156d42ab80 chanmgr: Postpone padding parameters computation
Now that we make an extract from the incoming NetDir, we can move the
padding parameters computation to after we take the lock.

This will be necessary for it to be able to depend on the config and
dormancy, records of which are protected by the chanmgr lock.
2022-08-16 18:43:23 +01:00
Ian Jackson eb9b164fd8 chanmgr: Introduce NetDirExtract
This will allow the padding parameter computation to have access to
the config, which is within the inner lock.
2022-08-16 18:43:23 +01:00
Ian Jackson 5e307a0989 chanmgr, testing: Provide config accessor for testing
The top-level global config is going to want to see whether its
machinations have the right effect.
2022-08-16 18:39:57 +01:00
Ian Jackson 582430d1ac channel: Use channel usage to control channel padding
We introduce the per-channel state that is used to keep track of
channel usage, and defer padding setup until it's wanted.
2022-08-16 18:39:57 +01:00
Ian Jackson 498d39626f channel: Introduce padding config
Nothing actually reads this yet, and we also want a client-global
default for padding.
2022-08-16 18:39:57 +01:00
Ian Jackson 76a1c45202 Introduce ChannelConfig
This commit is just the necessary plumbing.  The config is currently
empty.  We'll add something to it, for padding control, later.
2022-08-16 18:39:57 +01:00
Ian Jackson 2fbc196f8e tor-config: Introduce PaddingLevel
This will be used for controlling channel padding, for now.
2022-08-16 18:38:53 +01:00
Ian Jackson fbe80fd417 tor-config: Introduce ReconfigureError::Bug
Reconfigurations might fail due to internal errors.
2022-08-16 18:37:06 +01:00
Ian Jackson d407ef93ee channel: Provide somewhere for the frontend's mutable state
Right now this is just furniture.  We're going to put channel padding
control state here.
2022-08-16 18:37:06 +01:00
Ian Jackson 8d44ef05dc Provide ChannelUsage and plumb it all the way down
Channel padding depends on what the channel is being used for.  We
therefore need to let the channel code know this information.

The implementation of the per-channel padding control logic will be in
the new note_usage function, which for now is simply a stub.

A future commit will introduce a `PaddingControlState` which lives in
the channel frontend; consult the doc comment for that type to see why
the plumbing through the channel manager terminates in the channel
frontend.
2022-08-16 18:37:06 +01:00
Ian Jackson 3c23c2333a chanmgr: Introduce get_or_launch_internal
This is going to be useful in a moment.
2022-08-16 18:37:06 +01:00
Ian Jackson 61ab684f74 channel reparameterize: Change error type
This is going to be able to fail in other ways too, sadly.
2022-08-16 18:37:06 +01:00
Ian Jackson 4f44ef755a dormancy: Plumb through to chanmgr reconfigure_general
The chanmgr remembers the last dormancy state it was told.

We invent a chanmgr-specific Dormancy which the arti-client code knows
how to convert from the richer top-level dormant status.  This avoids
having to have everyone know all the variants of the top-level state.

To call reconfigure_general, we must also obtain and plumb through a
netdir.  Right now we must return an internal error if there is in
fact no netdir, because reconfigure_general does not yet cope with a
missing netdir.

Nothing actually *uses* the dormancy yet.
2022-08-16 18:37:06 +01:00
Ian Jackson 7387474be2 dormancy: tor-client: Break initial dormancy out into a variable
We're going to need to reuse this, so we can plumb the dormancy to
more places.  Breaking it out avoids having repeat the initial
dormancy value in two places.
2022-08-16 18:37:06 +01:00
Ian Jackson 968e6eab34 chanmgr: reconfigure_general: Rename fn and change types
This function is going to become the code for controlling channels, in
general.  (Including padding control.)  Right now it doesn't do most
of the things.

In this commit:

 * Change the prototype and the name now.
 * Pass `()` for the dormancy and config, adding TODOs.
 * Provide update_netdir method on AbstractChanMgr, and call that,
   rather than having the ChanMgr go directly into the channel.
   (That will enable us to test that `update_netdir` method
   with test cases that don't have a complete ChanMgr.)
2022-08-16 18:37:06 +01:00
Ian Jackson 6d16e3f947 channel params: ChannelsParamssUpdates: provide combine()
We're going to need this because the frontend is going to need to
defer some channel padding parameters updates.
2022-08-16 18:37:06 +01:00
Ian Jackson d1b7c06e0a channel params: Add a missing comma.
Unfortunately, because we don't have derive-adhoc here yet, rustfmt
didn't get to notice that this comma was needed.

We are going to add field(s), so add the comma now.
2022-08-16 18:37:06 +01:00
Ian Jackson cc731cef49 channel params: Rename initial_update (from total_update)
The semantics of this are going to become a bit more subtle.
2022-08-16 18:37:06 +01:00
Ian Jackson 35c8c3cd1b tor-proto: padding::Parameters: Provide all_zeroes
This exists so that we handle this case specially, as we will need to,
and so that we can represent disablement in a Parameters.
2022-08-16 18:37:06 +01:00
Ian Jackson e8a6cb62c4 tor-proto: padding::Parameters::padding_negotiate_cell
The channel manager is going to use this as part of constructing the
right cell for padding neogotiattion.
2022-08-16 18:37:06 +01:00
Ian Jackson 7843a09c90 tor-proto: padding::Parameters: Provide default_reduced constructor
We're going to want this so that we can do reduced padding.
2022-08-16 18:37:06 +01:00
Ian Jackson 38b76578be chancell: PaddingNegotiate: Provide start_default and a Default impl
As proposed in
  https://gitlab.torproject.org/tpo/core/torspec/-/merge_requests/77
2022-08-16 18:37:06 +01:00
Ian Jackson a26f341bd7 chancell: Introduce PaddingNegotiateCmd
This gets rid of some random hardcoded literals.  We're going to want
to reuse this, too.
2022-08-16 18:37:06 +01:00
Ian Jackson 0df72449b8 chancell: PaddingNegotiate: Provide two constructors, not one
We don't really want the caller to pass ignored timeout parameters.
And this makes more semantic sense.

The stop constructor uses zero, which is what C Tor does.  See
  https://gitlab.torproject.org/tpo/core/torspec/-/merge_requests/76
2022-08-16 18:37:06 +01:00
Ian Jackson ecd6f16b6e chancell: PaddingNegotiate: Make Eq
This will be convenient for managing when to send these negotiation
messages.

While we're here, edit the comment to explain how this is (going to
be) used.
2022-08-16 18:37:06 +01:00
Ian Jackson b417075f11 channel padding: Add doc commentary with the channel padding plan
Much of this does not exist yet.  It will do by the end of this
branch.

Expand a doc note for ChannelsParamsUpdates too.
2022-08-16 18:37:06 +01:00
Ian Jackson b4cc8de67c chanmgr: tests: Introduce new_test_channel_map
This is going to change.  Centralise it first.
2022-08-16 18:37:06 +01:00
Ian Jackson 2be3ebb2ce chanmgr: tests: Introsuce new_test_abstract_chanmgr
This is going to change.  Centralise it first.
2022-08-16 18:37:06 +01:00
Ian Jackson b2df8755a4 channel: Centralise Channel::send_control
Replaces 4 open-coded call sites.

I am going to add one more.
2022-08-16 18:37:06 +01:00
Ian Jackson 806828c01c tor-proto: padding::Parameters: use impl_standard_builder
This is more standard.  It also provides the ::build() method.

This isn't a config type, and build failures ought not to happen,
so we use Bug for the error.
2022-08-16 18:37:06 +01:00
Ian Jackson 69629e0ab0 arti-client: TorClient constructor: add a blank line
The rustfmt-mandated different formatting of these two very similar
blocks is bad enough, without them being smooshed together.
2022-08-16 18:37:06 +01:00
Emptycup 668d8d4858 Clarify `REASON_DONE` 2022-08-16 13:28:43 +00:00
Nick Mathewson 3b2d187315 Merge branch 'hardening' into 'main'
arti: Add support for process hardening

Closes #364

See merge request tpo/core/arti!672
2022-08-15 17:19:53 +00:00
Nick Mathewson 3c1bfb4916 arti: Add support for process hardening
This is a compile-time feature with an associated configuration
flag, both enabled by default.

When it's turned on, hardening prevents the arti process from
dumping core or being attached to by low-privileged processes.
(This is a defense-in-depth measure, not an absolute way to prevent
attacks.  For more information, see
[`secmem_proc`](https://docs.rs/secmem-proc/0.1.1/secmem_proc/).)

Closes #364.
2022-08-15 12:59:56 -04:00
eta d183ba0d75 Merge branch 'nightly_fix_rtt' into 'main'
Fix nightly CI: allow print_stderr in rtt tests.

See merge request tpo/core/arti!673
2022-08-15 15:56:58 +00:00
Nick Mathewson fb5695570e Add a semver note for TcpStream send conversion. 2022-08-15 09:48:54 -04:00
Ian Jackson 740f306cb0 tor-rtcompat: Require that TcpStream be Send
The lack of this seems to have been an oversight.
2022-08-15 09:47:40 -04:00
Nick Mathewson 027633b68a Fix nightly CI: allow print_stderr in rtt tests. 2022-08-11 17:20:49 -04:00
Nick Mathewson e74612456f Merge branch 'less_arti_surface' into 'main'
Reduce the arti crate's API surface; improve semver documentation.

Closes #522, #530, and #532

See merge request tpo/core/arti!664
2022-08-11 20:09:53 +00:00
Nick Mathewson 7d7cdcd749 Add a few dire warnings about main; make main_main experimental. 2022-08-11 15:35:32 -04:00
Nick Mathewson 32a78651d2 Document more explicitly what "voiding a semver warranty" entails
Closes #522.
2022-08-11 15:35:32 -04:00
Nick Mathewson 3287c30f1c arti: `main_main` takes command-line arguments does not call exit() 2022-08-11 15:35:32 -04:00
Nick Mathewson f548a6ac55 arti: Move most public APIs behind `experimental-api`.
The remaining unconditionally public APIs are those related to our
configuration objects, and the main_main() API.

The rationale for making main_main() public is to have an actual
entry point.

The rationale for making the config APIs public is:

  1. We really do intend for others to be able to read our
     configuration files using this API.
  2. The structure of our configuration files is already part of our
     interface.

Closes #530.
2022-08-11 15:35:32 -04:00
Nick Mathewson 79c609e4f1 arti: Add a feature flag for dns-proxy.
It remains on-by-default, so users shouldn't notice a difference,
but it may help when we want to save a few bytes of binary size.

Closes #532
2022-08-11 15:35:32 -04:00
eta 0775b6d42d tor-congestion: implement the RTT estimation algorithm from prop#324
This commit implements the round-trip-time estimation algorithm from Tor
proposal 324, validating the implementation against the test vectors
found in C tor. (Note that at the time of writing, the new test vectors
may not be committed to C tor yet, but they will be soon.)

This also adds the necessary consensus parameters to `NetParameters`.
Some of them have been renamed in order to (hopefully) make them more
understandable.
2022-08-11 15:33:50 +01:00
Nick Mathewson 192a48c496 tor-proto: Add a comment about the tor-proto layer.
We want to clarify that the tor-proto crate should only know _how_
its objects behave, not _why they behave that way_.  (In other
words, we can have a "padding strategy" setting on a channel, but
not a "general usage" setting.)

Closes #531.
2022-08-10 12:13:01 -04:00
Nick Mathewson 71242f1500 Clarify that tor-proto _does_ create timers. 2022-08-10 12:02:46 -04:00
Nick Mathewson 36a28a8587 Merge branch 'main' into 'linkspec_refactor_v3'
# Conflicts:
#   crates/tor-netdir/semver.md
2022-08-10 14:48:57 +00:00
Nick Mathewson 19079c5a7d tor-proto: Unify the check_match code in channel and handshake
This had to become a new internal function, since at the point that
the handshake needs this code, it does not yet have a Channel to use.

This change made the error messages in the handshake code more
informative: and now they require a regex to check.  Later, we might
want to defer formatting these strings, but I don't think we need
to do it now.
2022-08-10 10:39:47 -04:00
Nick Mathewson 9b91edcb19 tor-netdir: Add a static assertion about RelayIdType::COUNT
Doing this will make sure that we fix a correctness issue in netdir that
will be caused if we add more IDs.

(Also add RelayIdType::COUNT in tor-linkspec.)
2022-08-10 10:39:47 -04:00
Nick Mathewson 2f4d58762c Implement `Into<RelayIdRef>` for `&RelayId`.
This will let us use `&RelayId` in all the places that take
`Into<RelayIdRef>`.
2022-08-10 10:39:47 -04:00
Nick Mathewson 6dc8b1af20 Make sure all HasRelayIds constaints allow ?Sized. 2022-08-10 10:39:47 -04:00
Nick Mathewson d1b2dd6fcb netdir: remove long-unused missing_descriptor_for code 2022-08-10 10:39:47 -04:00
Nick Mathewson 8067c3f960 tor-netdir: Remove or hide some no-longer-used accessors.
The hidden ones are only used to implement higher-level accessors;
the others are not used at all.
2022-08-10 10:39:47 -04:00
Nick Mathewson 37b3daa11d tor-netdir: Collapse by_id and by_relay_id into a single fn.
There are some downstream changes required for this to work, but
they are all just unit tests that could no longer infer the type of
an Ed25519 key.
2022-08-10 10:39:46 -04:00
Nick Mathewson 2d4507ff35 Final (?) API revisions for tor-linkspec
With this change, each individual identity type becomes optional.
The functions that expose them unconditionally are now in a "legacy"
trait that only some downstream types are expected to implement.

There are new convenience APIs in HasRelayIds:
  * to return Option<&keytype>,
  * to see if one identity-set contains another.

This commit will break several downstream crates!  For the
reviewer's convenience, I will put the fixes for those crates into a
series of squash! commits on this one.

tor-netdir
----------

Revise tor-netdir to accept optional identities.  This required some
caveats and workarounds about the cases where we have to deal with a
key type that the tor-netdir code does not currently recognize at
all.  If we start to add more identity types in the future, we may
well want more internal indices in this code.

tor-proto
---------

In order to make tor-proto support optional identities, there were
fewer changes than I thought.  Some "check" functions needed to start
looking at "all the ids we want" rather than at "the two known IDs";
they also needed to accommodate that case where we don't have an ID
that we demand.

This change will also help with bridges, since we want to be able to
connect to a bridge without knowing all of its IDs up front.

The protocol currently _requires_ the two current ID types in some
places. To deal with that, I added a new `MissingId` error.

I also removed a couple of unconditional identity accessors for
chanmgr; code should use `target().identity(...)` instead.

tor-chanmgr
-----------

This is an incomplete conversion: it does not at all handle channel
targets without Ed25519 identities yet.  It still uses those
identities to index its internal map from identity to channel; but
it gives a new `MissingId` error type if it's given a channel target
that doesn't have one.

We'll want to revise the map type again down the road when we
implement bridges, but I'd rather not step on the channel-padding
work in progress right now.

tor-guardmgr
------------

This change is mostly a matter of constructing owned identity types
more sensibly, rather than unwrapping them directly.

There are some places marked with TODOs where we still depend on
particular identity types, because of how the directory protocol
works.  This will need revisiting when we add bridge support here.

tor-circmgr
-----------

These changes are just relatively simple API changes in the tests.
2022-08-10 10:39:37 -04:00
Nick Mathewson 2c2224d6db linkspec: Add more accessors (some internal) for ids.
These will all be used shortly.
2022-08-10 10:39:37 -04:00
Nick Mathewson 0d74085269 Remove get_ed_identity_key as unused. 2022-08-10 10:39:36 -04:00
Nick Mathewson b56e1bf119 Introduce a RelayIdSet and use it in place of HashSet<RelayId>.
This makes lookups a little more efficient.  I do with that HashSet
just supported this use-case, but for now this seems our best option.
2022-08-10 10:39:36 -04:00
Nick Mathewson deaf8b657d Teach guard restrictions about RelayId.
This implementation is (sadly) too copy-heavy or now, because
HashSet<RelayId> can't be indexed with RelayIdRef.
2022-08-10 10:39:36 -04:00
Nick Mathewson d60d875749 Parsing, encoding, and serde for RelayId.
The formats used here are backward-compatible with those used by C
tor and those used elsewhere in our code.  We need a way to encode
_both_ current kinds of identities as a string that tells you what
kind of ID they are.  Traditionally we have used hexadecimal,
sometimes with a $, for RSA ids, and we have used base64 for Ed25519
IDs.

We also introduce a new forward-compatible format for new identity
keys in the future.  (The new format is the key identity type, a
colon, and the id encoded as base64.)  We will use this new format
_only_ when we need to encode identities in a way where it would be
otherwise unclear what kind of key we are dealing with.
2022-08-10 10:39:36 -04:00
Nick Mathewson 8af41bd65f Use accessors in two places where tests look at specific keys.
(It's safe to require these specific keys, since we constructed the
objects for testing, and we know for certain that they contain given
keys.)
2022-08-10 10:39:36 -04:00