github.com/bigzoro/my_simplechain@v0.0.0-20240315012955-8ad0a2a29bb9/core/access_contoller/crypto/tls/alert.go (about)

     1  // Copyright 2009 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package tls
     6  
     7  import "strconv"
     8  
     9  type alert uint8
    10  
    11  const (
    12  	// alert level
    13  	alertLevelWarning = 1
    14  	alertLevelError   = 2
    15  )
    16  
    17  const (
    18  	alertCloseNotify            alert = 0
    19  	alertUnexpectedMessage      alert = 10
    20  	alertBadRecordMAC           alert = 20
    21  	alertDecryptionFailed       alert = 21
    22  	alertRecordOverflow         alert = 22
    23  	alertDecompressionFailure   alert = 30
    24  	alertHandshakeFailure       alert = 40
    25  	alertBadCertificate         alert = 42
    26  	alertUnsupportedCertificate alert = 43
    27  	alertCertificateRevoked     alert = 44
    28  	alertCertificateExpired     alert = 45
    29  	alertCertificateUnknown     alert = 46
    30  	alertIllegalParameter       alert = 47
    31  	alertUnknownCA              alert = 48
    32  	alertAccessDenied           alert = 49
    33  	alertDecodeError            alert = 50
    34  	alertDecryptError           alert = 51
    35  	alertProtocolVersion        alert = 70
    36  	alertInsufficientSecurity   alert = 71
    37  	alertInternalError          alert = 80
    38  	alertInappropriateFallback  alert = 86
    39  	alertUserCanceled           alert = 90
    40  	alertNoRenegotiation        alert = 100
    41  	alertMissingExtension       alert = 109
    42  	alertUnsupportedExtension   alert = 110
    43  	alertUnrecognizedName       alert = 112
    44  	alertNoApplicationProtocol  alert = 120
    45  	//GMT0024
    46  	alertUnsupporttedSite2Site alert = 200
    47  	alertNoArea                alert = 201
    48  	alertUnsupportedAreaType   alert = 202
    49  	alertBadIBCParam           alert = 203
    50  	alertUnsupportedIBCParam   alert = 204
    51  	alertIdentityNeed          alert = 205
    52  )
    53  
    54  var alertText = map[alert]string{
    55  	alertCloseNotify:            "close notify",
    56  	alertUnexpectedMessage:      "unexpected message",
    57  	alertBadRecordMAC:           "bad record MAC",
    58  	alertDecryptionFailed:       "decryption failed",
    59  	alertRecordOverflow:         "record overflow",
    60  	alertDecompressionFailure:   "decompression failure",
    61  	alertHandshakeFailure:       "handshake failure",
    62  	alertBadCertificate:         "bad certificate",
    63  	alertUnsupportedCertificate: "unsupported certificate",
    64  	alertCertificateRevoked:     "revoked certificate",
    65  	alertCertificateExpired:     "expired certificate",
    66  	alertCertificateUnknown:     "unknown certificate",
    67  	alertIllegalParameter:       "illegal parameter",
    68  	alertUnknownCA:              "unknown certificate authority",
    69  	alertAccessDenied:           "access denied",
    70  	alertDecodeError:            "error decoding message",
    71  	alertDecryptError:           "error decrypting message",
    72  	alertProtocolVersion:        "protocol version not supported",
    73  	alertInsufficientSecurity:   "insufficient security level",
    74  	alertInternalError:          "internal error",
    75  	alertInappropriateFallback:  "inappropriate fallback",
    76  	alertUserCanceled:           "user canceled",
    77  	alertNoRenegotiation:        "no renegotiation",
    78  	alertMissingExtension:       "missing extension",
    79  	alertUnsupportedExtension:   "unsupported extension",
    80  	alertUnrecognizedName:       "unrecognized name",
    81  	alertNoApplicationProtocol:  "no application protocol",
    82  	//GMT0024
    83  	alertUnsupporttedSite2Site: "unsupported site2site",
    84  	alertNoArea:                "no area",
    85  	alertUnsupportedAreaType:   "unsupported area type",
    86  	alertBadIBCParam:           "bad ibc param",
    87  	alertUnsupportedIBCParam:   "unsupport ibc param",
    88  	alertIdentityNeed:          "need ibc identity",
    89  }
    90  
    91  func (e alert) String() string {
    92  	s, ok := alertText[e]
    93  	if ok {
    94  		return "tls: " + s
    95  	}
    96  	return "tls: alert(" + strconv.Itoa(int(e)) + ")"
    97  }
    98  
    99  func (e alert) Error() string {
   100  	return e.String()
   101  }