pkg/quic: add backward compatibility for qtls
Change-Id: I2560074ece5b61d9ddb236269172325e1b5de83e
This commit is contained in:
parent
ca86820b8b
commit
824fd6f131
@ -15,6 +15,7 @@ import (
|
||||
|
||||
"storj.io/common/memory"
|
||||
"storj.io/common/rpc"
|
||||
"storj.io/storj/pkg/quic/qtls"
|
||||
)
|
||||
|
||||
// Conn is a wrapper around a quic connection and fulfills net.Conn interface.
|
||||
@ -71,7 +72,7 @@ func (c *Conn) getStream() (quic.Stream, error) {
|
||||
|
||||
// ConnectionState converts quic session state to tls connection state and returns tls state.
|
||||
func (c *Conn) ConnectionState() tls.ConnectionState {
|
||||
return c.session.ConnectionState().ConnectionState
|
||||
return qtls.ToTLSConnectionState(c.session.ConnectionState())
|
||||
}
|
||||
|
||||
// Close closes the quic connection.
|
||||
|
29
pkg/quic/qtls/go114.go
Normal file
29
pkg/quic/qtls/go114.go
Normal file
@ -0,0 +1,29 @@
|
||||
// Copyright (C) 2021 Storj Labs, Inc.
|
||||
// See LICENSE for copying information.
|
||||
|
||||
// +build go1.13 go1.14
|
||||
|
||||
package qtls
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
|
||||
quicgo "github.com/lucas-clemente/quic-go"
|
||||
)
|
||||
|
||||
// ToTLSConnectionState converts a quic-go connection state to tls connection
|
||||
// state.
|
||||
func ToTLSConnectionState(state quicgo.ConnectionState) tls.ConnectionState {
|
||||
return tls.ConnectionState{
|
||||
Version: state.Version,
|
||||
HandshakeComplete: state.HandshakeComplete,
|
||||
DidResume: state.DidResume,
|
||||
CipherSuite: state.CipherSuite,
|
||||
NegotiatedProtocol: state.NegotiatedProtocol,
|
||||
ServerName: state.ServerName,
|
||||
PeerCertificates: state.PeerCertificates,
|
||||
VerifiedChains: state.VerifiedChains,
|
||||
SignedCertificateTimestamps: state.SignedCertificateTimestamps,
|
||||
OCSPResponse: state.OCSPResponse,
|
||||
}
|
||||
}
|
18
pkg/quic/qtls/go115.go
Normal file
18
pkg/quic/qtls/go115.go
Normal file
@ -0,0 +1,18 @@
|
||||
// Copyright (C) 2021 Storj Labs, Inc.
|
||||
// See LICENSE for copying information.
|
||||
|
||||
// +build !go1.13 !go1.14
|
||||
|
||||
package qtls
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
|
||||
quicgo "github.com/lucas-clemente/quic-go"
|
||||
)
|
||||
|
||||
// ToTLSConnectionState converts a quic-go connection state to tls connection
|
||||
// state.
|
||||
func ToTLSConnectionState(state quicgo.ConnectionState) tls.ConnectionState {
|
||||
return state.ConnectionState
|
||||
}
|
Loading…
Reference in New Issue
Block a user