summaryrefslogtreecommitdiffhomepage
path: root/vendor/github.com/lucas-clemente/quic-go/server_tls.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/lucas-clemente/quic-go/server_tls.go')
-rw-r--r--vendor/github.com/lucas-clemente/quic-go/server_tls.go40
1 files changed, 23 insertions, 17 deletions
diff --git a/vendor/github.com/lucas-clemente/quic-go/server_tls.go b/vendor/github.com/lucas-clemente/quic-go/server_tls.go
index 5f270e349..9f3874090 100644
--- a/vendor/github.com/lucas-clemente/quic-go/server_tls.go
+++ b/vendor/github.com/lucas-clemente/quic-go/server_tls.go
@@ -21,9 +21,12 @@ type nullAEAD struct {
var _ quicAEAD = &nullAEAD{}
-func (n *nullAEAD) Open(dst, src []byte, packetNumber protocol.PacketNumber, associatedData []byte) ([]byte, protocol.EncryptionLevel, error) {
- data, err := n.aead.Open(dst, src, packetNumber, associatedData)
- return data, protocol.EncryptionUnencrypted, err
+func (n *nullAEAD) OpenHandshake(dst, src []byte, packetNumber protocol.PacketNumber, associatedData []byte) ([]byte, error) {
+ return n.aead.Open(dst, src, packetNumber, associatedData)
+}
+
+func (n *nullAEAD) Open1RTT(dst, src []byte, packetNumber protocol.PacketNumber, associatedData []byte) ([]byte, error) {
+ return nil, errors.New("no 1-RTT keys")
}
type tlsSession struct {
@@ -36,11 +39,12 @@ type serverTLS struct {
config *Config
supportedVersions []protocol.VersionNumber
mintConf *mint.Config
- cookieProtector mint.CookieProtector
params *handshake.TransportParameters
newMintConn func(*handshake.CryptoStreamConn, protocol.VersionNumber) (handshake.MintTLS, <-chan handshake.TransportParameters, error)
sessionChan chan<- tlsSession
+
+ logger utils.Logger
}
func newServerTLS(
@@ -48,6 +52,7 @@ func newServerTLS(
config *Config,
cookieHandler *handshake.CookieHandler,
tlsConf *tls.Config,
+ logger utils.Logger,
) (*serverTLS, <-chan tlsSession, error) {
mconf, err := tlsToMintConfig(tlsConf, protocol.PerspectiveServer)
if err != nil {
@@ -72,20 +77,20 @@ func newServerTLS(
StreamFlowControlWindow: protocol.ReceiveStreamFlowControlWindow,
ConnectionFlowControlWindow: protocol.ReceiveConnectionFlowControlWindow,
IdleTimeout: config.IdleTimeout,
- // TODO(#523): make these values configurable
- MaxBidiStreamID: protocol.MaxBidiStreamID(protocol.MaxIncomingStreams, protocol.PerspectiveServer),
- MaxUniStreamID: protocol.MaxUniStreamID(protocol.MaxIncomingStreams, protocol.PerspectiveServer),
+ MaxBidiStreams: uint16(config.MaxIncomingStreams),
+ MaxUniStreams: uint16(config.MaxIncomingUniStreams),
},
+ logger: logger,
}
s.newMintConn = s.newMintConnImpl
return s, sessionChan, nil
}
func (s *serverTLS) HandleInitial(remoteAddr net.Addr, hdr *wire.Header, data []byte) {
- utils.Debugf("Received a Packet. Handling it statelessly.")
+ s.logger.Debugf("Received a Packet. Handling it statelessly.")
sess, err := s.handleInitialImpl(remoteAddr, hdr, data)
if err != nil {
- utils.Errorf("Error occured handling initial packet: %s", err)
+ s.logger.Errorf("Error occurred handling initial packet: %s", err)
return
}
if sess == nil { // a stateless reset was done
@@ -99,7 +104,7 @@ func (s *serverTLS) HandleInitial(remoteAddr net.Addr, hdr *wire.Header, data []
// will be set to s.newMintConn by the constructor
func (s *serverTLS) newMintConnImpl(bc *handshake.CryptoStreamConn, v protocol.VersionNumber) (handshake.MintTLS, <-chan handshake.TransportParameters, error) {
- extHandler := handshake.NewExtensionHandlerServer(s.params, s.config.Versions, v)
+ extHandler := handshake.NewExtensionHandlerServer(s.params, s.config.Versions, v, s.logger)
conf := s.mintConf.Clone()
conf.ExtensionHandler = extHandler
return newMintController(bc, conf, protocol.PerspectiveServer), extHandler.GetPeerParams(), nil
@@ -117,7 +122,7 @@ func (s *serverTLS) sendConnectionClose(remoteAddr net.Addr, clientHdr *wire.Hea
PacketNumber: 1, // random packet number
Version: clientHdr.Version,
}
- data, err := packUnencryptedPacket(aead, replyHdr, ccf, protocol.PerspectiveServer)
+ data, err := packUnencryptedPacket(aead, replyHdr, ccf, protocol.PerspectiveServer, s.logger)
if err != nil {
return err
}
@@ -131,8 +136,8 @@ func (s *serverTLS) handleInitialImpl(remoteAddr net.Addr, hdr *wire.Header, dat
}
// check version, if not matching send VNP
if !protocol.IsSupportedVersion(s.supportedVersions, hdr.Version) {
- utils.Debugf("Client offered version %s, sending VersionNegotiationPacket", hdr.Version)
- _, err := s.conn.WriteTo(wire.ComposeVersionNegotiation(hdr.ConnectionID, hdr.PacketNumber, s.supportedVersions), remoteAddr)
+ s.logger.Debugf("Client offered version %s, sending VersionNegotiationPacket", hdr.Version)
+ _, err := s.conn.WriteTo(wire.ComposeVersionNegotiation(hdr.ConnectionID, s.supportedVersions), remoteAddr)
return nil, err
}
@@ -141,15 +146,15 @@ func (s *serverTLS) handleInitialImpl(remoteAddr net.Addr, hdr *wire.Header, dat
if err != nil {
return nil, err
}
- frame, err := unpackInitialPacket(aead, hdr, data, hdr.Version)
+ frame, err := unpackInitialPacket(aead, hdr, data, s.logger, hdr.Version)
if err != nil {
- utils.Debugf("Error unpacking initial packet: %s", err)
+ s.logger.Debugf("Error unpacking initial packet: %s", err)
return nil, nil
}
sess, err := s.handleUnpackedInitial(remoteAddr, hdr, frame, aead)
if err != nil {
if ccerr := s.sendConnectionClose(remoteAddr, hdr, aead, err); ccerr != nil {
- utils.Debugf("Error sending CONNECTION_CLOSE: ", ccerr)
+ s.logger.Debugf("Error sending CONNECTION_CLOSE: %s", ccerr)
}
return nil, err
}
@@ -179,7 +184,7 @@ func (s *serverTLS) handleUnpackedInitial(remoteAddr net.Addr, hdr *wire.Header,
StreamID: version.CryptoStreamID(),
Data: bc.GetDataForWriting(),
}
- data, err := packUnencryptedPacket(aead, replyHdr, f, protocol.PerspectiveServer)
+ data, err := packUnencryptedPacket(aead, replyHdr, f, protocol.PerspectiveServer, s.logger)
if err != nil {
return nil, err
}
@@ -209,6 +214,7 @@ func (s *serverTLS) handleUnpackedInitial(remoteAddr net.Addr, hdr *wire.Header,
aead,
&params,
version,
+ s.logger,
)
if err != nil {
return nil, err