yakuza0 2.22.33 → 2.22.34-beta.1
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/package.json +1 -1
- package/server/mode/stop.js +6 -0
- package/server/proxy/conf.js +27 -1
- package/server/proxy/tire.js +95 -43
- package/utils/inclusive.js +6 -0
package/package.json
CHANGED
package/server/mode/stop.js
CHANGED
|
@@ -29,6 +29,9 @@ var _chalk2 = _interopRequireDefault(_chalk);
|
|
|
29
29
|
|
|
30
30
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
31
31
|
|
|
32
|
+
var _require = require('child_process'),
|
|
33
|
+
exec = _require.exec;
|
|
34
|
+
|
|
32
35
|
var stat = exports.stat = function stat(_ref) {
|
|
33
36
|
var config = _ref.config;
|
|
34
37
|
|
|
@@ -63,6 +66,9 @@ exports.default = function (_ref2) {
|
|
|
63
66
|
_consola2.default.log('| ' + _chalk2.default.cyan(name) + ' is shutting down...');
|
|
64
67
|
}
|
|
65
68
|
return new _promise2.default(function (resolve) {
|
|
69
|
+
try {
|
|
70
|
+
exec(_config2.default.server.tire.guPath + ' -s stop');
|
|
71
|
+
} catch (e) {}
|
|
66
72
|
try {
|
|
67
73
|
_pm2.default.delete(_config2.default.name + processName);
|
|
68
74
|
} catch (e) {}
|
package/server/proxy/conf.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.apiV3PathRewrite = exports.serverHeaders = exports.usedPort = exports.includesTypePath = exports.crossPath = undefined;
|
|
6
|
+
exports.ng_conf = exports.apiV3PathRewrite = exports.serverHeaders = exports.usedPort = exports.includesTypePath = exports.crossPath = undefined;
|
|
7
7
|
|
|
8
8
|
var _stringify = require('babel-runtime/core-js/json/stringify');
|
|
9
9
|
|
|
@@ -41,6 +41,10 @@ var _tcpPortUsed2 = _interopRequireDefault(_tcpPortUsed);
|
|
|
41
41
|
|
|
42
42
|
var _def = require('yakuza1/lib/config/def');
|
|
43
43
|
|
|
44
|
+
var _os = require('os');
|
|
45
|
+
|
|
46
|
+
var _os2 = _interopRequireDefault(_os);
|
|
47
|
+
|
|
44
48
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
45
49
|
|
|
46
50
|
exports.default = function () {
|
|
@@ -179,4 +183,26 @@ var apiV3PathRewrite = exports.apiV3PathRewrite = function apiV3PathRewrite(path
|
|
|
179
183
|
path = path.replace(backendReg, 'apiv3/backend/');
|
|
180
184
|
}
|
|
181
185
|
return path;
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
var ng_conf = exports.ng_conf = function ng_conf(_ref6) {
|
|
189
|
+
var appUrl = _ref6.appUrl,
|
|
190
|
+
th = _ref6.th,
|
|
191
|
+
port = _ref6.port,
|
|
192
|
+
yk4Addr = _ref6.yk4Addr,
|
|
193
|
+
basePath = _ref6.basePath,
|
|
194
|
+
name = _ref6.name,
|
|
195
|
+
resolver = _ref6.resolver;
|
|
196
|
+
|
|
197
|
+
var confRoot = '/etc/nginx/extra';
|
|
198
|
+
if (_os2.default.platform() === 'darwin') {
|
|
199
|
+
confRoot = '/opt/homebrew/etc/nginx/extra';
|
|
200
|
+
}
|
|
201
|
+
if (!resolver) {
|
|
202
|
+
resolver = '';
|
|
203
|
+
} else {
|
|
204
|
+
resolver = 'resolver ' + resolver + ';';
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
return '\n ' + resolver + '\n\n server {\n listen ' + port + ';\n server_name localhost;\n include ' + confRoot + '/server.conf;\n\n location ' + basePath + ' {\n proxy_pass ' + appUrl + ';\n }\n\n location ' + basePath + 'apiv1 {\n proxy_set_header ' + _def.variable.ipHeader + ' \'' + th[_def.variable.ipHeader] + '\';\n proxy_set_header ' + _def.variable.childKeyHeader + ' \'' + th[_def.variable.childKeyHeader] + '\';\n proxy_set_header ' + _def.variable.appCodeHeader + ' \'' + th[_def.variable.appCodeHeader] + '\';\n proxy_set_header ' + _def.variable.appKeyHeader + ' \'' + th[_def.variable.appKeyHeader] + '\';\n proxy_set_header ' + _def.variable.shareRuleHeader + ' \'' + th[_def.variable.shareRuleHeader] + '\';\n include ' + confRoot + '/proxy.conf;\n proxy_pass ' + yk4Addr + '/apiv1/' + name + '/client/backend;\n }\n\n location ' + basePath + 'apiv2 {\n include ' + confRoot + '/proxy.conf;\n proxy_pass ' + yk4Addr + '/apiv2;\n }\n\n location ~ ' + basePath + 'apiv3/cln_.*feapiv1/ {\n rewrite ^' + basePath + 'apiv3/cln_(.*)feapiv1/(.*)$ ' + basePath + 'apiv3/fe/$2 last;\n include ' + confRoot + '/proxy.conf;\n proxy_pass ' + yk4Addr + ';\n }\n location ~ ' + basePath + 'apiv3/cln_[a-z]+/ {\n rewrite ^' + basePath + 'apiv3/cln_[a-z]+/(.*)$ ' + basePath + 'apiv3/backend/$1 last;\n include ' + confRoot + '/proxy.conf;\n proxy_pass ' + yk4Addr + ';\n }\n }\n ';
|
|
182
208
|
};
|
package/server/proxy/tire.js
CHANGED
|
@@ -54,6 +54,12 @@ var _control = require("../cache/control");
|
|
|
54
54
|
|
|
55
55
|
var _conf = require("./conf");
|
|
56
56
|
|
|
57
|
+
var _paths = require("../../config/paths");
|
|
58
|
+
|
|
59
|
+
var _paths2 = _interopRequireDefault(_paths);
|
|
60
|
+
|
|
61
|
+
var _child_process = require("child_process");
|
|
62
|
+
|
|
57
63
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
58
64
|
|
|
59
65
|
// import paths from '../../config/paths';
|
|
@@ -86,17 +92,23 @@ exports.default = function () {
|
|
|
86
92
|
var _ref2 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee4(_ref) {
|
|
87
93
|
var config = _ref.config;
|
|
88
94
|
|
|
89
|
-
var appConf, appName, server, pIp, pHost, timeout, commonHeaders, getHeader, isFastDfs, apiVer, getUc, build, baseConfig, app, _th, th, basePath;
|
|
95
|
+
var appConf, guPort, appConfPort, appName, server, pIp, pHost, timeout, commonHeaders, getHeader, isFastDfs, apiVer, getUc, build, baseConfig, app, _th, th, basePath, conf;
|
|
90
96
|
|
|
91
97
|
return _regenerator2.default.wrap(function _callee4$(_context4) {
|
|
92
98
|
while (1) {
|
|
93
99
|
switch (_context4.prev = _context4.next) {
|
|
94
100
|
case 0:
|
|
95
101
|
appConf = config.appConf;
|
|
102
|
+
guPort = appConf.port;
|
|
103
|
+
appConfPort = appConf.port;
|
|
104
|
+
|
|
105
|
+
if (_config2.default.security.isTire && _paths2.default.access(_config2.default.server.tire.guPath)) {
|
|
106
|
+
appConfPort = appConfPort + 1;
|
|
107
|
+
}
|
|
96
108
|
appName = config.appName;
|
|
97
109
|
server = appConf.server;
|
|
98
110
|
pIp = _server.ip.address();
|
|
99
|
-
pHost = server.protocol + "//" + pIp + ":" +
|
|
111
|
+
pHost = server.protocol + "//" + pIp + ":" + appConfPort;
|
|
100
112
|
timeout = _config2.default.server.infoTimeout + 5000;
|
|
101
113
|
commonHeaders = {};
|
|
102
114
|
|
|
@@ -128,7 +140,7 @@ exports.default = function () {
|
|
|
128
140
|
};
|
|
129
141
|
|
|
130
142
|
if (!server.generate.enabled) {
|
|
131
|
-
_context4.next =
|
|
143
|
+
_context4.next = 28;
|
|
132
144
|
break;
|
|
133
145
|
}
|
|
134
146
|
|
|
@@ -248,14 +260,14 @@ exports.default = function () {
|
|
|
248
260
|
}();
|
|
249
261
|
|
|
250
262
|
if (_config2.default.security.isTire) {
|
|
251
|
-
_context4.next =
|
|
263
|
+
_context4.next = 19;
|
|
252
264
|
break;
|
|
253
265
|
}
|
|
254
266
|
|
|
255
|
-
_context4.next =
|
|
267
|
+
_context4.next = 19;
|
|
256
268
|
return build();
|
|
257
269
|
|
|
258
|
-
case
|
|
270
|
+
case 19:
|
|
259
271
|
baseConfig = {
|
|
260
272
|
// changeOrigin: true,
|
|
261
273
|
secure: false,
|
|
@@ -288,6 +300,25 @@ exports.default = function () {
|
|
|
288
300
|
});
|
|
289
301
|
}
|
|
290
302
|
|
|
303
|
+
// if (yConf.security.isTire) {
|
|
304
|
+
// app.use((req, res, next) => {
|
|
305
|
+
// const ycp = paths.ykConfigJsonClient(config.appName);
|
|
306
|
+
// if (req.method.toUpperCase() === 'GET' && req.path === `${config.appConf.server.basePathMU}cln/init.js`) {
|
|
307
|
+
// // noCache(ctx);
|
|
308
|
+
// global.__yk_cln_init_client__ = global.__yk_cln_init_client__ || paths.read(ycp.confClient)
|
|
309
|
+
// res.setHeader('Content-Type', 'application/javascript; charset=utf-8')
|
|
310
|
+
// res.status(200).send(global.__yk_cln_init_client__)
|
|
311
|
+
// } else if (req.method.toUpperCase() === 'GET' && req.path === `${config.appConf.server.basePathMU}cln/ini`){
|
|
312
|
+
// // noCache(ctx);
|
|
313
|
+
// // clnInitCache(ctx)
|
|
314
|
+
// global.__yk_cln_init_server__ = global.__yk_cln_init_server__ || paths.read(ycp.confServer)
|
|
315
|
+
// res.status(200).send(global.__yk_cln_init_server__)
|
|
316
|
+
// } else {
|
|
317
|
+
// next();
|
|
318
|
+
// }
|
|
319
|
+
// })
|
|
320
|
+
// }
|
|
321
|
+
|
|
291
322
|
app.use(function (req, res, next) {
|
|
292
323
|
if (_config2.default.security.isTire) {
|
|
293
324
|
var data = (0, _secCache.secCacheGet)(getCacheKey(req.url));
|
|
@@ -385,7 +416,7 @@ exports.default = function () {
|
|
|
385
416
|
autoRefreshCapacity[arKey] = autoRefreshCapacity[arKey] || 0;
|
|
386
417
|
if (server.generate.autoRefresh && autoRefreshCapacity[arKey] < server.generate.capacity) {
|
|
387
418
|
autoRefreshCapacity[arKey] += 1;
|
|
388
|
-
(0, _curl.curl)("http://127.0.0.1:" +
|
|
419
|
+
(0, _curl.curl)("http://127.0.0.1:" + appConfPort + req.url, {
|
|
389
420
|
method: 'GET',
|
|
390
421
|
headers: {
|
|
391
422
|
"Cookie": req.get("cookie"),
|
|
@@ -419,42 +450,63 @@ exports.default = function () {
|
|
|
419
450
|
th = (_th = {}, (0, _defineProperty3.default)(_th, _def.variable.ipHeader, '127.0.0.1'), (0, _defineProperty3.default)(_th, _def.variable.childKeyHeader, _config2.default.childKey), (0, _defineProperty3.default)(_th, _def.variable.appCodeHeader, config.appConf.appCode), (0, _defineProperty3.default)(_th, _def.variable.appKeyHeader, config.appKey), (0, _defineProperty3.default)(_th, _def.variable.shareRuleHeader, (0, _stringify2.default)(_config2.default.shareRule)), _th);
|
|
420
451
|
basePath = _server._.bothAddFix(config.appConf.server.basePath, "/");
|
|
421
452
|
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
453
|
+
|
|
454
|
+
if (_paths2.default.access(_config2.default.server.tire.guPath)) {
|
|
455
|
+
conf = (0, _conf.ng_conf)({
|
|
456
|
+
appUrl: 'http://127.0.0.1:' + appConfPort,
|
|
457
|
+
th: th,
|
|
458
|
+
yk4Addr: _config2.default.server.orbProtocol.http + "//" + _config2.default.server.orbHost + ":" + _config2.default.server.orbPort,
|
|
459
|
+
basePath: basePath,
|
|
460
|
+
name: _config2.default.name,
|
|
461
|
+
port: guPort,
|
|
462
|
+
resolver: _config2.default.server.tire.resolver
|
|
463
|
+
});
|
|
464
|
+
|
|
465
|
+
_paths2.default.write(_config2.default.server.tire.clnConf, conf);
|
|
466
|
+
// spawn(yConf.server.tire.guPath, ['-c', yConf.server.tire.guConf]);
|
|
467
|
+
|
|
468
|
+
try {
|
|
469
|
+
(0, _child_process.exec)(_config2.default.server.tire.guPath + ' -s stop');
|
|
470
|
+
} catch (e) {}
|
|
471
|
+
(0, _child_process.exec)(_config2.default.server.tire.guPath + ' -c ' + _config2.default.server.tire.guConf + ' -g "daemon off;"');
|
|
472
|
+
} else {
|
|
473
|
+
app.use(basePath + "apiv1", createProxyMiddleware((0, _extends5.default)({}, baseConfig, {
|
|
474
|
+
target: _config2.default.server.orbProtocol.http + "//" + _config2.default.server.orbHost + ":" + _config2.default.server.orbPort,
|
|
475
|
+
headers: th,
|
|
476
|
+
pathRewrite: (0, _defineProperty3.default)({}, "^" + basePath + "apiv1", "/" + _config2.default.proxyServer.apiKey + "/" + _config2.default.name + "/client/backend")
|
|
477
|
+
})));
|
|
478
|
+
|
|
479
|
+
app.use(basePath + "apiv2", createProxyMiddleware((0, _extends5.default)({}, baseConfig, {
|
|
480
|
+
target: _config2.default.server.orbProtocol.http + "//" + _config2.default.server.orbHost + ":" + _config2.default.server.orbPort,
|
|
481
|
+
pathRewrite: (0, _defineProperty3.default)({}, "^" + basePath + "apiv2", "/apiv2")
|
|
482
|
+
})));
|
|
483
|
+
|
|
484
|
+
app.use(basePath + "apiv3", createProxyMiddleware((0, _extends5.default)({}, baseConfig, {
|
|
485
|
+
target: _config2.default.server.orbProtocol.http + "//" + _config2.default.server.orbHost + ":" + _config2.default.server.orbPort,
|
|
486
|
+
pathRewrite: function () {
|
|
487
|
+
var _ref6 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee3(path, req) {
|
|
488
|
+
return _regenerator2.default.wrap(function _callee3$(_context3) {
|
|
489
|
+
while (1) {
|
|
490
|
+
switch (_context3.prev = _context3.next) {
|
|
491
|
+
case 0:
|
|
492
|
+
return _context3.abrupt("return", (0, _conf.apiV3PathRewrite)(path));
|
|
493
|
+
|
|
494
|
+
case 1:
|
|
495
|
+
case "end":
|
|
496
|
+
return _context3.stop();
|
|
497
|
+
}
|
|
446
498
|
}
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
|
-
}));
|
|
499
|
+
}, _callee3, this);
|
|
500
|
+
}));
|
|
450
501
|
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
502
|
+
function pathRewrite(_x4, _x5) {
|
|
503
|
+
return _ref6.apply(this, arguments);
|
|
504
|
+
}
|
|
454
505
|
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
506
|
+
return pathRewrite;
|
|
507
|
+
}()
|
|
508
|
+
})));
|
|
509
|
+
}
|
|
458
510
|
}
|
|
459
511
|
|
|
460
512
|
// let {main} = paths.appBuildDir(appName);
|
|
@@ -591,8 +643,8 @@ exports.default = function () {
|
|
|
591
643
|
});
|
|
592
644
|
}
|
|
593
645
|
})));
|
|
594
|
-
|
|
595
|
-
|
|
646
|
+
|
|
647
|
+
app.listen(appConfPort);
|
|
596
648
|
// sv.keepAliveTimeout = server.generate.keepAliveTimeout;
|
|
597
649
|
// sv.headersTimeout = server.generate.headersTimeout;
|
|
598
650
|
|
|
@@ -602,7 +654,7 @@ exports.default = function () {
|
|
|
602
654
|
}, server.generate.maxAge * 1000);
|
|
603
655
|
}
|
|
604
656
|
|
|
605
|
-
case
|
|
657
|
+
case 28:
|
|
606
658
|
case "end":
|
|
607
659
|
return _context4.stop();
|
|
608
660
|
}
|
package/utils/inclusive.js
CHANGED
|
@@ -519,6 +519,12 @@ var render = function () {
|
|
|
519
519
|
stupid: {
|
|
520
520
|
referrerPolicy: { policy: "strict-origin-when-cross-origin" },
|
|
521
521
|
crossOriginResourcePolicy: { policy: "same-origin" }
|
|
522
|
+
},
|
|
523
|
+
tire: {
|
|
524
|
+
guPath: '/nginx',
|
|
525
|
+
guConf: '/etc/nginx/nginx.conf',
|
|
526
|
+
clnConf: '/etc/nginx/conf.d/cln2.conf',
|
|
527
|
+
resolve: ''
|
|
522
528
|
}
|
|
523
529
|
},
|
|
524
530
|
extend: {
|