mirror of
https://github.com/cloudflare/cloudflared.git
synced 2025-07-28 12:49:57 +00:00
TUN-4961: Update quic-go to latest
- Updates fips-go to be the latest on cfsetup.yaml - Updates sumtype's x/tools to be latest to avoid Internal: nil pkg errors with fips.
This commit is contained in:
57
vendor/github.com/lucas-clemente/quic-go/internal/qerr/error_codes.go
generated
vendored
57
vendor/github.com/lucas-clemente/quic-go/internal/qerr/error_codes.go
generated
vendored
@@ -6,51 +6,44 @@ import (
|
||||
"github.com/lucas-clemente/quic-go/internal/qtls"
|
||||
)
|
||||
|
||||
// ErrorCode can be used as a normal error without reason.
|
||||
type ErrorCode uint64
|
||||
// TransportErrorCode is a QUIC transport error.
|
||||
type TransportErrorCode uint64
|
||||
|
||||
// The error codes defined by QUIC
|
||||
const (
|
||||
NoError ErrorCode = 0x0
|
||||
InternalError ErrorCode = 0x1
|
||||
ConnectionRefused ErrorCode = 0x2
|
||||
FlowControlError ErrorCode = 0x3
|
||||
StreamLimitError ErrorCode = 0x4
|
||||
StreamStateError ErrorCode = 0x5
|
||||
FinalSizeError ErrorCode = 0x6
|
||||
FrameEncodingError ErrorCode = 0x7
|
||||
TransportParameterError ErrorCode = 0x8
|
||||
ConnectionIDLimitError ErrorCode = 0x9
|
||||
ProtocolViolation ErrorCode = 0xa
|
||||
InvalidToken ErrorCode = 0xb
|
||||
ApplicationError ErrorCode = 0xc
|
||||
CryptoBufferExceeded ErrorCode = 0xd
|
||||
KeyUpdateError ErrorCode = 0xe
|
||||
AEADLimitReached ErrorCode = 0xf
|
||||
NoViablePathError ErrorCode = 0x10
|
||||
NoError TransportErrorCode = 0x0
|
||||
InternalError TransportErrorCode = 0x1
|
||||
ConnectionRefused TransportErrorCode = 0x2
|
||||
FlowControlError TransportErrorCode = 0x3
|
||||
StreamLimitError TransportErrorCode = 0x4
|
||||
StreamStateError TransportErrorCode = 0x5
|
||||
FinalSizeError TransportErrorCode = 0x6
|
||||
FrameEncodingError TransportErrorCode = 0x7
|
||||
TransportParameterError TransportErrorCode = 0x8
|
||||
ConnectionIDLimitError TransportErrorCode = 0x9
|
||||
ProtocolViolation TransportErrorCode = 0xa
|
||||
InvalidToken TransportErrorCode = 0xb
|
||||
ApplicationErrorErrorCode TransportErrorCode = 0xc
|
||||
CryptoBufferExceeded TransportErrorCode = 0xd
|
||||
KeyUpdateError TransportErrorCode = 0xe
|
||||
AEADLimitReached TransportErrorCode = 0xf
|
||||
NoViablePathError TransportErrorCode = 0x10
|
||||
)
|
||||
|
||||
func (e ErrorCode) isCryptoError() bool {
|
||||
func (e TransportErrorCode) IsCryptoError() bool {
|
||||
return e >= 0x100 && e < 0x200
|
||||
}
|
||||
|
||||
func (e ErrorCode) Error() string {
|
||||
if e.isCryptoError() {
|
||||
return fmt.Sprintf("%s: %s", e.String(), e.Message())
|
||||
}
|
||||
return e.String()
|
||||
}
|
||||
|
||||
// Message is a description of the error.
|
||||
// It only returns a non-empty string for crypto errors.
|
||||
func (e ErrorCode) Message() string {
|
||||
if !e.isCryptoError() {
|
||||
func (e TransportErrorCode) Message() string {
|
||||
if !e.IsCryptoError() {
|
||||
return ""
|
||||
}
|
||||
return qtls.Alert(e - 0x100).Error()
|
||||
}
|
||||
|
||||
func (e ErrorCode) String() string {
|
||||
func (e TransportErrorCode) String() string {
|
||||
switch e {
|
||||
case NoError:
|
||||
return "NO_ERROR"
|
||||
@@ -76,7 +69,7 @@ func (e ErrorCode) String() string {
|
||||
return "PROTOCOL_VIOLATION"
|
||||
case InvalidToken:
|
||||
return "INVALID_TOKEN"
|
||||
case ApplicationError:
|
||||
case ApplicationErrorErrorCode:
|
||||
return "APPLICATION_ERROR"
|
||||
case CryptoBufferExceeded:
|
||||
return "CRYPTO_BUFFER_EXCEEDED"
|
||||
@@ -87,7 +80,7 @@ func (e ErrorCode) String() string {
|
||||
case NoViablePathError:
|
||||
return "NO_VIABLE_PATH"
|
||||
default:
|
||||
if e.isCryptoError() {
|
||||
if e.IsCryptoError() {
|
||||
return fmt.Sprintf("CRYPTO_ERROR (%#x)", uint16(e))
|
||||
}
|
||||
return fmt.Sprintf("unknown error code: %#x", uint16(e))
|
||||
|
124
vendor/github.com/lucas-clemente/quic-go/internal/qerr/errors.go
generated
vendored
Normal file
124
vendor/github.com/lucas-clemente/quic-go/internal/qerr/errors.go
generated
vendored
Normal file
@@ -0,0 +1,124 @@
|
||||
package qerr
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
|
||||
"github.com/lucas-clemente/quic-go/internal/protocol"
|
||||
)
|
||||
|
||||
var (
|
||||
ErrHandshakeTimeout = &HandshakeTimeoutError{}
|
||||
ErrIdleTimeout = &IdleTimeoutError{}
|
||||
)
|
||||
|
||||
type TransportError struct {
|
||||
Remote bool
|
||||
FrameType uint64
|
||||
ErrorCode TransportErrorCode
|
||||
ErrorMessage string
|
||||
}
|
||||
|
||||
var _ error = &TransportError{}
|
||||
|
||||
// NewCryptoError create a new TransportError instance for a crypto error
|
||||
func NewCryptoError(tlsAlert uint8, errorMessage string) *TransportError {
|
||||
return &TransportError{
|
||||
ErrorCode: 0x100 + TransportErrorCode(tlsAlert),
|
||||
ErrorMessage: errorMessage,
|
||||
}
|
||||
}
|
||||
|
||||
func (e *TransportError) Error() string {
|
||||
str := e.ErrorCode.String()
|
||||
if e.FrameType != 0 {
|
||||
str += fmt.Sprintf(" (frame type: %#x)", e.FrameType)
|
||||
}
|
||||
msg := e.ErrorMessage
|
||||
if len(msg) == 0 {
|
||||
msg = e.ErrorCode.Message()
|
||||
}
|
||||
if len(msg) == 0 {
|
||||
return str
|
||||
}
|
||||
return str + ": " + msg
|
||||
}
|
||||
|
||||
func (e *TransportError) Is(target error) bool {
|
||||
return target == net.ErrClosed
|
||||
}
|
||||
|
||||
// An ApplicationErrorCode is an application-defined error code.
|
||||
type ApplicationErrorCode uint64
|
||||
|
||||
func (e *ApplicationError) Is(target error) bool {
|
||||
return target == net.ErrClosed
|
||||
}
|
||||
|
||||
// A StreamErrorCode is an error code used to cancel streams.
|
||||
type StreamErrorCode uint64
|
||||
|
||||
type ApplicationError struct {
|
||||
Remote bool
|
||||
ErrorCode ApplicationErrorCode
|
||||
ErrorMessage string
|
||||
}
|
||||
|
||||
var _ error = &ApplicationError{}
|
||||
|
||||
func (e *ApplicationError) Error() string {
|
||||
if len(e.ErrorMessage) == 0 {
|
||||
return fmt.Sprintf("Application error %#x", e.ErrorCode)
|
||||
}
|
||||
return fmt.Sprintf("Application error %#x: %s", e.ErrorCode, e.ErrorMessage)
|
||||
}
|
||||
|
||||
type IdleTimeoutError struct{}
|
||||
|
||||
var _ error = &IdleTimeoutError{}
|
||||
|
||||
func (e *IdleTimeoutError) Timeout() bool { return true }
|
||||
func (e *IdleTimeoutError) Temporary() bool { return false }
|
||||
func (e *IdleTimeoutError) Error() string { return "timeout: no recent network activity" }
|
||||
func (e *IdleTimeoutError) Is(target error) bool { return target == net.ErrClosed }
|
||||
|
||||
type HandshakeTimeoutError struct{}
|
||||
|
||||
var _ error = &HandshakeTimeoutError{}
|
||||
|
||||
func (e *HandshakeTimeoutError) Timeout() bool { return true }
|
||||
func (e *HandshakeTimeoutError) Temporary() bool { return false }
|
||||
func (e *HandshakeTimeoutError) Error() string { return "timeout: handshake did not complete in time" }
|
||||
func (e *HandshakeTimeoutError) Is(target error) bool { return target == net.ErrClosed }
|
||||
|
||||
// A VersionNegotiationError occurs when the client and the server can't agree on a QUIC version.
|
||||
type VersionNegotiationError struct {
|
||||
Ours []protocol.VersionNumber
|
||||
Theirs []protocol.VersionNumber
|
||||
}
|
||||
|
||||
func (e *VersionNegotiationError) Error() string {
|
||||
return fmt.Sprintf("no compatible QUIC version found (we support %s, server offered %s)", e.Ours, e.Theirs)
|
||||
}
|
||||
|
||||
func (e *VersionNegotiationError) Is(target error) bool {
|
||||
return target == net.ErrClosed
|
||||
}
|
||||
|
||||
// A StatelessResetError occurs when we receive a stateless reset.
|
||||
type StatelessResetError struct {
|
||||
Token protocol.StatelessResetToken
|
||||
}
|
||||
|
||||
var _ net.Error = &StatelessResetError{}
|
||||
|
||||
func (e *StatelessResetError) Error() string {
|
||||
return fmt.Sprintf("received a stateless reset with token %x", e.Token)
|
||||
}
|
||||
|
||||
func (e *StatelessResetError) Is(target error) bool {
|
||||
return target == net.ErrClosed
|
||||
}
|
||||
|
||||
func (e *StatelessResetError) Timeout() bool { return false }
|
||||
func (e *StatelessResetError) Temporary() bool { return true }
|
112
vendor/github.com/lucas-clemente/quic-go/internal/qerr/quic_error.go
generated
vendored
112
vendor/github.com/lucas-clemente/quic-go/internal/qerr/quic_error.go
generated
vendored
@@ -1,112 +0,0 @@
|
||||
package qerr
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
)
|
||||
|
||||
// A QuicError consists of an error code plus a error reason
|
||||
type QuicError struct {
|
||||
ErrorCode ErrorCode
|
||||
FrameType uint64 // only valid if this not an application error
|
||||
ErrorMessage string
|
||||
isTimeout bool
|
||||
isApplicationError bool
|
||||
}
|
||||
|
||||
var _ net.Error = &QuicError{}
|
||||
|
||||
// NewError creates a new QuicError instance
|
||||
func NewError(errorCode ErrorCode, errorMessage string) *QuicError {
|
||||
return &QuicError{
|
||||
ErrorCode: errorCode,
|
||||
ErrorMessage: errorMessage,
|
||||
}
|
||||
}
|
||||
|
||||
// NewErrorWithFrameType creates a new QuicError instance for a specific frame type
|
||||
func NewErrorWithFrameType(errorCode ErrorCode, frameType uint64, errorMessage string) *QuicError {
|
||||
return &QuicError{
|
||||
ErrorCode: errorCode,
|
||||
FrameType: frameType,
|
||||
ErrorMessage: errorMessage,
|
||||
}
|
||||
}
|
||||
|
||||
// NewTimeoutError creates a new QuicError instance for a timeout error
|
||||
func NewTimeoutError(errorMessage string) *QuicError {
|
||||
return &QuicError{
|
||||
ErrorMessage: errorMessage,
|
||||
isTimeout: true,
|
||||
}
|
||||
}
|
||||
|
||||
// NewCryptoError create a new QuicError instance for a crypto error
|
||||
func NewCryptoError(tlsAlert uint8, errorMessage string) *QuicError {
|
||||
return &QuicError{
|
||||
ErrorCode: 0x100 + ErrorCode(tlsAlert),
|
||||
ErrorMessage: errorMessage,
|
||||
}
|
||||
}
|
||||
|
||||
// NewApplicationError creates a new QuicError instance for an application error
|
||||
func NewApplicationError(errorCode ErrorCode, errorMessage string) *QuicError {
|
||||
return &QuicError{
|
||||
ErrorCode: errorCode,
|
||||
ErrorMessage: errorMessage,
|
||||
isApplicationError: true,
|
||||
}
|
||||
}
|
||||
|
||||
func (e *QuicError) Error() string {
|
||||
if e.isApplicationError {
|
||||
if len(e.ErrorMessage) == 0 {
|
||||
return fmt.Sprintf("Application error %#x", uint64(e.ErrorCode))
|
||||
}
|
||||
return fmt.Sprintf("Application error %#x: %s", uint64(e.ErrorCode), e.ErrorMessage)
|
||||
}
|
||||
str := e.ErrorCode.String()
|
||||
if e.FrameType != 0 {
|
||||
str += fmt.Sprintf(" (frame type: %#x)", e.FrameType)
|
||||
}
|
||||
msg := e.ErrorMessage
|
||||
if len(msg) == 0 {
|
||||
msg = e.ErrorCode.Message()
|
||||
}
|
||||
if len(msg) == 0 {
|
||||
return str
|
||||
}
|
||||
return str + ": " + msg
|
||||
}
|
||||
|
||||
// IsCryptoError says if this error is a crypto error
|
||||
func (e *QuicError) IsCryptoError() bool {
|
||||
return e.ErrorCode.isCryptoError()
|
||||
}
|
||||
|
||||
// IsApplicationError says if this error is an application error
|
||||
func (e *QuicError) IsApplicationError() bool {
|
||||
return e.isApplicationError
|
||||
}
|
||||
|
||||
// Temporary says if the error is temporary.
|
||||
func (e *QuicError) Temporary() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// Timeout says if this error is a timeout.
|
||||
func (e *QuicError) Timeout() bool {
|
||||
return e.isTimeout
|
||||
}
|
||||
|
||||
// ToQuicError converts an arbitrary error to a QuicError. It leaves QuicErrors
|
||||
// unchanged, and properly handles `ErrorCode`s.
|
||||
func ToQuicError(err error) *QuicError {
|
||||
switch e := err.(type) {
|
||||
case *QuicError:
|
||||
return e
|
||||
case ErrorCode:
|
||||
return NewError(e, "")
|
||||
}
|
||||
return NewError(InternalError, err.Error())
|
||||
}
|
Reference in New Issue
Block a user