A simple proxy on Node.js
Switch branches/tags
Nothing to show
Clone or download
jin5354 update
update
Latest commit 88eae0c Aug 7, 2016
Permalink
Failed to load latest commit information.
.gitignore update Aug 7, 2016
README.md 0.1.7 fix readme Aug 7, 2016
package.json update Aug 7, 2016
proxy.js update mock Aug 4, 2016

README.md

tinyproxy

支持http、https的透明转发代理,支持抓包改包,目前支持socks5的二次转发。

使用

let proxy = new tinyProxy({
    port: 9999,
    agent: 'http'
});

proxy.start();
console.log(`proxy started! Listening on port 9999.`);

可配置项:

{
    port: 9999,
    agent: 'http',
    mock: mock,  //是否启用mock模式
    onServerError: function(){},
    onBeforeRequest: function(){},
    onBeforeResponse: function(){},
    onRequestError: function(){}
}


//mock 处理函数

let mock = (req, res, requestOptions) => {  //req:原始请求 res:回送数据 requestOptions:处理后的req,可以直接用于request库
    console.log(`MOCK ${req.method}: ${req.url}`);
    res.writeHead(result.statusCode, '', result.headers); //自己的mock数据...
    res.end(result.body);
};

license

MIT

致谢

mini-proxy