1
2
3
4
5 package http3
6
7 import (
8 "net/http"
9 "time"
10 _ "unsafe"
11
12 . "golang.org/x/net/internal/http3"
13 "golang.org/x/net/quic"
14 )
15
16
17
18 const handshakeTimeout = 1 * time.Minute
19
20
21 func registerHTTP3Server(s *http.Server) <-chan *quic.Endpoint {
22 endpointCh := make(chan *quic.Endpoint)
23 RegisterServer(s, ServerOpts{
24 ListenQUIC: func(addr string, config *quic.Config) (*quic.Endpoint, error) {
25 e, err := quic.Listen("udp", addr, config)
26 endpointCh <- e
27 return e, err
28 },
29 QUICConfig: &quic.Config{HandshakeTimeout: handshakeTimeout},
30 })
31 return endpointCh
32 }
33
34
35 func registerHTTP3Transport(tr *http.Transport) <-chan *quic.Endpoint {
36 endpointCh := make(chan *quic.Endpoint)
37 RegisterTransport(tr, TransportOpts{
38 ListenQUIC: func(addr string, config *quic.Config) (*quic.Endpoint, error) {
39 e, err := quic.Listen("udp", addr, config)
40 endpointCh <- e
41 return e, err
42 },
43 QUICConfig: &quic.Config{HandshakeTimeout: handshakeTimeout},
44 })
45 return endpointCh
46 }
47
View as plain text