| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
package mint |
| 6 |
|
| 7 |
import "strconv" |
| 8 |
|
| 9 |
type Alert uint8 |
| 10 |
|
| 11 |
const ( |
| 12 |
|
| 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 |
AlertCertificateUnobtainable Alert = 111 |
| 44 |
AlertUnrecognizedName Alert = 112 |
| 45 |
AlertBadCertificateStatsResponse Alert = 113 |
| 46 |
AlertBadCertificateHashValue Alert = 114 |
| 47 |
AlertUnknownPSKIdentity Alert = 115 |
| 48 |
AlertNoApplicationProtocol Alert = 120 |
| 49 |
AlertStatelessRetry Alert = 253 |
| 50 |
AlertWouldBlock Alert = 254 |
| 51 |
AlertNoAlert Alert = 255 |
| 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 |
AlertMissingExtension: "missing extension", |
| 78 |
AlertUnsupportedExtension: "unsupported extension", |
| 79 |
AlertCertificateUnobtainable: "certificate unobtainable", |
| 80 |
AlertUnrecognizedName: "unrecognized name", |
| 81 |
AlertBadCertificateStatsResponse: "bad certificate status response", |
| 82 |
AlertBadCertificateHashValue: "bad certificate hash value", |
| 83 |
AlertUnknownPSKIdentity: "unknown PSK identity", |
| 84 |
AlertNoApplicationProtocol: "no application protocol", |
| 85 |
AlertNoRenegotiation: "no renegotiation", |
| 86 |
AlertStatelessRetry: "stateless retry", |
| 87 |
AlertWouldBlock: "would have blocked", |
| 88 |
AlertNoAlert: "no alert", |
| 89 |
} |
| 90 |
|
| 91 |
func (e Alert) String() string { |
| 92 |
s, ok := alertText[e] |
| 93 |
if ok { |
| 94 |
return s |
| 95 |
} |
| 96 |
return "alert(" + strconv.Itoa(int(e)) + ")" |
| 97 |
} |
| 98 |
|
| 99 |
func (e Alert) Error() string { |
| 100 |
return e.String() |
| 101 |
} |