From 913ddc5081a78e0d2f5262162e7bf96523bea68c Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Sun, 6 Oct 2019 17:49:49 +0200 Subject: [PATCH] add a quic.Config option for DATAGRAM frames --- client_test.go | 2 ++ config.go | 1 + config_test.go | 2 ++ interface.go | 5 ++++- 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/client_test.go b/client_test.go index bbdf35f5..6004e64e 100644 --- a/client_test.go +++ b/client_test.go @@ -465,6 +465,7 @@ var _ = Describe("Client", func() { ConnectionIDLength: 13, StatelessResetKey: []byte("foobar"), TokenStore: tokenStore, + EnableDatagrams: true, } c := populateClientConfig(config, false) Expect(c.HandshakeTimeout).To(Equal(1337 * time.Minute)) @@ -474,6 +475,7 @@ var _ = Describe("Client", func() { Expect(c.ConnectionIDLength).To(Equal(13)) Expect(c.StatelessResetKey).To(Equal([]byte("foobar"))) Expect(c.TokenStore).To(Equal(tokenStore)) + Expect(c.EnableDatagrams).To(BeTrue()) }) It("errors when the Config contains an invalid version", func() { diff --git a/config.go b/config.go index 7e211e7b..833051f0 100644 --- a/config.go +++ b/config.go @@ -98,6 +98,7 @@ func populateConfig(config *Config) *Config { ConnectionIDLength: config.ConnectionIDLength, StatelessResetKey: config.StatelessResetKey, TokenStore: config.TokenStore, + EnableDatagrams: config.EnableDatagrams, Tracer: config.Tracer, } } diff --git a/config_test.go b/config_test.go index 71aa3e76..f45e8179 100644 --- a/config_test.go +++ b/config_test.go @@ -69,6 +69,8 @@ var _ = Describe("Config", func() { f.Set(reflect.ValueOf([]byte{1, 2, 3, 4})) case "KeepAlive": f.Set(reflect.ValueOf(true)) + case "EnableDatagrams": + f.Set(reflect.ValueOf(true)) case "Tracer": f.Set(reflect.ValueOf(mocklogging.NewMockTracer(mockCtrl))) default: diff --git a/interface.go b/interface.go index e27a81d1..dba6b34c 100644 --- a/interface.go +++ b/interface.go @@ -259,7 +259,10 @@ type Config struct { StatelessResetKey []byte // KeepAlive defines whether this peer will periodically send a packet to keep the connection alive. 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