Comparing version 3.0.6 to 3.0.7
@@ -0,1 +1,18 @@ | ||
## [3.0.7](https://github.com/feix760/feproxy/compare/v3.0.6...v3.0.7) (2020-03-11) | ||
### Bug Fixes | ||
* Fix close alive socket ([092cc7d](https://github.com/feix760/feproxy/commit/092cc7d)) | ||
* Fix devtools websocket ip updated bug ([b0a23c5](https://github.com/feix760/feproxy/commit/b0a23c5)) | ||
* host not the same fix for android ([2151bce](https://github.com/feix760/feproxy/commit/2151bce)) | ||
* save https settings to file ([d972fe3](https://github.com/feix760/feproxy/commit/d972fe3)) | ||
### Features | ||
* https capture settings ([686da51](https://github.com/feix760/feproxy/commit/686da51)) | ||
## [3.0.6](https://github.com/feix760/feproxy/compare/v3.0.4...v3.0.6) (2019-07-17) | ||
@@ -2,0 +19,0 @@ |
@@ -5,2 +5,3 @@ | ||
const chalk = require('chalk'); | ||
const ip = require('ip'); | ||
@@ -40,3 +41,9 @@ exports.crt = async ctx => { | ||
exports.getConfig = async ctx => { | ||
ctx.body = ctx.app.config; | ||
const { config } = ctx.app; | ||
ctx.body = { | ||
...config, | ||
devtoolsURL: `/devtools/inspector.html?ws=${ip.address()}:${config.port}/ws`, | ||
}; | ||
}; |
const url = require('url'); | ||
const URL = Symbol('URL'); | ||
@@ -29,3 +30,11 @@ | ||
} else { | ||
this[URL] = this.request.url; | ||
let href = this.request.url; | ||
const hrefInfo = url.parse(href); | ||
const headerHost = this.get('host'); | ||
if (headerHost && hrefInfo.host && hrefInfo.host !== headerHost) { | ||
const replacedHref = href.replace(hrefInfo.host, headerHost); | ||
console.log('replace', href, replacedHref); | ||
href = replacedHref; | ||
} | ||
this[URL] = href; | ||
} | ||
@@ -32,0 +41,0 @@ } |
const EventEmitter = require('events'); | ||
const Client = require('./Client'); | ||
const REQUEST_ID = Symbol('REQUEST_ID'); | ||
@@ -105,4 +106,4 @@ const modules = [ | ||
nextId() { | ||
this._id = this._id || 100; | ||
return `${++this._id}`; | ||
this[REQUEST_ID] = this[REQUEST_ID] || 100; | ||
return `${++this[REQUEST_ID]}`; | ||
} | ||
@@ -109,0 +110,0 @@ |
@@ -5,2 +5,3 @@ const Stream = require('stream'); | ||
const inspectorUtil = require('../util/inspectorUtil'); | ||
const INSPECTOR = Symbol('INSPECTOR'); | ||
@@ -14,3 +15,3 @@ module.exports = inspector => { | ||
loaderId: inspector.frame.loaderId, | ||
requestId: ctx._inspector.requestId, | ||
requestId: ctx[INSPECTOR].requestId, | ||
documentURL: inspector.frame.url, | ||
@@ -21,3 +22,3 @@ }); | ||
const requestId = inspector.nextId(); | ||
ctx._inspector = { | ||
ctx[INSPECTOR] = { | ||
requestId, | ||
@@ -69,3 +70,3 @@ }; | ||
Object.assign(ctx._inspector, { | ||
Object.assign(ctx[INSPECTOR], { | ||
mimeType, | ||
@@ -146,7 +147,7 @@ type, | ||
if (ctx._inspector.type.match(/Stylesheet|Document|Script|XHR/)) { | ||
if (ctx[INSPECTOR].type.match(/Stylesheet|Document|Script|XHR/)) { | ||
decoded = inspectorUtil.buffer2String(decoded) || decoded; | ||
} | ||
const info = requestInfoPool.get(ctx._inspector.requestId); | ||
const info = requestInfoPool.get(ctx[INSPECTOR].requestId); | ||
if (info) { | ||
@@ -153,0 +154,0 @@ info.body = decoded; |
@@ -36,3 +36,5 @@ | ||
const urlInfo = url.parse(param.url || ctx.url); | ||
headers.host = urlInfo.hostname; | ||
if (param.url) { | ||
headers.host = urlInfo.hostname; | ||
} | ||
@@ -39,0 +41,0 @@ let proxy; |
const net = require('net'); | ||
const catchError = require('../util/catchError'); | ||
const ServerFactory = require('./ServerFactory'); | ||
const ALIVE_ID = Symbol('ALIVE_ID'); | ||
@@ -113,4 +114,4 @@ class ProxyServer { | ||
const { aliveSockets } = this; | ||
this._aliveId = this._aliveId || 1; | ||
const id = this._aliveId; | ||
this[ALIVE_ID] = this[ALIVE_ID] || 1; | ||
const id = this[ALIVE_ID]++; | ||
aliveSockets[id] = socket; | ||
@@ -117,0 +118,0 @@ socket.once('close', () => { |
@@ -13,2 +13,6 @@ const http = require('http'); | ||
const ignoreCertErrorCodes = [ | ||
'UNABLE_TO_GET_ISSUER_CERT_LOCALLY', | ||
]; | ||
class ServerFactory { | ||
@@ -86,3 +90,6 @@ constructor(app) { | ||
req.on('error', err => { | ||
if (certErrorCodes.includes(err.code)) { | ||
if (ignoreCertErrorCodes.includes(err.code)) { | ||
resolve('SUCCESS'); | ||
} else if (certErrorCodes.includes(err.code)) { | ||
console.log(hostname, err.code); | ||
resolve('FAIL'); | ||
@@ -89,0 +96,0 @@ } else { |
const path = require('path'); | ||
const fs = require('fs-extra'); | ||
const ip = require('ip'); | ||
const escapeStringRegexp = require('escape-string-regexp'); | ||
@@ -29,4 +28,2 @@ const RULES = Symbol('RULES'); | ||
config.devtoolsURL = `/devtools/inspector.html?ws=${ip.address()}:${config.port}/ws`; | ||
Object.assign(this, config); | ||
@@ -44,2 +41,3 @@ this[RULES] = []; | ||
projects: this.projects, | ||
https: this.https, | ||
}); | ||
@@ -46,0 +44,0 @@ } |
{ | ||
"name": "feproxy", | ||
"version": "3.0.6", | ||
"version": "3.0.7", | ||
"description": "An node proxy server for web development", | ||
@@ -5,0 +5,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
740937
3856