@abtnode/router-provider 1.7.6 → 1.7.9
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/lib/default/daemon.js +7 -0
- package/lib/default/proxy.js +2 -15
- package/lib/nginx/index.js +7 -1
- package/package.json +7 -7
package/lib/default/daemon.js
CHANGED
|
@@ -329,3 +329,10 @@ config.sites.forEach((site) => {
|
|
|
329
329
|
config.sites.filter((x) => x.port).forEach((x) => ensureInternalServer(x.port));
|
|
330
330
|
|
|
331
331
|
logger.info(`Default routing engine ready on ${httpPort} and ${httpsPort}`);
|
|
332
|
+
|
|
333
|
+
['exit', 'SIGINT', 'SIGUSR1', 'SIGUSR2', 'uncaughtException', 'SIGTERM'].forEach((e) => {
|
|
334
|
+
process.on(e, () => {
|
|
335
|
+
main.close();
|
|
336
|
+
Object.keys(internalServers).forEach((key) => internalServers[key].close());
|
|
337
|
+
});
|
|
338
|
+
});
|
package/lib/default/proxy.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
/* eslint-disable consistent-return */
|
|
3
3
|
const fs = require('fs');
|
|
4
4
|
const http = require('http');
|
|
5
|
+
const https = require('https');
|
|
5
6
|
const httpProxy = require('http-proxy');
|
|
6
7
|
const validUrl = require('valid-url');
|
|
7
8
|
const path = require('path');
|
|
@@ -119,8 +120,7 @@ module.exports = class ReverseProxy {
|
|
|
119
120
|
}
|
|
120
121
|
|
|
121
122
|
setupHttpProxy(proxy, websocketUpgrade, opts) {
|
|
122
|
-
const
|
|
123
|
-
const server = httpServerModule.createServer((req, res) => {
|
|
123
|
+
const server = http.createServer((req, res) => {
|
|
124
124
|
const src = this._getSource(req);
|
|
125
125
|
if (this.opts.corsHandler(req, res) === false) {
|
|
126
126
|
return;
|
|
@@ -163,8 +163,6 @@ module.exports = class ReverseProxy {
|
|
|
163
163
|
}
|
|
164
164
|
|
|
165
165
|
setupHttpsProxy(proxy, websocketUpgrade, sslOpts) {
|
|
166
|
-
let https;
|
|
167
|
-
|
|
168
166
|
let ssl = {
|
|
169
167
|
SNICallback: (hostname, cb) => {
|
|
170
168
|
if (cb) {
|
|
@@ -187,17 +185,6 @@ module.exports = class ReverseProxy {
|
|
|
187
185
|
ssl = _.defaults(ssl, sslOpts.opts);
|
|
188
186
|
}
|
|
189
187
|
|
|
190
|
-
if (sslOpts.http2) {
|
|
191
|
-
// eslint-disable-next-line
|
|
192
|
-
https = sslOpts.serverModule || require('spdy');
|
|
193
|
-
if (_.isObject(sslOpts.http2)) {
|
|
194
|
-
sslOpts.spdy = sslOpts.http2;
|
|
195
|
-
}
|
|
196
|
-
} else {
|
|
197
|
-
// eslint-disable-next-line global-require
|
|
198
|
-
https = sslOpts.serverModule || require('https');
|
|
199
|
-
}
|
|
200
|
-
|
|
201
188
|
this.httpsServer = https.createServer(ssl, (req, res) => {
|
|
202
189
|
const src = this._getSource(req);
|
|
203
190
|
if (this.opts.corsHandler(req, res) === false) {
|
package/lib/nginx/index.js
CHANGED
|
@@ -105,6 +105,7 @@ class NginxProvider extends BaseProvider {
|
|
|
105
105
|
this.httpPort = decideHttpPort(httpPort);
|
|
106
106
|
this.httpsPort = decideHttpsPort(httpsPort);
|
|
107
107
|
this.cacheDisabled = !!cacheDisabled;
|
|
108
|
+
this.isHttp2Supported = this._isHttp2Supported();
|
|
108
109
|
|
|
109
110
|
logger.info('nginx provider config', {
|
|
110
111
|
configDir,
|
|
@@ -302,6 +303,11 @@ class NginxProvider extends BaseProvider {
|
|
|
302
303
|
return result;
|
|
303
304
|
}
|
|
304
305
|
|
|
306
|
+
_isHttp2Supported() {
|
|
307
|
+
const configArgs = this.readNginxConfigParams();
|
|
308
|
+
return typeof configArgs['with-http_v2_module'] !== 'undefined';
|
|
309
|
+
}
|
|
310
|
+
|
|
305
311
|
readNginxConfigParams() {
|
|
306
312
|
const result = shelljs.exec(`${this.binPath} -V`, { silent: true });
|
|
307
313
|
|
|
@@ -690,7 +696,7 @@ class NginxProvider extends BaseProvider {
|
|
|
690
696
|
const crtPath = `${path.join(this.certDir, certificateFileName)}.crt`;
|
|
691
697
|
const keyPath = `${path.join(this.certDir, certificateFileName)}.key`;
|
|
692
698
|
|
|
693
|
-
let listen = `${this.httpsPort} ssl
|
|
699
|
+
let listen = `${this.httpsPort} ssl ${this.isHttp2Supported ? 'http2' : ''}`.trim();
|
|
694
700
|
if (serverName === '_') {
|
|
695
701
|
listen = `${listen} default_server`;
|
|
696
702
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abtnode/router-provider",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.9",
|
|
4
4
|
"description": "Routing engine implementations for abt node",
|
|
5
5
|
"author": "polunzh <polunzh@gmail.com>",
|
|
6
6
|
"homepage": "https://github.com/ArcBlock/blocklet-server#readme",
|
|
@@ -32,11 +32,11 @@
|
|
|
32
32
|
"url": "https://github.com/ArcBlock/blocklet-server/issues"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@abtnode/constant": "1.7.
|
|
36
|
-
"@abtnode/logger": "1.7.
|
|
37
|
-
"@abtnode/router-templates": "1.7.
|
|
38
|
-
"@abtnode/util": "1.7.
|
|
39
|
-
"axios": "^0.
|
|
35
|
+
"@abtnode/constant": "1.7.9",
|
|
36
|
+
"@abtnode/logger": "1.7.9",
|
|
37
|
+
"@abtnode/router-templates": "1.7.9",
|
|
38
|
+
"@abtnode/util": "1.7.9",
|
|
39
|
+
"axios": "^0.26.1",
|
|
40
40
|
"debug": "^4.3.3",
|
|
41
41
|
"find-process": "^1.4.3",
|
|
42
42
|
"fkill": "^7.0.1",
|
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
"fs-extra": "^10.0.1",
|
|
63
63
|
"needle": "^3.0.0"
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "285f4fedd41fcb8e1814ce5d8250ac10616e67e0"
|
|
66
66
|
}
|