check that QUIC layer negotiated datagram support when handing SETTINGS

This commit is contained in:
Marten Seemann
2020-12-22 14:10:30 +07:00
parent 3cb07d8f00
commit b753005137
4 changed files with 77 additions and 2 deletions

View File

@@ -301,8 +301,19 @@ func (s *Server) handleUnidirectionalStreams(sess quic.EarlySession) {
sess.CloseWithError(quic.ErrorCode(errorFrameError), "")
return
}
if _, ok := f.(*settingsFrame); !ok {
sf, ok := f.(*settingsFrame)
if !ok {
sess.CloseWithError(quic.ErrorCode(errorMissingSettings), "")
return
}
if !sf.Datagram {
return
}
// If datagram support was enabled on our side as well as on the client side,
// we can expect it to have been negotiated both on the transport and on the HTTP/3 layer.
// Note: ConnectionState() will block until the handshake is complete (relevant when using 0-RTT).
if s.EnableDatagrams && !sess.ConnectionState().SupportsDatagrams {
sess.CloseWithError(quic.ErrorCode(errorSettingsError), "missing QUIC Datagram support")
}
}(str)
}