whistle 2.9.10 → 2.9.13

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/biz/index.js CHANGED
@@ -18,6 +18,7 @@ var CUSTOM_REAL_WEBUI_HOST = new RegExp('^/[\\w.-]*\\.whistle-path\\.5b6af7b9884
18
18
  var CUSTOM_INTERNAL_APP = new RegExp('^/[\\w.-]*\\.whistle-path\\.5b6af7b9884e1165[\\w.-]*/+(log|weinre|cgi)(?:\\.(\\d{1,5}))?/');
19
19
  var CUSTOM_PLUGIN_RE = new RegExp('^/[\\w.-]*\\.whistle-path\\.5b6af7b9884e1165[\\w.-]*/+whistle\\.([a-z\\d_-]+)/');
20
20
  var REAL_WEBUI_HOST_PARAM = /_whistleInternalHost_=(__([a-z\d.-]+)(?:__(\d{1,5}))?__)/;
21
+ var OUTER_PLUGIN_RE = /^(?:\/whistle)?\/((?:whistle|plugin)\.[a-z\\d_-]+)::(\d{1,5})\//;
21
22
 
22
23
  module.exports = function(req, res, next) {
23
24
  var config = this.config;
@@ -118,8 +119,16 @@ module.exports = function(req, res, next) {
118
119
  if (isOthers) {
119
120
  util.transformReq(req, res, transformPort);
120
121
  } else {
121
- req._hasRespond = true;
122
122
  req.url = req.url.replace(transformPort ? internalAppRe : webUI, '/');
123
+ if (OUTER_PLUGIN_RE.test(req.path)) {
124
+ var outerPort = RegExp.$2;
125
+ req.url = req.url.replace(RegExp['$&'], '/' + RegExp.$1 + '/');
126
+ if (outerPort > 0 && outerPort < 65536 && outerPort != config.port) {
127
+ req.headers.host = '127.0.0.1:' + outerPort;
128
+ return util.transformReq(req, res, outerPort);
129
+ }
130
+ }
131
+ req._hasRespond = true;
123
132
  if (isWeinre) {
124
133
  handleWeinreReq(req, res);
125
134
  } else {
@@ -52,6 +52,7 @@ exports.getServerInfo = function(req) {
52
52
  isWin: util.isWin,
53
53
  port: config.port,
54
54
  realPort: config.realPort,
55
+ realHost: config.realHost,
55
56
  socksPort: config.socksPort,
56
57
  httpPort: config.httpPort,
57
58
  httpsPort: config.httpsPort,
@@ -8,6 +8,6 @@
8
8
  </head>
9
9
  <body style="overscroll-behavior-x: none;">
10
10
  <div id="container" class="main"></div>
11
- <script src="js/index.js?v=2.9.10"></script>
11
+ <script src="js/index.js?v=2.9.11"></script>
12
12
  </body>
13
13
  </html>