summaryrefslogtreecommitdiff
path: root/crates/tor-cell/src/chancell
Commit message (Collapse)AuthorAgeFilesLines
* Some HasMemoryCost impls in tor-cellIan Jackson2024-10-021-18/+44
|
* Change tor_bytes::Readable name to `b` in many placesIan Jackson2024-09-111-15/+15
| | | | | | | | | | | | | | | The codebase uses `r` sometimes and `b` at other times. Making this consistent makes widespread changes easier, and is clearer for humans. I think `b` is better than `r` because `r` might be "return". It is indeed used that way in a couple of places in reader.rs, even. I haven't changed *everywhere*, just Readable impls (where `r` is particularly likely to be "return value") and occurrences in tor-bytes. No functional change.
* Use uXX::MAX in place of std::uXX::MAXNick Mathewson2024-04-222-3/+3
| | | | | | The old code produced a warning from clippy nightly; we may as well update to use the new associated consts. (They've been there since Rust 1.4x.)
* Run maint/add_warning.Nick Mathewson2024-03-131-0/+1
|
* Fix typosDimitris Apostolou2024-01-081-1/+1
|
* tor-cell: Fix ambitious certtypeEmil Engler2023-12-281-1/+2
| | | | | | | When using the `arti-client` crate in other contexes, the Rust compiler sometimes has difficulties with determining the current type in this particular case, due to a collision with the popular serde json crate, which also provides an implementation for converting u8.
* Add a caret_int HandshakeType for HTYPE constantsJim Newsome2023-10-261-5/+21
|
* Change `CircId` to never be zeroJim Newsome2023-10-252-4/+5
| | | | | | | | | | This changes the internal representation to be `NonZeroU32` instead of just `u32`. Various places where a circuit ID is optional now use `Option<CircId>`. Fixes a bug in `CircIdRange::sample` that would previously return a circuit ID of 0, when the rng returned 0x8000_0000 for a low range.
* Run maint/add_warning to add lint block everywhereIan Jackson2023-08-231-0/+1
|
* Run maint/add_warning to actually apply new lint allowsIan Jackson2023-07-101-0/+1
|
* tor-cell: remove use of arrayrefNick Mathewson2023-06-011-3/+7
| | | | Closes #872
* tor-cell: add a TODO comment about simplifying Body away.Nick Mathewson2023-02-151-0/+4
|
* tor-cell: Implement {Relay,Chan}Msg for every body typeNick Mathewson2023-02-151-0/+48
| | | | | This will make it ergonomic to decode a single body type without having to declare a variant that accepts only a single message.
* tor-cell: Refactor relay cells to copy much lessNick Mathewson2023-02-151-10/+9
| | | | | | | | | | | | | 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/+5
| | | | | | | | | | 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: Remove chancell::msg::Body::into_message.Nick Mathewson2023-02-091-52/+1
| | | | | It's now redundant, since `restricted_msg!` defines From and Into for us.
* tor-cell: Make RelayEarly a separate type.Nick Mathewson2023-02-091-4/+30
| | | | This allows us to remove a shenanigan from `restricted_msg!{}`.
* tor-cell: Have restrict_msg add conversion functions.Nick Mathewson2023-02-091-6/+2
| | | | | | | | | | | | | | | | Every FooMsg type now implements Into<AnyFooMsg>, and TryFrom<FooMsg>. Additionally, it now implements From<X> for every distinct type that it supports. This last part lets us discard a bunch of code. Unfortunately, I needed some downright hackish trickery in order to get these macros to avoid generating `From<AnyFooMsg> for AnyFooMsg` and conflicting with the blanket implementation. The trickery to deal with RelayEarly and Relay being the same type was not necessarily worth it; I will be separating them and removing said trickery in the next commit.
* cell: Parameterize ChannelCodec::decode and encode.Nick Mathewson2023-02-091-7/+14
| | | | | | | This change lets us use ChannelCodec to encode and decode any restricted channel message type we want. (Later on, we'll turn the related Codec class in tor-proto into a more type-restricted version of this.)
* tor-cell: Rename ChanMsg and ChanCell-related types.Nick Mathewson2023-02-072-44/+44
|
* tor-cell: Remove ChanMsg methods that are duplicated in ChanMsgClass.Nick Mathewson2023-02-072-23/+4
|
* tor-cell: Use macro to generate ChanMsg too.Nick Mathewson2023-02-071-105/+34
|
* tor-cell: Make Body and MsgClass traits more uniform.Nick Mathewson2023-02-071-49/+53
| | | | | | | | Doing this will make it much easier to implement a macro that generates restricted instances of the Msg types (for #525). The Body change is a breaking change. I don't think anybody else implements Body, but in theory they could.
* tor-cell: Generic "Restricted{Relay,Chan}Cell" types.Nick Mathewson2023-02-071-9/+23
| | | | | | | These are generalizations of RelayCell and ChanCell respectively, that allow using an arbitrary message type in place of the fully general RelayMsg and ChanMsg types. Doing this is a prerequisite for usefully implementing arti#525.
* Allow clippy::unchecked_duration_subtraction in testsNick Mathewson2023-01-271-0/+1
| | | | | This panics on error, and we're fine with a panic on misbehavior in tests.
* Merge branch 'test-lints' into 'main'eta2023-01-061-0/+9
|\ | | | | | | | | Add test lint blocks to all "mod test" See merge request tpo/core/arti!937
| * test lint blocks: Add many many automaticallyIan Jackson2022-12-121-0/+9
| | | | | | | | | | This is precisely the result of running the rune in maint/adhoc-add-lint-blocks.
* | msg::{CreateFast/CreatedFast}: Rename accessor to (into_)body()Neel Chauhan2022-12-181-2/+2
|/
* Fix typosDimitris Apostolou2022-11-061-1/+1
|
* Merge branch 'rename_for_to_from' into 'main'Nick Mathewson2022-10-251-2/+2
|\ | | | | | | | | tor-cell: Rename for_client and for_relay See merge request tpo/core/arti!793
| * tor-cell: Rename for_client and for_relayEmil Engler2022-10-211-2/+2
| | | | | | | | | | | | | | This commit renames the for_client and for_relay functions to from_client and from_relay respectively, in order to indicate their origin, as the term "for" is more likely to indicate a destination, which is not true in that situation.
* | Merge branch 'fix_typos' into 'main'eta2022-10-211-3/+3
|\ \ | | | | | | | | | | | | tor-cell: Fix typos in msg.rs See merge request tpo/core/arti!788
| * | tor-cell: Fix typos in msg.rsEmil Engler2022-10-211-3/+3
| |/
* | Merge branch 'remove_redundant' into 'main'eta2022-10-211-2/+0
|\ \ | | | | | | | | | | | | tor-cell: Remove redundant match clauses See merge request tpo/core/arti!792
| * | tor-cell: Remove redundant match clausesEmil Engler2022-10-211-2/+0
| |/ | | | | | | | | This commit removes two redundant match clauses inside the take_one_netinfo_addr function found inside msg.rs.
* | Merge branch 'concrete_comments' into 'main'eta2022-10-211-3/+6
|\ \ | | | | | | | | | | | | tor-cell: Make historical comments more concrete See merge request tpo/core/arti!787
| * | tor-cell: Make historical comments more concreteEmil Engler2022-10-211-3/+6
| |/ | | | | | | | | This commit extends comments that make references to historical protocol versions of Tor, by adding the concrete protocol version numbers.
* | Merge branch 'no_redundant_copy' into 'main'Ian Jackson2022-10-211-2/+2
|\ \ | | | | | | | | | | | | tor-cell: Avoid redundant pointer copy See merge request tpo/core/arti!791
| * | tor-cell: Avoid redundant pointer copyEmil Engler2022-10-211-2/+2
| |/ | | | | | | | | | | This commit changes an iteration by copying a u16 (which is 2 bytes) instead of a pointer address, which is most likely 8 bytes on most machines.
* | Merge branch 'no_redundant_allocation' into 'main'Nick Mathewson2022-10-211-1/+1
|\ \ | | | | | | | | | | | | tor-cell: Avoid redundant allocation See merge request tpo/core/arti!790
| * | tor-cell: Avoid redundant allocationEmil Engler2022-10-211-1/+1
| |/ | | | | | | | | | | This commit changes the way how a vector with a known sized gets allocated, by using Vec::with_capacity() instead of Vec::new(). It will eventually avoid an allocation of more memory than required.
* / tor-cell: Rename fixed_len to fixed_len_handshakeEmil Engler2022-10-211-7/+7
|/ | | | | | This commit renames the fixed_len! macro to fixed_len_handshake!, in order to indicate, that this macro is only suited for cells with commands related to handshaking.
* tor-cell: PaddingNegotiate::start: take IntegerMillisecondsIan Jackson2022-08-171-3/+4
|
* tor-cell: PaddingNegotiate: give better spec xrefsIan Jackson2022-08-171-0/+6
|
* channel padding: Rename low_ms and high_msIan Jackson2022-08-171-1/+5
| | | | | These have the unit in the type. Putting that in the field name too is otiose.
* tor-cell, testing: Provide PaddingNegotiate::from_rawIan Jackson2022-08-161-0/+8
| | | | | This allows test cases to describe precisely the contents of the negotiation cell ought to be generated.
* chancell: PaddingNegotiate: Provide start_default and a Default implIan Jackson2022-08-161-0/+20
| | | | | As proposed in https://gitlab.torproject.org/tpo/core/torspec/-/merge_requests/77
* chancell: Introduce PaddingNegotiateCmdIan Jackson2022-08-161-5/+17
| | | | | This gets rid of some random hardcoded literals. We're going to want to reuse this, too.
* chancell: PaddingNegotiate: Provide two constructors, not oneIan Jackson2022-08-161-7/+14
| | | | | | | | 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
* chancell: PaddingNegotiate: Make EqIan Jackson2022-08-161-2/+2
| | | | | | | | 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.