Source File
alert.go
Belonging Package
github.com/pion/dtls/v3/pkg/protocol/alert
// SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>// SPDX-License-Identifier: MIT// Package alert implements TLS alert protocol https://tools.ietf.org/html/rfc5246#section-7.2package alertimport ()var errBufferTooSmall = &protocol.TemporaryError{Err: errors.New("buffer is too small")} //nolint:goerr113// Level is the level of the TLS Alert.type Level byte// Level enums.const (Warning Level = 1Fatal Level = 2)func ( Level) () string {switch {case Warning:return "Warning"case Fatal:return "Fatal"default:return "Invalid alert level"}}// Description is the extended info of the TLS Alert.type Description byte// Description enums.const (CloseNotify Description = 0UnexpectedMessage Description = 10BadRecordMac Description = 20DecryptionFailed Description = 21RecordOverflow Description = 22DecompressionFailure Description = 30HandshakeFailure Description = 40NoCertificate Description = 41BadCertificate Description = 42UnsupportedCertificate Description = 43CertificateRevoked Description = 44CertificateExpired Description = 45CertificateUnknown Description = 46IllegalParameter Description = 47UnknownCA Description = 48AccessDenied Description = 49DecodeError Description = 50DecryptError Description = 51ExportRestriction Description = 60ProtocolVersion Description = 70InsufficientSecurity Description = 71InternalError Description = 80UserCanceled Description = 90NoRenegotiation Description = 100UnsupportedExtension Description = 110NoApplicationProtocol Description = 120)func ( Description) () string { //nolint:cyclopswitch {case CloseNotify:return "CloseNotify"case UnexpectedMessage:return "UnexpectedMessage"case BadRecordMac:return "BadRecordMac"case DecryptionFailed:return "DecryptionFailed"case RecordOverflow:return "RecordOverflow"case DecompressionFailure:return "DecompressionFailure"case HandshakeFailure:return "HandshakeFailure"case NoCertificate:return "NoCertificate"case BadCertificate:return "BadCertificate"case UnsupportedCertificate:return "UnsupportedCertificate"case CertificateRevoked:return "CertificateRevoked"case CertificateExpired:return "CertificateExpired"case CertificateUnknown:return "CertificateUnknown"case IllegalParameter:return "IllegalParameter"case UnknownCA:return "UnknownCA"case AccessDenied:return "AccessDenied"case DecodeError:return "DecodeError"case DecryptError:return "DecryptError"case ExportRestriction:return "ExportRestriction"case ProtocolVersion:return "ProtocolVersion"case InsufficientSecurity:return "InsufficientSecurity"case InternalError:return "InternalError"case UserCanceled:return "UserCanceled"case NoRenegotiation:return "NoRenegotiation"case UnsupportedExtension:return "UnsupportedExtension"case NoApplicationProtocol:return "NoApplicationProtocol"default:return "Invalid alert description"}}// Alert is one of the content types supported by the TLS record layer.// Alert messages convey the severity of the message// (warning or fatal) and a description of the alert. Alert messages// with a level of fatal result in the immediate termination of the// connection. In this case, other connections corresponding to the// session may continue, but the session identifier MUST be invalidated,// preventing the failed session from being used to establish new// connections. Like other messages, alert messages are encrypted and// compressed, as specified by the current connection state.// https://tools.ietf.org/html/rfc5246#section-7.2type Alert struct {Level LevelDescription Description}// ContentType returns the ContentType of this Content.func ( Alert) () protocol.ContentType {return protocol.ContentTypeAlert}// Marshal returns the encoded alert.func ( *Alert) () ([]byte, error) {return []byte{byte(.Level), byte(.Description)}, nil}// Unmarshal populates the alert from binary data.func ( *Alert) ( []byte) error {if len() != 2 {return errBufferTooSmall}.Level = Level([0]).Description = Description([1])return nil}func ( *Alert) () string {return fmt.Sprintf("Alert %s: %s", .Level, .Description)}
![]() |
The pages are generated with Golds v0.8.2. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |