return a quic.ConnectionState from Session.ConnectionState()

This commit is contained in:
Marten Seemann
2020-01-04 15:55:58 +07:00
parent d7948d627a
commit 539097fc6e
8 changed files with 22 additions and 27 deletions

View File

@@ -8,7 +8,6 @@ import (
"io"
"net"
"sync"
"unsafe"
"github.com/lucas-clemente/quic-go/internal/congestion"
"github.com/lucas-clemente/quic-go/internal/protocol"
@@ -782,12 +781,6 @@ func (h *cryptoSetup) Get1RTTOpener() (ShortHeaderOpener, error) {
return h.aead, nil
}
func (h *cryptoSetup) ConnectionState() tls.ConnectionState {
cs := h.conn.ConnectionState()
// h.conn is a qtls.Conn, which returns a qtls.ConnectionState.
// qtls.ConnectionState is identical to the tls.ConnectionState.
// It contains an unexported field which is used ExportKeyingMaterial().
// The only way to return a tls.ConnectionState is to use unsafe.
// In unsafe.go we check that the two objects are actually identical.
return *(*tls.ConnectionState)(unsafe.Pointer(&cs))
func (h *cryptoSetup) ConnectionState() ConnectionState {
return h.conn.ConnectionState()
}

View File

@@ -1,7 +1,6 @@
package handshake
import (
"crypto/tls"
"errors"
"io"
"time"
@@ -22,6 +21,9 @@ var (
ErrDecryptionFailed = errors.New("decryption failed")
)
// ConnectionState contains information about the state of the connection.
type ConnectionState = qtls.ConnectionState
type headerDecryptor interface {
DecryptHeader(sample []byte, firstByte *byte, pnBytes []byte)
}
@@ -74,7 +76,7 @@ type CryptoSetup interface {
HandleMessage([]byte, protocol.EncryptionLevel) bool
SetLargest1RTTAcked(protocol.PacketNumber)
DropHandshakeKeys()
ConnectionState() tls.ConnectionState
ConnectionState() ConnectionState
GetInitialOpener() (LongHeaderOpener, error)
GetHandshakeOpener() (LongHeaderOpener, error)

View File

@@ -13,9 +13,6 @@ import (
)
func init() {
if !structsEqual(&tls.ConnectionState{}, &qtls.ConnectionState{}) {
panic("qtls.ConnectionState not compatible with tls.ConnectionState")
}
if !structsEqual(&tls.ClientSessionState{}, &qtls.ClientSessionState{}) {
panic("qtls.ClientSessionState not compatible with tls.ClientSessionState")
}