• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
5package runner
6
7import "strconv"
8
9type alert uint8
10
11const (
12	// alert level
13	alertLevelWarning = 1
14	alertLevelError   = 2
15)
16
17const (
18	alertCloseNotify            alert = 0
19	alertEndOfEarlyData         alert = 1
20	alertUnexpectedMessage      alert = 10
21	alertBadRecordMAC           alert = 20
22	alertDecryptionFailed       alert = 21
23	alertRecordOverflow         alert = 22
24	alertDecompressionFailure   alert = 30
25	alertHandshakeFailure       alert = 40
26	alertNoCertificate          alert = 41
27	alertBadCertificate         alert = 42
28	alertUnsupportedCertificate alert = 43
29	alertCertificateRevoked     alert = 44
30	alertCertificateExpired     alert = 45
31	alertCertificateUnknown     alert = 46
32	alertIllegalParameter       alert = 47
33	alertUnknownCA              alert = 48
34	alertAccessDenied           alert = 49
35	alertDecodeError            alert = 50
36	alertDecryptError           alert = 51
37	alertProtocolVersion        alert = 70
38	alertInsufficientSecurity   alert = 71
39	alertInternalError          alert = 80
40	alertInappropriateFallback  alert = 86
41	alertUserCanceled           alert = 90
42	alertNoRenegotiation        alert = 100
43	alertMissingExtension       alert = 109
44	alertUnsupportedExtension   alert = 110
45	alertUnrecognizedName       alert = 112
46	alertUnknownPSKIdentity     alert = 115
47	alertCertificateRequired    alert = 116
48)
49
50var alertText = map[alert]string{
51	alertCloseNotify:            "close notify",
52	alertEndOfEarlyData:         "end of early data",
53	alertUnexpectedMessage:      "unexpected message",
54	alertBadRecordMAC:           "bad record MAC",
55	alertDecryptionFailed:       "decryption failed",
56	alertRecordOverflow:         "record overflow",
57	alertDecompressionFailure:   "decompression failure",
58	alertHandshakeFailure:       "handshake failure",
59	alertNoCertificate:          "no certificate",
60	alertBadCertificate:         "bad certificate",
61	alertUnsupportedCertificate: "unsupported certificate",
62	alertCertificateRevoked:     "revoked certificate",
63	alertCertificateExpired:     "expired certificate",
64	alertCertificateUnknown:     "unknown certificate",
65	alertIllegalParameter:       "illegal parameter",
66	alertUnknownCA:              "unknown certificate authority",
67	alertAccessDenied:           "access denied",
68	alertDecodeError:            "error decoding message",
69	alertDecryptError:           "error decrypting message",
70	alertProtocolVersion:        "protocol version not supported",
71	alertInsufficientSecurity:   "insufficient security level",
72	alertInternalError:          "internal error",
73	alertInappropriateFallback:  "inappropriate fallback",
74	alertUserCanceled:           "user canceled",
75	alertNoRenegotiation:        "no renegotiation",
76	alertMissingExtension:       "missing extension",
77	alertUnsupportedExtension:   "unsupported extension",
78	alertUnrecognizedName:       "unrecognized name",
79	alertUnknownPSKIdentity:     "unknown PSK identity",
80	alertCertificateRequired:    "certificate required",
81}
82
83func (e alert) String() string {
84	s, ok := alertText[e]
85	if ok {
86		return s
87	}
88	return "alert(" + strconv.Itoa(int(e)) + ")"
89}
90
91func (e alert) Error() string {
92	return e.String()
93}
94