1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-09-19 10:26:10 -04:00
v2fly/external/github.com/lucas-clemente/quic-go/internal/handshake/interface.go

50 lines
1.6 KiB
Go
Raw Normal View History

2018-11-20 17:51:25 -05:00
package handshake
import (
"crypto/x509"
2018-11-23 11:04:53 -05:00
"io"
2018-11-20 17:51:25 -05:00
2019-01-17 09:33:18 -05:00
"v2ray.com/core/external/github.com/lucas-clemente/quic-go/internal/protocol"
"v2ray.com/core/external/github.com/marten-seemann/qtls"
2018-11-20 17:51:25 -05:00
)
2018-11-23 11:04:53 -05:00
// Opener opens a packet
type Opener interface {
Open(dst, src []byte, packetNumber protocol.PacketNumber, associatedData []byte) ([]byte, error)
2019-01-02 07:01:06 -05:00
DecryptHeader(sample []byte, firstByte *byte, pnBytes []byte)
2018-11-23 11:04:53 -05:00
}
2018-11-20 17:51:25 -05:00
// Sealer seals a packet
type Sealer interface {
Seal(dst, src []byte, packetNumber protocol.PacketNumber, associatedData []byte) []byte
2019-01-02 07:01:06 -05:00
EncryptHeader(sample []byte, firstByte *byte, pnBytes []byte)
2018-11-20 17:51:25 -05:00
Overhead() int
}
2018-11-23 11:04:53 -05:00
// A tlsExtensionHandler sends and received the QUIC TLS extension.
type tlsExtensionHandler interface {
GetExtensions(msgType uint8) []qtls.Extension
ReceivedExtensions(msgType uint8, exts []qtls.Extension) error
2018-11-20 17:51:25 -05:00
}
2018-11-23 11:04:53 -05:00
// CryptoSetup handles the handshake and protecting / unprotecting packets
type CryptoSetup interface {
RunHandshake() error
io.Closer
2018-11-20 17:51:25 -05:00
2018-11-23 11:04:53 -05:00
HandleMessage([]byte, protocol.EncryptionLevel) bool
2018-11-20 17:51:25 -05:00
ConnectionState() ConnectionState
GetSealer() (protocol.EncryptionLevel, Sealer)
GetSealerWithEncryptionLevel(protocol.EncryptionLevel) (Sealer, error)
2019-01-02 07:01:06 -05:00
GetOpener(protocol.EncryptionLevel) (Opener, error)
2018-11-20 17:51:25 -05:00
}
// ConnectionState records basic details about the QUIC connection.
// Warning: This API should not be considered stable and might change soon.
type ConnectionState struct {
HandshakeComplete bool // handshake is complete
ServerName string // server name requested by client, if any (server side only)
PeerCertificates []*x509.Certificate // certificate chain presented by remote peer
}