aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/client.rs4
-rw-r--r--examples/http3-client.rs4
-rw-r--r--examples/http3-server.rs11
-rw-r--r--examples/server.rs11
4 files changed, 18 insertions, 12 deletions
diff --git a/examples/client.rs b/examples/client.rs
index b019322b..28655980 100644
--- a/examples/client.rs
+++ b/examples/client.rs
@@ -101,10 +101,10 @@ fn main() {
config.set_disable_active_migration(true);
// Generate a random source connection ID for the connection.
- let mut scid = vec![0; quiche::MAX_CONN_ID_LEN];
+ let mut scid = [0; quiche::MAX_CONN_ID_LEN];
SystemRandom::new().fill(&mut scid[..]).unwrap();
- let scid = quiche::ConnectionId::from_vec(scid);
+ let scid = quiche::ConnectionId::from_ref(&scid);
// Create a QUIC connection and initiate handshake.
let mut conn = quiche::connect(url.domain(), &scid, &mut config).unwrap();
diff --git a/examples/http3-client.rs b/examples/http3-client.rs
index abd504cc..bb770100 100644
--- a/examples/http3-client.rs
+++ b/examples/http3-client.rs
@@ -102,10 +102,10 @@ fn main() {
let mut http3_conn = None;
// Generate a random source connection ID for the connection.
- let mut scid = vec![0; quiche::MAX_CONN_ID_LEN];
+ let mut scid = [0; quiche::MAX_CONN_ID_LEN];
SystemRandom::new().fill(&mut scid[..]).unwrap();
- let scid = quiche::ConnectionId::from_vec(scid);
+ let scid = quiche::ConnectionId::from_ref(&scid);
// Create a QUIC connection and initiate handshake.
let mut conn = quiche::connect(url.domain(), &scid, &mut config).unwrap();
diff --git a/examples/http3-server.rs b/examples/http3-server.rs
index 23e8eedc..cf8b7387 100644
--- a/examples/http3-server.rs
+++ b/examples/http3-server.rs
@@ -214,6 +214,8 @@ fn main() {
let mut scid = [0; quiche::MAX_CONN_ID_LEN];
scid.copy_from_slice(&conn_id);
+ let scid = quiche::ConnectionId::from_ref(&scid);
+
// Token is always present in Initial packets.
let token = hdr.token.as_ref().unwrap();
@@ -250,7 +252,7 @@ fn main() {
// The token was not valid, meaning the retry failed, so
// drop the packet.
- if odcid == None {
+ if odcid.is_none() {
error!("Invalid address validation token");
continue 'read;
}
@@ -266,7 +268,8 @@ fn main() {
debug!("New connection: dcid={:?} scid={:?}", hdr.dcid, scid);
- let conn = quiche::accept(&scid, odcid, &mut config).unwrap();
+ let conn =
+ quiche::accept(&scid, odcid.as_ref(), &mut config).unwrap();
let client = Client {
conn,
@@ -463,7 +466,7 @@ fn mint_token(hdr: &quiche::Header, src: &net::SocketAddr) -> Vec<u8> {
/// authenticate of the token. *It should not be used in production system*.
fn validate_token<'a>(
src: &net::SocketAddr, token: &'a [u8],
-) -> Option<&'a [u8]> {
+) -> Option<quiche::ConnectionId<'a>> {
if token.len() < 6 {
return None;
}
@@ -485,7 +488,7 @@ fn validate_token<'a>(
let token = &token[addr.len()..];
- Some(&token[..])
+ Some(quiche::ConnectionId::from_ref(&token[..]))
}
/// Handles incoming HTTP/3 requests.
diff --git a/examples/server.rs b/examples/server.rs
index 04d1f5fb..425d245b 100644
--- a/examples/server.rs
+++ b/examples/server.rs
@@ -206,6 +206,8 @@ fn main() {
let mut scid = [0; quiche::MAX_CONN_ID_LEN];
scid.copy_from_slice(&conn_id);
+ let scid = quiche::ConnectionId::from_ref(&scid);
+
// Token is always present in Initial packets.
let token = hdr.token.as_ref().unwrap();
@@ -242,7 +244,7 @@ fn main() {
// The token was not valid, meaning the retry failed, so
// drop the packet.
- if odcid == None {
+ if odcid.is_none() {
error!("Invalid address validation token");
continue 'read;
}
@@ -258,7 +260,8 @@ fn main() {
debug!("New connection: dcid={:?} scid={:?}", hdr.dcid, scid);
- let conn = quiche::accept(&scid, odcid, &mut config).unwrap();
+ let conn =
+ quiche::accept(&scid, odcid.as_ref(), &mut config).unwrap();
let client = Client {
conn,
@@ -406,7 +409,7 @@ fn mint_token(hdr: &quiche::Header, src: &net::SocketAddr) -> Vec<u8> {
/// authenticate of the token. *It should not be used in production system*.
fn validate_token<'a>(
src: &net::SocketAddr, token: &'a [u8],
-) -> Option<&'a [u8]> {
+) -> Option<quiche::ConnectionId<'a>> {
if token.len() < 6 {
return None;
}
@@ -428,7 +431,7 @@ fn validate_token<'a>(
let token = &token[addr.len()..];
- Some(&token[..])
+ Some(quiche::ConnectionId::from_ref(&token[..]))
}
/// Handles incoming HTTP/0.9 requests.