File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -18,10 +18,10 @@ Applications can identify which QUIC connection these callbacks are called for b
18
18
For example:
19
19
``` go
20
20
tr := quic.Transport {
21
- ConnContext : func (ctx context.Context ) context.Context {
21
+ ConnContext : func (ctx context.Context , info *quic. ClientInfo ) ( context.Context , error ) {
22
22
// In practice, generate an identifier that's unique to this one connection,
23
23
// for example by incrementing a counter.
24
- return context.WithValue (ctx, " foo" , " bar" )
24
+ return context.WithValue (ctx, " foo" , " bar" ), nil
25
25
}
26
26
}
27
27
@@ -43,6 +43,10 @@ _ = conn.Context()
43
43
The context passed to ` ConnContext ` is closed once the QUIC connection is closed, or if the handshake fails for any reason.
44
44
This allows applications to clean up state that might they might have created in the ` ConnContext ` callback (e.g. by using ` context.AfterFunc ` ).
45
45
46
+ {{< callout type="info" >}}
47
+ By returning an error, ` ConnContext ` can also be used to reject a connection attempt at a very early stage, before the QUIC handshake is started.
48
+ In that case, the connection is closed with a CONNECTION_REFUSED error code.
49
+ {{< /callout >}}
46
50
47
51
## Closing a Connection {#closing}
48
52
You can’t perform that action at this time.
0 commit comments