total5 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +211 -0
- package/README.md +32 -0
- package/api.js +297 -0
- package/bin/flow5 +142 -0
- package/bin/total5 +245 -0
- package/builders.js +1770 -0
- package/bundles.js +447 -0
- package/cache.js +58 -0
- package/changelog.txt +5 -0
- package/cluster.js +320 -0
- package/cms.js +759 -0
- package/controller.js +1640 -0
- package/cron.js +99 -0
- package/debug.js +546 -0
- package/edit.js +462 -0
- package/error.html +49 -0
- package/filestorage.js +1109 -0
- package/flow-flowstream.js +3352 -0
- package/flow.js +238 -0
- package/flowstream.js +2061 -0
- package/global.js +274 -0
- package/htmlparser.js +662 -0
- package/http.js +83 -0
- package/image.js +777 -0
- package/images.js +747 -0
- package/index.js +2851 -0
- package/jsonschema.js +699 -0
- package/ldap.js +792 -0
- package/macros.js +222 -0
- package/mail.js +922 -0
- package/markdown.js +762 -0
- package/minificators.js +858 -0
- package/nosql-builder.js +440 -0
- package/nosql-querybuilder.js +320 -0
- package/nosql-reader.js +353 -0
- package/nosql-stream.js +617 -0
- package/nosql.js +782 -0
- package/openclient.js +219 -0
- package/package.json +14 -5
- package/pause.html +67 -0
- package/querybuilder.js +1220 -0
- package/release.js +167 -0
- package/routing.js +1028 -0
- package/sourcemap.js +163 -0
- package/tangular.js +409 -0
- package/templates.js +145 -0
- package/test.js +51 -0
- package/tms.js +380 -0
- package/uibuilder.js +242 -0
- package/utils.js +6432 -0
- package/viewengine.js +891 -0
- package/websocket.js +1944 -0
- package/workers.js +129 -0
package/http.js
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
// Total.js HTTP Server handler
|
|
2
|
+
// The MIT License
|
|
3
|
+
// Copyright 2023 (c) Peter Širka <petersirka@gmail.com>
|
|
4
|
+
|
|
5
|
+
'use strict';
|
|
6
|
+
|
|
7
|
+
const TController = require('./controller');
|
|
8
|
+
|
|
9
|
+
exports.listen = function(req, res) {
|
|
10
|
+
|
|
11
|
+
// req.ip
|
|
12
|
+
// req.headers
|
|
13
|
+
// req.url
|
|
14
|
+
// req.method
|
|
15
|
+
// req.on('data', function(chunk))
|
|
16
|
+
// req.destroy()
|
|
17
|
+
|
|
18
|
+
// res.writeHead(status, headers)
|
|
19
|
+
// res.pipe();
|
|
20
|
+
// res.write();
|
|
21
|
+
// res.end()
|
|
22
|
+
|
|
23
|
+
F.stats.request.request++;
|
|
24
|
+
|
|
25
|
+
// Not supported
|
|
26
|
+
if (req.method === 'HEAD') {
|
|
27
|
+
F.stats.request.blocked++;
|
|
28
|
+
req.destroy();
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
var ctrl = new TController.Controller(req, res);
|
|
33
|
+
|
|
34
|
+
if (F.paused.length) {
|
|
35
|
+
ctrl.fallback(999);
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (F.config.$blacklist && F.config.$blacklist.indexOf(ctrl.ip) !== -1) {
|
|
40
|
+
F.stats.request.blocked++;
|
|
41
|
+
ctrl.fallback(400, 'IP address is blocked');
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (F.config.$httpreqlimit) {
|
|
46
|
+
if (F.temporary.ddos[ctrl.ip] > F.config.$httpreqlimit) {
|
|
47
|
+
F.stats.response.ddos++;
|
|
48
|
+
ctrl.fallback(503);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
if (F.temporary.ddos[ctrl.ip])
|
|
52
|
+
F.temporary.ddos[ctrl.ip]++;
|
|
53
|
+
else
|
|
54
|
+
F.temporary.ddos[ctrl.ip] = 1;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (F.routes.proxies.length && F.TRouting.lookupproxy(ctrl))
|
|
58
|
+
return;
|
|
59
|
+
|
|
60
|
+
if (F.routes.virtual[ctrl.url]) {
|
|
61
|
+
F.routes.virtual[ctrl.url](ctrl);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Pending requests
|
|
66
|
+
F.temporary.pending.push(ctrl);
|
|
67
|
+
|
|
68
|
+
if (ctrl.headers.origin && (F.def.onCORS || F.config.$cors)) {
|
|
69
|
+
if (F.TRouting.lookupcors(ctrl))
|
|
70
|
+
ctrl.$route();
|
|
71
|
+
} else
|
|
72
|
+
ctrl.$route();
|
|
73
|
+
|
|
74
|
+
// stream.headers
|
|
75
|
+
// stream.url
|
|
76
|
+
|
|
77
|
+
// respond(opt);
|
|
78
|
+
// opt.status = 200;
|
|
79
|
+
// opt.headers = {};
|
|
80
|
+
// opt.stream = '';
|
|
81
|
+
// opt.end = '';
|
|
82
|
+
|
|
83
|
+
};
|