-
Notifications
You must be signed in to change notification settings - Fork 1
/
consts.go
238 lines (224 loc) · 8.53 KB
/
consts.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
// Copyright 2021 fangyousong(方友松). All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package paddy
import "github.com/truexf/goutil"
var (
ErrorNoError = goutil.NewError(ErrCodeNoError, "")
DefaultBackendMaxIdleConn = 10
DefaultBackendWaitResponseTimeout = 2000
DefaultBackendConnTimeout = 3000
AllMethods = []string{MethodRandom, MethodRoundrobin, MethodMinPending, MethodIpHash, MethodUrlParam}
)
const (
// for restart
EnvVarInheritedListenerHttp = "inherited_listener_http"
EnvVarInheritedListenerTcp = "inherited_listener_tcp"
ContextVarResponseFilter = "__response_filter__"
// can use in location_regexp.proxy_pass
MacroBackend = "{{backend}}"
MacroDomain = "{{domain}}"
MacroHost = "{{host}}"
MacroPort = "{{port}}"
MacroURI = "{{uri}}"
MacroPath = "{{path}}"
MacroParams = "{{params}}"
)
const (
ErrCodeNoError = 0
ErrCodeConfigNotExist = 100
ErrMsgConfigNotExist = "config file %s not exist"
ErrCodeConfigReadFail = 101
ErrMsgConfigReadFail = "config file %s read fail, %s"
ErrCodeCfgItemInvalid = 102
ErrMsgCfgItemInvalid = "config item: %s is invalid"
ErrCodeCfgItem2Invalid = 103
ErrMsgCfgItem2Invalid = "config item: %s.%s is invalid"
ErrCodeNewBackendGroupFail = 104
ErrMsgNewBackendGroupFail = "new backend group fail, %s"
ErrCodeNewBackendDefFail = 105
ErrMsgNewBackendDefFail = "new backend def fail, %s"
ErrCodeBackendGroupDup = 106
ErrMsgBackendGroupDup = "backend group: %s duplicated"
ErrCodeBackendDefDup = 107
ErrMsgBackendDefDup = "backend def: %s duplicated"
ErrCodeNewServerFail = 108
ErrMsgNewServerFail = "new server fail, %s"
ErrCodeListenPortDup = 109
ErrMsgListenPortDup = "listen port: %d duplicated"
ErrCodeHostDup = 110
ErrMsgHostDup = "host: %s duplicated"
ErrCodeCfgItem3Invalid = 111
ErrMsgCfgItem3Invalid = "config item: %s.%s.%s is invalid"
ErrCodeListenFail = 112
ErrCodePluginDup = 113
ErrMsgPluginDup = "plugin %s duplicated"
ErrCodeDemo = 114
ErrMsgDemo = "demo error %s"
ErrCodeJsonexpExecute = 115
ErrMsgJsonexpExecute = "execute jsonexp fail, %s"
ErrCodeBackendNotFound = 116
ErrMsgBackendNotFound = "backend %s not found"
ErrCodeBackendRequestFail = 117
ErrMsgBackendRequestFail = "backend %s request fail, %s"
ErrCodeCommonError = 118
ErrCodeNewUpstream = 119
ErrMsgNewUpstream = "new upstream fail, %s"
ErrCodeUpstreamDup = 120
ErrMsgUpstreamDup = "upstream: %s duplicated"
ErrCodeNewTcpServerFail = 121
ErrMsgNewTcpServerFail = "new tcp server fail, %s"
)
const (
MethodRoundrobin = "roundrobin"
MethodMinPending = "minpending"
MethodRandom = "random"
MethodIpHash = "iphash"
MethodUrlParam = "uri_param"
)
const (
CfgPidFile = "pid_file"
CfgLogDir = "log_dir"
CfgLogLevel = "log_level"
CfgInclude = "include"
CfgUpstream = "upstream"
CfgUpstreamAlias = "alias"
CfgUpstreamMethod = "method"
CfgUpstreamBackendList = "backend_list"
CfgUpstreamConnTimeout = "connect_timeout"
CfgBackendGroup = "backend_group"
CfgBackendDef = "backend_def"
CfgBackendDefAlias = "alias"
CfgBackendDefGroupList = "group_list"
CfgBackendDefBackendList = "backend_list"
CfgBackendDefBackendMethend = "method"
CfgBackendDefBackendParamkey = "param_key"
CfgBackendDefJsonexp = "jsonexp"
CfgBackendDefMaxIdleConn = "max_idle_conn"
CfgBackendDefWaitResponseTimeout = "wait_response_timeout"
CfgServer = "server"
CfgServerListen = "listen"
CfgServerHosts = "hosts"
CfgServerTlsCert = "tls_cert"
CfgServerTlsCertKey = "tls_cert_key"
CfgServerSessionTimeout = "tls_cert_session_timeout"
CfgServerLocationRegexp = "location_regexp"
CfgServerLocationRegexpExp = "exp"
CfgServerLocationRegexpFileRoot = "file_root"
CfgServerLocationRegexpBackend = "backend"
CfgServerLocationRegexpProxyPass = "proxy_pass"
CfgServerLocationRegexpRequestFilter = "request_filter"
CfgServerLocationRegexpResponseFilter = "response_filter"
CfgServerLocationJsonexp = "location_jsonexp"
CfgServerLocationJsonexpExp = "exp"
CfgServerLocationJsonexpRequestFilter = "request_filter"
CfgServerLocationJsonexpResponseFilter = "response_filter"
CfgTcpServer = "tcp_server"
CfgTcpServerListen = "listen"
CfgTcpServerUpstream = "upstream"
)
var MimeTypeMap map[string]string = map[string]string{
"3gp": "video/3gpp",
"3gpp": "video/3gpp",
"7z": "application/x-7z-compressed",
"ai": "application/postscript",
"asf": "video/x-ms-asf",
"asx": "video/x-ms-asf",
"atom": "application/atom+xml",
"avi": "video/x-msvideo",
"bin": "application/octet-stream",
"bmp": "image/x-ms-bmp",
"cco": "application/x-cocoa",
"crt": "application/x-x509-ca-cert",
"css": "text/css",
"deb": "application/octet-stream",
"der": "application/x-x509-ca-cert",
"dll": "application/octet-stream",
"dmg": "application/octet-stream",
"doc": "application/msword",
"docx": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"ear": "application/java-archive",
"eot": "application/vnd.ms-fontobject",
"eps": "application/postscript",
"exe": "application/octet-stream",
"flv": "video/x-flv",
"gif": "image/gif",
"hqx": "application/mac-binhex40",
"htc": "text/x-component",
"htm": "text/html",
"html": "text/html",
"ico": "image/x-icon",
"img": "application/octet-stream",
"iso": "application/octet-stream",
"jad": "text/vnd.sun.j2me.app-descriptor",
"jar": "application/java-archive",
"jardiff": "application/x-java-archive-diff",
"jng": "image/x-jng",
"jnlp": "application/x-java-jnlp-file",
"jpeg": "image/jpeg",
"jpg": "image/jpeg",
"js": "application/javascript",
"json": "application/json",
"kar": "audio/midi",
"kml": "application/vnd.google-earth.kml+xml",
"kmz": "application/vnd.google-earth.kmz",
"m3u8": "application/vnd.apple.mpegurl",
"m4a": "audio/x-m4a",
"m4v": "video/x-m4v",
"mid": "audio/midi",
"midi": "audio/midi",
"mml": "text/mathml",
"mng": "video/x-mng",
"mov": "video/quicktime",
"mp3": "audio/mpeg",
"mp4": "video/mp4",
"mpeg": "video/mpeg",
"mpg": "video/mpeg",
"msi": "application/octet-stream",
"msm": "application/octet-stream",
"msp": "application/octet-stream",
"ogg": "audio/ogg",
"pdb": "application/x-pilot",
"pdf": "application/pdf",
"pem": "application/x-x509-ca-cert",
"pl": "application/x-perl",
"pm": "application/x-perl",
"png": "image/png",
"ppt": "application/vnd.ms-powerpoint",
"pptx": "application/vnd.openxmlformats-officedocument.presentationml.presentation",
"prc": "application/x-pilot",
"ps": "application/postscript",
"ra": "audio/x-realaudio",
"rar": "application/x-rar-compressed",
"rpm": "application/x-redhat-package-manager",
"rss": "application/rss+xml",
"rtf": "application/rtf",
"run": "application/x-makeself",
"sea": "application/x-sea",
"shtml": "text/html",
"sit": "application/x-stuffit",
"svg": "image/svg+xml",
"svgz": "image/svg+xml",
"swf": "application/x-shockwave-flash",
"tcl": "application/x-tcl",
"tif": "image/tiff",
"tiff": "image/tiff",
"tk": "application/x-tcl",
"ts": "video/mp2t",
"txt": "text/plain",
"war": "application/java-archive",
"wbmp": "image/vnd.wap.wbmp",
"webm": "video/webm",
"webp": "image/webp",
"wml": "text/vnd.wap.wml",
"wmlc": "application/vnd.wap.wmlc",
"wmv": "video/x-ms-wmv",
"woff": "application/font-woff",
"xhtml": "application/xhtml+xml",
"xls": "application/vnd.ms-excel",
"xlsx": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"xml": "text/xml",
"xpi": "application/x-xpinstall",
"xspf": "application/xspf+xml",
"zip": "application/zip",
}