mirror of
https://github.com/alibaba/anyproxy.git
synced 2025-04-23 20:31:25 +00:00
Merge branch 'master' into optimize_web_server
This commit is contained in:
commit
d25a8a2274
@ -116,7 +116,7 @@ var options = {
|
|||||||
webConfigPort : 8088, // optional, internal port for web config(beta), replace this when it is conflict with your own service
|
webConfigPort : 8088, // optional, internal port for web config(beta), replace this when it is conflict with your own service
|
||||||
throttle : 10, // optional, speed limit in kb/s
|
throttle : 10, // optional, speed limit in kb/s
|
||||||
disableWebInterface : false, //optional, set it when you don't want to use the web interface
|
disableWebInterface : false, //optional, set it when you don't want to use the web interface
|
||||||
silent : false, //optional, do not print anything into terminal. do not set it when you are still debugging.
|
silent : false //optional, do not print anything into terminal. do not set it when you are still debugging.
|
||||||
};
|
};
|
||||||
new proxy.proxyServer(options);
|
new proxy.proxyServer(options);
|
||||||
|
|
||||||
|
7
proxy.js
7
proxy.js
@ -51,12 +51,7 @@ try{
|
|||||||
if(fs.existsSync(path.join(process.cwd(),'rule.js'))){
|
if(fs.existsSync(path.join(process.cwd(),'rule.js'))){
|
||||||
default_rule = require(path.join(process.cwd(),'rule'));
|
default_rule = require(path.join(process.cwd(),'rule'));
|
||||||
}
|
}
|
||||||
}catch(e){
|
}catch(e){}
|
||||||
if(e){
|
|
||||||
logUtil.printLog("error" + e, logUtil.T_ERR);
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//option
|
//option
|
||||||
//option.type : 'http'(default) or 'https'
|
//option.type : 'http'(default) or 'https'
|
||||||
|
@ -98,7 +98,7 @@ module.exports = {
|
|||||||
//替换服务器响应的数据
|
//替换服务器响应的数据
|
||||||
//replace the response from the server before it's sent to the user
|
//replace the response from the server before it's sent to the user
|
||||||
//you may return either a Buffer or a string
|
//you may return either a Buffer or a string
|
||||||
//serverResData is a Buffer, you may get its content by calling serverResData.toString()
|
//serverResData is a Buffer. for those non-unicode reponse , serverResData.toString() should not be your first choice.
|
||||||
replaceServerResDataAsync: function(req,res,serverResData,callback){
|
replaceServerResDataAsync: function(req,res,serverResData,callback){
|
||||||
callback(serverResData);
|
callback(serverResData);
|
||||||
},
|
},
|
||||||
|
@ -4,6 +4,9 @@ module.exports = {
|
|||||||
|
|
||||||
replaceServerResDataAsync: function(req,res,serverResData,callback){
|
replaceServerResDataAsync: function(req,res,serverResData,callback){
|
||||||
//append "hello world" to all web pages
|
//append "hello world" to all web pages
|
||||||
|
|
||||||
|
//for those non-unicode response , serverResData.toString() should not be your first choice.
|
||||||
|
//this issue may help you understanding how to modify an non-unicode response: https://github.com/alibaba/anyproxy/issues/20
|
||||||
if(/html/i.test(res.headers['content-type'])){
|
if(/html/i.test(res.headers['content-type'])){
|
||||||
var newDataStr = serverResData.toString();
|
var newDataStr = serverResData.toString();
|
||||||
newDataStr += "hello world!";
|
newDataStr += "hello world!";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user