summaryrefslogtreecommitdiff
path: root/crates/tor-proto
Commit message (Collapse)AuthorAgeFilesLines
* Bump all arti*, tor* crates to 0.2.0Nick Mathewson2022-04-011-11/+11
| | | | | | | | Not all of these strictly need to be bumped to 0.2.0; many could go to 0.1.1 instead. But since everything at the tor-rtcompat and higher layers has had breaking API changes, it seems not so useful to distinguish. (It seems unlikely that anybody at this stage is depending on e.g. tor-protover but not arti-client.)
* Merge branch 'netinfo-clock-skew' into 'main'Nick Mathewson2022-03-235-25/+231
|\ | | | | | | | | tor-proto: add the ability to learn clock skew from NETINFO cells See merge request tpo/core/arti!410
| * tor-proto: better errors when handshake fails due to untimely certsNick Mathewson2022-03-232-15/+63
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We now check the handshake certificates unconditionally, and only report them as _expired_ as a last resort. (Rationale: if somebody is presenting the wrong identity from a year ago, it is more interesting that they are presenting the wrong ID than it is that they are doing so with an expired cert. We also now report a different error if the certificate is expired, but its expiration is within the range of reported clock skew. (Rationale: it's helpful to distinguish this case, so that we can blame the failure on possible clock skew rather than definitely attributing it to a misbehaving relay.) Part of #405.
| * tor-proto: add a backend to detect reported clock skew.Nick Mathewson2022-03-234-10/+168
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | NETINFO cells, which are sent in every handshake, may contain timestamps. This patch adds an accessor for the timestamp in the Netinfo messages, and teaches the tor-proto code how to compute the minimum clock skew in the code. The computation isn't terribly precise, but it doesn't need to be: Tor should work fine if your clock is accurate to within a few hours. This patch also notes a Y2038 problem in the protocol: see torspec#80. Part of #405.
* | Define accessors for circuit hops.Nick Mathewson2022-03-172-0/+39
| | | | | | | | Closes #415
* | tor-proto: Remember peer information in circuit and channelNick Mathewson2022-03-176-36/+68
| | | | | | | | | | | | | | | | | | Each channel now remembers an OwnedChanTarget. Each circuit now remembers a vector of OwnedChanTarget to represent the path that it was constructed for. Part of #415.
* | ClientCirc: Move n_hops into a new Path type.Nick Mathewson2022-03-173-14/+36
|/ | | | This will help with #415
* Merge branch 'educe-traits' into 'main'Ian Jackson2022-03-042-32/+25
|\ | | | | | | | | Replace many manual trait impls with use of educe See merge request tpo/core/arti!375
| * Move skip_fmt into tor-basic-utilsIan Jackson2022-03-042-1/+2
| | | | | | | | | | | | | | Code motion and the minimal mechanical changes. As per https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/375#note_2783078
| * Replace manual Debug impls with educe in tor-protoIan Jackson2022-03-022-32/+24
| | | | | | | | We now print slighly more information.
* | Replace manual Default and new with std derive in tor-protoIan Jackson2022-03-021-7/+2
|/
* Merge branch 'clippy-allow-arc-clone' into 'main'Nick Mathewson2022-03-011-1/+0
|\ | | | | | | | | Disable clippy::clone_on_ref_ptr See merge request tpo/core/arti!352
| * Disable clippy::clone_on_ref_ptrIan Jackson2022-02-241-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This lint is IMO inherently ill-conceived. I have looked for the reasons why this might be thought to be a good idea and there were basically two (and they are sort of contradictory): I. "Calling ‘.clone()` on an Rc, Arc, or Weak can obscure the fact that only the pointer is being cloned, not the underlying data." This is the wording from https://rust-lang.github.io/rust-clippy/v0.0.212/#clone_on_ref_ptr It is a bit terse; we are left to infer why it is a bad idea to obscure this fact. It seems to me that if it is bad to obscure some fact, that must be because the fact is a hazard. But why would it be a hazard to not copy the underlying data ? In other languages, faliing to copy the underlying data is a serious correctness hazard. There is a whose class of bugs where things were not copied, and then mutated and/or reused in multiple places in ways that were not what the programmer intended. In my experience, this is a very common bug when writing Python and Javascript. I'm told it's common in golang too. But in Rust this bug is much much harder to write. The data inside an Arc is immutable. To have this bug you'd have use interior mutability - ie mess around with Mutex or RefCell. That provides a good barrier to these kind of accidents. II. "The reason for writing Rc::clone and Arc::clone [is] to make it clear that only the pointer is being cloned, as opposed to the underlying data. The former is always fast, while the latter can be very expensive depending on what is being cloned." This is the reasoning found here https://github.com/rust-lang/rust-clippy/issues/2048 This is saying that *not* using Arc::clone is hazardous. Specifically, that a deep clone is a performance hazard. But for this argument, the lint is precisely backwards. It's linting the "good" case and asking for it to be written in a more explicit way; while the supposedly bad case can be written conveniently. Also, many objects (in our codebase, and in all the libraries we use) that are Clone are in fact simply handles. They contain Arc(s) (or similar) and are cheap to clone. Indeed, that is the usual case. It does not make sense to distinguish in the syntax we use to clone such a handle, whether the handle is a transparent Arc, or an opaque struct containing one or more other handles. Forcing Arc::clone to be written as such makes for code churn when a type is changed from Arc<Something> to Something: Clone, or vice versa.
* | Bump all crates to 0.1.0arti-v0.1.0Nick Mathewson2022-03-011-10/+10
| |
* | remove usage of dbg!(..)trinity-1686a2022-02-281-1/+0
| | | | | | | | it's making rust-nightly job fail
* | Merge branch 'always-coarsetime' into 'main'eta2022-02-283-12/+2
|\ \ | | | | | | | | | | | | Make coarsetime dependency and traffic-timestamping non-optional. See merge request tpo/core/arti!358
| * | Make coarsetime dependency and traffic-timestamping non-optional.Nick Mathewson2022-02-253-12/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously coarsetime and the traffic-timestamp feature were enabled, since they were only required for a small corner of the guardmgr algorithm. But in 1.0 and beyond we'll be adding a bunch of other features (eg, netflow padding, DoS prevention) that will need coarsetime all over the place. And since we're going to be doing coarsetime all over the place, the previous justification for making traffic-timestamping optional (the tiny performance hit) is no longer relevant.
* | | Merge branch 'upgrade-dependencies' into 'main'Nick Mathewson2022-02-251-2/+2
|\ \ \ | |/ / |/| | | | | | | | Upgrade a few dependencies to newer versions See merge request tpo/core/arti!357
| * | Bump minimum tokio to 1.7, since tokio-util now needs that.Nick Mathewson2022-02-251-1/+1
| | |
| * | Upgrade dependency to new version of tokio-util.Nick Mathewson2022-02-251-1/+1
| | |
* | | tor-proto datastream: Fix typo in Debug implIan Jackson2022-02-251-1/+1
|/ / | | | | | | | | As per https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/353#note_2781632
* | Merge branch 'debug-datastream' into 'main'eta2022-02-241-4/+11
|\ \ | | | | | | | | | | | | tor-proto datastream: Do not dump packet data in DataWriterImpl See merge request tpo/core/arti!353
| * | Fix rustfmtIan Jackson2022-02-241-1/+1
| | |
| * | tor-proto datastream: Do not dump packet data in DataWriterImplIan Jackson2022-02-241-2/+9
| | |
| * | tor-proto datastream: import std::fmt::Debug trait nameIan Jackson2022-02-241-2/+2
| | |
* | | Merge branch 'proto_handshake_err' into 'main'Nick Mathewson2022-02-249-95/+140
|\ \ \ | |/ / |/| | | | | | | | | | | | | | tor-proto: Split up a couple of handshake-based errors Closes #359 and #358 See merge request tpo/core/arti!344
| * | proto: Refactor conversion from CodecError to ErrorNick Mathewson2022-02-243-32/+37
| | | | | | | | | | | | | | | Remove default conversion; instead use a specific conversion in each of the two modules that need to do it.
| * | tor-proto: refactor handshake protocol errors to a different typeNick Mathewson2022-02-232-52/+79
| | | | | | | | | | | | | | | | | | | | | | | | This helps the user distinguish between protocol violations that happen when connecting to the tor network from those that happen while connected. Closes #358.
| * | tor-proto: Rename BadHandshake to BadCircHandshakeNick Mathewson2022-02-237-12/+12
| | | | | | | | | | | | (We'll have a BadChanHandshake soon.)
| * | tor-proto: Split IoErr based on when it occursNick Mathewson2022-02-233-18/+31
| |/ | | | | | | | | | | | | We want to distinguish handshake failures from errors later on in the channel's lifetime. Closes #359.
* | Merge branch 'remote_stream_err' into 'main'eta2022-02-241-3/+1
|\ \ | | | | | | | | | | | | | | | | | | Give specific error kinds to different END reasons Closes #360 See merge request tpo/core/arti!343
| * | Give specific error kinds to different END reasonsNick Mathewson2022-02-231-3/+1
| |/ | | | | | | Closes #360.
* | Merge branch 'debug-datastream' into 'main'eta2022-02-243-2/+19
|\ \ | |/ |/| | | | | impl Debug for DataStream (and its components) See merge request tpo/core/arti!351
| * impl Debug for DataStream (and its components)Ian Jackson2022-02-243-2/+19
| | | | | | | | | | | | | | | | | | My proximate motivation is that tls-api wants its inner streams to be Debug. But in general, I agree with the Rust API Guidelines notion that almost everything should be Debug. I have gone for the "dump all the things" approach. A more nuanced approach would be possible too.
* | Merge remote-tracking branch 'origin/mr/340'Nick Mathewson2022-02-235-29/+52
|\ \
| * | Eliminate RequestedResourceAbsent kind.Nick Mathewson2022-02-225-23/+46
| | | | | | | | | | | | | | | | | | | | | | | | There was only one use of this, and it was in as-yet-unused relay-only code. Removing this type required refactoring the relay onion handshake code to use its own error type, which is probably clever anyway.
| * | Fold NamespaceFull into BadApiUsage.Nick Mathewson2022-02-221-1/+1
| | |
| * | Rename RemoteNameError to RemoteHostNotFoundNick Mathewson2022-02-221-2/+2
| | | | | | | | | | | | | | | This is a bit ugly but we need it to work around the problem where exits aren't always clear about _why_ a hostname lookup failed.
| * | Replace RemoteRefused with CircuitRefused.Nick Mathewson2022-02-221-1/+1
| | | | | | | | | | | | Also document that it's a lower-level error kind.
| * | Rename RemoteIdMismatch to RelayIdMismatch.Nick Mathewson2022-02-221-1/+1
| | |
| * | Fold AlreadyClosed into BadApiUsageNick Mathewson2022-02-221-1/+1
| |/
* / Remove clippy::needless_borrow exception in CI.Nick Mathewson2022-02-201-1/+0
|/ | | | | This exception is no longer necessary now that the underlying CI bug is fixed.
* Replace as_mut with deref impl for MutCircEntYuan Lyu2022-02-162-26/+34
|
* Make CircMap open_ent_count O(1)Yuan Lyu2022-02-162-26/+76
|
* tor_proto::Error: Fix an incomplete sentence.Nick Mathewson2022-02-161-1/+2
|
* Update tor-proto errors to latest API.Nick Mathewson2022-02-1511-43/+41
|
* Make tor-proto::Error implement HasKind.Nick Mathewson2022-02-153-26/+54
| | | | | | This took some refactoring, and gave an opportunity to notice a few error variants that weren't being used, or didn't mean what they said on the tin.
* tor-proto: use InternalError for internal errors.Nick Mathewson2022-02-1513-45/+84
|
* tor-cell: provide HasKind.Nick Mathewson2022-02-154-17/+49
| | | | | | | | | Additionally, refactor the IoError out of tor_cell::Error: nothing in TorCell created this; it was only used by tor_proto. This required refactoring in tor_proto to use a new error type. Here I decided to use a new CodecError for now, though we may refactor that away soon too.
* Merge branch 'warn_not_deny' into 'main'eta2022-02-141-1/+1
|\ | | | | | | | | | | | | Change deny(clippy::all) to warn(clippy::all). Closes #338 See merge request tpo/core/arti!306