forked from mengelbart/moqtransport
-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.go
50 lines (47 loc) · 1.5 KB
/
client.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package moqtransport
import (
"context"
"crypto/tls"
"errors"
"github.com/danielpfeifer02/quic-go-prio-packs"
)
func DialQUIC(ctx context.Context, addr string) (*Peer, error) {
tlsConf := &tls.Config{
InsecureSkipVerify: true,
NextProtos: []string{"moq-00"},
}
conn, err := quic.DialAddr(context.TODO(), addr, tlsConf, &quic.Config{
GetConfigForClient: nil,
Versions: nil,
HandshakeIdleTimeout: 0,
MaxIdleTimeout: 1<<63 - 1,
TokenStore: nil,
InitialStreamReceiveWindow: 1 << 30, // TODONOW: what should this be?
MaxStreamReceiveWindow: 1 << 30, // TODONOW: what should this be?
InitialConnectionReceiveWindow: 1 << 30, // TODONOW: what should this be?
MaxConnectionReceiveWindow: 1 << 30, // TODONOW: what should this be?
AllowConnectionWindowIncrease: nil,
MaxIncomingStreams: 0,
MaxIncomingUniStreams: 0,
KeepAlivePeriod: 0,
DisablePathMTUDiscovery: false,
Allow0RTT: false,
EnableDatagrams: true,
Tracer: nil,
})
if err != nil {
return nil, err
}
qc := &quicConn{
conn: conn,
}
p, err := newClientPeer(ctx, qc, true)
if err != nil {
if errors.Is(err, errUnsupportedVersion) {
conn.CloseWithError(SessionTerminatedErrorCode, errUnsupportedVersion.Error())
}
conn.CloseWithError(GenericErrorCode, "internal server error")
return nil, err
}
return p, nil
}