Skip to content

grpc-uds: update to h2 v0.3.26 #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 44 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
072f7ee
Serialize debug_data when present in GOAWAY frames
Herbstein Apr 14, 2023
b0e5470
Fix markdown code element in error::is_library
foresterre Apr 27, 2023
70eade5
Add too_many_resets debug_data to the GOAWAY we send (#678)
Herbstein Apr 28, 2023
7a77f93
Rename is_local_reset to is_local_error
nox May 10, 2023
3d558a6
Ignore Error::GoAway in State::is_remote_reset
nox May 10, 2023
f126229
v0.3.19
seanmonstar May 12, 2023
04e6398
fix: panicked when a reset stream would decrement twice
seanmonstar May 23, 2023
66c36c4
fix panic on receiving invalid headers frame by making the `take_requ…
May 23, 2023
97bc3e3
hammer test requires a new tokio feature
Jun 8, 2023
972fb6f
chore: add funding file
seanmonstar Jun 12, 2023
864430c
Enabled clippy in CI and ran `clippy --fix`
Jun 9, 2023
478f7b9
Fix for invalid header panic corrected (#695)
f0rki Jun 22, 2023
0189722
Fix for a fuzzer-discovered integer underflow of the flow control win…
f0rki Jun 26, 2023
6a75f23
v0.3.20
seanmonstar Jun 26, 2023
46fb80b
test: early server response with data (#703)
DDtKey Jul 22, 2023
633116e
fix: do not ignore result of `ensure_recv_open` (#687)
DDtKey Jul 24, 2023
cdcc641
msrv: bump to 1.63 (#708)
seanmonstar Aug 21, 2023
da9f34b
chore: fix up some clippy nags (#709)
seanmonstar Aug 21, 2023
9bd62a2
Test that client reacts correctly on rogue HEADERS (#667)
nox Aug 21, 2023
ee04292
Fix opening new streams over max concurrent (#707)
seanmonstar Aug 21, 2023
da38b1c
v0.3.21
seanmonstar Aug 21, 2023
62cf7a6
Check minimal versions more precisely
tottoto Sep 16, 2023
a3f01c1
perf: Improve throughput when vectored IO is not enabled (#712)
xiaoyawei Sep 28, 2023
1f247de
Update indexmap to version 2 (#698)
djc Oct 9, 2023
cbe7744
chore(ci): update to actions/checkout@v4 (#716)
tottoto Oct 16, 2023
05cf352
chore(ci): add minimal versions checking on stable rust
tottoto Oct 16, 2023
3cdef96
fix(test): mark h2-support as private crate
tottoto Oct 16, 2023
d03c54a
chore(dependencies): update tracing minimal version to 0.1.35
tottoto Oct 16, 2023
4aa7b16
Fix documentation for max_send_buffer_size (#718)
Protryon Oct 18, 2023
56651e6
fix lint about unused import
seanmonstar Oct 30, 2023
ef743ec
Add a setter for header_table_size (#638)
4JX Oct 30, 2023
c7ca62f
docs: fix typos (#724)
vuittont60 Nov 7, 2023
0f412d8
v0.3.22
seanmonstar Nov 15, 2023
b668c7f
fix: streams awaiting capacity lockout (#730) (#734)
seanmonstar Jan 10, 2024
a7eb14a
v0.3.23
seanmonstar Jan 10, 2024
d919cd6
streams: limit error resets for misbehaving connections
Noah-Kennedy Jan 10, 2024
7243ab5
Prepare v0.3.24
Noah-Kennedy Jan 17, 2024
94e80b1
perf: optimize header list size calculations (#750)
Noah-Kennedy Feb 22, 2024
3a79832
v0.3.25
seanmonstar Mar 15, 2024
5b6c9e0
refactor: cleanup new unused warnings (#757)
seanmonstar Apr 2, 2024
1a357aa
fix: limit number of CONTINUATION frames allowed
seanmonstar Apr 3, 2024
357127e
v0.3.26
seanmonstar Apr 3, 2024
19ec427
Merge tag 'v0.3.26' into feature/grpc-uds
nightkr May 8, 2024
4e77adb
Update tests to account for grpc-uds patch
nightkr May 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github: seanmonstar
38 changes: 25 additions & 13 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install Rust
uses: dtolnay/rust-toolchain@stable
Expand All @@ -31,12 +31,11 @@ jobs:
strategy:
matrix:
rust:
- nightly
- beta
- stable
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install Rust (${{ matrix.rust }})
uses: dtolnay/rust-toolchain@master
Expand All @@ -61,9 +60,12 @@ jobs:
run: ./ci/h2spec.sh
if: matrix.rust == 'stable'

- name: Check minimal versions
run: cargo clean; cargo update -Zminimal-versions; cargo check
if: matrix.rust == 'nightly'
#clippy_check:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - name: Run Clippy
# run: cargo clippy --all-targets --all-features

msrv:
name: Check MSRV
Expand All @@ -73,17 +75,27 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Get MSRV from package metadata
id: metadata
run: |
cargo metadata --no-deps --format-version 1 |
jq -r '"msrv=" + (.packages[] | select(.name == "h2")).rust_version' >> $GITHUB_OUTPUT
id: msrv
run: grep rust-version Cargo.toml | cut -d '"' -f2 | sed 's/^/version=/' >> $GITHUB_OUTPUT

- name: Install Rust (${{ steps.metadata.outputs.msrv }})
id: msrv-toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ steps.metadata.outputs.msrv }}
toolchain: ${{ steps.msrv.outputs.version }}

- run: cargo check
- run: cargo check -p h2

minimal-versions:
runs-on: ubuntu-latest
needs: [style]
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
- uses: dtolnay/rust-toolchain@stable
- uses: taiki-e/install-action@cargo-hack
- uses: taiki-e/install-action@cargo-minimal-versions
- run: cargo minimal-versions --ignore-private check
39 changes: 39 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,42 @@
# 0.3.26 (April 3, 2024)

* Limit number of CONTINUATION frames for misbehaving connections.

# 0.3.25 (March 15, 2024)

* Improve performance decoding many headers.

# 0.3.24 (January 17, 2024)

* Limit error resets for misbehaving connections.

# 0.3.23 (January 10, 2024)

* Backport fix from 0.4.1 for stream capacity assignment.

# 0.3.22 (November 15, 2023)

* Add `header_table_size(usize)` option to client and server builders.
* Improve throughput when vectored IO is not available.
* Update indexmap to 2.

# 0.3.21 (August 21, 2023)

* Fix opening of new streams over peer's max concurrent limit.
* Fix `RecvStream` to return data even if it has received a `CANCEL` stream error.
* Update MSRV to 1.63.

# 0.3.20 (June 26, 2023)

* Fix panic if a server received a request with a `:status` pseudo header in the 1xx range.
* Fix panic if a reset stream had pending push promises that were more than allowed.
* Fix potential flow control overflow by subtraction, instead returning a connection error.

# 0.3.19 (May 12, 2023)

* Fix counting reset streams when triggered by a GOAWAY.
* Send `too_many_resets` in opaque debug data of GOAWAY when too many resets received.

# 0.3.18 (April 17, 2023)

* Fix panic because of opposite check in `is_remote_local()`.
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
## Getting Help ##

If you have a question about the h2 library or have encountered problems using it, you may
[file an issue][issue] or ask ask a question on the [Tokio Gitter][gitter].
[file an issue][issue] or ask a question on the [Tokio Gitter][gitter].

## Submitting a Pull Request ##

Expand All @@ -15,7 +15,7 @@ Do you have an improvement?
2. We will try to respond to your issue promptly.
3. Fork this repo, develop and test your code changes. See the project's [README](README.md) for further information about working in this repository.
4. Submit a pull request against this repo's `master` branch.
6. Your branch may be merged once all configured checks pass, including:
5. Your branch may be merged once all configured checks pass, including:
- Code review has been completed.
- The branch has passed tests in CI.

Expand Down
16 changes: 8 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ name = "h2"
# - html_root_url.
# - Update CHANGELOG.md.
# - Create git tag
version = "0.3.18"
version = "0.3.26"
license = "MIT"
authors = [
"Carl Lerche <[email protected]>",
Expand All @@ -19,7 +19,7 @@ keywords = ["http", "async", "non-blocking"]
categories = ["asynchronous", "web-programming", "network-programming"]
exclude = ["fixtures/**", "ci/**"]
edition = "2018"
rust-version = "1.56"
rust-version = "1.63"

[features]
# Enables `futures::Stream` implementations for various types.
Expand All @@ -44,14 +44,14 @@ members = [
futures-core = { version = "0.3", default-features = false }
futures-sink = { version = "0.3", default-features = false }
futures-util = { version = "0.3", default-features = false }
tokio-util = { version = "0.7.1", features = ["codec"] }
tokio-util = { version = "0.7.1", features = ["codec", "io"] }
tokio = { version = "1", features = ["io-util"] }
bytes = "1"
http = "0.2"
tracing = { version = "0.1.21", default-features = false, features = ["std"] }
tracing = { version = "0.1.35", default-features = false, features = ["std"] }
fnv = "1.0.5"
slab = "0.4.2"
indexmap = { version = "1.5.2", features = ["std"] }
indexmap = { version = "2", features = ["std"] }

[dev-dependencies]

Expand All @@ -67,9 +67,9 @@ serde_json = "1.0.0"

# Examples
tokio = { version = "1", features = ["rt-multi-thread", "macros", "sync", "net"] }
env_logger = { version = "0.9", default-features = false }
tokio-rustls = "0.23.2"
webpki-roots = "0.22.2"
env_logger = { version = "0.10", default-features = false }
tokio-rustls = "0.24"
webpki-roots = "0.25"

[package.metadata.docs.rs]
features = ["stream"]
2 changes: 1 addition & 1 deletion examples/akamai.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub async fn main() -> Result<(), Box<dyn Error>> {

let tls_client_config = std::sync::Arc::new({
let mut root_store = RootCertStore::empty();
root_store.add_server_trust_anchors(webpki_roots::TLS_SERVER_ROOTS.0.iter().map(|ta| {
root_store.add_trust_anchors(webpki_roots::TLS_SERVER_ROOTS.iter().map(|ta| {
OwnedTrustAnchor::from_subject_spki_name_constraints(
ta.subject,
ta.spki,
Expand Down
68 changes: 65 additions & 3 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,12 @@ pub struct Builder {
/// The stream ID of the first (lowest) stream. Subsequent streams will use
/// monotonically increasing stream IDs.
stream_id: StreamId,

/// Maximum number of locally reset streams due to protocol error across
/// the lifetime of the connection.
///
/// When this gets exceeded, we issue GOAWAYs.
local_max_error_reset_streams: Option<usize>,
}

#[derive(Debug)]
Expand Down Expand Up @@ -510,8 +516,10 @@ where
self.inner
.send_request(request, end_of_stream, self.pending.as_ref())
.map_err(Into::into)
.map(|stream| {
if stream.is_pending_open() {
.map(|(stream, is_full)| {
if stream.is_pending_open() && is_full {
// Only prevent sending another request when the request queue
// is not full.
self.pending = Some(stream.clone_to_opaque());
}

Expand Down Expand Up @@ -643,6 +651,7 @@ impl Builder {
initial_max_send_streams: usize::MAX,
settings: Default::default(),
stream_id: 1.into(),
local_max_error_reset_streams: Some(proto::DEFAULT_LOCAL_RESET_COUNT_MAX),
}
}

Expand Down Expand Up @@ -971,6 +980,23 @@ impl Builder {
self
}

/// Sets the maximum number of local resets due to protocol errors made by the remote end.
///
/// Invalid frames and many other protocol errors will lead to resets being generated for those streams.
/// Too many of these often indicate a malicious client, and there are attacks which can abuse this to DOS servers.
/// This limit protects against these DOS attacks by limiting the amount of resets we can be forced to generate.
///
/// When the number of local resets exceeds this threshold, the client will close the connection.
///
/// If you really want to disable this, supply [`Option::None`] here.
/// Disabling this is not recommended and may expose you to DOS attacks.
///
/// The default value is currently 1024, but could change.
pub fn max_local_error_reset_streams(&mut self, max: Option<usize>) -> &mut Self {
self.local_max_error_reset_streams = max;
self
}

/// Sets the maximum number of pending-accept remotely-reset streams.
///
/// Streams that have been received by the peer, but not accepted by the
Expand Down Expand Up @@ -1021,7 +1047,7 @@ impl Builder {
/// stream have been written to the connection, the send buffer capacity
/// will be freed up again.
///
/// The default is currently ~400MB, but may change.
/// The default is currently ~400KB, but may change.
///
/// # Panics
///
Expand Down Expand Up @@ -1070,6 +1096,39 @@ impl Builder {
self
}

/// Sets the header table size.
///
/// This setting informs the peer of the maximum size of the header compression
/// table used to encode header blocks, in octets. The encoder may select any value
/// equal to or less than the header table size specified by the sender.
///
/// The default value is 4,096.
///
/// # Examples
///
/// ```
/// # use tokio::io::{AsyncRead, AsyncWrite};
/// # use h2::client::*;
/// # use bytes::Bytes;
/// #
/// # async fn doc<T: AsyncRead + AsyncWrite + Unpin>(my_io: T)
/// # -> Result<((SendRequest<Bytes>, Connection<T, Bytes>)), h2::Error>
/// # {
/// // `client_fut` is a future representing the completion of the HTTP/2
/// // handshake.
/// let client_fut = Builder::new()
/// .header_table_size(1_000_000)
/// .handshake(my_io);
/// # client_fut.await
/// # }
/// #
/// # pub fn main() {}
/// ```
pub fn header_table_size(&mut self, size: u32) -> &mut Self {
self.settings.set_header_table_size(Some(size));
self
}

/// Sets the first stream ID to something other than 1.
#[cfg(feature = "unstable")]
pub fn initial_stream_id(&mut self, stream_id: u32) -> &mut Self {
Expand Down Expand Up @@ -1258,6 +1317,7 @@ where
reset_stream_duration: builder.reset_stream_duration,
reset_stream_max: builder.reset_stream_max,
remote_reset_stream_max: builder.pending_accept_reset_stream_max,
local_error_reset_streams_max: builder.local_max_error_reset_streams,
settings: builder.settings.clone(),
},
);
Expand Down Expand Up @@ -1571,9 +1631,11 @@ impl proto::Peer for Peer {
proto::DynPeer::Client
}

/*
fn is_server() -> bool {
false
}
*/

fn convert_poll_message(
pseudo: Pseudo,
Expand Down
Loading