| 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 runner |
| 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 |
alertNoCertficate alert = 41 |
| 26 |
alertBadCertificate alert = 42 |
| 27 |
alertUnsupportedCertificate alert = 43 |
| 28 |
alertCertificateRevoked alert = 44 |
| 29 |
alertCertificateExpired alert = 45 |
| 30 |
alertCertificateUnknown alert = 46 |
| 31 |
alertIllegalParameter alert = 47 |
| 32 |
alertUnknownCA alert = 48 |
| 33 |
alertAccessDenied alert = 49 |
| 34 |
alertDecodeError alert = 50 |
| 35 |
alertDecryptError alert = 51 |
| 36 |
alertProtocolVersion alert = 70 |
| 37 |
alertInsufficientSecurity alert = 71 |
| 38 |
alertInternalError alert = 80 |
| 39 |
alertUserCanceled alert = 90 |
| 40 |
alertNoRenegotiation alert = 100 |
| 41 |
) |
| 42 |
|
| 43 |
var alertText = map[alert]string{ |
| 44 |
alertCloseNotify: "close notify", |
| 45 |
alertUnexpectedMessage: "unexpected message", |
| 46 |
alertBadRecordMAC: "bad record MAC", |
| 47 |
alertDecryptionFailed: "decryption failed", |
| 48 |
alertRecordOverflow: "record overflow", |
| 49 |
alertDecompressionFailure: "decompression failure", |
| 50 |
alertHandshakeFailure: "handshake failure", |
| 51 |
alertBadCertificate: "bad certificate", |
| 52 |
alertUnsupportedCertificate: "unsupported certificate", |
| 53 |
alertCertificateRevoked: "revoked certificate", |
| 54 |
alertCertificateExpired: "expired certificate", |
| 55 |
alertCertificateUnknown: "unknown certificate", |
| 56 |
alertIllegalParameter: "illegal parameter", |
| 57 |
alertUnknownCA: "unknown certificate authority", |
| 58 |
alertAccessDenied: "access denied", |
| 59 |
alertDecodeError: "error decoding message", |
| 60 |
alertDecryptError: "error decrypting message", |
| 61 |
alertProtocolVersion: "protocol version not supported", |
| 62 |
alertInsufficientSecurity: "insufficient security level", |
| 63 |
alertInternalError: "internal error", |
| 64 |
alertUserCanceled: "user canceled", |
| 65 |
alertNoRenegotiation: "no renegotiation", |
| 66 |
} |
| 67 |
|
| 68 |
func (e alert) String() string { |
| 69 |
s, ok := alertText[e] |
| 70 |
if ok { |
| 71 |
return s |
| 72 |
} |
| 73 |
return "alert(" + strconv.Itoa(int(e)) + ")" |
| 74 |
} |
| 75 |
|
| 76 |
func (e alert) Error() string { |
| 77 |
return e.String() |
| 78 |
} |