Commit Graph

3553 Commits

Author SHA1 Message Date
Ian Jackson ddd323c6ff tor-hsservice: Fix an erroneous reference to an hs-client feature 2023-02-28 11:10:17 +00:00
Ian Jackson f63c7c48af Rename onion-* cargo features to hs-* in tor-* crates
Fixes #756
2023-02-28 11:10:17 +00:00
Nick Mathewson fcbeceeb61 Merge branch 'cmd_checker' into 'main'
tor-proto: Introduce CmdChecker, and use it to enforce correctness for our streams.

Closes #774 and #769

See merge request tpo/core/arti!1026
2023-02-27 16:43:34 +00:00
Nick Mathewson 07473ed1fc proto: Tweak documentation and names around CmdChecker. 2023-02-27 08:14:15 -05:00
Nick Mathewson d09273a6e3 Apply a missing cfg_attr(docsrs...) in netdoc 2023-02-21 15:18:46 +00:00
Nick Mathewson c1fbcb34f6 Rearrange cfg_attr in relaycell::msg
docsrs wants to find its `cfg_attr(docsrs...)` line after the
`cfg()` line.
2023-02-21 15:18:46 +00:00
Ian Jackson 750c512264 Merge branch 'unparsed_linkspec' into 'main'
HsDesc: Use a new UnparsedLinkSpecifier to avoid leaking which linkspec types we know

See merge request tpo/core/arti!1029
2023-02-21 15:16:45 +00:00
Ian Jackson 67234568bc Merge branch 'hsdir_remove_comment' into 'main'
netdoc: Remove a TODO hs comment.

See merge request tpo/core/arti!1028
2023-02-21 15:15:10 +00:00
Nick Mathewson 3233c25943 tor-netdoc: Use UnparsedLinkSpec in IntroPointDesc. 2023-02-17 15:29:37 -05:00
Nick Mathewson bc68974212 tor-linkspec: New UnparsedLinkspec type.
Unlike linkspec, this doesn't validate the actual contents of the
specifiers. We'll use this so we can handle the linkspec list for an
introduction point in an HsDesc, and just pass it on when
constructing our circuits.

I haven't added any accessor or constructor functions, because I
don't expect to need them.
2023-02-17 15:26:23 -05:00
Nick Mathewson 757c6d333f netdoc: Remove a TODO hs comment.
It said to check whether C enforces an absence of extraneous bytes
at the end of the link specifiers.  It does, in
`hs_desc.c:decode_link_specifiers()`, where it says:

```
  if (link_specifier_list_parse(&specs, decoded,
                                (size_t) decoded_len) < decoded_len) {
    goto err;
  }
```

The comparison with "decoded_len" checks whether all the bytes were
decoded.
2023-02-17 15:06:09 -05:00
Nick Mathewson 2b515c8d25 tor-dirmgr: Work around an apparent regression in `time`.
Some code in our tests that worked fine with time 0.3.17 no
longer works with 0.3.19, despite the semver.

See https://github.com/time-rs/time/issues/552 for the upstream bug.
2023-02-17 14:36:19 -05:00
Nick Mathewson 814563dfd6 tor-proto: Rename end_received.
It can now indicate _any_ cell that means we can forget about a stream.
2023-02-17 11:56:53 -05:00
Nick Mathewson d81a9c9aad Use CmdChecker in our stream handling code.
This change makes sure that open streams and half-closed streams
have the same stream-type-dependent state machines with respect to
which cells are acceptable.

Fixes #774.

Fixes #769.
2023-02-17 11:52:09 -05:00
Nick Mathewson c5be3c089e tor-proto: Introduce CmdChecker, and define it for our streams.
The role of CmdChecker is to verify that messages are arriving at
the appropriate sequence on a stream, with respect to the other
messages that have been received.  Once the stream becomes
half-closed, the CmdChecker is also in charge of consuming incoming
messages on the stream and making sure that they are well-formed.
2023-02-17 11:50:27 -05:00
Nick Mathewson 1297dfb5e3 Merge branch 'doc-iter' into 'main'
tor-netdoc: Abolish PauseAt in favour of using itertools

Closes #760

See merge request tpo/core/arti!1021
2023-02-17 12:34:32 +00:00
Nick Mathewson 878531af90 Merge branch 'hs-cells-1' into 'main'
Start refactoring hs cell implementations

See merge request tpo/core/arti!1020
2023-02-16 15:36:31 +00:00
Nick Mathewson c4b451ffa6 Mark a quoted block as text, so doctest ignores it. 2023-02-16 09:00:07 -05:00
Nick Mathewson 14417dc098 Add a TODO about combining several macros and patterns 2023-02-16 08:25:12 -05:00
Ian Jackson b4e48b0695 Make a comment more accurate 2023-02-16 13:19:04 +00:00
Ian Jackson 66beab6c9e tor-netdoc: Fix doc comment following removal of PauseAt 2023-02-16 11:53:32 +00:00
Ian Jackson ca127b013f Expire routerdescs as soon as any of their expiries expire
Fixes #772
2023-02-15 17:41:28 +00:00
Ian Jackson 676241c349 tor-netdoc: Run rustfmt (separately from the refactoring) 2023-02-15 17:17:01 +00:00
Ian Jackson 1993165f22 tor-netdoc: Abolish NetDocReader::iter and into_iter
Nothing uses these now; the NetDocReader is simply an iterator, itself.
2023-02-15 17:17:01 +00:00
Ian Jackson 4a91c732fe tor-netdoc: Remove many needless calls to .iter() and .into_iter() 2023-02-15 17:17:01 +00:00
Ian Jackson fa2e164939 tor-netdoc: Use impl Iterator for NetdocReader in .pause_at
This simplifies the return type!
2023-02-15 17:17:01 +00:00
Ian Jackson db79e3f369 tor-netdoc: impl Iterator etc. for NetdocReader
This will simplify things at many call sites.
2023-02-15 17:17:01 +00:00
Ian Jackson b58977b428 tor-netdoc: move PeekableIterator to util.rs
We're going to want this a bit more widely.
2023-02-15 17:17:01 +00:00
Ian Jackson 11660f84b0 tor-netdoc: Delete now-unused PauseAt type 2023-02-15 17:17:01 +00:00
Ian Jackson 15d93bd642 tor-netdoc: Use itertools to implement NetDocReader::pause_at
This is the last use of PauseAt.
2023-02-15 17:17:01 +00:00
Ian Jackson 089ebb7d11 tor-netdoc: Replace use of PauseAt::new_pred()
We can just make a new PauseAt, since it can take the inner peekable
iterator by mutable reference.

This seems to tidy the code up a bit too.
2023-02-15 17:16:57 +00:00
Ian Jackson 7491424ee9 tor-netdoc: Have sectionrules.parse take I, not &mut I
There's a blanket impl of Itertor for &mut impl Iterator, so this
isn't necessary, and it prevents us passing iterators by value
producing syntactic vinegar.
2023-02-15 17:16:57 +00:00
Ian Jackson 80d8d94c96 tor-netdoc: Import Peekable rather than referring to it by path
This makes things easier to read.  We're about to add another
site (albeit, temporarily).
2023-02-15 17:16:57 +00:00
Nick Mathewson 0f2218f4d3 Merge branch 'ticket_525_part3_take2' into 'main'
Finish #525 for relay messages: Only parse messages at the last instant.

Closes #773 and #525

See merge request tpo/core/arti!1017
2023-02-15 16:35:27 +00:00
Nick Mathewson 19c0dd153a tor-proto: Add a TODO about simplifying a common pattern. 2023-02-15 10:51:03 -05:00
Nick Mathewson 21db73f182 tor-cell: add a TODO comment about simplifying Body away. 2023-02-15 10:48:19 -05:00
Nick Mathewson fce1c83f2e tor-cell: Add another debug_assert to relay cell encoding 2023-02-15 10:48:19 -05:00
Nick Mathewson 5d28e9e7d0 slicewriter: rename a local variable. 2023-02-15 10:48:19 -05:00
Nick Mathewson 19c9593acf Move slicewriter to tor-cell and make it private.
Also, add some comments about how it is likely to change.
2023-02-15 10:48:19 -05:00
Nick Mathewson 1ee6bfa59c tor-proto: note implications for future HS work 2023-02-15 10:48:19 -05:00
Nick Mathewson 41b50b6c56 tor-proto: Push stream message parsing into the stream objects.
This closes #525, and ensures, at last, that we don't parse any
message that we wouldn't accept.
2023-02-15 10:48:19 -05:00
Nick Mathewson 58c3b8276c tor-proto: Defer parsing of messages send to half-closed streams
This includes a partial solution for #769, but also turned up
another bug (#774) while I was working on it.  I'll close them both
once I have a real solution.
2023-02-15 10:48:19 -05:00
Nick Mathewson bd0f6f5adf tor-proto: stop reactor (and kill circuit) if meta handler fails
If the meta handler reports an error, then the circuit has violated
its protocol, and needs to be shut down.

Fixes #773.
2023-02-15 10:48:19 -05:00
Nick Mathewson 2e483124cb tor-proto: defer meta-cell parsing to the last moment. 2023-02-15 10:48:19 -05:00
Nick Mathewson 0765243f5e tor-proto: Use UnparsedRelayCell to start deferring cell processing.
In general, we want to avoid parsing these cells until we are
fairly sure that they are something we would accept.
2023-02-15 10:48:19 -05:00
Nick Mathewson e4bc7ef57b tor-cell: Add RelayCell::into_msg. 2023-02-15 10:48:19 -05:00
Nick Mathewson 3f1457ea04 tor-cell: Implement {Relay,Chan}Msg for every body type
This will make it ergonomic to decode a single body type without
having to declare a variant that accepts only a single message.
2023-02-15 10:48:19 -05:00
Nick Mathewson 65cc7d0974 tor-cell: Note an opportunity for future optimization 2023-02-15 10:48:19 -05:00
Nick Mathewson a809a809ba tor-cell: Add a new UnparsedRelayCell
We'll use this to router relay messages on a circuit to the
appropriate stream, and hand them to that stream, without parsing
the message until the stream has been determined.
2023-02-15 10:48:19 -05:00
Nick Mathewson ca3b33a1af tor-cell: Refactor relay cells to copy much less
We now manipulate raw relay cell bodies as (an alias for)
`Box<[u8;509]>` rather than as (an alias for) `[u8;509]`.  This
enables us to do much less copying.  It will become more important
soon, as we defer parsing relay cell bodies even longer.

Related to #7.

We also use SliceWriter to avoid allocating a Vec<> for every relay
message we want to encode, and instead encode directly into the
cell.
2023-02-15 10:48:19 -05:00