Commit Graph

333 Commits

Author SHA1 Message Date
Ian Jackson f63c7c48af Rename onion-* cargo features to hs-* in tor-* crates
Fixes #756
2023-02-28 11:10:17 +00:00
Nick Mathewson d09273a6e3 Apply a missing cfg_attr(docsrs...) in netdoc 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
Nick Mathewson 3233c25943 tor-netdoc: Use UnparsedLinkSpec in IntroPointDesc. 2023-02-17 15:29:37 -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 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
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 e00dfcf41e netdoc: Add a basic fuzzer for the hsdesc layers.
I've been running this for 5 minutes and haven't found any
crashes. I'll run it for an hour or two, then add the results to the
corpus repository.
2023-02-14 07:49:34 -05:00
Nick Mathewson 79dd2ef995 netdoc: Add a feature to expose hsdesc inner doc parsers
We want to fuzz these parsers, but there's no currently way to get
at the parsers for inner documents without going through a lot of
encryption.  (Coverage-guided fuzzers are powerful, but they
can't find SHA3 preimages.)
2023-02-14 07:44:18 -05:00
Nick Mathewson 74ef8de86f Merge branch 'doc-iter' into 'main'
Introduce new batching iterator and use it in two places

See merge request tpo/core/arti!1016
2023-02-13 18:59:42 +00:00
Ian Jackson 297019bb23 batching_split_before: Whitespace error fix 2023-02-13 17:34:04 +00:00
Ian Jackson b4d0b585c2 batching_split_before: Better xref for doc hidden
And another UNSTABLE warning.
2023-02-13 17:32:54 +00:00
Ian Jackson 1232bb6661 batching_split_before: Clarify API sequential restriction 2023-02-13 17:29:17 +00:00
Ian Jackson 5be6db006c batching_split_before: Fix and clarify Batches/LendingIterator doc 2023-02-13 17:28:39 +00:00
Ian Jackson 15f33ce13c batching_split_before: Introduce unit token types
And explain why we're not using booleans.
2023-02-13 17:19:13 +00:00
Ian Jackson 73a20cdc36 batching_split_before: Expand on the remaining use of "meta-iterator" 2023-02-13 17:13:55 +00:00
Ian Jackson 04e3a22b82 batching_split_before: Fix link to BatchesWithHeader::subsequent 2023-02-13 17:12:17 +00:00
Ian Jackson 53ef0d65ea batching_split_before: Provide description for BatchesWithHeader 2023-02-13 17:09:08 +00:00
Ian Jackson 6799fb6e3e batching_split_before: Document generics on our non-private types 2023-02-13 17:04:29 +00:00
Ian Jackson e44be77f52 batching_split_before: Rename "prefix" to "header"
As per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/1016#note_2877759

"_prefixed" becomes "_with_header".  That mirrors the returned struct
which is nice.
2023-02-13 16:55:36 +00:00
Ian Jackson 72b1cb797d batching_split_before: Rename "start" to "batch-starting"
Roughly as per
  https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/1016#note_2877822
2023-02-13 16:52:07 +00:00
Ian Jackson 09060b4748 batching_split_before: Remove false assertions about batch contents 2023-02-13 16:44:47 +00:00
Ian Jackson 4333a1ef1c batching_split_before: Clarify heading of BatchesWithPrefix 2023-02-13 16:37:13 +00:00
Nick Mathewson 5c1cbd5486 batching_split_before: docs improvements. 2023-02-13 16:12:26 +00:00
Nick Mathewson 7363bee6a4 netdoc: give hsdesc test info in its original form. 2023-02-13 10:30:27 -05:00
Ian Jackson 8703a969f4 tor-netdoc: Use batching iterator in authcert.rs
This gets rid of a lot of manual boolean state variable iterator
stuff.
2023-02-10 19:48:26 +00:00
Ian Jackson d35f7990e8 tor-netdoc: Use batching_split_before in HsDescInner 2023-02-10 19:47:45 +00:00
Ian Jackson fd35f05b26 tor-netdoc: Provide new batching_split_before
There will be two call sites to demonstrate it.

Eventually maybe this will want to be in tor-basic-utils, since it
doesn't depend on any of the tor-netdoc types.  But it would be
sensible to wait until the situation with PeekableIterator and
Itertools is improved.

For now we make this #[doc(hidden)] to avoid it becoming part of our
stable API.
2023-02-10 19:47:45 +00:00
Ian Jackson 1b5a5eb57a tor-netdoc: Provide NetDocReader::into_iter
This will avoids some hairy borrowck disasters when we try to use
iterator adapters.
2023-02-10 19:47:45 +00:00
Ian Jackson 5f0ff78c2d tor-netdoc: util: use super::* in tests
Not xure how my MR to try to do this everyone missed this one.
2023-02-10 19:47:45 +00:00
Ian Jackson a5be14ed5e tor-netdoc: util: Add standard lint block to tests
Not xure how my MR to try to do this everyone missed this one.
2023-02-10 12:47:02 +00:00
Nick Mathewson 3f5502c5bc netdoc: Add a test for HSDesc decryption. 2023-02-10 07:36:40 -05:00
Nick Mathewson ced33029f6 Add another test hsdesc to parse.
This one was generated (by dgoulet) using `ClientDescEncKey`
encryption.  Its information is:

```
Address: paozpdhgz2okvc6kgbxvh2bnfsmt4xergrtcl4obkhopyvwxkpjzvoad.onion

Time period: 19397

Client:

  paozpdhgz2okvc6kgbxvh2bnfsmt4xergrtcl4obkhopyvwxkpjzvoad:descriptor:x25519:SDZNMD4RP4SCH4EYTTUZPFRZINNFWAOPPKZ6BINZAC7LREV24RBQ

Service:

  descriptor:x25519:SACGOAEODFGCYY22NYZV45ZESFPFLDGLMBWFACKEO34XGHASSAMQ
```
2023-02-10 07:26:31 -05:00
Ian Jackson 62fa652fcd Merge branch 'hsdir' into 'main'
Compute the HS directory hash ring

See merge request tpo/core/arti!1012
2023-02-09 16:35:42 +00:00
Nick Mathewson 73ce68ac21 Rename DescEncNonce => HsDescEncNonce 2023-02-09 08:57:09 -05:00
Ian Jackson f5c3c1f277 hsdir: Be able to enumerate the hidden service directories
* Provide an accessor for the HSDIR flag
* Provide a function for testing a relay for hsdir inclusion
* Provide an iterator on NetDir that returns the hsdirs
2023-02-09 13:01:37 +00:00
Ian Jackson 81d4e6971b tor-netdoc: Discuss that relays are ordered by rsa id in Consensus 2023-02-09 12:56:18 +00:00
Nick Mathewson 0a80c468df hsdesc: Use an IntegerMinutes<u16> to hold lifetime. 2023-02-08 13:33:07 -05:00