Skip to content

Commit a90b81e

Browse files
author
youngday
committed
crate update
1 parent 3f441f0 commit a90b81e

10 files changed

Lines changed: 1474 additions & 1546 deletions

File tree

Cargo.lock

Lines changed: 1352 additions & 1436 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "easy_example"
3-
version = "0.4.6"
3+
version = "0.4.7"
44
authors = ["youngday"]
55
edition = "2024"
66

@@ -14,62 +14,62 @@ rustls = ["dep:rustls", "proto/rustls", "proto/ring"]
1414
# Enables `Endpoint::client` and `Endpoint::server` conveniences
1515
ring = ["proto/ring"]
1616
runtime-tokio = ["tokio/time", "tokio/rt", "tokio/net"]
17-
runtime-async-std = ["async-io", "async-std"]
17+
# runtime-async-std = ["async-io", "async-std"]
1818
runtime-smol = ["async-io", "smol"]
1919

2020
# Write logs via the `log` crate when no `tracing` subscriber exists
2121
log = ["tracing/log", "proto/log", "udp/log"]
2222

2323
[dependencies]
2424
log = "0.4"
25-
log4rs = { version = "1.3", features = ["toml", "json_encoder"] }
25+
log4rs = { version = "1.4", features = ["toml", "json_encoder"] }
2626
env_logger = "0.11"
2727
pretty_env_logger ="0.5"
2828
config = "0.15"
2929
once_cell = { version = "1.21" }
30-
bytes = "1.10"
30+
bytes = "1.11"
3131
assert2 = "0.3"
3232
trybuild = "1.0"
33-
criterion = "0.7"
33+
criterion = "0.8"
3434
anyhow = "1.0"
3535

3636

3737
serde = { version = "1.0", features = ["derive"] }
3838
serde_derive = "1.0"
3939
serde_yaml = "0.9"
40-
tokio = { version = "1.47", features = ["full", "macros","tracing"] }
40+
tokio = { version = "1.48", features = ["full", "macros","tracing"] }
4141
tokio-rustls = "0.26"
4242
rustls-pemfile = "2.2"
4343
tokio-stream = { version = "0.1", features = ["net"] }
4444
tokio-util = { version = "0.7", features = ["full"] }
4545
tokio-serial = "5.4.5"
46-
reqwest = { version = "0.12", features = ["json"] }
46+
reqwest = { version = "0.13.0-rc.1", features = ["json"] }
4747
futures = { version = "0.3", default-features = false, features = ["alloc"] }
4848
futures-util = { version = "0.3", default-features = false, features = ["sink", "std"] }
4949

5050
tmq = { version = "0.5" }
5151

52-
rumqttc = "0.24"
53-
rumqttd="0.19"
52+
rumqttc = "0.25"
53+
rumqttd="0.20"
5454
base64 = "0.22"
5555

56-
ndarray = "0.16"
56+
ndarray = "0.17"
5757
rand = "0.9"
5858
rand_distr = "0.5"
5959
itertools = "0.14"
60-
csv = "1.3"
61-
image = "0.25"
60+
csv = "1.4"
61+
image = "0.25"
6262

63-
iceoryx2 ="0.6"
64-
iceoryx2-bb-container = "0.6"
63+
iceoryx2 ="0.8"
64+
iceoryx2-bb-container = "0.8"
6565

6666

6767
# network
68-
hyper = { version = "1.6", features = ["http1", "server", "client"] }
68+
hyper = { version = "1.8", features = ["http1", "server", "client"] }
6969
hyper-util = { version = "0.1", features = ["tokio"] }
7070
http-body-util = { version = "0.1" }
7171
axum = { version="0.8", features = ["ws"] }
72-
axum-extra = { version="0.10", features = ["typed-header"] }
72+
axum-extra = { version="0.12", features = ["typed-header"] }
7373

7474
poem="3.1"
7575
webpki-roots = "1.0"
@@ -86,8 +86,8 @@ tracing-subscriber = { version = "0.3", features = ["env-filter"] }
8686
fastwebsockets = { version = "0.10", features = ["upgrade"] }
8787

8888
# quiche++++++++++++++++++++++++++++++++++++++++++++
89-
async-io = { version = "2.5", optional = true }
90-
async-std = { version = "1.13.1", optional = true }
89+
async-io = { version = "2.6", optional = true }
90+
# async-std = { version = "1.13.2", optional = true }
9191
# Enables futures::io::{AsyncRead, AsyncWrite} support for streams
9292
futures-io = { version = "0.3", optional = true }
9393
rustc-hash = "2.1"
@@ -101,27 +101,26 @@ thiserror = "2.0"
101101
udp = { package = "quinn-udp", version = "0.5", default-features = false }
102102
#quiche----------------------------------------------
103103

104-
tokio-tungstenite = "0.27"
105-
tungstenite = "0.27"
104+
tokio-tungstenite = "0.28"
105+
tungstenite = "0.28"
106106

107107

108108

109109
[dev-dependencies]
110110
# quiche++++++++++++++++++++++++++++++++++++++++++++
111-
crc = "3.3"
111+
crc = "3.4"
112112
bencher = "0.1"
113113
directories-next = "2.0"
114114
rand = "0.9"
115115
rcgen = "0.14"
116116
rustls-pemfile = "2.2"
117117
clap = { version = "4.5", features = ["derive"] }
118-
# tokio = { version = "1.38", features = ["rt", "rt-multi-thread", "time", "macros", "sync"] }
119118
tracing-subscriber = { version = "0.3", default-features = false, features = ["env-filter", "fmt", "ansi", "time", "local-time"] }
120119
tracing-futures = { version = "0.2", default-features = false, features = ["std-future"] }
121120
url = "2.5"
122121
#quiche----------------------------------------------
123122

124-
web-transport-quinn="0.7.3"
123+
web-transport-quinn="0.10"
125124

126125
[build-dependencies]
127126
poem-grpc-build="0.5"
@@ -148,17 +147,17 @@ name = "zeromq_tmq"
148147
path = "examples/zeromq_tmq/zeromq_tmq.rs"
149148
# websocket
150149
[[example]]
151-
name = "ws-server"
150+
name = "ws_server"
152151
path = "examples/websocket/src/main.rs"
153152
[[example]]
154-
name = "ws-client"
153+
name = "ws_client"
155154
path = "examples/websocket/src/client.rs"
156155
# websocket transport
157156
[[example]]
158-
name = "wt-server"
157+
name = "wt_server"
159158
path = "examples/webtransport/src/echo-server.rs"
160159
[[example]]
161-
name = "wt-client"
160+
name = "wt_client"
162161
path = "examples/webtransport/src/echo-client.rs"
163162

164163
[[example]]

README.md

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
|discovery|iceoryx2 discovery| |
4040
|grpc-client,grpc-server,grpc-jsoncodec-server|poem grpc examples ,with json codec |⚠️ grpc branch |
4141
|ws_client,ws_server| | websocket |
42-
|wt-server,wt-client|webtransport|replace websocket with http3/quic|
42+
|wt_server,wt_client|webtransport|replace websocket with http3/quic|
4343
## vscode build
4444

4545
https://code.visualstudio.com/docs/languages/rust
@@ -74,7 +74,13 @@ for building proto not work on github workflow,
7474

7575
mqtt update to v5 protocol
7676

77-
run rumqttd broker first
77+
```sh
78+
cargo run --example rumqttd
79+
```
80+
pub and sub
81+
```sh
82+
cargo run --example mqtt_asyncpubsub
83+
```
7884

7985
```sh
8086
cargo run --release --example rumqttd -- -c rumqttd.toml -vvv
@@ -84,10 +90,22 @@ or ./rumqtt.sh
8490
please check examples/webtransport/src/README.md
8591
and
8692

87-
- Generate a certificate: `./cert/generate`
88-
- Run the Rust server: `cargo run --example wt-server -- --tls-cert cert/localhost.crt --tls-key cert/localhost.key`
89-
- Run the Rust client: `cargo run --example wt-client -- --tls-cert cert/localhost.crt`
90-
- Run a Web client: `cd web; npm install; npx parcel serve client.html --open`
93+
- Generate a certificate:
94+
```sh
95+
./cert/generate
96+
```
97+
- Run the Rust server:
98+
```sh
99+
cargo run --example wt_server -- --tls-cert cert/localhost.crt --tls-key cert/localhost.key
100+
```
101+
- Run the Rust client:
102+
```sh
103+
cargo run --example wt_client -- --tls-cert cert/localhost.crt
104+
```
105+
- Run a Web client:
106+
```sh
107+
cd web; npm install; npx parcel serve client.html --open
108+
```
91109

92110
## examples
93111

@@ -96,21 +114,17 @@ and
96114
ice_pub
97115
ice_sub
98116
load_csv
99-
mpsc_std
100117
mpsc_tokio
101118
mqtt_asyncpubsub
102119
post
103120
rumqttd
104121
serial-print
105-
tcp-client
106-
tcp-server
107-
udp-client
108-
udp-echo
109-
ws-client
110-
ws-server
122+
tcp_client
123+
tcp_server
124+
udp_client
125+
udp_echo
126+
ws_client
127+
ws_server
111128
zeromq_tmq
112129
zmq_pub
113130
zmq_sub
114-
115-
116-

examples/mpsc_std.rs

Lines changed: 0 additions & 59 deletions
This file was deleted.

examples/webtransport/src/echo-client.rs

Lines changed: 66 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,56 @@
1-
use std::{fs, io, path};
1+
use std::{fs, io, path, sync::Arc};
22

33
use anyhow::Context;
44
use clap::Parser;
5-
use rustls::pki_types::CertificateDer;
5+
use rustls::pki_types::{CertificateDer, ServerName, UnixTime};
6+
use rustls::{
7+
client::danger::{HandshakeSignatureValid, ServerCertVerified, ServerCertVerifier},
8+
crypto::aws_lc_rs,
9+
};
610
use url::Url;
711

12+
// Custom certificate verifier that doesn't verify certificates
13+
#[derive(Debug)]
14+
struct NoCertificateVerification;
15+
16+
impl ServerCertVerifier for NoCertificateVerification {
17+
fn verify_server_cert(
18+
&self,
19+
_end_entity: &CertificateDer,
20+
_intermediates: &[CertificateDer],
21+
_server_name: &ServerName,
22+
_ocsp_response: &[u8],
23+
_now: UnixTime,
24+
) -> Result<ServerCertVerified, rustls::Error> {
25+
// Always accept the certificate
26+
Ok(ServerCertVerified::assertion())
27+
}
28+
29+
fn verify_tls12_signature(
30+
&self,
31+
_message: &[u8],
32+
_cert: &CertificateDer,
33+
_dss: &rustls::DigitallySignedStruct,
34+
) -> Result<HandshakeSignatureValid, rustls::Error> {
35+
Ok(HandshakeSignatureValid::assertion())
36+
}
37+
38+
fn verify_tls13_signature(
39+
&self,
40+
_message: &[u8],
41+
_cert: &CertificateDer,
42+
_dss: &rustls::DigitallySignedStruct,
43+
) -> Result<HandshakeSignatureValid, rustls::Error> {
44+
Ok(HandshakeSignatureValid::assertion())
45+
}
46+
47+
fn supported_verify_schemes(&self) -> Vec<rustls::SignatureScheme> {
48+
aws_lc_rs::default_provider()
49+
.signature_verification_algorithms
50+
.supported_schemes()
51+
}
52+
}
53+
854
#[derive(Parser, Debug)]
955
#[command(author, version, about, long_about = None)]
1056
struct Args {
@@ -28,13 +74,24 @@ async fn main() -> anyhow::Result<()> {
2874

2975
let args = Args::parse();
3076

31-
let client = web_transport_quinn::ClientBuilder::new();
32-
3377
let client = if args.tls_disable_verify {
3478
log::warn!("disabling TLS certificate verification; a MITM attack is possible");
3579

36-
// Accept any certificate.
37-
unsafe { client.with_no_certificate_verification()? }
80+
// Create a custom TLS configuration that doesn't verify certificates
81+
let mut config = rustls::ClientConfig::builder_with_provider(Arc::new(
82+
rustls::crypto::aws_lc_rs::default_provider(),
83+
))
84+
.with_protocol_versions(&[&rustls::version::TLS13])?
85+
.dangerous()
86+
.with_custom_certificate_verifier(Arc::new(NoCertificateVerification))
87+
.with_no_client_auth();
88+
config.alpn_protocols = vec![web_transport_quinn::ALPN.as_bytes().to_vec()];
89+
90+
let config: quinn::crypto::rustls::QuicClientConfig = config.try_into()?;
91+
let config = quinn::ClientConfig::new(Arc::new(config));
92+
93+
let client = quinn::Endpoint::client("[::]:0".parse()?)?;
94+
web_transport_quinn::Client::new(client, config)
3895
} else if let Some(path) = &args.tls_cert {
3996
// Read the PEM certificate chain
4097
let chain = fs::File::open(path).context("failed to open cert file")?;
@@ -46,11 +103,12 @@ async fn main() -> anyhow::Result<()> {
46103

47104
anyhow::ensure!(!chain.is_empty(), "could not find certificate");
48105

49-
// Only accept these certificates.
50-
// Also available: with_server_certificate_hashes
106+
// Create a client builder with custom certificates
107+
let client = web_transport_quinn::ClientBuilder::new();
51108
client.with_server_certificates(chain)?
52109
} else {
53110
// Accept any certificate that matches a system root.
111+
let client = web_transport_quinn::ClientBuilder::new();
54112
client.with_system_roots()?
55113
};
56114

0 commit comments

Comments
 (0)