Skip to content

Commit 683fbd1

Browse files
committed
Merge branch 'Frando/hooks' of github.com:okdistribute/docs into Frando/hooks
2 parents f813f69 + 5cb34e3 commit 683fbd1

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

connecting/endpoint-hooks.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Hooks run at two points:
1919

2020
Hooks are registered with `Endpoint::builder().hooks(...)`. If multiple hooks are installed, they run in the order they were added, and a rejection from any hook short-circuits the rest.
2121

22-
Note that hooks cannot *use* connections, they can only *observe* or *reject* them. This is an important separation of concerns: If hooks were allowed to use the connections in any way, they could interfer with the actual protocols running within these connections. Hooks can, however, *reject* connections before they are passed on to protocol handlers. This makes it possible to implement custom authentication schemes with hooks that work without any support from the protocols running in these connections.
22+
Note that hooks cannot *use* connections, they can only *observe* or *reject* them. This is an important separation of concerns: If hooks were allowed to use the connections in any way, they could interfere with the actual protocols running within these connections. Hooks can, however, *reject* connections before they are passed on to protocol handlers. This makes it possible to implement custom authentication schemes with hooks that work without any support from the protocols running in these connections.
2323

2424
> **Note:** Hooks live on the `Endpoint` instance. Never store an `Endpoint` inside your hook type (even indirectly), or it may cause reference-counting cycles and prevent clean shutdown.
2525
@@ -89,7 +89,7 @@ async fn main() -> n0_error::Result<()> {
8989
Hooks can be used to enforce policy. If a hook returns a rejection result, the connection is immediately aborted.
9090
The example below rejects all incoming connections after the handshake. Outgoing connections will still dial.
9191

92-
In real applications, you would inspect `ConnectionInfo` and reject connections by checking the connection's remote id or aLPN against authentication state in your app.
92+
In real applications, you would inspect `ConnectionInfo` and reject connections by checking the connection's remote id or ALPN against authentication state in your app.
9393

9494
```rust
9595
use iroh::endpoint::{AfterHandshakeOutcome, ConnectionInfo, Endpoint, EndpointHooks, Side};
@@ -144,7 +144,7 @@ This example demonstrates how hooks can feed information to external tasks, givi
144144
### [Aggregating information about remote endpoints](https://github.com/n0-computer/iroh/blob/feat-multipath/iroh/examples/remote-info.rs)
145145

146146
This example implements a `RemoteMap` that tracks and aggregates information about all remotes our endpoint knows about.
147-
This can be useful if your app needs to chose between remotes, or for building diagnostic tools.
147+
This can be useful if your app needs to choose between remotes, or for building diagnostic tools.
148148

149149
* A hook forwards `ConnectionInfo` updates into a worker task.
150150
* The worker maintains a map of all remotes with counts of active connections and observed statistics (e.g. latency/RTT, whether relay/IP paths were used, etc).

0 commit comments

Comments
 (0)