diff --git a/README.md b/README.md index b88e11c..43419e8 100644 --- a/README.md +++ b/README.md @@ -101,7 +101,7 @@ Others #### to save request data * to save request data to local file, use ``` anyproxy --file /path/to/file ``` * anyproxy uses [nedb](https://github.com/louischatriot/nedb) to save request data. Since NeDB's persistence uses an append-only format, you may get some redundant record in local file. For those dupplicated ones with the same id, just use the lastest line of record. -* [TrafficeRecorder](https://github.com/ottomao/TrafficRecorder) is another tool based on anyproxy to help recording all requests. You may have a try. +* [TrafficeRecorder](https://github.com/ottomao/TrafficRecorder) is another tool based on anyproxy to help recording all request data, including header and body. You may have a try. #### throttling * for instance, ``` anyproxy --throttle 10 ``` sets the speed limit to 10kb/s (kbyte/sec) diff --git a/lib/requestHandler.js b/lib/requestHandler.js index c2b81fd..c3e764e 100644 --- a/lib/requestHandler.js +++ b/lib/requestHandler.js @@ -365,8 +365,6 @@ function setRules(newRule){ } }); - //'function' == typeof(userRule.init) && console.log(userRule.init()); - //'function' == typeof(userRule.summary) && console.log(userRule.summary()); } } diff --git a/lib/rule_default.js b/lib/rule_default.js index 525496a..09ee670 100644 --- a/lib/rule_default.js +++ b/lib/rule_default.js @@ -59,7 +59,18 @@ module.exports = { //[beta] //fetch entire traffic data - fetchTrafficData: function(id,info){} + fetchTrafficData: function(id,info){}, + + customMenu:[ + { + name :"test", + handler :function(){} + },{ + name :"second-test", + handler :function(){} + } + ] + }; function mergeCORSHeader(reqHeader,originHeader){ diff --git a/proxy.js b/proxy.js index f2e52f6..291f6aa 100644 --- a/proxy.js +++ b/proxy.js @@ -124,9 +124,20 @@ function proxyServer(option){ console.log('web interface is disabled'); callback(null); }else{ - + + var customMenuConfig = proxyRules.customMenu, + menuList = [], + menuListStr; + + if(customMenuConfig && customMenuConfig.length){ + for(var i = 0 ; i < customMenuConfig.length ; i++){ + menuList.push(customMenuConfig[i].name); + } + } + menuListStr = menuList.join("@@@"); + //web interface - var args = [proxyWebPort, socketPort, proxyConfigPort, requestHandler.getRuleSummary(), ip.address()]; + var args = [proxyWebPort, socketPort, proxyConfigPort, requestHandler.getRuleSummary(), ip.address(),menuListStr]; var child_webServer = fork(path.join(__dirname,"./webServer.js"),args); child_webServer.on("message",function(data){ if(data.type == "reqBody" && data.id){ @@ -248,8 +259,7 @@ function UIConfigServer(port){ }; customerRule.dealLocalResponse = function(req,reqBody,callback){ - callback(200,{"content-type":"text/html"},req.willResponse) - + callback(200,{"content-type":"text/html"},req.willResponse); return req.willResponse; }; diff --git a/web/index.html b/web/index.html index 1105577..0cac75c 100644 --- a/web/index.html +++ b/web/index.html @@ -24,7 +24,9 @@ Clear Logs(Ctrl+X) | Fetch rootCA.crt - Config Local Response(beta) + Others + + | Anyproxy(Github) @@ -66,6 +68,7 @@ +