aboutsummaryrefslogtreecommitdiff
path: root/examples/http3-server.rs
diff options
context:
space:
mode:
authorGravatar Alessandro Ghedini <alessandro@ghedini.me> 2020-12-16 13:39:16 +0000
committerGravatar Alessandro Ghedini <alessandro@ghedini.me> 2021-01-21 14:11:19 +0000
commitc4786c06a71cd6b41d9f49d6a055800e19f96a57 (patch)
tree65ce40def20b20bdd274286dbcde9f31d392e640 /examples/http3-server.rs
parent9d0c677ef1411b24d720b5c8b73bcc94b5535c29 (diff)
downloadquiche-c4786c06a71cd6b41d9f49d6a055800e19f96a57.tar.gz
quiche-c4786c06a71cd6b41d9f49d6a055800e19f96a57.tar.zst
quiche-c4786c06a71cd6b41d9f49d6a055800e19f96a57.zip
use ConnectionId in public functions
This changes the remaining public APIs to use the ConnectionId type for connection ID values, instead of slices. The FFI API is left as-is, as there isn't much point to introduce a new type there.
Diffstat (limited to 'examples/http3-server.rs')
-rw-r--r--examples/http3-server.rs11
1 files changed, 7 insertions, 4 deletions
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.