@abtnode/router-provider 1.7.8 → 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.
@@ -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 httpServerModule = opts.serverModule || http;
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) {
@@ -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.8",
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,10 +32,10 @@
32
32
  "url": "https://github.com/ArcBlock/blocklet-server/issues"
33
33
  },
34
34
  "dependencies": {
35
- "@abtnode/constant": "1.7.8",
36
- "@abtnode/logger": "1.7.8",
37
- "@abtnode/router-templates": "1.7.8",
38
- "@abtnode/util": "1.7.8",
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
39
  "axios": "^0.26.1",
40
40
  "debug": "^4.3.3",
41
41
  "find-process": "^1.4.3",
@@ -62,5 +62,5 @@
62
62
  "fs-extra": "^10.0.1",
63
63
  "needle": "^3.0.0"
64
64
  },
65
- "gitHead": "ae75dd20b4750a31dc53c88b75ed1d95c8f15397"
65
+ "gitHead": "285f4fedd41fcb8e1814ce5d8250ac10616e67e0"
66
66
  }