add a quic.Config option for DATAGRAM frames

This commit is contained in:
Marten Seemann
2019-10-06 17:49:49 +02:00
parent 231bc918d4
commit 913ddc5081
4 changed files with 9 additions and 1 deletions

View File

@@ -465,6 +465,7 @@ var _ = Describe("Client", func() {
ConnectionIDLength: 13, ConnectionIDLength: 13,
StatelessResetKey: []byte("foobar"), StatelessResetKey: []byte("foobar"),
TokenStore: tokenStore, TokenStore: tokenStore,
EnableDatagrams: true,
} }
c := populateClientConfig(config, false) c := populateClientConfig(config, false)
Expect(c.HandshakeTimeout).To(Equal(1337 * time.Minute)) Expect(c.HandshakeTimeout).To(Equal(1337 * time.Minute))
@@ -474,6 +475,7 @@ var _ = Describe("Client", func() {
Expect(c.ConnectionIDLength).To(Equal(13)) Expect(c.ConnectionIDLength).To(Equal(13))
Expect(c.StatelessResetKey).To(Equal([]byte("foobar"))) Expect(c.StatelessResetKey).To(Equal([]byte("foobar")))
Expect(c.TokenStore).To(Equal(tokenStore)) Expect(c.TokenStore).To(Equal(tokenStore))
Expect(c.EnableDatagrams).To(BeTrue())
}) })
It("errors when the Config contains an invalid version", func() { It("errors when the Config contains an invalid version", func() {

View File

@@ -98,6 +98,7 @@ func populateConfig(config *Config) *Config {
ConnectionIDLength: config.ConnectionIDLength, ConnectionIDLength: config.ConnectionIDLength,
StatelessResetKey: config.StatelessResetKey, StatelessResetKey: config.StatelessResetKey,
TokenStore: config.TokenStore, TokenStore: config.TokenStore,
EnableDatagrams: config.EnableDatagrams,
Tracer: config.Tracer, Tracer: config.Tracer,
} }
} }

View File

@@ -69,6 +69,8 @@ var _ = Describe("Config", func() {
f.Set(reflect.ValueOf([]byte{1, 2, 3, 4})) f.Set(reflect.ValueOf([]byte{1, 2, 3, 4}))
case "KeepAlive": case "KeepAlive":
f.Set(reflect.ValueOf(true)) f.Set(reflect.ValueOf(true))
case "EnableDatagrams":
f.Set(reflect.ValueOf(true))
case "Tracer": case "Tracer":
f.Set(reflect.ValueOf(mocklogging.NewMockTracer(mockCtrl))) f.Set(reflect.ValueOf(mocklogging.NewMockTracer(mockCtrl)))
default: default:

View File

@@ -259,7 +259,10 @@ type Config struct {
StatelessResetKey []byte StatelessResetKey []byte
// KeepAlive defines whether this peer will periodically send a packet to keep the connection alive. // KeepAlive defines whether this peer will periodically send a packet to keep the connection alive.
KeepAlive bool KeepAlive bool
Tracer logging.Tracer // See https://datatracker.ietf.org/doc/draft-ietf-quic-datagram/.
// Datagrams will only be available when both peers enable datagram support.
EnableDatagrams bool
Tracer logging.Tracer
} }
// ConnectionState records basic details about a QUIC connection // ConnectionState records basic details about a QUIC connection