Skip to content

Commit ab0596a

Browse files
djcRalith
authored andcommitted
book: rely on implicit targets
1 parent 62fc039 commit ab0596a

File tree

7 files changed

+27
-40
lines changed

7 files changed

+27
-40
lines changed

docs/book/Cargo.toml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,3 @@ quinn = { version = "0.11.7", path = "../../quinn" }
1515
rcgen.workspace = true
1616
rustls.workspace = true
1717
rustls-pemfile.workspace = true
18-
19-
[[bin]]
20-
name = "certificate"
21-
path = "src/quinn/certificate.rs"
22-
23-
[[bin]]
24-
name = "data-transfer"
25-
path = "src/quinn/data-transfer.rs"
26-
27-
[[bin]]
28-
name = "set-up-connection"
29-
path = "src/quinn/set-up-connection.rs"

docs/book/src/quinn/certificate.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ rustls = { version = "*", features = ["dangerous_configuration", "quic"] }
1919
Then, allow the client to skip the certificate validation by implementing [ServerCertVerifier][ServerCertVerifier] and letting it assert verification for any server.
2020

2121
```rust
22-
{{#include certificate.rs:8:60}}
22+
{{#include ../bin/certificate.rs:8:60}}
2323
```
2424

2525
After that, modify the [ClientConfig][ClientConfig] to use this [ServerCertVerifier][ServerCertVerifier] implementation.
2626

2727
```rust
28-
{{#include certificate.rs:63:72}}
28+
{{#include ../bin/certificate.rs:63:72}}
2929
```
3030

3131
Finally, if you plug this [ClientConfig][ClientConfig] into the [Endpoint::set_default_client_config()][set_default_client_config] your client endpoint should verify all connections as trustworthy.
@@ -45,10 +45,10 @@ This example uses [rcgen][4] to generate a certificate.
4545
Let's look at an example:
4646

4747
```rust
48-
{{#include certificate.rs:90:101}}
48+
{{#include ../bin/certificate.rs:90:101}}
4949
```
5050

51-
*Note that [generate_simple_self_signed][generate_simple_self_signed] returns a [Certificate][2] that can be serialized to both `.der` and `.pem` formats.*
51+
_Note that [generate_simple_self_signed][generate_simple_self_signed] returns a [Certificate][2] that can be serialized to both `.der` and `.pem` formats._
5252

5353
### Non-self-signed Certificates
5454

@@ -68,7 +68,7 @@ certbot asks for the required data and writes the certificates to `fullchain.pem
6868
These files can then be referenced in code.
6969

7070
```rust
71-
{{#include certificate.rs:75:88}}
71+
{{#include ../bin/certificate.rs:75:88}}
7272
```
7373

7474
### Configuring Certificates
@@ -79,15 +79,15 @@ After configuring plug the configuration into the `Endpoint`.
7979
**Configure Server**
8080

8181
```rust
82-
{{#include certificate.rs:107}}
82+
{{#include ../bin/certificate.rs:107}}
8383
```
8484

8585
This is the only thing you need to do for your server to be secured.
8686

8787
**Configure Client**
8888

8989
```rust
90-
{{#include certificate.rs:108}}
90+
{{#include ../bin/certificate.rs:108}}
9191
```
9292

9393
This is the only thing you need to do for your client to trust a server certificate signed by a conventional certificate authority.
@@ -103,7 +103,6 @@ This is the only thing you need to do for your client to trust a server certific
103103
[5]: https://en.wikipedia.org/wiki/Self-signed_certificate#:~:text=In%20cryptography%20and%20computer%20security,a%20CA%20aim%20to%20provide.
104104
[6]: https://letsencrypt.org/getting-started/
105105
[7]: https://certbot.eff.org/instructions
106-
107106
[ClientConfig]: https://docs.rs/quinn/latest/quinn/struct.ClientConfig.html
108107
[ServerCertVerifier]: https://docs.rs/rustls/latest/rustls/client/trait.ServerCertVerifier.html
109108
[set_default_client_config]: https://docs.rs/quinn/latest/quinn/struct.Endpoint.html#method.set_default_client_config

docs/book/src/quinn/data-transfer.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ With QUIC, the programmer is in full control over the stream allocation.
1515
QUIC provides support for both stream and message-based communication.
1616
Streams and messages can be initiated both on the client and server.
1717

18-
| Type | Description | Reference |
19-
| :----- | :----- | :----- |
20-
| **Bidirectional Stream** | two way stream communication. | see [open_bi][open_bi] |
21-
| **Unidirectional Stream** | one way stream communication. | see [open_uni][open_uni] |
18+
| Type | Description | Reference |
19+
| :----------------------------------- | :-------------------------------------- | :--------------------------------- |
20+
| **Bidirectional Stream** | two way stream communication. | see [open_bi][open_bi] |
21+
| **Unidirectional Stream** | one way stream communication. | see [open_uni][open_uni] |
2222
| **Unreliable Messaging (extension)** | message based unreliable communication. | see [send_datagram][send_datagram] |
2323

2424
## How to Use
@@ -31,50 +31,50 @@ New streams can be created with [Connection][Connection]'s [open_bi()][open_bi]
3131
With bidirectional streams, data can be sent in both directions.
3232
For example, from the connection initiator to the peer and the other way around.
3333

34-
*open bidirectional stream*
34+
_open bidirectional stream_
3535

3636
```rust
37-
{{#include data-transfer.rs:5:11}}
37+
{{#include ../bin/data-transfer.rs:5:11}}
3838
```
3939

40-
*iterate incoming bidirectional stream(s)*
40+
_iterate incoming bidirectional stream(s)_
4141

4242
```rust
43-
{{#include data-transfer.rs:14:22}}
43+
{{#include ../bin/data-transfer.rs:14:22}}
4444
```
4545

4646
## Unidirectional Streams
4747

4848
With unidirectional streams, you can carry data only in one direction: from the initiator of the stream to its peer.
4949
It is possible to get reliability without ordering (so no head-of-line blocking) by opening a new stream for each packet.
5050

51-
*open unidirectional stream*
51+
_open unidirectional stream_
5252

5353
```rust
54-
{{#include data-transfer.rs:25:30}}
54+
{{#include ../bin/data-transfer.rs:25:30}}
5555
```
5656

57-
*iterating incoming unidirectional stream(s)*
57+
_iterating incoming unidirectional stream(s)_
5858

5959
```rust
60-
{{#include data-transfer.rs:33:39}}
60+
{{#include ../bin/data-transfer.rs:33:39}}
6161
```
6262

6363
## Unreliable Messaging
6464

6565
With unreliable messaging, you can transfer data without reliability.
6666
This could be useful if data arrival isn't essential or when high throughput is important.
6767

68-
*send datagram*
68+
_send datagram_
6969

7070
```rust
71-
{{#include data-transfer.rs:42:45}}
71+
{{#include ../bin/data-transfer.rs:42:45}}
7272
```
7373

74-
*iterating datagram stream(s)*
74+
_iterating datagram stream(s)_
7575

7676
```rust
77-
{{#include data-transfer.rs:48:54}}
77+
{{#include ../bin/data-transfer.rs:48:54}}
7878
```
7979

8080
[Endpoint]: https://docs.rs/quinn/latest/quinn/struct.Endpoint.html

docs/book/src/quinn/set-up-connection.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ It all starts with the [Endpoint][Endpoint] struct, this is the entry point of t
1212
Let's start by defining some constants.
1313

1414
```rust
15-
{{#include set-up-connection.rs:5:13}}
15+
{{#include ../bin/set-up-connection.rs:5:13}}
1616
```
1717

1818
**Server**
@@ -22,7 +22,7 @@ The [server()][server] method, which can be used for this, returns the `Endpoint
2222
`Endpoint` is used to start outgoing connections and accept incoming connections.
2323

2424
```rust
25-
{{#include set-up-connection.rs:16:28}}
25+
{{#include ../bin/set-up-connection.rs:16:28}}
2626
```
2727

2828
**Client**
@@ -32,13 +32,13 @@ The client needs to connect to the server using the [connect(server_name)][conne
3232
The `SERVER_NAME` argument is the DNS name, matching the certificate configured in the server.
3333

3434
```rust
35-
{{#include set-up-connection.rs:31:41}}
35+
{{#include ../bin/set-up-connection.rs:31:41}}
3636
```
37+
3738
<br><hr>
3839

3940
[Next up](data-transfer.md), let's have a look at sending data over this connection.
4041

41-
4242
[Endpoint]: https://docs.rs/quinn/latest/quinn/struct.Endpoint.html
4343
[server]: https://docs.rs/quinn/latest/quinn/struct.Endpoint.html#method.server
4444
[client]: https://docs.rs/quinn/latest/quinn/struct.Endpoint.html#method.client

0 commit comments

Comments
 (0)