mirror of
https://github.com/alibaba/anyproxy.git
synced 2025-05-10 14:58:27 +00:00
remove redundant rule file
This commit is contained in:
parent
1057676b9b
commit
e8d7e12960
64
diff.txt
Normal file
64
diff.txt
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
diff --git a/bin.js b/bin.js
|
||||||
|
index 9b7f39b..86ccdee 100644
|
||||||
|
--- a/bin.js
|
||||||
|
+++ b/bin.js
|
||||||
|
@@ -4,6 +4,7 @@ var program = require('commander'),
|
||||||
|
proxy = require("./proxy.js"),
|
||||||
|
color = require('colorful'),
|
||||||
|
fs = require("fs"),
|
||||||
|
+ path = require("path"),
|
||||||
|
packageInfo = require("./package.json");
|
||||||
|
|
||||||
|
program
|
||||||
|
@@ -33,15 +34,16 @@ if(program.clear){
|
||||||
|
var ruleModule;
|
||||||
|
|
||||||
|
if(program.rule){
|
||||||
|
- if(fs.existsSync(program.rule)){
|
||||||
|
- try{ //for abs path
|
||||||
|
+ var ruleFilePath = path.join(process.cwd(),program.rule);
|
||||||
|
+ try{
|
||||||
|
+ if(fs.existsSync(ruleFilePath)){
|
||||||
|
ruleModule = require(program.rule);
|
||||||
|
- }catch(e){ //for relative path
|
||||||
|
- ruleModule = require(process.cwd() + '/' + program.rule.replace(/^\.\//,''));
|
||||||
|
+ console.log("rule file loaded :" + ruleFilePath);
|
||||||
|
+ }else{
|
||||||
|
+ console.log(color.red("can not find rule file"));
|
||||||
|
}
|
||||||
|
- console.log(color.green("rule file loaded"));
|
||||||
|
- }else{
|
||||||
|
- console.log(color.red("can not find rule file"));
|
||||||
|
+ }catch(e){
|
||||||
|
+ console.log("failed to load rule file :" + e.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
diff --git a/lib/requestHandler.js b/lib/requestHandler.js
|
||||||
|
index 37f19d4..620b7f9 100644
|
||||||
|
--- a/lib/requestHandler.js
|
||||||
|
+++ b/lib/requestHandler.js
|
||||||
|
@@ -364,7 +364,7 @@ function setRules(newRule){
|
||||||
|
}
|
||||||
|
if('function' == typeof(userRule.summary)){
|
||||||
|
functions.push(function(cb){
|
||||||
|
- userRule.summary();
|
||||||
|
+ console.log(userRule.summary());
|
||||||
|
cb(null);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
diff --git a/rule_sample/README.md b/rule_sample/README.md
|
||||||
|
index 7a8eabb..7c29ff5 100644
|
||||||
|
--- a/rule_sample/README.md
|
||||||
|
+++ b/rule_sample/README.md
|
||||||
|
@@ -27,6 +27,9 @@ The following are sample rules.
|
||||||
|
* rule_replace_response_status_code.js
|
||||||
|
* replace server's status code
|
||||||
|
* 改变服务端响应的http状态码
|
||||||
|
+* rule_reverse_proxy.js
|
||||||
|
+ * assign a specific ip address for request
|
||||||
|
+ * 为请求绑定目标ip
|
||||||
|
* rule_use_local_data.js
|
||||||
|
* map some requests to local file
|
||||||
|
* 把图片响应映射到本地
|
||||||
|
\ No newline at end of file
|
@ -9,9 +9,6 @@ The following are sample rules.
|
|||||||
* rule_allow_CORS.js
|
* rule_allow_CORS.js
|
||||||
* add CORS headers to allow cross-domain ajax request
|
* add CORS headers to allow cross-domain ajax request
|
||||||
* 为ajax请求增加跨域头
|
* 为ajax请求增加跨域头
|
||||||
* rule_assign_ip_address.js
|
|
||||||
* assign an ip address to a specified domain
|
|
||||||
* 为某个域名指定ip地址
|
|
||||||
* rule_intercept_some_https_requests.js
|
* rule_intercept_some_https_requests.js
|
||||||
* intercept https requests toward github.com and append some data
|
* intercept https requests toward github.com and append some data
|
||||||
* 截获github.com的https请求,再在最后加点文字
|
* 截获github.com的https请求,再在最后加点文字
|
||||||
|
@ -1,13 +0,0 @@
|
|||||||
//sample : assign 127.0.0.1 to www.taobao.com
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
|
|
||||||
replaceRequestOption : function(req,option){
|
|
||||||
if(option.hostname == "www.taobao.com"){
|
|
||||||
option.hostname = "127.0.0.1";
|
|
||||||
}
|
|
||||||
|
|
||||||
return option;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
Loading…
x
Reference in New Issue
Block a user