aboutsummaryrefslogtreecommitdiff
path: root/crates/tor-cell/tests/test_relaycell.rs
Commit message (Collapse)AuthorAgeFilesLines
* Upgrade rand crates to 0.10.Wesley Aptekar-Cassels2026-05-121-8/+12
| | | | | | | | | | | When the circ-padding feature is enabled, we use maybenot, which does not yet support rand 0.10. In the meantime, enabling this feature pulls in rand 0.9. This is not ideal, but should be okay as a temporary situation. This also replaces the use of ReseedingRng (which was removed in 0.10) with the reseeding_rng crate. This is somewhat less performant, but it should be okay.
* Switch Cargo.toml files to edition 2024.Nick Mathewson2025-08-071-1/+1
| | | | | | | | | | | | | | First, run ``` git grep -l "^edition =" | xargs perl -i -pe 's/^edition *=.*/edition = "2024"/;' ``` Second, manually verify that all Cargo.toml files have changed, and nothing else has changed. Third, run cargo fmt again.
* tor-cell: change `UnparsedRelayMsg::data_len`Steven Engler2025-07-151-3/+19
| | | | | | | | | It now performs some validation and can return a `Result`. We perform validation here since different cell formats may have different maximum data lengths in the future, and `UnparsedRelayMsg` doesn't expose the cell format so it's difficult to perform this validation at a higher layer.
* tor-cell: add some testing for `UnparsedRelayMsg`Steven Engler2025-04-301-4/+27
|
* cell: Implement parsing and encoding for V1 relay cellsNick Mathewson2025-04-161-7/+77
| | | | This is the main part of #1944, and will be needed for CGO.
* Add a RelayCellFormat argument to encode().Nick Mathewson2025-04-161-2/+3
| | | | | | | | | This will let us actually _send_ messages in the right format. This approach is not ideal for packed/fragmented messages; they will need a separate RelayCellEncoder. part of #1944.
* squash! Upgrade rand dependency to 0.9.Nick Mathewson2025-03-181-5/+1
| | | | - `try_fill_bytes()` is no longer a member of RngCore.
* relay-cell: Update relay cell decoding API for prop340Jim Newsome2024-03-121-5/+7
| | | | | | | | | | | Prop 340: https://spec.torproject.org/proposals/340-packed-and-fragmented.html This updates the decoding API to support multiple versions of the relay cell encoding, including the new encoding proposed in prop340 that supports relay message packing and fragmentation. This commit doesn't actually add support for that new encoding yet.
* Rename UnparsedRelayCell -> UnparsedRelayMsgJim Newsome2024-03-121-2/+2
| | | | | For consistency with the terminology proposed in https://gitlab.torproject.org/tpo/core/torspec/-/issues/253
* Rename {Any}RelayCell to {Any}RelayMsgOuterNick Mathewson2023-12-141-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | This commit is pure renaming, done automatically with rust-analyzer. Comment fixes and other cleanups will be in the subsequent commits. We're doing this renaming because we need a name for the combination of a `RelayMsg` and an `Option<StreamId>` that we use when we have a `RelayMsg` we intend to route to a given stream or circuit internally. Previously we called this a `RelayCell`, but that name was already somewhat inaccurate, and will become _very_ inaccurate with the arrival of prop340, which breaksthe 1:1 relationship between relay cells and relay messages. (If we didn't do this renaming now, we'd soon be making the relationship between `UnparsedRelayCell`and `RelayCell` many-to-many, which would be ridiculous and confusing.) The `RelayMsgOuter` name is a placeholder: We expect that we'll want to rename this type, and may also want to rename `RelayMsg`, and unify our vocabulary in other areas too. But such a renaming will have to wait for a larger discussion affecting the specifications, so that we can use the same vocabulary everywhere.
* Convert StreamId to NonZeroU16Jim Newsome2023-10-251-11/+10
|
* tor-cell: Add a new UnparsedRelayCellNick Mathewson2023-02-151-2/+14
| | | | | | 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.
* tor-cell: Refactor relay cells to copy much lessNick Mathewson2023-02-151-2/+2
| | | | | | | | | | | | | 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.
* Change tor_bytes::Error::BadMessage to a Cow.Nick Mathewson2023-02-091-3/+8
| | | | | | | | | | Actually, to avoid making a breaking change, I'm deprecating BadMessage and creating a new InvalidMessage variant that takes a Cow. This way I don't need to track every crate that re-exposes tor_bytes::Error and call this a breaking change in those. Making this change will allow tor_bytes errors to be much more helpful.
* tor-cell: Rename RelayMsg and RelayCell-related types.Nick Mathewson2023-02-071-6/+6
| | | | Thanks to rust-analyzer for making this simple.
* tor-cell: Remove RelayMsg methods that are duplicated in RelayMsgClass.Nick Mathewson2023-02-071-1/+1
|
* Disable clippy::unlinlined-format-argsNick Mathewson2023-01-271-0/+1
| | | | | | | | This warning kind of snuck up on us! (See #748) For now, let's disable it. (I've cleaned it up in a couple of examples, since those are meant to be more idiomatic and user-facing.) Closes #748.
* udp: Allow empty hostname and no nul byteIan Jackson2022-06-071-2/+17
| | | | | | | | | | | | | | | After changes to the prop339, the domain name in an Address can only be 255 bytes max and can NOT contain nul byte(s). Unit tests had to be modified to accept this change: - Centralise msg_ip_address - Add currently-passing tests for address length - Test counted address length longer than type wants Related to #463 Signed-off-by: David Goulet <[email protected]>
* cell: Don't use NUL terminated string in CONNECT_UDPDavid Goulet2022-06-071-2/+2
| | | | Signed-off-by: David Goulet <[email protected]>
* cell: Move UDP to its own module and feature gate itDavid Goulet2022-06-071-3/+7
| | | | | | Related to #463 Signed-off-by: David Goulet <[email protected]>
* cell: Implement CONNECT_UDP cell from prop339David Goulet2022-06-071-1/+57
| | | | | | | | | Decoding and encoding is implemented according to proposal 339 specifications. Related to #463 Signed-off-by: David Goulet <[email protected]>
* Remove many needless borrows and slicesIan Jackson2022-02-021-1/+1
| | | | | | | Found via clippy::needless_borrow. In some cases I removed needless `[..]` too. See also: needless_borrow suggestion doesn't go far enough https://github.com/rust-lang/rust-clippy/issues/8389
* Move all crates into a `crates` subdirectory.Nick Mathewson2021-08-271-0/+116
This will cause some pain for now, but now is really the best time to do this kind of thing.