isite 2024.8.7 → 2024.8.10
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/apps/client-side/site_files/css/bootstrap5-addon.css +30 -6
- package/apps/client-side/site_files/css/dropdown.css +62 -60
- package/apps/client-side/site_files/html/directive/i-list.html +5 -7
- package/apps/client-side/site_files/html/directive-core/i-list.html +1 -1
- package/apps/client-side/site_files/js/bootstrap-5-directive.js +26 -11
- package/apps/client-side/site_files/js/directive-core.js +8 -8
- package/apps/client-side/site_files/js/directive.js +2 -2
- package/apps/client-side/site_files/js/site.js +2 -2
- package/index.js +7 -6
- package/lib/proxy.js +83 -0
- package/lib/routing.js +33 -22
- package/lib/ws.js +93 -99
- package/object-options/index.js +11 -5
- package/package.json +1 -1
- package/proxy.js +131 -0
|
@@ -36,15 +36,22 @@ body {
|
|
|
36
36
|
.container {
|
|
37
37
|
max-width: 100%;
|
|
38
38
|
}
|
|
39
|
-
.ar .form-check .form-check-input
|
|
39
|
+
.ar .form-check .form-check-input,
|
|
40
|
+
.AR .form-check .form-check-input {
|
|
40
41
|
float: right;
|
|
41
42
|
margin-right: -1.5em;
|
|
42
43
|
}
|
|
44
|
+
.form-label {
|
|
45
|
+
margin-bottom: 0.5rem;
|
|
46
|
+
margin-left: 5px;
|
|
47
|
+
border-bottom: 1px solid #00000061;
|
|
48
|
+
}
|
|
43
49
|
label {
|
|
44
50
|
float: left;
|
|
45
51
|
color: var(--label-color);
|
|
46
52
|
}
|
|
47
|
-
.ar label
|
|
53
|
+
.ar label,
|
|
54
|
+
.AR label {
|
|
48
55
|
float: right;
|
|
49
56
|
}
|
|
50
57
|
fieldset {
|
|
@@ -67,7 +74,8 @@ fieldset legend {
|
|
|
67
74
|
width: auto;
|
|
68
75
|
padding: 5px;
|
|
69
76
|
}
|
|
70
|
-
.ar fieldset legend
|
|
77
|
+
.ar fieldset legend,
|
|
78
|
+
.AR fieldset legend {
|
|
71
79
|
float: right;
|
|
72
80
|
}
|
|
73
81
|
legend::after {
|
|
@@ -105,6 +113,7 @@ i-button button {
|
|
|
105
113
|
margin: 5px !important;
|
|
106
114
|
margin-top: 30px !important;
|
|
107
115
|
padding: 7px 9px !important;
|
|
116
|
+
max-height: 40px;
|
|
108
117
|
}
|
|
109
118
|
i-button.default button {
|
|
110
119
|
margin: 3px;
|
|
@@ -129,7 +138,7 @@ i-file i-button {
|
|
|
129
138
|
i-upload {
|
|
130
139
|
display: contents;
|
|
131
140
|
}
|
|
132
|
-
i-upload form{
|
|
141
|
+
i-upload form {
|
|
133
142
|
display: inline-block;
|
|
134
143
|
}
|
|
135
144
|
i-date .left-10,
|
|
@@ -181,7 +190,21 @@ i-datetime input {
|
|
|
181
190
|
width: 100%;
|
|
182
191
|
}
|
|
183
192
|
.dropdown-content {
|
|
184
|
-
|
|
193
|
+
display: none;
|
|
194
|
+
position: absolute;
|
|
195
|
+
top: 30px !important;
|
|
196
|
+
background-color: #ffffff;
|
|
197
|
+
width: 100%;
|
|
198
|
+
box-shadow: 0px 20px 16px 16px rgb(0 0 0);
|
|
199
|
+
z-index: 999;
|
|
200
|
+
max-height: 75vh;
|
|
201
|
+
min-height: 20%;
|
|
202
|
+
padding: 0px;
|
|
203
|
+
margin: 0;
|
|
204
|
+
scroll-behavior: auto;
|
|
205
|
+
overflow: auto;
|
|
206
|
+
border: 5px solid #6b6868;
|
|
207
|
+
transition: all 0.2s ease;
|
|
185
208
|
}
|
|
186
209
|
.v-tabs .nav-link {
|
|
187
210
|
color: #aaa !important;
|
|
@@ -213,7 +236,8 @@ i-datetime input {
|
|
|
213
236
|
transform: translateY(-50%);
|
|
214
237
|
opacity: 0;
|
|
215
238
|
}
|
|
216
|
-
.ar .v-tabs .nav-link::before
|
|
239
|
+
.ar .v-tabs .nav-link::before,
|
|
240
|
+
.AR .v-tabs .nav-link::before {
|
|
217
241
|
border-right: 10px solid #fff;
|
|
218
242
|
left: -10px;
|
|
219
243
|
}
|
|
@@ -1,87 +1,89 @@
|
|
|
1
1
|
/* The container <div> - needed to position the dropdown content */
|
|
2
2
|
.dropdown {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
position: relative;
|
|
4
|
+
display: inline-block;
|
|
5
|
+
width: 100%;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
/* Dropdown Content (Hidden by Default) */
|
|
9
9
|
.dropdown-content {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
10
|
+
display: none;
|
|
11
|
+
position: absolute;
|
|
12
|
+
top: 40px;
|
|
13
|
+
background-color: #ffffff;
|
|
14
|
+
width: 100%;
|
|
15
|
+
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
|
|
16
|
+
z-index: 999;
|
|
17
|
+
max-height: 50vh;
|
|
18
|
+
padding: 0px;
|
|
19
|
+
scroll-behavior: auto;
|
|
20
|
+
overflow: auto;
|
|
21
|
+
border: 1px solid var(--theme-color);
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
.dropdown .dropdown-search{
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
.dropdown .dropdown-search {
|
|
25
|
+
padding: 5px;
|
|
26
|
+
position: sticky;
|
|
27
|
+
top: 0;
|
|
28
|
+
background: #eee;
|
|
29
29
|
}
|
|
30
|
+
.dropdown .dropdown-search i-control {
|
|
31
|
+
display: inline-block;
|
|
32
|
+
width: 85%;
|
|
33
|
+
}
|
|
34
|
+
.dropdown .dropdown-search i-button button {
|
|
35
|
+
margin-top: 10px !important;
|
|
36
|
+
}
|
|
37
|
+
|
|
30
38
|
/* Links inside the dropdown */
|
|
31
39
|
.dropdown-content p {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
40
|
+
color: black;
|
|
41
|
+
background-color: #ffffff;
|
|
42
|
+
padding: 12px 16px;
|
|
43
|
+
text-decoration: none;
|
|
44
|
+
display: block;
|
|
37
45
|
}
|
|
38
46
|
|
|
39
47
|
/* Change color of dropdown links on hover */
|
|
40
48
|
.dropdown-content .dropdown-item:hover {
|
|
41
|
-
|
|
42
|
-
color: #fff;
|
|
43
|
-
}
|
|
44
|
-
.dropdown-content .dropdown-item:hover p,
|
|
45
|
-
.dropdown-content .dropdown-item:hover small {
|
|
46
|
-
color: #fff;
|
|
49
|
+
background-color: #bbbbbb;
|
|
47
50
|
}
|
|
51
|
+
|
|
48
52
|
/* Show the dropdown menu on hover */
|
|
49
53
|
.dropdown:hover .dropdown-content {
|
|
50
|
-
|
|
54
|
+
display: block;
|
|
51
55
|
}
|
|
52
56
|
|
|
53
|
-
.dropdown-text:hover > .dropdown-content {
|
|
54
|
-
display: block;
|
|
55
|
-
}
|
|
56
57
|
|
|
57
|
-
.dropdown-item {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
58
|
+
i-list .dropdown-item {
|
|
59
|
+
display: inline-block !important;
|
|
60
|
+
cursor: pointer;
|
|
61
|
+
background: var(--dropdown-background);
|
|
62
|
+
padding: 0px !important;
|
|
63
|
+
margin: 0px !important;
|
|
64
|
+
transition: all 0.1s ease;
|
|
65
|
+
border-bottom: 1px solid #ddd !important;
|
|
64
66
|
}
|
|
65
67
|
.dropdown-item p {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
68
|
+
color: var(--color);
|
|
69
|
+
font-size: 16px;
|
|
70
|
+
font-weight: bold;
|
|
71
|
+
background: transparent;
|
|
72
|
+
text-align: center;
|
|
73
|
+
padding: 0;
|
|
71
74
|
}
|
|
72
|
-
.ar .dropdown-item p
|
|
73
|
-
|
|
75
|
+
.ar .dropdown-item p,
|
|
76
|
+
.AR .dropdown-item p {
|
|
77
|
+
text-align: right;
|
|
74
78
|
}
|
|
75
|
-
.dropdown-item small {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
font-weight: bold;
|
|
82
|
-
padding-right: 9px;
|
|
83
|
-
padding-left: 9px;
|
|
79
|
+
.dropdown-item .small {
|
|
80
|
+
color: #000000;
|
|
81
|
+
font-size: 12px;
|
|
82
|
+
text-align: center;
|
|
83
|
+
font-weight: bold;
|
|
84
|
+
padding: 0;
|
|
84
85
|
}
|
|
85
|
-
.ar .dropdown-item small
|
|
86
|
-
|
|
86
|
+
.ar .dropdown-item .small,
|
|
87
|
+
.AR .dropdown-item small {
|
|
88
|
+
text-align: right;
|
|
87
89
|
}
|
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
<div class="dropdown i-list">
|
|
2
2
|
<div class="mb-3 {{class2}}">
|
|
3
3
|
<label class="form-label"> <span class="red bold"> {{requird}} </span> {{label}} </label>
|
|
4
|
-
<input
|
|
4
|
+
<input class="full-width text dropdown-text form-control {{css}}" ng-disabled="disabled" v="{{v}}" readonly ng-model="ngModel.$display" />
|
|
5
5
|
</div>
|
|
6
6
|
|
|
7
7
|
<div class="dropdown-content">
|
|
8
8
|
<div class="dropdown-search" ng-show="showSearch">
|
|
9
|
-
<
|
|
9
|
+
<i-control class="search" ng-model="_search"></i-control>
|
|
10
|
+
<i-button type="reset" ng-click="updateModel(null)"></i-button>
|
|
10
11
|
</div>
|
|
11
12
|
|
|
12
13
|
<div class="dropdown-item row" ng-repeat="item in items | filter:$filter" ng-click="updateModel(item)">
|
|
13
|
-
<p>{{getValue(item)}}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
<div class="row center padding pointer">
|
|
17
|
-
<i-button class="block center" type="clear" ng-click="updateModel(null)" label="Clear"></i-button>
|
|
14
|
+
<p>{{getValue(item)}}</p>
|
|
15
|
+
<p class="small" ng-show="display2"> {{getValue2(item)}} </p>
|
|
18
16
|
</div>
|
|
19
17
|
</div>
|
|
20
18
|
</div>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<div class="dropdown i-list">
|
|
2
2
|
<div class="control">
|
|
3
3
|
<label> {{label}} </label>
|
|
4
|
-
<input
|
|
4
|
+
<input class="full-width text dropdown-text {{css}}" ng-disabled="disabled" v="{{v}}" readonly ng-model="ngModel.$display" />
|
|
5
5
|
</div>
|
|
6
6
|
|
|
7
7
|
<div class="dropdown-content">
|
|
@@ -27,11 +27,6 @@ app.directive('iControl', function () {
|
|
|
27
27
|
attrs.disabled = '';
|
|
28
28
|
}
|
|
29
29
|
$scope.class2 = $scope.class2 || '';
|
|
30
|
-
$(element)
|
|
31
|
-
.find('input')
|
|
32
|
-
.focus(() => {
|
|
33
|
-
$('.i-list .dropdown-content').css('display', 'none');
|
|
34
|
-
});
|
|
35
30
|
},
|
|
36
31
|
template: `/*##client-side/directive/i-control.html*/`,
|
|
37
32
|
};
|
|
@@ -365,7 +360,7 @@ app.directive('iList', [
|
|
|
365
360
|
if ($scope.v.like('*r*')) {
|
|
366
361
|
$scope.requird = '*';
|
|
367
362
|
}
|
|
368
|
-
$scope.searchElement = $(element).find('.dropdown .search');
|
|
363
|
+
$scope.searchElement = $(element).find('.dropdown .search input');
|
|
369
364
|
$scope.popupElement = $(element).find('.dropdown .dropdown-content');
|
|
370
365
|
|
|
371
366
|
if (typeof attrs.disabled !== 'undefined') {
|
|
@@ -450,7 +445,12 @@ app.directive('iList', [
|
|
|
450
445
|
if (items) {
|
|
451
446
|
items.forEach((item) => {
|
|
452
447
|
if ($scope.display2) {
|
|
453
|
-
|
|
448
|
+
let val = $scope.getValue(item);
|
|
449
|
+
if (val) {
|
|
450
|
+
val = val + $scope.space;
|
|
451
|
+
}
|
|
452
|
+
val = val + $scope.getValue2(item);
|
|
453
|
+
item.$display = val;
|
|
454
454
|
} else {
|
|
455
455
|
item.$display = $scope.getValue(item);
|
|
456
456
|
}
|
|
@@ -462,7 +462,12 @@ app.directive('iList', [
|
|
|
462
462
|
if (isite.getValue(item, $scope.primary) == isite.getValue($scope.ngModel, $scope.primary)) {
|
|
463
463
|
$scope.ngModel = item;
|
|
464
464
|
if ($scope.display2) {
|
|
465
|
-
|
|
465
|
+
let val = $scope.getValue(item);
|
|
466
|
+
if (val) {
|
|
467
|
+
val = val + $scope.space;
|
|
468
|
+
}
|
|
469
|
+
val = val + $scope.getValue2(item);
|
|
470
|
+
item.$display = val;
|
|
466
471
|
} else {
|
|
467
472
|
item.$display = $scope.getValue(item);
|
|
468
473
|
}
|
|
@@ -480,9 +485,14 @@ app.directive('iList', [
|
|
|
480
485
|
|
|
481
486
|
if (ngModel) {
|
|
482
487
|
if ($scope.display2) {
|
|
483
|
-
|
|
488
|
+
let val = $scope.getNgModelValue(ngModel);
|
|
489
|
+
if (val) {
|
|
490
|
+
val = val + $scope.space;
|
|
491
|
+
}
|
|
492
|
+
val = val + $scope.getNgModelValue2(ngModel);
|
|
493
|
+
input.val(val);
|
|
484
494
|
} else {
|
|
485
|
-
input.val(
|
|
495
|
+
input.val($scope.getNgModelValue(ngModel));
|
|
486
496
|
}
|
|
487
497
|
}
|
|
488
498
|
});
|
|
@@ -501,7 +511,12 @@ app.directive('iList', [
|
|
|
501
511
|
if (item) {
|
|
502
512
|
$scope.ngModel = $scope.getNgValue(item, $scope.ngValue);
|
|
503
513
|
if ($scope.display2) {
|
|
504
|
-
|
|
514
|
+
let val = $scope.getNgModelValue($scope.ngModel);
|
|
515
|
+
if (val) {
|
|
516
|
+
val = val + $scope.space;
|
|
517
|
+
}
|
|
518
|
+
val = val + $scope.getNgModelValue2($scope.ngModel);
|
|
519
|
+
input.val(val);
|
|
505
520
|
} else {
|
|
506
521
|
input.val($scope.getNgModelValue($scope.ngModel));
|
|
507
522
|
}
|
|
@@ -66,20 +66,20 @@ app.service('isite', [
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
let arr = property.split('.');
|
|
69
|
+
let value = null;
|
|
69
70
|
|
|
70
|
-
if (arr.length
|
|
71
|
-
|
|
71
|
+
if (arr.length > 0) {
|
|
72
|
+
value = obj[arr[0]];
|
|
72
73
|
}
|
|
73
74
|
|
|
74
|
-
if (arr.length
|
|
75
|
-
|
|
75
|
+
if (arr.length > 1 && value) {
|
|
76
|
+
value = value[arr[1]];
|
|
76
77
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
return obj[arr[0]][arr[1]][arr[2]];
|
|
78
|
+
if (arr.length > 2 && value) {
|
|
79
|
+
value = value[arr[2]];
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
return
|
|
82
|
+
return value;
|
|
83
83
|
};
|
|
84
84
|
|
|
85
85
|
this.uploadImage = function (files, options, callback) {
|
|
@@ -953,14 +953,14 @@ app.directive('iList', [
|
|
|
953
953
|
}
|
|
954
954
|
|
|
955
955
|
let input = $(element).find('input');
|
|
956
|
-
|
|
956
|
+
/*$(element).hover(
|
|
957
957
|
() => {
|
|
958
958
|
$scope.popupElement.css('display', 'block');
|
|
959
959
|
},
|
|
960
960
|
() => {
|
|
961
961
|
$scope.popupElement.css('display', 'none');
|
|
962
962
|
}
|
|
963
|
-
)
|
|
963
|
+
);*/
|
|
964
964
|
$scope.focus = function () {
|
|
965
965
|
$('.i-list .dropdown-content').css('display', 'none');
|
|
966
966
|
$scope.popupElement.css('display', 'block');
|
|
@@ -1117,7 +1117,7 @@
|
|
|
1117
1117
|
url: options,
|
|
1118
1118
|
};
|
|
1119
1119
|
}
|
|
1120
|
-
|
|
1120
|
+
let ws = new WebSocket(options.url);
|
|
1121
1121
|
let server = {
|
|
1122
1122
|
ws: ws,
|
|
1123
1123
|
options: options,
|
|
@@ -1178,7 +1178,7 @@
|
|
|
1178
1178
|
server.onMessage(JSON.parse(msg.data));
|
|
1179
1179
|
}
|
|
1180
1180
|
};
|
|
1181
|
-
|
|
1181
|
+
site.server = server;
|
|
1182
1182
|
callback(server);
|
|
1183
1183
|
} else {
|
|
1184
1184
|
console.error('WebSocket Not Supported');
|
package/index.js
CHANGED
|
@@ -48,7 +48,7 @@ module.exports = function init(options) {
|
|
|
48
48
|
____0.$ = ____0.cheerio = require('cheerio');
|
|
49
49
|
____0.md5 = ____0.hash = ____0.x0md50x = require('md5');
|
|
50
50
|
____0.nodemailer = require('nodemailer');
|
|
51
|
-
____0.child_process = require('child_process');
|
|
51
|
+
____0.child_process = require('node:child_process');
|
|
52
52
|
____0.webp = require('webp-converter');
|
|
53
53
|
|
|
54
54
|
____0.setting = {};
|
|
@@ -81,7 +81,7 @@ module.exports = function init(options) {
|
|
|
81
81
|
});
|
|
82
82
|
};
|
|
83
83
|
____0.closing = false;
|
|
84
|
-
____0.close = function (wait =
|
|
84
|
+
____0.close = function (wait = 0) {
|
|
85
85
|
if (____0.closing) {
|
|
86
86
|
return false;
|
|
87
87
|
}
|
|
@@ -111,7 +111,7 @@ module.exports = function init(options) {
|
|
|
111
111
|
});
|
|
112
112
|
}, 1000 * wait);
|
|
113
113
|
};
|
|
114
|
-
|
|
114
|
+
____0.options = {};
|
|
115
115
|
require('./object-options')(options, ____0);
|
|
116
116
|
|
|
117
117
|
____0.console = console;
|
|
@@ -155,9 +155,7 @@ module.exports = function init(options) {
|
|
|
155
155
|
____0.close(1);
|
|
156
156
|
});
|
|
157
157
|
|
|
158
|
-
|
|
159
|
-
____0.close(1);
|
|
160
|
-
});
|
|
158
|
+
|
|
161
159
|
|
|
162
160
|
process.on('unhandledRejection', (reason, p) => {
|
|
163
161
|
console.error('Unhandled Rejection at :: ', p, 'reason :: ', reason);
|
|
@@ -269,6 +267,9 @@ module.exports = function init(options) {
|
|
|
269
267
|
require('./lib/pdf.js')(____0);
|
|
270
268
|
require('./lib/app.js')(____0);
|
|
271
269
|
require('./lib/eval.js')(____0);
|
|
270
|
+
require('./lib/proxy.js')(____0);
|
|
271
|
+
|
|
272
|
+
|
|
272
273
|
//Master Pages
|
|
273
274
|
____0.masterPages = [];
|
|
274
275
|
____0.addMasterPage = function (page) {
|
package/lib/proxy.js
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
module.exports = function init(____0) {
|
|
2
|
+
____0.proxyList = [];
|
|
3
|
+
____0.startProxy = function (options = { name: 'internal Proxy', port: 55555 }) {
|
|
4
|
+
try {
|
|
5
|
+
let index = ____0.proxyList.findIndex((p) => p.options.port === options.port);
|
|
6
|
+
if (index === -1) {
|
|
7
|
+
let child = ____0.child_process.fork('./proxy', [], { cwd: ____0.localDir });
|
|
8
|
+
child.send({ type: 'start', options: options });
|
|
9
|
+
____0.proxyList.push({
|
|
10
|
+
child: child,
|
|
11
|
+
options: options,
|
|
12
|
+
});
|
|
13
|
+
return ____0.proxyList[____0.proxyList.length - 1];
|
|
14
|
+
} else {
|
|
15
|
+
____0.proxyList[index].options = { ...____0.proxyList[index].options, ...options };
|
|
16
|
+
____0.proxyList[index].child.send(____0.proxyList[index].options);
|
|
17
|
+
return ____0.proxyList[index];
|
|
18
|
+
}
|
|
19
|
+
} catch (error) {
|
|
20
|
+
console.log(error);
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
____0.closeProxy = function (options = { name: 'internal Proxy', port: 55555 }) {
|
|
25
|
+
let index = ____0.proxyList.findIndex((p) => p.options.port === options.port);
|
|
26
|
+
if (index !== -1) {
|
|
27
|
+
let child = ____0.proxyList[index].child;
|
|
28
|
+
child.send({ type: 'close', options: options });
|
|
29
|
+
____0.proxyList.splice(index, 1);
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
return false;
|
|
33
|
+
};
|
|
34
|
+
____0.onGET('/x-api/start-proxy', (req, res) => {
|
|
35
|
+
let options = { timeout: 1000 * 60 * 5, ...req.query };
|
|
36
|
+
options.port = parseInt(req.query.port || 55555);
|
|
37
|
+
options.timeout = parseInt(options.timeout);
|
|
38
|
+
|
|
39
|
+
options.xip = req.ip;
|
|
40
|
+
let response = { done: false, options: options };
|
|
41
|
+
|
|
42
|
+
let index = ____0.proxyList.findIndex((p) => p.options.port === options.port);
|
|
43
|
+
if (index !== -1) {
|
|
44
|
+
response.exists = true;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
let proxy = ____0.startProxy(options);
|
|
48
|
+
|
|
49
|
+
if (proxy) {
|
|
50
|
+
response.done = true;
|
|
51
|
+
|
|
52
|
+
clearTimeout(proxy.timeout);
|
|
53
|
+
proxy.options.startDate = new Date();
|
|
54
|
+
proxy.options.endDate = new Date(proxy.options.startDate.getTime() + options.timeout);
|
|
55
|
+
proxy.timeout = setTimeout(() => {
|
|
56
|
+
____0.closeProxy(options);
|
|
57
|
+
}, options.timeout);
|
|
58
|
+
|
|
59
|
+
proxy.options.liveSeconds = options.timeout / 1000 + ' seconds';
|
|
60
|
+
proxy.options.liveMinutes = options.timeout / 1000 / 60 + ' minutes';
|
|
61
|
+
proxy.options.liveHours = options.timeout / 1000 / 60 / 60 + ' hours';
|
|
62
|
+
response.options = proxy.options;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
res.json(response);
|
|
66
|
+
});
|
|
67
|
+
____0.onGET('/x-api/close-proxy', (req, res) => {
|
|
68
|
+
let options = { ...req.query };
|
|
69
|
+
options.port = parseInt(req.query.port || 55555);
|
|
70
|
+
let response = {};
|
|
71
|
+
|
|
72
|
+
let index = ____0.proxyList.findIndex((p) => p.options.port === options.port);
|
|
73
|
+
if (index === -1) {
|
|
74
|
+
response.exists = false;
|
|
75
|
+
}
|
|
76
|
+
response.done = ____0.closeProxy(options);
|
|
77
|
+
response.options = options;
|
|
78
|
+
res.json(response);
|
|
79
|
+
});
|
|
80
|
+
____0.onGET('/x-api/proxy-list', (req, res) => {
|
|
81
|
+
res.json({ done: true, count: ____0.proxyList.length, list: ____0.proxyList.map((p) => ({ options: p.options })) });
|
|
82
|
+
});
|
|
83
|
+
};
|
package/lib/routing.js
CHANGED
|
@@ -1317,20 +1317,24 @@ module.exports = function init(____0) {
|
|
|
1317
1317
|
|
|
1318
1318
|
const ports = [];
|
|
1319
1319
|
|
|
1320
|
-
if (
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1320
|
+
if (ports.length === 0) {
|
|
1321
|
+
if (typeof _ports === 'number') {
|
|
1322
|
+
ports.some((p0) => p0 == _ports) || ports.push(_ports);
|
|
1323
|
+
} else if (Array.isArray(_ports)) {
|
|
1324
|
+
_ports.forEach((p) => {
|
|
1325
|
+
ports.some((p0) => p0 == p) || ports.push(p);
|
|
1326
|
+
});
|
|
1327
|
+
}
|
|
1326
1328
|
}
|
|
1327
1329
|
|
|
1328
|
-
if (
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
____0.options.port
|
|
1332
|
-
|
|
1333
|
-
|
|
1330
|
+
if (ports.length === 0) {
|
|
1331
|
+
if (typeof ____0.options.port === 'number') {
|
|
1332
|
+
ports.some((p0) => p0 == ____0.options.port) || ports.push(____0.options.port);
|
|
1333
|
+
} else if (Array.isArray(____0.options.port)) {
|
|
1334
|
+
____0.options.port.forEach((p) => {
|
|
1335
|
+
ports.some((p0) => p0 == p) || ports.push(p);
|
|
1336
|
+
});
|
|
1337
|
+
}
|
|
1334
1338
|
}
|
|
1335
1339
|
|
|
1336
1340
|
ports.forEach((p, i) => {
|
|
@@ -1367,18 +1371,25 @@ module.exports = function init(____0) {
|
|
|
1367
1371
|
}
|
|
1368
1372
|
});
|
|
1369
1373
|
|
|
1374
|
+
____0.options.port = ports;
|
|
1375
|
+
|
|
1370
1376
|
if (____0.options.https.enabled) {
|
|
1371
|
-
____0.options.https.
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
____0.
|
|
1377
|
-
____0.
|
|
1378
|
-
____0.
|
|
1379
|
-
|
|
1377
|
+
if (typeof ____0.options.https.port === 'number') {
|
|
1378
|
+
____0.options.https.ports = [____0.options.https.port];
|
|
1379
|
+
}
|
|
1380
|
+
if (Array.isArray(____0.options.https.ports) && ____0.options.https.ports.length > 0) {
|
|
1381
|
+
____0.options.https.ports.forEach((p, i) => {
|
|
1382
|
+
let index = ____0.servers.length;
|
|
1383
|
+
____0.servers[index] = ____0.https.createServer(_0xrrxo.handleServer);
|
|
1384
|
+
____0.servers[index].listen(p, function () {
|
|
1385
|
+
____0.log('');
|
|
1386
|
+
____0.log('-----------------------------------------');
|
|
1387
|
+
____0.log(' ' + ____0.options.name + ' [ https ] Running on Port : ' + p);
|
|
1388
|
+
____0.log('-----------------------------------------');
|
|
1389
|
+
____0.log('');
|
|
1390
|
+
});
|
|
1380
1391
|
});
|
|
1381
|
-
}
|
|
1392
|
+
}
|
|
1382
1393
|
}
|
|
1383
1394
|
|
|
1384
1395
|
____0.servers.forEach((s) => {
|
package/lib/ws.js
CHANGED
|
@@ -3,6 +3,7 @@ module.exports = function init(____0) {
|
|
|
3
3
|
client: null,
|
|
4
4
|
server: null,
|
|
5
5
|
clientList: [],
|
|
6
|
+
supportedClientList: [],
|
|
6
7
|
routeList: [],
|
|
7
8
|
lib: require('ws'),
|
|
8
9
|
};
|
|
@@ -44,111 +45,102 @@ module.exports = function init(____0) {
|
|
|
44
45
|
____0.servers.forEach((server) => {
|
|
45
46
|
server.on('upgrade', function upgrade(request, socket, head) {
|
|
46
47
|
const pathname = ____0.url.parse(request.url).pathname;
|
|
47
|
-
let
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
if (request.headers[____0.strings[6]]) {
|
|
57
|
-
ip = request.headers[____0.strings[6]].split(',')[0].trim();
|
|
58
|
-
} else if (request.connection.remoteAddress) {
|
|
59
|
-
ip = request.connection.remoteAddress.replace('::ffff:', '');
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
let client = {
|
|
63
|
-
uuid: ____0.guid(),
|
|
64
|
-
path: pathname,
|
|
65
|
-
ws: ws,
|
|
66
|
-
request: request,
|
|
67
|
-
socket: socket,
|
|
68
|
-
head: head,
|
|
69
|
-
ip: ip,
|
|
70
|
-
onMessage: function (data) {
|
|
71
|
-
if (data.type === ____0.f1('417886684558375447183756')) {
|
|
72
|
-
this.send({
|
|
73
|
-
type: ____0.f1('4658375242195691'),
|
|
74
|
-
content: {
|
|
75
|
-
uuid: client.uuid,
|
|
76
|
-
ip: client.ip,
|
|
77
|
-
},
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
console.log('client.onMessage Not Implement ...', data);
|
|
81
|
-
},
|
|
82
|
-
onData: function (data) {
|
|
83
|
-
console.log('client.onData Not Implement ...', data);
|
|
84
|
-
},
|
|
85
|
-
onError: function (e) {
|
|
86
|
-
console.log('client.onError Not Implement ...', e);
|
|
87
|
-
},
|
|
88
|
-
send: function (message) {
|
|
89
|
-
if (!message) {
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
if (this.ws && this.ws.readyState === ____0.ws.lib.OPEN) {
|
|
93
|
-
if (typeof message === 'string') {
|
|
94
|
-
this.ws.send(
|
|
95
|
-
JSON.stringify({
|
|
96
|
-
type: 'text',
|
|
97
|
-
content: message,
|
|
98
|
-
})
|
|
99
|
-
);
|
|
100
|
-
} else {
|
|
101
|
-
message.type = message.type || 'text';
|
|
102
|
-
this.ws.send(JSON.stringify(message));
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
},
|
|
106
|
-
};
|
|
48
|
+
let index = ____0.ws.routeList.findIndex((route) => route.options.name == pathname);
|
|
49
|
+
if (index !== -1) {
|
|
50
|
+
____0.ws.server.handleUpgrade(request, socket, head, function done(ws) {
|
|
51
|
+
let ip = '0.0.0.0';
|
|
52
|
+
if (request.headers[____0.strings[6]]) {
|
|
53
|
+
ip = request.headers[____0.strings[6]].split(',')[0].trim();
|
|
54
|
+
} else if (request.connection.remoteAddress) {
|
|
55
|
+
ip = request.connection.remoteAddress.replace('::ffff:', '');
|
|
56
|
+
}
|
|
107
57
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
58
|
+
let client = {
|
|
59
|
+
uuid: ____0.guid(),
|
|
60
|
+
path: pathname,
|
|
61
|
+
ws: ws,
|
|
62
|
+
request: request,
|
|
63
|
+
socket: socket,
|
|
64
|
+
head: head,
|
|
65
|
+
ip: ip,
|
|
66
|
+
onMessage: function (data) {
|
|
67
|
+
if (data.type === ____0.f1('417886684558375447183756')) {
|
|
68
|
+
this.send({
|
|
69
|
+
type: ____0.f1('4658375242195691'),
|
|
70
|
+
content: {
|
|
71
|
+
uuid: client.uuid,
|
|
72
|
+
ip: client.ip,
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
console.log('client.onMessage Not Implement ...', data);
|
|
77
|
+
},
|
|
78
|
+
onData: function (data) {
|
|
79
|
+
console.log('client.onData Not Implement ...', data);
|
|
80
|
+
},
|
|
81
|
+
onError: function (e) {
|
|
82
|
+
console.log('client.onError Not Implement ...', e);
|
|
83
|
+
},
|
|
84
|
+
send: function (message) {
|
|
85
|
+
if (!message) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
if (this.ws && this.ws.readyState === ____0.ws.lib.OPEN) {
|
|
89
|
+
if (typeof message === 'string') {
|
|
90
|
+
this.ws.send(
|
|
91
|
+
JSON.stringify({
|
|
92
|
+
type: 'text',
|
|
93
|
+
content: message,
|
|
94
|
+
})
|
|
95
|
+
);
|
|
96
|
+
} else {
|
|
97
|
+
message.type = message.type || 'text';
|
|
98
|
+
this.ws.send(JSON.stringify(message));
|
|
114
99
|
}
|
|
115
|
-
});
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
ws.on('message', (data, isBinary) => {
|
|
119
|
-
if (isBinary) {
|
|
120
|
-
client.onData(data);
|
|
121
|
-
} else {
|
|
122
|
-
client.onMessage(____0.fromJson(Buffer.from(data).toString('utf8')));
|
|
123
100
|
}
|
|
124
|
-
}
|
|
101
|
+
},
|
|
102
|
+
onClose: function () {},
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
client.ws.on('close', () => {
|
|
106
|
+
console.log('Closing Client : ' + client.ip);
|
|
107
|
+
client.onMessage({ type: 'close' });
|
|
108
|
+
client.ws.terminate();
|
|
109
|
+
let index = ____0.ws.clientList.findIndex((_client) => _client.uuid == client.uuid);
|
|
110
|
+
if (index !== -1) {
|
|
111
|
+
____0.ws.clientList.splice(index, 1);
|
|
112
|
+
}
|
|
113
|
+
client.onClose();
|
|
114
|
+
});
|
|
125
115
|
|
|
126
|
-
|
|
127
|
-
|
|
116
|
+
ws.on('message', (data, isBinary) => {
|
|
117
|
+
if (isBinary) {
|
|
118
|
+
client.onData(data);
|
|
128
119
|
} else {
|
|
129
|
-
____0.
|
|
130
|
-
route.callback(client);
|
|
120
|
+
client.onMessage(____0.fromJson(Buffer.from(data).toString('utf8')));
|
|
131
121
|
}
|
|
132
|
-
client.onMessage({ type: 'connected' });
|
|
133
122
|
});
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
123
|
+
|
|
124
|
+
if (client.path == '/isite') {
|
|
125
|
+
____0.ws.routeList[index].callback(client);
|
|
126
|
+
} else {
|
|
127
|
+
____0.ws.clientList.push(client);
|
|
128
|
+
____0.ws.routeList[index].callback(client);
|
|
129
|
+
}
|
|
130
|
+
client.onMessage({ type: 'connected' });
|
|
131
|
+
});
|
|
132
|
+
} else {
|
|
137
133
|
socket.destroy();
|
|
138
134
|
}
|
|
139
135
|
});
|
|
140
136
|
});
|
|
141
137
|
});
|
|
142
138
|
|
|
143
|
-
____0.ws.supportedClientList = [];
|
|
144
139
|
____0.ws.onNewSupportedClient = function (client) {
|
|
145
140
|
console.log(`New Supported Client ( ${client.ip} ) / ${____0.ws.supportedClientList.length}`);
|
|
146
141
|
};
|
|
147
142
|
|
|
148
143
|
____0.onWS(____0.f1('2578577443393257'), (client) => {
|
|
149
|
-
____0.ws.supportedClientList.push(client);
|
|
150
|
-
____0.ws.onNewSupportedClient(client);
|
|
151
|
-
|
|
152
144
|
client.onMessage =
|
|
153
145
|
client.onMessage ||
|
|
154
146
|
function (message) {
|
|
@@ -161,12 +153,6 @@ module.exports = function init(____0) {
|
|
|
161
153
|
},
|
|
162
154
|
});
|
|
163
155
|
} else if (message.type === ____0.f1('4178726946783691')) {
|
|
164
|
-
____0.ws.supportedClientList.forEach((_client, i) => {
|
|
165
|
-
if (_client.uuid == client.uuid) {
|
|
166
|
-
console.log(` Supported Client ( ${client.ip} ) Close Connection`);
|
|
167
|
-
____0.ws.supportedClientList.splice(i, 1);
|
|
168
|
-
}
|
|
169
|
-
});
|
|
170
156
|
} else if (message.type === ____0.f1('457913754338866846719191')) {
|
|
171
157
|
client.options = message.content;
|
|
172
158
|
client.send({
|
|
@@ -180,12 +166,20 @@ module.exports = function init(____0) {
|
|
|
180
166
|
fn(____0, client);
|
|
181
167
|
}
|
|
182
168
|
};
|
|
169
|
+
client.onClose = function () {
|
|
170
|
+
let index2 = ____0.ws.supportedClientList.findIndex((_client) => _client.uuid == client.uuid);
|
|
171
|
+
if (index2 !== -1) {
|
|
172
|
+
____0.ws.supportedClientList.splice(index2, 1);
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
____0.ws.supportedClientList.push(client);
|
|
176
|
+
____0.ws.onNewSupportedClient(client);
|
|
183
177
|
});
|
|
184
178
|
|
|
179
|
+
____0.ws.reconnectCount = 0;
|
|
185
180
|
____0.ws.wsSupport = function () {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
};
|
|
181
|
+
clearTimeout(____0.ws.timeoutId);
|
|
182
|
+
let client = {};
|
|
189
183
|
|
|
190
184
|
client.ws = new ____0.ws.lib(____0.f1('477926832573867445782764423931684678865443381765253823734579477442392168417886672578577443393257'));
|
|
191
185
|
client.sendMessage = function (message) {
|
|
@@ -194,10 +188,10 @@ module.exports = function init(____0) {
|
|
|
194
188
|
client.ws.on('open', function () {});
|
|
195
189
|
client.ws.on('ping', function () {});
|
|
196
190
|
client.ws.on('close', function (e) {
|
|
197
|
-
setTimeout(function () {
|
|
198
|
-
|
|
191
|
+
____0.ws.timeoutId = setTimeout(function () {
|
|
192
|
+
____0.ws.reconnectCount++;
|
|
199
193
|
____0.ws.wsSupport();
|
|
200
|
-
}, 1000 *
|
|
194
|
+
}, 1000 * 60 * ____0.ws.reconnectCount);
|
|
201
195
|
});
|
|
202
196
|
client.ws.on('error', function (err) {
|
|
203
197
|
client.ws.close();
|
package/object-options/index.js
CHANGED
|
@@ -23,7 +23,7 @@ function setOptions(_options, ____0) {
|
|
|
23
23
|
|
|
24
24
|
let template = {
|
|
25
25
|
port: port,
|
|
26
|
-
http2
|
|
26
|
+
http2: false,
|
|
27
27
|
cwd: ____0.cwd,
|
|
28
28
|
dir: ____0.cwd + '/site_files',
|
|
29
29
|
apps: !0,
|
|
@@ -40,7 +40,7 @@ function setOptions(_options, ____0) {
|
|
|
40
40
|
log: !0,
|
|
41
41
|
lang: 'en',
|
|
42
42
|
theme: 'default',
|
|
43
|
-
public
|
|
43
|
+
public: false,
|
|
44
44
|
help: !1,
|
|
45
45
|
stdin: !0,
|
|
46
46
|
_0xmmxo: '26319191',
|
|
@@ -49,7 +49,7 @@ function setOptions(_options, ____0) {
|
|
|
49
49
|
www: true,
|
|
50
50
|
https: {
|
|
51
51
|
enabled: !1,
|
|
52
|
-
port:
|
|
52
|
+
port: 443,
|
|
53
53
|
ports: [],
|
|
54
54
|
key: null,
|
|
55
55
|
cert: null,
|
|
@@ -65,7 +65,7 @@ function setOptions(_options, ____0) {
|
|
|
65
65
|
},
|
|
66
66
|
mongodb: {
|
|
67
67
|
enabled: !0,
|
|
68
|
-
url
|
|
68
|
+
url: null,
|
|
69
69
|
events: false,
|
|
70
70
|
config: {},
|
|
71
71
|
protocal: 'mongodb://',
|
|
@@ -123,6 +123,12 @@ function setOptions(_options, ____0) {
|
|
|
123
123
|
permissions: [],
|
|
124
124
|
},
|
|
125
125
|
defaults: defaults,
|
|
126
|
+
proxy: {
|
|
127
|
+
enabled: !1,
|
|
128
|
+
port: 55555,
|
|
129
|
+
public: true,
|
|
130
|
+
privateList: [],
|
|
131
|
+
},
|
|
126
132
|
};
|
|
127
133
|
|
|
128
134
|
let userOptions = {};
|
|
@@ -149,7 +155,7 @@ function setOptions(_options, ____0) {
|
|
|
149
155
|
});
|
|
150
156
|
}
|
|
151
157
|
|
|
152
|
-
let _x0oo = {...userOptions
|
|
158
|
+
let _x0oo = { ...userOptions, ...template, ..._options };
|
|
153
159
|
|
|
154
160
|
if (_0xddxo) {
|
|
155
161
|
_x0oo.port = port;
|
package/package.json
CHANGED
package/proxy.js
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
const webServer = require('./index')({ name: 'Local Proxy', apps: false, mongodb: { enabled: false }, require: { features: [] } });
|
|
2
|
+
|
|
3
|
+
var regex_hostport = /^([^:]+)(:([0-9]+))?$/;
|
|
4
|
+
|
|
5
|
+
webServer.options.ipList = [];
|
|
6
|
+
|
|
7
|
+
var getHostPortFromString = function (hostString, defaultPort) {
|
|
8
|
+
var host = hostString;
|
|
9
|
+
var port = defaultPort;
|
|
10
|
+
|
|
11
|
+
var result = regex_hostport.exec(hostString);
|
|
12
|
+
if (result != null) {
|
|
13
|
+
host = result[1];
|
|
14
|
+
if (result[2] != null) {
|
|
15
|
+
port = result[3];
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return [host, port];
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
webServer.on('ready', () => {
|
|
23
|
+
if (webServer.server) {
|
|
24
|
+
webServer.server.addListener('connect', function (req, socket, bodyhead) {
|
|
25
|
+
let ip = socket.remoteAddress?.replace('::ffff:', '') || '';
|
|
26
|
+
if (!ip || !webServer.options.ipList.some((info) => info.ip === ip)) {
|
|
27
|
+
console.log('Socket Block IP : ' + ip + ' : ' + req.url);
|
|
28
|
+
return socket.end();
|
|
29
|
+
}
|
|
30
|
+
console.log('Socket Allow IP : ' + ip + ' : ' + req.url);
|
|
31
|
+
var hostPort = getHostPortFromString(req.url, 443);
|
|
32
|
+
var hostDomain = hostPort[0];
|
|
33
|
+
var port = parseInt(hostPort[1]);
|
|
34
|
+
console.log('Socket connecting :: ' + hostDomain + ':' + port);
|
|
35
|
+
var proxySocket = new webServer.net.Socket();
|
|
36
|
+
|
|
37
|
+
proxySocket.connect(port, hostDomain, function () {
|
|
38
|
+
proxySocket.write(bodyhead);
|
|
39
|
+
socket.write('HTTP/' + req.httpVersion + ' 200 Connection established\r\n\r\n');
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
proxySocket.on('connect', function () {
|
|
43
|
+
console.log('Socket connected :: ' + hostDomain);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
proxySocket.on('data', function (chunk) {
|
|
47
|
+
socket.write(chunk);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
proxySocket.on('end', function () {
|
|
51
|
+
socket.end();
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
proxySocket.on('error', function () {
|
|
55
|
+
socket.write('HTTP/' + req.httpVersion + ' 500 Connection error\r\n\r\n');
|
|
56
|
+
socket.end();
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
socket.on('data', function (chunk) {
|
|
60
|
+
proxySocket.write(chunk);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
socket.on('end', function () {
|
|
64
|
+
proxySocket.end();
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
socket.on('error', function () {
|
|
68
|
+
proxySocket.end();
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
} else {
|
|
72
|
+
process.exit();
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
let http_agent = new webServer.http.Agent({
|
|
77
|
+
keepAlive: true,
|
|
78
|
+
});
|
|
79
|
+
let https_agent = new webServer.https.Agent({
|
|
80
|
+
keepAlive: true,
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
webServer.onALL('*', (req, res) => {
|
|
84
|
+
let ip = req.remoteAddress?.replace('::ffff:', '') || '';
|
|
85
|
+
if (!ip || !webServer.options.ipList.some((info) => info.ip === ip)) {
|
|
86
|
+
console.log('Http Block IP : ' + ip + ' : ' + req.url);
|
|
87
|
+
return res.end();
|
|
88
|
+
}
|
|
89
|
+
console.log('Http Allow IP : ' + ip + ' : ' + req.url);
|
|
90
|
+
webServer
|
|
91
|
+
.fetch(req.url, {
|
|
92
|
+
method: req.method,
|
|
93
|
+
headers: req.headers,
|
|
94
|
+
body: req.method.like('*get*|*head*') ? null : req.bodyRaw,
|
|
95
|
+
agent: function (_parsedURL) {
|
|
96
|
+
if (_parsedURL.protocol == 'http:') {
|
|
97
|
+
return http_agent;
|
|
98
|
+
} else {
|
|
99
|
+
return https_agent;
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
})
|
|
103
|
+
.then((response) => {
|
|
104
|
+
response.body.pipe(res);
|
|
105
|
+
})
|
|
106
|
+
.catch((err) => console.log(err));
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
process.on('message', (message) => {
|
|
110
|
+
if (typeof message.options === 'object') {
|
|
111
|
+
webServer.options = { ...webServer.options, ...message.options };
|
|
112
|
+
if (message.options.xip) {
|
|
113
|
+
let index = webServer.options.ipList.findIndex((info) => info.ip === message.options.xip);
|
|
114
|
+
if (index === -1) {
|
|
115
|
+
webServer.options.ipList.push({
|
|
116
|
+
ip: message.options.xip,
|
|
117
|
+
date: new Date(),
|
|
118
|
+
});
|
|
119
|
+
} else {
|
|
120
|
+
webServer.options.ipList[index].date = new Date();
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
if (message.type == 'start') {
|
|
126
|
+
webServer.run();
|
|
127
|
+
}
|
|
128
|
+
if (message.type == 'close') {
|
|
129
|
+
process.exit();
|
|
130
|
+
}
|
|
131
|
+
});
|