cloudflare/cloudflared

Public

mirrored from https://github.com/cloudflare/cloudflaredAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
2019.3.0

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

h2mux/error.go

61lines · modecode

1package h2mux
2
3import (
4 "fmt"
5
6 "golang.org/x/net/http2"
7)
8
9var (
10 ErrHandshakeTimeout = MuxerHandshakeError{"1000 handshake timeout"}
11 ErrBadHandshakeNotSettings = MuxerHandshakeError{"1001 unexpected response"}
12 ErrBadHandshakeUnexpectedAck = MuxerHandshakeError{"1002 unexpected response"}
13 ErrBadHandshakeNoMagic = MuxerHandshakeError{"1003 unexpected response"}
14 ErrBadHandshakeWrongMagic = MuxerHandshakeError{"1004 connected to endpoint of wrong type"}
15 ErrBadHandshakeNotSettingsAck = MuxerHandshakeError{"1005 unexpected response"}
16 ErrBadHandshakeUnexpectedSettings = MuxerHandshakeError{"1006 unexpected response"}
17
18 ErrUnexpectedFrameType = MuxerProtocolError{"2001 unexpected frame type", http2.ErrCodeProtocol}
19 ErrUnknownStream = MuxerProtocolError{"2002 unknown stream", http2.ErrCodeProtocol}
20 ErrInvalidStream = MuxerProtocolError{"2003 invalid stream", http2.ErrCodeProtocol}
21
22 ErrStreamHeadersSent = MuxerApplicationError{"3000 headers already sent"}
23 ErrConnectionClosed = MuxerApplicationError{"3001 connection closed"}
24 ErrConnectionDropped = MuxerApplicationError{"3002 connection dropped"}
25
26 ErrClosedStream = MuxerStreamError{"4000 stream closed", http2.ErrCodeStreamClosed}
27)
28
29type MuxerHandshakeError struct {
30 cause string
31}
32
33func (e MuxerHandshakeError) Error() string {
34 return fmt.Sprintf("Handshake error: %s", e.cause)
35}
36
37type MuxerProtocolError struct {
38 cause string
39 h2code http2.ErrCode
40}
41
42func (e MuxerProtocolError) Error() string {
43 return fmt.Sprintf("Protocol error: %s", e.cause)
44}
45
46type MuxerApplicationError struct {
47 cause string
48}
49
50func (e MuxerApplicationError) Error() string {
51 return fmt.Sprintf("Application error: %s", e.cause)
52}
53
54type MuxerStreamError struct {
55 cause string
56 h2code http2.ErrCode
57}
58
59func (e MuxerStreamError) Error() string {
60 return fmt.Sprintf("Stream error: %s", e.cause)
61}
62