Skip to content

Commit 5438b66

Browse files
authored
Merge pull request #3 from stackabletech/feature/grpc-uds-/v0.3.26
grpc-uds: update to h2 v0.3.26
2 parents 557dd10 + 4e77adb commit 5438b66

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1302
-272
lines changed

.github/FUNDING.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
github: seanmonstar

.github/workflows/CI.yml

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
runs-on: ubuntu-latest
1414
steps:
1515
- name: Checkout
16-
uses: actions/checkout@v3
16+
uses: actions/checkout@v4
1717

1818
- name: Install Rust
1919
uses: dtolnay/rust-toolchain@stable
@@ -31,12 +31,11 @@ jobs:
3131
strategy:
3232
matrix:
3333
rust:
34-
- nightly
3534
- beta
3635
- stable
3736
steps:
3837
- name: Checkout
39-
uses: actions/checkout@v3
38+
uses: actions/checkout@v4
4039

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

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

6870
msrv:
6971
name: Check MSRV
@@ -73,17 +75,27 @@ jobs:
7375

7476
steps:
7577
- name: Checkout
76-
uses: actions/checkout@v3
78+
uses: actions/checkout@v4
7779

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

8484
- name: Install Rust (${{ steps.metadata.outputs.msrv }})
85+
id: msrv-toolchain
8586
uses: dtolnay/rust-toolchain@master
8687
with:
87-
toolchain: ${{ steps.metadata.outputs.msrv }}
88+
toolchain: ${{ steps.msrv.outputs.version }}
8889

89-
- run: cargo check
90+
- run: cargo check -p h2
91+
92+
minimal-versions:
93+
runs-on: ubuntu-latest
94+
needs: [style]
95+
steps:
96+
- uses: actions/checkout@v4
97+
- uses: dtolnay/rust-toolchain@nightly
98+
- uses: dtolnay/rust-toolchain@stable
99+
- uses: taiki-e/install-action@cargo-hack
100+
- uses: taiki-e/install-action@cargo-minimal-versions
101+
- run: cargo minimal-versions --ignore-private check

CHANGELOG.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,42 @@
1+
# 0.3.26 (April 3, 2024)
2+
3+
* Limit number of CONTINUATION frames for misbehaving connections.
4+
5+
# 0.3.25 (March 15, 2024)
6+
7+
* Improve performance decoding many headers.
8+
9+
# 0.3.24 (January 17, 2024)
10+
11+
* Limit error resets for misbehaving connections.
12+
13+
# 0.3.23 (January 10, 2024)
14+
15+
* Backport fix from 0.4.1 for stream capacity assignment.
16+
17+
# 0.3.22 (November 15, 2023)
18+
19+
* Add `header_table_size(usize)` option to client and server builders.
20+
* Improve throughput when vectored IO is not available.
21+
* Update indexmap to 2.
22+
23+
# 0.3.21 (August 21, 2023)
24+
25+
* Fix opening of new streams over peer's max concurrent limit.
26+
* Fix `RecvStream` to return data even if it has received a `CANCEL` stream error.
27+
* Update MSRV to 1.63.
28+
29+
# 0.3.20 (June 26, 2023)
30+
31+
* Fix panic if a server received a request with a `:status` pseudo header in the 1xx range.
32+
* Fix panic if a reset stream had pending push promises that were more than allowed.
33+
* Fix potential flow control overflow by subtraction, instead returning a connection error.
34+
35+
# 0.3.19 (May 12, 2023)
36+
37+
* Fix counting reset streams when triggered by a GOAWAY.
38+
* Send `too_many_resets` in opaque debug data of GOAWAY when too many resets received.
39+
140
# 0.3.18 (April 17, 2023)
241

342
* Fix panic because of opposite check in `is_remote_local()`.

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
## Getting Help ##
66

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

1010
## Submitting a Pull Request ##
1111

@@ -15,7 +15,7 @@ Do you have an improvement?
1515
2. We will try to respond to your issue promptly.
1616
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.
1717
4. Submit a pull request against this repo's `master` branch.
18-
6. Your branch may be merged once all configured checks pass, including:
18+
5. Your branch may be merged once all configured checks pass, including:
1919
- Code review has been completed.
2020
- The branch has passed tests in CI.
2121

Cargo.toml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ name = "h2"
55
# - html_root_url.
66
# - Update CHANGELOG.md.
77
# - Create git tag
8-
version = "0.3.18"
8+
version = "0.3.26"
99
license = "MIT"
1010
authors = [
1111
"Carl Lerche <[email protected]>",
@@ -19,7 +19,7 @@ keywords = ["http", "async", "non-blocking"]
1919
categories = ["asynchronous", "web-programming", "network-programming"]
2020
exclude = ["fixtures/**", "ci/**"]
2121
edition = "2018"
22-
rust-version = "1.56"
22+
rust-version = "1.63"
2323

2424
[features]
2525
# Enables `futures::Stream` implementations for various types.
@@ -44,14 +44,14 @@ members = [
4444
futures-core = { version = "0.3", default-features = false }
4545
futures-sink = { version = "0.3", default-features = false }
4646
futures-util = { version = "0.3", default-features = false }
47-
tokio-util = { version = "0.7.1", features = ["codec"] }
47+
tokio-util = { version = "0.7.1", features = ["codec", "io"] }
4848
tokio = { version = "1", features = ["io-util"] }
4949
bytes = "1"
5050
http = "0.2"
51-
tracing = { version = "0.1.21", default-features = false, features = ["std"] }
51+
tracing = { version = "0.1.35", default-features = false, features = ["std"] }
5252
fnv = "1.0.5"
5353
slab = "0.4.2"
54-
indexmap = { version = "1.5.2", features = ["std"] }
54+
indexmap = { version = "2", features = ["std"] }
5555

5656
[dev-dependencies]
5757

@@ -67,9 +67,9 @@ serde_json = "1.0.0"
6767

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

7474
[package.metadata.docs.rs]
7575
features = ["stream"]

examples/akamai.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub async fn main() -> Result<(), Box<dyn Error>> {
1717

1818
let tls_client_config = std::sync::Arc::new({
1919
let mut root_store = RootCertStore::empty();
20-
root_store.add_server_trust_anchors(webpki_roots::TLS_SERVER_ROOTS.0.iter().map(|ta| {
20+
root_store.add_trust_anchors(webpki_roots::TLS_SERVER_ROOTS.iter().map(|ta| {
2121
OwnedTrustAnchor::from_subject_spki_name_constraints(
2222
ta.subject,
2323
ta.spki,

src/client.rs

Lines changed: 65 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,12 @@ pub struct Builder {
336336
/// The stream ID of the first (lowest) stream. Subsequent streams will use
337337
/// monotonically increasing stream IDs.
338338
stream_id: StreamId,
339+
340+
/// Maximum number of locally reset streams due to protocol error across
341+
/// the lifetime of the connection.
342+
///
343+
/// When this gets exceeded, we issue GOAWAYs.
344+
local_max_error_reset_streams: Option<usize>,
339345
}
340346

341347
#[derive(Debug)]
@@ -510,8 +516,10 @@ where
510516
self.inner
511517
.send_request(request, end_of_stream, self.pending.as_ref())
512518
.map_err(Into::into)
513-
.map(|stream| {
514-
if stream.is_pending_open() {
519+
.map(|(stream, is_full)| {
520+
if stream.is_pending_open() && is_full {
521+
// Only prevent sending another request when the request queue
522+
// is not full.
515523
self.pending = Some(stream.clone_to_opaque());
516524
}
517525

@@ -643,6 +651,7 @@ impl Builder {
643651
initial_max_send_streams: usize::MAX,
644652
settings: Default::default(),
645653
stream_id: 1.into(),
654+
local_max_error_reset_streams: Some(proto::DEFAULT_LOCAL_RESET_COUNT_MAX),
646655
}
647656
}
648657

@@ -971,6 +980,23 @@ impl Builder {
971980
self
972981
}
973982

983+
/// Sets the maximum number of local resets due to protocol errors made by the remote end.
984+
///
985+
/// Invalid frames and many other protocol errors will lead to resets being generated for those streams.
986+
/// Too many of these often indicate a malicious client, and there are attacks which can abuse this to DOS servers.
987+
/// This limit protects against these DOS attacks by limiting the amount of resets we can be forced to generate.
988+
///
989+
/// When the number of local resets exceeds this threshold, the client will close the connection.
990+
///
991+
/// If you really want to disable this, supply [`Option::None`] here.
992+
/// Disabling this is not recommended and may expose you to DOS attacks.
993+
///
994+
/// The default value is currently 1024, but could change.
995+
pub fn max_local_error_reset_streams(&mut self, max: Option<usize>) -> &mut Self {
996+
self.local_max_error_reset_streams = max;
997+
self
998+
}
999+
9741000
/// Sets the maximum number of pending-accept remotely-reset streams.
9751001
///
9761002
/// Streams that have been received by the peer, but not accepted by the
@@ -1021,7 +1047,7 @@ impl Builder {
10211047
/// stream have been written to the connection, the send buffer capacity
10221048
/// will be freed up again.
10231049
///
1024-
/// The default is currently ~400MB, but may change.
1050+
/// The default is currently ~400KB, but may change.
10251051
///
10261052
/// # Panics
10271053
///
@@ -1070,6 +1096,39 @@ impl Builder {
10701096
self
10711097
}
10721098

1099+
/// Sets the header table size.
1100+
///
1101+
/// This setting informs the peer of the maximum size of the header compression
1102+
/// table used to encode header blocks, in octets. The encoder may select any value
1103+
/// equal to or less than the header table size specified by the sender.
1104+
///
1105+
/// The default value is 4,096.
1106+
///
1107+
/// # Examples
1108+
///
1109+
/// ```
1110+
/// # use tokio::io::{AsyncRead, AsyncWrite};
1111+
/// # use h2::client::*;
1112+
/// # use bytes::Bytes;
1113+
/// #
1114+
/// # async fn doc<T: AsyncRead + AsyncWrite + Unpin>(my_io: T)
1115+
/// # -> Result<((SendRequest<Bytes>, Connection<T, Bytes>)), h2::Error>
1116+
/// # {
1117+
/// // `client_fut` is a future representing the completion of the HTTP/2
1118+
/// // handshake.
1119+
/// let client_fut = Builder::new()
1120+
/// .header_table_size(1_000_000)
1121+
/// .handshake(my_io);
1122+
/// # client_fut.await
1123+
/// # }
1124+
/// #
1125+
/// # pub fn main() {}
1126+
/// ```
1127+
pub fn header_table_size(&mut self, size: u32) -> &mut Self {
1128+
self.settings.set_header_table_size(Some(size));
1129+
self
1130+
}
1131+
10731132
/// Sets the first stream ID to something other than 1.
10741133
#[cfg(feature = "unstable")]
10751134
pub fn initial_stream_id(&mut self, stream_id: u32) -> &mut Self {
@@ -1258,6 +1317,7 @@ where
12581317
reset_stream_duration: builder.reset_stream_duration,
12591318
reset_stream_max: builder.reset_stream_max,
12601319
remote_reset_stream_max: builder.pending_accept_reset_stream_max,
1320+
local_error_reset_streams_max: builder.local_max_error_reset_streams,
12611321
settings: builder.settings.clone(),
12621322
},
12631323
);
@@ -1571,9 +1631,11 @@ impl proto::Peer for Peer {
15711631
proto::DynPeer::Client
15721632
}
15731633

1634+
/*
15741635
fn is_server() -> bool {
15751636
false
15761637
}
1638+
*/
15771639

15781640
fn convert_poll_message(
15791641
pseudo: Pseudo,

0 commit comments

Comments
 (0)