Commit Graph

73 Commits

Author SHA1 Message Date
Dirkjan Ochtman 7b97a3fbd8 Apply clippy suggestions from Rust 1.79 2024-06-13 10:59:05 -07:00
Benjamin Saunders b42e21e74d Make SendStream::finish synchronous
`await`ing on this was error-prone and not very useful, since it gave
little insight into application state, and was redundant to `stopped`.
2024-05-03 11:52:44 -07: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 a85a4c12ee Update rustls to 0.23 and ring to 0.17 2024-04-22 09:45:53 +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 597b10b2d5 Fix parsing of IPV6 URLs in client example
Currently, when trying to run the client example with an IPV6 address
URL, such as by running:

    cargo run --example client https://[::1]:4433/Cargo.toml --host localhost

A "failed to lookup address information: Name or service not known"
error is raised. This is because `url.host_str()` is `"[::1]"`, which
is wrapped in brackets. These brackets, specified by by RFC 2732, are
part of the URL syntax, not the IP address syntax.

Although this code succeeds, because the standard library treats this
like a URL:

    use std::net::ToSocketAddrs;
    "[::1]:4433".to_socket_addrs()

This code does not:

    use std::net::Ipv6Addr;
    "[::1]".parse::<Ipv6Addr>()

As the stdlib expects to just receive "::1". Consequentially, this
does not succeed, counterintuitively:

    use std::net::ToSocketAddrs;
    ("[::1]", 4433).to_socket_addrs()

This code fixes the client example's URL parsing behavior by
stripping out such brackets in the same way as [is done in
tokio-tungstenite][1].

[1]: https://github.com/snapview/tokio-tungstenite/blob/052d085aff4708b924b92becaa83923b15045841/src/lib.rs#L404
2024-01-20 18:15:03 -08:00
Benjamin Saunders 044eab53ff Update clap 2023-05-11 14:10:19 +02:00
Benjamin Saunders 092a7686a4 Enable PMTUD by default when appropriate 2023-05-06 08:05:17 +02:00
Adolfo Ochagavía 2d48482180 Use PLPMTUD in bench, perf and examples
Sponsored by Stormshield
2023-04-04 17:40:20 -07:00
Benjamin Saunders 90a99193a9 Borrow self in read_to_end, rather than consuming
Allows `RecvStream::stop` to be called with custom error codes if
`ReadToEndError::TooLong` is encountered.
2023-03-05 08:52:31 +01:00
Dirkjan Ochtman f7354ef6ac Inline format arguments 2023-02-27 07:34:35 +01:00
Dirkjan Ochtman 2c6aa43610 Apply clippy suggestions from Rust 1.66 2022-12-19 10:13:01 -08:00
Benjamin Saunders 6e4bcbb2fc Drop NewConnection in favor of simpler API 2022-09-27 11:08:26 +02:00
Benjamin Saunders fe93a68108 Replace structopt with its successor, clap 3 2022-07-03 21:02:33 +02:00
Benjamin Saunders 1159ae3c65 Non-exhaustive ClientConfig 2021-11-10 11:25:19 +01:00
Benjamin Saunders b923c4c8b0 Pass SocketAddr by value
We always consume this by value in the end, and it's a little more
ergonomic.
2021-10-29 20:12:45 +02:00
Benjamin Saunders 5d1b6a101b Remove EndpointBuilder
Now that rustls configuration is more straightforward, this is not
adding significant value.
2021-10-29 20:12:45 +02:00
Benjamin Saunders 34ca6cff61 Privatize crypto config helpers
We're now sufficiently compatible with rustls defaults that these
aren't worth the API surface area.
2021-10-29 08:02:13 +02:00
Benjamin Saunders 4927355049 Remove config builders
These aren't significantly more convenient than working with rustls
directly at this point.
2021-10-27 17:49:48 -07:00
Dirkjan Ochtman a7efd92044 Require explicit construction of ClientConfigs 2021-09-29 10:12:44 -07:00
Dirkjan Ochtman d78b3187a9 Apply clippy suggestions from Rust 1.54 2021-07-30 13:29:32 -07:00
Benjamin Saunders 612c9ac2b8 Remove unnecessary dropping in client/server examples 2021-01-26 06:46:32 +01:00
Benjamin Saunders 03de1d0374 Ensure graceful close in client example 2021-01-26 06:46:32 +01:00
Dirkjan Ochtman 4420b61aaa quinn: print socket addresses in example client/server 2020-12-11 16:17:48 -08:00
Timon 83cff80908 Create example README (#910) 2020-11-15 21:43:28 +01:00
Dirkjan Ochtman 5484d37c76 Migrate to directories-next
directories is no longer being maintained and the final released version
causes a dependency conflict (cfg-if, versus tracing).
2020-06-22 14:46:13 +02:00
Benjamin Saunders 5774071b48 Spawn driver tasks implicitly 2020-01-13 09:54:26 +01:00
Dirkjan Ochtman 102f537d40 Fix remaining lints 2019-12-22 14:28:02 -08:00
daxpedda 7233455078 Update tokio, futures and bytes. (#528) 2019-12-02 10:42:05 +01:00
Benjamin Saunders f48aa59512 Document a NewConnection footgun and the meaning of server_name
Non-obvious details identified in the course of assisting a new user.
2019-11-29 22:14:16 +01:00
Benjamin Saunders 4902bfe6ba Use anyhow instead of failure in examples
Anyhow was already in our depgraph and is more modern and actively
maintained.
2019-11-19 11:46:43 -08:00
Timon Post ac810125c1 merge imports 2019-11-19 08:23:35 +01:00
Benjamin Saunders a957bf4aa2 Replace slog with tracing 2019-10-29 10:36:50 +01:00
Benjamin Saunders 8e1c6b605e Remove ToSocketAddrs from EndpointBuilder::bind
Improves consistency with Endpoint::connect and removes the
possibility of silent blocking should the user pass in a domain
name. The generic API was originally motivated by the convenience of
passing in numeric addresses as strings, but `.parse().unwrap()` is
pretty easy too.
2019-09-29 07:21:06 +02:00
Benjamin Saunders d07dc907ad Update for async/await 2019-09-28 10:23:26 +02:00
Benjamin Saunders f50dd9f54a Restore NewConnection struct for parts of a connection
This enables forwards-compatibility with future extensions such as
a datagram stream.
2019-08-25 14:50:01 -07:00
Dirkjan Ochtman 01b9d212be Upgrade to url 2 2019-07-24 21:29:48 +02:00
Benjamin Saunders e7929713cd Handle unclear interop ALPN 2019-07-11 20:52:19 +02:00
Benjamin Saunders 5fbe96f46a Public VarInt type
Ensures correctness of application error codes without panics or
adding new internal failure paths.
2019-07-11 20:52:19 +02:00
Benjamin Saunders b502306ab3 Refactor ReadToEnd helper to work after reads 2019-07-05 08:35:26 +02:00
Benjamin Saunders 747d5a263b Colorful logging in examples 2019-06-24 19:31:38 +02:00
Dirkjan Ochtman 7b507d82b1 Move ALPN_QUIC_HTTP from library to examples/interop code 2019-06-20 12:30:02 -07:00
Benjamin Saunders dcaa80c170 Define helper future for finishing streams
More convenient than the tokio::io shutdown helper, and preserves
specific error information.
2019-04-27 20:57:19 +02:00
Benjamin Saunders 9eea392e35 Restrict read_to_end to unread streams 2019-04-25 06:46:09 +02:00
Benjamin Saunders 8966c7e2d1 Don't yield stream from ReadToEnd
This was left over from before bidirectional streams were decoupled.
2019-04-25 06:46:09 +02:00
Dirkjan Ochtman 734978e59e Rename quinn::Endpoint::new() to builder() 2019-04-16 17:55:13 -07:00
Dirkjan Ochtman 16e4b96f4b Simplify high-level streams API 2019-04-12 19:59:23 +02:00
Benjamin Saunders 6ec3b021cb Move ClientConfig into quinn-proto 2019-04-08 07:12:21 +02:00
Benjamin Saunders 6b15147891 Graceful close in HTTP/0.9 client example 2019-04-07 00:34:15 -07:00
Dirkjan Ochtman aae9edecd4 Return new connections as tuples 2019-04-01 10:56:38 +02:00