Skip to content

Commit 7b26575

Browse files
committed
docs(iroh-relay): add section on how to use as a library
1 parent 5809a56 commit 7b26575

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

iroh-relay/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,18 @@ The relay server will run over http on port 3340, as it does using the `--dev` f
6464

6565
The relay will use the configured TLS certificates for the QUIC connection, but use http (rather than https) for the server.
6666

67+
### Using iroh-relay as a library to run in-process relays in integration tests
68+
69+
When using iroh as a transport library in an application or other library, there is a simple way of running an in-process relay server:
70+
71+
- Enable `test-utils` feature of the `iroh` crate
72+
```toml
73+
iroh = { version = "0.95", features = ["test-utils"] }
74+
```
75+
- Spawn a relay server by calling [`iroh::test_utils::run_relay_server().await`](https://docs.rs/iroh/latest/iroh/test_utils/fn.run_relay_server.html)
76+
This will start a relay server with self-signed TLS certificate, listening on a localhost port, and return the server's URL.
77+
- For the clients (= endpoints) to successfully connect to the relay, disable TLS certificate verification on the client by calling [`Endpoint::insecure_skip_relay_cert_verify`](https://docs.rs/iroh/latest/iroh/endpoint/struct.Builder.html#method.insecure_skip_relay_cert_verify).
78+
6779
# License
6880

6981
This project is licensed under either of

0 commit comments

Comments
 (0)