Skip to content

Commit

Permalink
examples: full example
Browse files Browse the repository at this point in the history
  • Loading branch information
BiagioFesta committed Oct 31, 2023
1 parent 597e50e commit a25df17
Show file tree
Hide file tree
Showing 3 changed files with 702 additions and 37 deletions.
43 changes: 7 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,56 +81,27 @@ async fn main() -> Result<()> {
</table>

## Getting Started
### 0. Clone the Repository
### Clone the Repository
```bash
git clone https://github.com/BiagioFesta/wtransport.git
```
```bash
cd wtransport/
```

### 1. Generate TLS Certificate
```bash
cargo run --example gencert
```

This will generate `cert.pem` and `key.pem` in the current working directory.

Moreover, the program will also output the *fingerprint* of the certificate. Something like this:
```
Certificate generated
Fingerprint: OjyqTe//WoGnvBrgiO37tkOQJyuN1r7hhyBzwX0gotg=
```
### Run `Full` Example

Please take note of the fingerprint, as you will need it to verify the certificate on the client side.
The [`examples/full.rs`](wtransport/examples/full.rs) is a minimal but complete server example that demonstrates the usage of WebTransport.

### 2. Run Example Server
You can run this example using *Cargo*, Rust's package manager, with the following command:
```bash
cargo run --example server
cargo run --example full
```

### 3. Run Client on Browser
[Latest versions](https://chromestatus.com/feature/4854144902889472) of *Google Chrome* started
supporting some implementations of the protocol.

Since the generated certificate is self-signed, it cannot be directly accepted by the browser at the moment.
In order to allow the local certificate, you need to launch Google Chrome with two additional options:
```
google-chrome \
--webtransport-developer-mode \
--ignore-certificate-errors-spki-list=FINGERPRINT
```

Replace `FINGERPRINT` with the value obtained in *step 1*.
For example, `OjyqTe//WoGnvBrgiO37tkOQJyuN1r7hhyBzwX0gotg=`.

### 4. Connect to the Server
Open the website https://webtransport.day/ on Google Chrome instance. Use the *URL*: `https://localhost:4433`, and click on *Connect*.

Enjoy!
This example initiates an *echo* WebTransport server that can receive messages. It also includes an integrated HTTP server and
launches Google Chrome with the necessary options to establish connections using self-signed TLS certificates.

## Examples
* https://github.com/BiagioFesta/wtransport-examples
* [Local Examples](wtransport/examples/)

## Other languages
Expand Down
6 changes: 5 additions & 1 deletion wtransport/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,15 @@ wtransport-proto = { version = "0.1.7", path = "../wtransport-proto", features =

[dev-dependencies]
anyhow = "1.0.71"
axum = "0.6.20"
base64 = "0.21.0"
hyper = "0.14.27"
pathsearch = "0.2.0"
rcgen = "0.11.1"
ring = "0.17.0"
sysinfo = "0.29.10"
time = "0.3.21"
tokio = { version = "1.28.1", features = ["rt", "rt-multi-thread", "macros"] }
tokio = { version = "1.28.1", features = ["rt", "rt-multi-thread", "macros", "process"] }
tracing-subscriber = { version = "0.3.17", features = ["env-filter"] }

[features]
Expand Down
Loading

0 comments on commit a25df17

Please sign in to comment.