forked from quic-go/quic-go
use server generated connection IDs when accepting a connection
This commit is contained in:
@@ -26,7 +26,7 @@ type serverTLS struct {
|
||||
params *handshake.TransportParameters
|
||||
cookieGenerator *handshake.CookieGenerator
|
||||
|
||||
newSession func(connection, sessionRunner, protocol.ConnectionID, protocol.ConnectionID, protocol.PacketNumber, *Config, *mint.Config, *handshake.TransportParameters, utils.Logger, protocol.VersionNumber) (quicSession, error)
|
||||
newSession func(connection, sessionRunner, protocol.ConnectionID, protocol.ConnectionID, protocol.ConnectionID, protocol.PacketNumber, *Config, *mint.Config, *handshake.TransportParameters, utils.Logger, protocol.VersionNumber) (quicSession, error)
|
||||
|
||||
sessionRunner sessionRunner
|
||||
sessionChan chan<- tlsSession
|
||||
@@ -128,12 +128,15 @@ func (s *serverTLS) handleInitialImpl(p *receivedPacket) (quicSession, protocol.
|
||||
mconf := s.mintConf.Clone()
|
||||
mconf.ExtensionHandler = extHandler
|
||||
|
||||
// TODO: change the connection ID
|
||||
// This means that the server crypto setup will need two different null AEADs.
|
||||
connID := hdr.DestConnectionID
|
||||
connID, err := protocol.GenerateConnectionID(s.config.ConnectionIDLength)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
s.logger.Debugf("Changing connection ID to %s.", connID)
|
||||
sess, err := s.newSession(
|
||||
&conn{pconn: s.conn, currentAddr: p.remoteAddr},
|
||||
s.sessionRunner,
|
||||
hdr.DestConnectionID,
|
||||
hdr.SrcConnectionID,
|
||||
connID,
|
||||
1,
|
||||
@@ -169,7 +172,7 @@ func (s *serverTLS) sendRetry(remoteAddr net.Addr, hdr *wire.Header) error {
|
||||
OrigDestConnectionID: hdr.DestConnectionID,
|
||||
Token: token,
|
||||
}
|
||||
s.logger.Debugf("-> Sending Retry")
|
||||
s.logger.Debugf("Changing connection ID to %s.\n-> Sending Retry", connID)
|
||||
replyHdr.Log(s.logger)
|
||||
buf := &bytes.Buffer{}
|
||||
if err := replyHdr.Write(buf, protocol.PerspectiveServer, hdr.Version); err != nil {
|
||||
|
||||
@@ -114,7 +114,7 @@ var _ = Describe("Stateless TLS handling", func() {
|
||||
data: bytes.Repeat([]byte{0}, protocol.MinInitialPacketSize),
|
||||
}
|
||||
run := make(chan struct{})
|
||||
server.newSession = func(connection, sessionRunner, protocol.ConnectionID, protocol.ConnectionID, protocol.PacketNumber, *Config, *mint.Config, *handshake.TransportParameters, utils.Logger, protocol.VersionNumber) (quicSession, error) {
|
||||
server.newSession = func(connection, sessionRunner, protocol.ConnectionID, protocol.ConnectionID, protocol.ConnectionID, protocol.PacketNumber, *Config, *mint.Config, *handshake.TransportParameters, utils.Logger, protocol.VersionNumber) (quicSession, error) {
|
||||
sess := NewMockQuicSession(mockCtrl)
|
||||
sess.EXPECT().handlePacket(p)
|
||||
sess.EXPECT().run().Do(func() { close(run) })
|
||||
@@ -133,8 +133,7 @@ var _ = Describe("Stateless TLS handling", func() {
|
||||
Eventually(sessionChan).Should(Receive(&tlsSess))
|
||||
// make sure we're using a server-generated connection ID
|
||||
Expect(tlsSess.connID).ToNot(Equal(hdr.SrcConnectionID))
|
||||
// TODO: use server-generated connection ID here
|
||||
// Expect(tlsSess.connID).ToNot(Equal(hdr.DestConnectionID))
|
||||
Expect(tlsSess.connID).ToNot(Equal(hdr.DestConnectionID))
|
||||
Eventually(run).Should(BeClosed())
|
||||
Eventually(done).Should(BeClosed())
|
||||
})
|
||||
|
||||
@@ -294,6 +294,7 @@ var newClientSession = func(
|
||||
func newTLSServerSession(
|
||||
conn connection,
|
||||
runner sessionRunner,
|
||||
origConnID protocol.ConnectionID,
|
||||
destConnID protocol.ConnectionID,
|
||||
srcConnID protocol.ConnectionID,
|
||||
initialPacketNumber protocol.PacketNumber,
|
||||
@@ -318,7 +319,7 @@ func newTLSServerSession(
|
||||
s.preSetup()
|
||||
cs, err := handshake.NewCryptoSetupTLSServer(
|
||||
s.cryptoStream,
|
||||
s.srcConnID,
|
||||
origConnID,
|
||||
mintConf,
|
||||
handshakeEvent,
|
||||
v,
|
||||
|
||||
Reference in New Issue
Block a user