Skip to content

Commit 6174875

Browse files
authored
Initial web-transport-quiche support (#118)
* Don't use a newer Rust method. * WIP * Initial web-transport-quiche work. * Move some stuff. * WIP * More WIP * Client echo works. * More tweaks. * Fix some bugs and dramatically improve the DriverState. * Documentation. * Fix CI maybe. * More CI stuff. * Try using the boring crate to see if it fixes CI.
1 parent fff2230 commit 6174875

Some content is hidden

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

60 files changed

+4312
-350
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
members = [
33
"web-transport",
44
"web-transport-proto",
5+
"web-transport-quiche",
56
"web-transport-quinn",
67
"web-transport-trait",
78
"web-transport-wasm",
File renamed without changes.
File renamed without changes.
File renamed without changes.

flake.nix

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,17 @@
3030
pkgs.pkg-config
3131
pkgs.glib
3232
pkgs.gtk3
33+
# Required to compile boringssl (via bindgen loading libclang)
34+
pkgs.llvmPackages.libclang.lib
3335
];
3436
in
3537
{
3638
devShells.default = pkgs.mkShell {
3739
packages = tools;
40+
41+
shellHook = ''
42+
export LD_LIBRARY_PATH=${pkgs.lib.makeLibraryPath [pkgs.llvmPackages.libclang.lib]}:$LD_LIBRARY_PATH
43+
'';
3844
};
3945
}
4046
);
File renamed without changes.
File renamed without changes.

web-demo/client.js

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
// @ts-expect-error embed the certificate fingerprint using bundler
2+
import fingerprintHex from "bundle-text:../dev/localhost.hex";
3+
4+
// Convert the hex to binary.
5+
const fingerprint = [];
6+
for (let c = 0; c < fingerprintHex.length - 1; c += 2) {
7+
fingerprint.push(parseInt(fingerprintHex.substring(c, c + 2), 16));
8+
}
9+
10+
const params = new URLSearchParams(window.location.search);
11+
12+
const url = params.get("url") || "https://localhost:4443";
13+
const datagram = params.get("datagram") || false;
14+
15+
function log(msg) {
16+
const element = document.createElement("div");
17+
element.innerText = msg;
18+
19+
document.body.appendChild(element);
20+
}
21+
22+
async function run() {
23+
// Connect using the hex fingerprint in the cert folder.
24+
const transport = new WebTransport(url, {
25+
serverCertificateHashes: [
26+
{
27+
algorithm: "sha-256",
28+
value: new Uint8Array(fingerprint),
29+
},
30+
],
31+
});
32+
await transport.ready;
33+
34+
log("connected");
35+
36+
let writer;
37+
let reader;
38+
39+
if (!datagram) {
40+
// Create a bidirectional stream
41+
const stream = await transport.createBidirectionalStream();
42+
log("created stream");
43+
44+
writer = stream.writable.getWriter();
45+
reader = stream.readable.getReader();
46+
} else {
47+
log("using datagram");
48+
49+
// Create a datagram
50+
writer = transport.datagrams.writable.getWriter();
51+
reader = transport.datagrams.readable.getReader();
52+
}
53+
54+
// Create a message
55+
const msg = "Hello, world!";
56+
const encoded = new TextEncoder().encode(msg);
57+
58+
await writer.write(encoded);
59+
await writer.close();
60+
writer.releaseLock();
61+
62+
log("send: " + msg);
63+
64+
// Read a message from it
65+
// TODO handle partial reads
66+
const { value } = await reader.read();
67+
68+
const recv = new TextDecoder().decode(value);
69+
log("recv: " + recv);
70+
71+
transport.close();
72+
log("closed");
73+
}
74+
75+
run();
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)