Commit Graph

3653 Commits

Author SHA1 Message Date
Benjamin Saunders 040f6d7256 Forbid new outgoing connections on closed endpoints 2024-04-22 14:56:40 +02:00
Benjamin Saunders 9ce24f93e4 Refuse incoming connections after endpoint is closed 2024-04-22 14:56:40 +02:00
gabrik ce13559778 proto: validate ServerConfig crypto provider
Signed-off-by: gabrik <gabriele.baldoni@gmail.com>
2024-04-22 09:45:53 +02:00
Dirkjan Ochtman e6d48970af proto: validate ClientConfig crypto provider
Co-authored-by: gabrik <gabriele.baldoni@gmail.com>
2024-04-22 09:45:53 +02:00
Dirkjan Ochtman 3be1ab5ab2 Upgrade to rcgen 0.13 2024-04-22 09:45:53 +02:00
Dirkjan Ochtman a85a4c12ee Update rustls to 0.23 and ring to 0.17 2024-04-22 09:45:53 +02:00
Dirkjan Ochtman f0d1a45639 perf: hoist config construction out of conditionals 2024-04-22 09:45:53 +02:00
Dirkjan Ochtman 76875408a9 quinn: inline single-use helper function 2024-04-22 09:45:53 +02:00
Dirkjan Ochtman ae82c380dc quinn: use ClientConfig helper for tests 2024-04-22 09:45:53 +02:00
Dirkjan Ochtman 285e1b650c proto: add test helpers for custom ALPN crypto configs 2024-04-22 09:45:53 +02:00
Dirkjan Ochtman 07e428169b proto: deduplicate rustls ClientConfig setup 2024-04-22 09:45:53 +02:00
Dirkjan Ochtman e28b29f76e quinn: add bounds in dyn Error types 2024-04-22 09:45:53 +02:00
Dirkjan Ochtman b61d9ec574 proto: rename InvalidDnsName to InvalidServerName
In preparation for allowing IP server names (with rustls 0.23).
2024-04-22 09:45:53 +02:00
Dirkjan Ochtman 85351bc399 proto: remove the Side argument from ServerConfig::initial_keys() 2024-04-22 09:45:53 +02:00
Damien Deville 90118e76b3 perf: change throughput units from MiB/s into Mb/s. 2024-04-18 19:26:36 +02:00
dependabot[bot] 52c285d60f build(deps): bump peaceiris/actions-gh-pages from 3 to 4
Bumps [peaceiris/actions-gh-pages](https://github.com/peaceiris/actions-gh-pages) from 3 to 4.
- [Release notes](https://github.com/peaceiris/actions-gh-pages/releases)
- [Changelog](https://github.com/peaceiris/actions-gh-pages/blob/main/CHANGELOG.md)
- [Commits](https://github.com/peaceiris/actions-gh-pages/compare/v3...v4)

---
updated-dependencies:
- dependency-name: peaceiris/actions-gh-pages
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-15 14:59:51 -07:00
dependabot[bot] b469e1c7ad build(deps): bump peaceiris/actions-mdbook from 1 to 2
Bumps [peaceiris/actions-mdbook](https://github.com/peaceiris/actions-mdbook) from 1 to 2.
- [Release notes](https://github.com/peaceiris/actions-mdbook/releases)
- [Changelog](https://github.com/peaceiris/actions-mdbook/blob/main/CHANGELOG.md)
- [Commits](https://github.com/peaceiris/actions-mdbook/compare/v1...v2)

---
updated-dependencies:
- dependency-name: peaceiris/actions-mdbook
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-15 16:03:39 +02:00
Gus Caplan 82a67dbeeb add send_datagram_wait 2024-04-14 11:34:54 +02:00
Gus Caplan a7d185d615 rename 2024-04-14 11:34:54 +02:00
Gus Caplan d546b90570 add drop param to datagram send 2024-04-14 11:34:54 +02:00
Gus Caplan 2714162152 Per-connection ServerConfigs 2024-04-12 19:18:43 -07:00
Gus Caplan ce62df434d Server-side preferred address support 2024-04-12 19:18:43 -07:00
Pixelstorm 88f48b0179 Add test ensuring send & sync are impled 2024-04-09 10:41:02 -07:00
Pixelstorm 33c6bdeac5 Add sync bounds to traits 2024-04-09 10:41:02 -07:00
Pixelstorm 345fabec95 Refactor stream priority management
The main goal of this refactor is to remove a
`RefCell` that is preventing
`Connection` from being `Sync`.
This is achieved by replacing it with a
monotonically decreasing 'recency' counter.

See #1769 for more information.
2024-04-09 10:41:02 -07:00
Benjamin Saunders cc0d2e9563 Allocate Incoming response buffers as needed
Threading buffers through alongside the `Incoming` does not reduce the
number of allocations.
2024-04-07 09:21:58 +02:00
Benjamin Saunders 8fbcf08424 Simplify BTreeMap RangeSet min/max getters for Rust 1.66 2024-04-06 09:54:15 -07:00
Benjamin Saunders 10155c1c41 Update MSRV to 1.66 2024-04-06 09:54:15 -07:00
Benjamin Saunders bbf68c51ab Use hashed connection IDs by default 2024-04-06 09:43:59 -07:00
Benjamin Saunders abdff8061e Introduce hashed connection ID generator 2024-04-06 09:43:59 -07:00
Benjamin Saunders 0871135ad0 Allow packets with impossible CIDs to be ignored rather than reset 2024-04-06 09:43:59 -07:00
Benjamin Saunders 7e8e0ad56b Introduce InitialPacket helper struct to avoid an unreachable 2024-04-04 12:45:06 -07:00
Benjamin Saunders c248769c5e Remove duplicates of header fields from Incoming 2024-04-04 12:45:06 -07:00
Benjamin Saunders 1d32dcb275 Factor Header::Initial variant out into freestanding struct 2024-04-04 12:45:06 -07:00
Max Inden 65bddc9018 refactor(endpoint): use array::from_fn instead of unsafe MaybeUninit
With Rust 1.63.0 one can initialize a `std::array` via `std::array::from_fn`.

https://doc.rust-lang.org/std/array/fn.from_fn.html

Thus there is no need to start with an uninitialized array via `MaybeUninit`,
initialize it and then use `unsafe` to `assume_init`. Instead one can initialize
the array with the concrete elements right away.
2024-04-04 12:38:58 -07:00
Benjamin Saunders 1f8611d5cb Defer initial packet payload decryption until after accept
Reduces the amount of work done for connection attempts that will be
refused or ignored when the application layer can do so
cheaply, e.g. using a blocked IP list.
2024-04-03 23:01:22 -07:00
Felician Nemeth e28a7f2c62 Break linkability on client-side after planned migration
(See bug #1803 for the server-side case.)
2024-04-03 20:24:56 -07:00
Benjamin Saunders 21499cd11c Introduce Connection::local_address_changed for active migration 2024-04-03 20:24:56 -07:00
Phoenix Kahlo ff487f01c8 Demonstrate connection limiting in example
This commit adds a new --connection-limit option to the server example
to illustrate how a user could implement a limit to the number of
connections open at a time with the new "incoming" API and
Endpoint::open_connections method rather than with the now-removed
concurrent_connections ServerConfig parameter.
2024-04-03 10:02:29 +02:00
Phoenix Kahlo 75c0e0192a Demonstrate IP blocking in example
This commit adds a new --block option to the server example to
illustate in a simplified way the general structure one would use to
implement IP address blocking with the new accept/reject/retry API.

For example:

    cargo run --example server ./ --listen 127.0.0.1:4433 --stateless-retry --block 127.0.0.1:8065
    cargo run --example client https://127.0.0.1:4433/Cargo.toml --host localhost --bind 127.0.0.1:8065

One thing to note is that that example places the reject condition
before the retry condition. This expends slightly less effort rejecting
connections, but does create a blocked IP address oracle for an attacker
who can do address spoofing.
2024-04-03 10:02:29 +02:00
Phoenix Kahlo 54d5d60b42 Allow accept/refuse/retry before handshake begins
This commit removes use_retry from the server config and provides a
public API for the user to manually accept/refuse/retry incoming
connections before a handshake begins, and inspect properties such as
an incoming connection's remote address and whether that address is
validated when doing so.

In quinn-proto, Incoming is made public, as well as Endpoint's accept/
refuse/retry methods which operate on it. The
DatagramEvent::NewConnection event is modified to return an incoming
but not yet accepted connection.

In quinn, awaiting Endpoint::accept now yields a new
quinn::Incoming type, rather than quinn::Connecting. The new
quinn::Incoming type has all the methods its quinn_proto equivalent has,
as well as an accept method to (fallibly) transition it into a
Connecting, and also refuse, retry, and ignore methods.

Furthermore, quinn::Incoming implements IntoFuture with the output type
Result<Connection, ConnectionError>>, which is the same as the Future
output type of Connecting. This lets server code which was
straightforwardly awaiting the result of quinn::Endpoint::accept work
with little to no modification.

The test accept_after_close was removed because the functionality it
was testing for no longer exists.
2024-04-03 10:02:29 +02:00
Phoenix Kahlo 83111249e8 proto: refactor Endpoint to use Incoming
This commit refactors the logic for a quinn_proto::Endpoint accepting
an incoming connection so that it constructs an explicit Incoming struct
containing all the necessary state to accept/reject/retry the
connection-creating packet. However, the external API stays the same.

The bulk of this code change is just moving around existing code.
Additionally, adds some gitignore lines I was using for coverage
testing.
2024-04-03 10:02:29 +02:00
Phoenix Kahlo a9c4dbf91e proto: Factor out Endpoint::retry 2024-04-03 10:02:29 +02:00
Phoenix Kahlo e6ee90cb2b quinn: Factor out TransmitState sub-struct from State
This commit factors out the two fields of a quinn::Endpoint's State
necessary to process a proto::Transmit into a new sub-struct,
TransmitState. This is to alleviate borrowing issues, because
proto::Transmit will soon be called from more call sites than
previously.

The bulk of this code change is just moving around existing code.

Co-authored-by: Dirkjan Ochtman <dirkjan@ochtman.nl>
2024-04-03 10:02:29 +02:00
Phoenix Kahlo 2925d2bd10 Remove concurrent_connections
Subsequent commits will allow the user to achieve the removed behavior
manually and more flexibly.

- Removes concurrent_connections from ServerConfig, as well as
  corresponding check in early_validate_first_packet.
- Adds ConnectionError::CidsExhausted error, although it is not yet
  instantiated.
- Renames ConnectError variant TooManyConnections to CidsExhausted.
- Renames proto Endpoint internal method is_full to cids_exhausted.
- Adds method open_connections to Endpoint (both proto and quinn).
- Removes Endpoint method reject_new_connection from Endpoint (both
  proto and quinn).
- Deletes obselete tests concurrent_connections_full and
  reject_new_connections.
2024-04-03 10:02:29 +02:00
Felician Nemeth f879a35a8e Use the correct MTU for prev_path
Co-Authored-By: Benjamin Saunders <ben.e.saunders@gmail.com>
2024-04-02 11:22:38 -07:00
Benjamin Saunders 4822fd456a Rate-limit stateless resets 2024-03-29 01:44:21 -07:00
Dirkjan Ochtman 56f03f1b37 Tweak comment alignment for transport parameter validation 2024-03-26 19:08:09 -07:00
Benjamin Saunders a509b4a429 Add missing transport parameter validation checks 2024-03-26 11:08:52 -07:00
Benjamin Saunders 6a1467d231 Document and tighten CID length validation 2024-03-26 10:59:06 -07:00