update readme and doc

This commit is contained in:
Otto Mao 2017-12-01 21:58:32 +08:00
parent 4be5aa8954
commit 3022f1de18
16 changed files with 43 additions and 108 deletions

View File

@ -22,7 +22,7 @@ AnyProxy是一个基于NodeJS的可供插件配置的HTTP/HTTPS代理服务
主页:[AnyProxy.io](http://anyproxy.io) 主页:[AnyProxy.io](http://anyproxy.io)
![](https://gw.alipayobjects.com/zos/rmsportal/JoxHUbVhXNedsPUUilnj.gif) ![](http://alipay-os.oss-cn-hangzhou-zmf.aliyuncs.com/rmsportal/JlbMhWBYnuPMsvVfOXyl.jpg)
---------------- ----------------

View File

@ -14,6 +14,7 @@ Github主页https://github.com/alibaba/anyproxy/tree/4.x
* 基于Node.js开放二次开发能力允许自定义请求处理逻辑 * 基于Node.js开放二次开发能力允许自定义请求处理逻辑
* 支持Https的解析 * 支持Https的解析
* 提供GUI界面用以观察请求 * 提供GUI界面用以观察请求
相比3.x版本AnyProxy 4.0的主要变化: 相比3.x版本AnyProxy 4.0的主要变化:
* 规则文件Rule全面支持Promise和Generator * 规则文件Rule全面支持Promise和Generator
@ -29,7 +30,7 @@ Github主页https://github.com/alibaba/anyproxy/tree/4.x
对于Debian或者Ubuntu系统在安装AnyProxy之前可能还需要安装 `nodejs-legacy` 对于Debian或者Ubuntu系统在安装AnyProxy之前可能还需要安装 `nodejs-legacy`
```bash ```bash
sudo apg-get install nodejs-legacy sudo apt-get install nodejs-legacy
``` ```
然后安装AnyProxy 然后安装AnyProxy
@ -223,19 +224,11 @@ AnyProxy提供了二次开发的能力你可以用js编写自己的规则模
```js ```js
// file: sample.js // file: sample.js
module.exports = { module.exports = {
summary: 'a rule to modify response', summary: 'a rule to hack response',
*beforeSendResponse(requestDetail, responseDetail) { *beforeSendResponse(requestDetail, responseDetail) {
if (requestDetail.url === 'http://httpbin.org/user-agent') { if (requestDetail.url === 'http://httpbin.org/user-agent') {
const newResponse = responseDetail.response; const newResponse = responseDetail.response;
newResponse.body += '<br/><span style="color:blue">-- AnyProxy Hacked! --</span>'; newResponse.body += '- AnyProxy Hacked!';
newResponse.body += `<script>
setTimeout(
function (){
window.alert("Sorry, You Are Hacked...")
}, 300);
</script>`;
newResponse.header['Content-Type'] = 'text/html';
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
setTimeout(() => { // delay setTimeout(() => { // delay

View File

@ -5,7 +5,7 @@
对于Debian或者Ubuntu系统在安装AnyProxy之前可能还需要安装 `nodejs-legacy` 对于Debian或者Ubuntu系统在安装AnyProxy之前可能还需要安装 `nodejs-legacy`
```bash ```bash
sudo apg-get install nodejs-legacy sudo apt-get install nodejs-legacy
``` ```
然后安装AnyProxy 然后安装AnyProxy

View File

@ -14,6 +14,7 @@ Github主页https://github.com/alibaba/anyproxy/tree/4.x
* 基于Node.js开放二次开发能力允许自定义请求处理逻辑 * 基于Node.js开放二次开发能力允许自定义请求处理逻辑
* 支持Https的解析 * 支持Https的解析
* 提供GUI界面用以观察请求 * 提供GUI界面用以观察请求
相比3.x版本AnyProxy 4.0的主要变化: 相比3.x版本AnyProxy 4.0的主要变化:
* 规则文件Rule全面支持Promise和Generator * 规则文件Rule全面支持Promise和Generator
@ -29,7 +30,7 @@ Github主页https://github.com/alibaba/anyproxy/tree/4.x
对于Debian或者Ubuntu系统在安装AnyProxy之前可能还需要安装 `nodejs-legacy` 对于Debian或者Ubuntu系统在安装AnyProxy之前可能还需要安装 `nodejs-legacy`
```bash ```bash
sudo apg-get install nodejs-legacy sudo apt-get install nodejs-legacy
``` ```
然后安装AnyProxy 然后安装AnyProxy
@ -223,19 +224,11 @@ AnyProxy提供了二次开发的能力你可以用js编写自己的规则模
```js ```js
// file: sample.js // file: sample.js
module.exports = { module.exports = {
summary: 'a rule to modify response', summary: 'a rule to hack response',
*beforeSendResponse(requestDetail, responseDetail) { *beforeSendResponse(requestDetail, responseDetail) {
if (requestDetail.url === 'http://httpbin.org/user-agent') { if (requestDetail.url === 'http://httpbin.org/user-agent') {
const newResponse = responseDetail.response; const newResponse = responseDetail.response;
newResponse.body += '<br/><span style="color:blue">-- AnyProxy Hacked! --</span>'; newResponse.body += '- AnyProxy Hacked!';
newResponse.body += `<script>
setTimeout(
function (){
window.alert("Sorry, You Are Hacked...")
}, 300);
</script>`;
newResponse.header['Content-Type'] = 'text/html';
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
setTimeout(() => { // delay setTimeout(() => { // delay

View File

@ -29,7 +29,7 @@ Change Logs since 3.x:
To Debian and Ubuntu users, you may need to install `nodejs-legacy` at the same time To Debian and Ubuntu users, you may need to install `nodejs-legacy` at the same time
```bash ```bash
sudo apg-get install nodejs-legacy sudo apt-get install nodejs-legacy
``` ```
Then install the AnyProxy Then install the AnyProxy
@ -222,20 +222,11 @@ Rule module could do the following stuff:
```js ```js
// file: sample.js // file: sample.js
module.exports = { module.exports = {
summary: 'a rule to modify response', summary: 'a rule to hack response',
*beforeSendResponse(requestDetail, responseDetail) { *beforeSendResponse(requestDetail, responseDetail) {
if (requestDetail.url === 'http://httpbin.org/user-agent') { if (requestDetail.url === 'http://httpbin.org/user-agent') {
const newResponse = responseDetail.response; const newResponse = responseDetail.response;
newResponse.body += '- AnyProxy Hacked!';
newResponse.body += '<br/><span style="color:blue">-- AnyProxy Hacked! --</span>';
newResponse.body += `<script>
setTimeout(
function (){
window.alert("Sorry, You Are Hacked...")
}, 300);
</script>`;
newResponse.header['Content-Type'] = 'text/html';
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
setTimeout(() => { // delay setTimeout(() => { // delay

View File

@ -4,7 +4,7 @@
To Debian and Ubuntu users, you may need to install `nodejs-legacy` at the same time To Debian and Ubuntu users, you may need to install `nodejs-legacy` at the same time
```bash ```bash
sudo apg-get install nodejs-legacy sudo apt-get install nodejs-legacy
``` ```
Then install the AnyProxy Then install the AnyProxy

View File

@ -29,7 +29,7 @@ Change Logs since 3.x:
To Debian and Ubuntu users, you may need to install `nodejs-legacy` at the same time To Debian and Ubuntu users, you may need to install `nodejs-legacy` at the same time
```bash ```bash
sudo apg-get install nodejs-legacy sudo apt-get install nodejs-legacy
``` ```
Then install the AnyProxy Then install the AnyProxy
@ -222,20 +222,11 @@ Rule module could do the following stuff:
```js ```js
// file: sample.js // file: sample.js
module.exports = { module.exports = {
summary: 'a rule to modify response', summary: 'a rule to hack response',
*beforeSendResponse(requestDetail, responseDetail) { *beforeSendResponse(requestDetail, responseDetail) {
if (requestDetail.url === 'http://httpbin.org/user-agent') { if (requestDetail.url === 'http://httpbin.org/user-agent') {
const newResponse = responseDetail.response; const newResponse = responseDetail.response;
newResponse.body += '- AnyProxy Hacked!';
newResponse.body += '<br/><span style="color:blue">-- AnyProxy Hacked! --</span>';
newResponse.body += `<script>
setTimeout(
function (){
window.alert("Sorry, You Are Hacked...")
}, 300);
</script>`;
newResponse.header['Content-Type'] = 'text/html';
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
setTimeout(() => { // delay setTimeout(() => { // delay

View File

@ -5,7 +5,7 @@
对于Debian或者Ubuntu系统在安装AnyProxy之前可能还需要安装 `nodejs-legacy` 对于Debian或者Ubuntu系统在安装AnyProxy之前可能还需要安装 `nodejs-legacy`
```bash ```bash
sudo apg-get install nodejs-legacy sudo apt-get install nodejs-legacy
``` ```
然后安装AnyProxy 然后安装AnyProxy

View File

@ -755,11 +755,11 @@
<ul> <ul>
<li>&#x57FA;&#x4E8E;Node.js&#xFF0C;&#x5F00;&#x653E;&#x4E8C;&#x6B21;&#x5F00;&#x53D1;&#x80FD;&#x529B;&#xFF0C;&#x5141;&#x8BB8;&#x81EA;&#x5B9A;&#x4E49;&#x8BF7;&#x6C42;&#x5904;&#x7406;&#x903B;&#x8F91;</li> <li>&#x57FA;&#x4E8E;Node.js&#xFF0C;&#x5F00;&#x653E;&#x4E8C;&#x6B21;&#x5F00;&#x53D1;&#x80FD;&#x529B;&#xFF0C;&#x5141;&#x8BB8;&#x81EA;&#x5B9A;&#x4E49;&#x8BF7;&#x6C42;&#x5904;&#x7406;&#x903B;&#x8F91;</li>
<li>&#x652F;&#x6301;Https&#x7684;&#x89E3;&#x6790;</li> <li>&#x652F;&#x6301;Https&#x7684;&#x89E3;&#x6790;</li>
<li><p>&#x63D0;&#x4F9B;GUI&#x754C;&#x9762;&#xFF0C;&#x7528;&#x4EE5;&#x89C2;&#x5BDF;&#x8BF7;&#x6C42; <li>&#x63D0;&#x4F9B;GUI&#x754C;&#x9762;&#xFF0C;&#x7528;&#x4EE5;&#x89C2;&#x5BDF;&#x8BF7;&#x6C42;</li>
&#x76F8;&#x6BD4;3.x&#x7248;&#x672C;&#xFF0C;AnyProxy 4.0&#x7684;&#x4E3B;&#x8981;&#x53D8;&#x5316;&#xFF1A;</p> </ul>
</li> <p>&#x76F8;&#x6BD4;3.x&#x7248;&#x672C;&#xFF0C;AnyProxy 4.0&#x7684;&#x4E3B;&#x8981;&#x53D8;&#x5316;&#xFF1A;</p>
<li><p>&#x89C4;&#x5219;&#x6587;&#x4EF6;&#xFF08;Rule&#xFF09;&#x5168;&#x9762;&#x652F;&#x6301;Promise&#x548C;Generator</p> <ul>
</li> <li>&#x89C4;&#x5219;&#x6587;&#x4EF6;&#xFF08;Rule&#xFF09;&#x5168;&#x9762;&#x652F;&#x6301;Promise&#x548C;Generator</li>
<li>&#x7B80;&#x5316;&#x4E86;&#x89C4;&#x5219;&#x6587;&#x4EF6;&#x5185;&#x7684;&#x63A5;&#x53E3;</li> <li>&#x7B80;&#x5316;&#x4E86;&#x89C4;&#x5219;&#x6587;&#x4EF6;&#x5185;&#x7684;&#x63A5;&#x53E3;</li>
<li>Web&#x7248;&#x754C;&#x9762;&#x91CD;&#x6784;</li> <li>Web&#x7248;&#x754C;&#x9762;&#x91CD;&#x6784;</li>
</ul> </ul>
@ -768,7 +768,7 @@
<h2 id="&#x4F5C;&#x4E3A;&#x5168;&#x5C40;&#x6A21;&#x5757;">&#x4F5C;&#x4E3A;&#x5168;&#x5C40;&#x6A21;&#x5757;</h2> <h2 id="&#x4F5C;&#x4E3A;&#x5168;&#x5C40;&#x6A21;&#x5757;">&#x4F5C;&#x4E3A;&#x5168;&#x5C40;&#x6A21;&#x5757;</h2>
<h3 id="&#x5B89;&#x88C5;">&#x5B89;&#x88C5;</h3> <h3 id="&#x5B89;&#x88C5;">&#x5B89;&#x88C5;</h3>
<p>&#x5BF9;&#x4E8E;Debian&#x6216;&#x8005;Ubuntu&#x7CFB;&#x7EDF;&#xFF0C;&#x5728;&#x5B89;&#x88C5;AnyProxy&#x4E4B;&#x524D;&#xFF0C;&#x53EF;&#x80FD;&#x8FD8;&#x9700;&#x8981;&#x5B89;&#x88C5; <code>nodejs-legacy</code></p> <p>&#x5BF9;&#x4E8E;Debian&#x6216;&#x8005;Ubuntu&#x7CFB;&#x7EDF;&#xFF0C;&#x5728;&#x5B89;&#x88C5;AnyProxy&#x4E4B;&#x524D;&#xFF0C;&#x53EF;&#x80FD;&#x8FD8;&#x9700;&#x8981;&#x5B89;&#x88C5; <code>nodejs-legacy</code></p>
<pre><code class="lang-bash">sudo apg-get install nodejs-legacy <pre><code class="lang-bash">sudo apt-get install nodejs-legacy
</code></pre> </code></pre>
<p>&#x7136;&#x540E;&#xFF0C;&#x5B89;&#x88C5;AnyProxy</p> <p>&#x7136;&#x540E;&#xFF0C;&#x5B89;&#x88C5;AnyProxy</p>
<pre><code class="lang-bash">npm install -g anyproxy <pre><code class="lang-bash">npm install -g anyproxy
@ -974,19 +974,11 @@ anyproxy --intercept <span class="hljs-comment">#&#x542F;&#x52A8;AnyProxy&#xFF0C
<li><p>Step 1&#xFF0C;&#x7F16;&#x5199;&#x89C4;&#x5219;</p> <li><p>Step 1&#xFF0C;&#x7F16;&#x5199;&#x89C4;&#x5219;</p>
<pre><code class="lang-js"><span class="hljs-comment">// file: sample.js</span> <pre><code class="lang-js"><span class="hljs-comment">// file: sample.js</span>
<span class="hljs-built_in">module</span>.exports = { <span class="hljs-built_in">module</span>.exports = {
summary: <span class="hljs-string">&apos;a rule to modify response&apos;</span>, summary: <span class="hljs-string">&apos;a rule to hack response&apos;</span>,
*beforeSendResponse(requestDetail, responseDetail) { *beforeSendResponse(requestDetail, responseDetail) {
<span class="hljs-keyword">if</span> (requestDetail.url === <span class="hljs-string">&apos;http://httpbin.org/user-agent&apos;</span>) { <span class="hljs-keyword">if</span> (requestDetail.url === <span class="hljs-string">&apos;http://httpbin.org/user-agent&apos;</span>) {
<span class="hljs-keyword">const</span> newResponse = responseDetail.response; <span class="hljs-keyword">const</span> newResponse = responseDetail.response;
newResponse.body += <span class="hljs-string">&apos;&lt;br/&gt;&lt;span style=&quot;color:blue&quot;&gt;-- AnyProxy Hacked! --&lt;/span&gt;&apos;</span>; newResponse.body += <span class="hljs-string">&apos;- AnyProxy Hacked!&apos;</span>;
newResponse.body += <span class="hljs-string">`&lt;script&gt;
setTimeout(
function (){
window.alert(&quot;Sorry, You Are Hacked...&quot;)
}, 300);
&lt;/script&gt;`</span>;
newResponse.header[<span class="hljs-string">&apos;Content-Type&apos;</span>] = <span class="hljs-string">&apos;text/html&apos;</span>;
<span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Promise</span>((resolve, reject) =&gt; { <span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Promise</span>((resolve, reject) =&gt; {
setTimeout(() =&gt; { <span class="hljs-comment">// delay</span> setTimeout(() =&gt; { <span class="hljs-comment">// delay</span>
@ -1632,7 +1624,7 @@ newResponse.body += <span class="hljs-string">&apos;--from anyproxy--&apos;</spa
<script> <script>
var gitbook = gitbook || []; var gitbook = gitbook || [];
gitbook.push(function() { gitbook.push(function() {
gitbook.page.hasChanged({"page":{"title":"简介","level":"1.1","depth":1,"next":{"title":"快速开始","level":"1.2","depth":1,"anchor":"#快速开始","path":"README.md","ref":"README.md#快速开始","articles":[{"title":"安装","level":"1.2.1","depth":2,"anchor":"#安装","path":"README.md","ref":"README.md#安装","articles":[]},{"title":"启动","level":"1.2.2","depth":2,"anchor":"#启动","path":"README.md","ref":"README.md#启动","articles":[]},{"title":"其他命令","level":"1.2.3","depth":2,"anchor":"#其他命令","path":"README.md","ref":"README.md#其他命令","articles":[]},{"title":"作为npm模块启动","level":"1.2.4","depth":2,"anchor":"#作为npm模块使用","path":"README.md","ref":"README.md#作为npm模块使用","articles":[]}]},"dir":"ltr"},"config":{"plugins":[],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"livereload":{},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"AnyProxy","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"AnyProxy","language":"cn","gitbook":"*","description":"A fully configurable http/https proxy in NodeJS"},"file":{"path":"README.md","mtime":"2017-12-01T13:25:56.899Z","type":"markdown"},"gitbook":{"version":"3.2.2","time":"2017-12-01T13:25:58.040Z"},"basePath":".","book":{"language":"cn"}}); gitbook.page.hasChanged({"page":{"title":"简介","level":"1.1","depth":1,"next":{"title":"快速开始","level":"1.2","depth":1,"anchor":"#快速开始","path":"README.md","ref":"README.md#快速开始","articles":[{"title":"安装","level":"1.2.1","depth":2,"anchor":"#安装","path":"README.md","ref":"README.md#安装","articles":[]},{"title":"启动","level":"1.2.2","depth":2,"anchor":"#启动","path":"README.md","ref":"README.md#启动","articles":[]},{"title":"其他命令","level":"1.2.3","depth":2,"anchor":"#其他命令","path":"README.md","ref":"README.md#其他命令","articles":[]},{"title":"作为npm模块启动","level":"1.2.4","depth":2,"anchor":"#作为npm模块使用","path":"README.md","ref":"README.md#作为npm模块使用","articles":[]}]},"dir":"ltr"},"config":{"plugins":[],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"livereload":{},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"AnyProxy","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"AnyProxy","language":"cn","gitbook":"*","description":"A fully configurable http/https proxy in NodeJS"},"file":{"path":"README.md","mtime":"2017-12-01T13:58:00.991Z","type":"markdown"},"gitbook":{"version":"3.2.2","time":"2017-12-01T13:58:02.250Z"},"basePath":".","book":{"language":"cn"}});
}); });
</script> </script>
</div> </div>

File diff suppressed because one or more lines are too long

View File

@ -14,6 +14,7 @@ Github主页https://github.com/alibaba/anyproxy/tree/4.x
* 基于Node.js开放二次开发能力允许自定义请求处理逻辑 * 基于Node.js开放二次开发能力允许自定义请求处理逻辑
* 支持Https的解析 * 支持Https的解析
* 提供GUI界面用以观察请求 * 提供GUI界面用以观察请求
相比3.x版本AnyProxy 4.0的主要变化: 相比3.x版本AnyProxy 4.0的主要变化:
* 规则文件Rule全面支持Promise和Generator * 规则文件Rule全面支持Promise和Generator
@ -29,7 +30,7 @@ Github主页https://github.com/alibaba/anyproxy/tree/4.x
对于Debian或者Ubuntu系统在安装AnyProxy之前可能还需要安装 `nodejs-legacy` 对于Debian或者Ubuntu系统在安装AnyProxy之前可能还需要安装 `nodejs-legacy`
```bash ```bash
sudo apg-get install nodejs-legacy sudo apt-get install nodejs-legacy
``` ```
然后安装AnyProxy 然后安装AnyProxy
@ -223,19 +224,11 @@ AnyProxy提供了二次开发的能力你可以用js编写自己的规则模
```js ```js
// file: sample.js // file: sample.js
module.exports = { module.exports = {
summary: 'a rule to modify response', summary: 'a rule to hack response',
*beforeSendResponse(requestDetail, responseDetail) { *beforeSendResponse(requestDetail, responseDetail) {
if (requestDetail.url === 'http://httpbin.org/user-agent') { if (requestDetail.url === 'http://httpbin.org/user-agent') {
const newResponse = responseDetail.response; const newResponse = responseDetail.response;
newResponse.body += '<br/><span style="color:blue">-- AnyProxy Hacked! --</span>'; newResponse.body += '- AnyProxy Hacked!';
newResponse.body += `<script>
setTimeout(
function (){
window.alert("Sorry, You Are Hacked...")
}, 300);
</script>`;
newResponse.header['Content-Type'] = 'text/html';
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
setTimeout(() => { // delay setTimeout(() => { // delay

View File

@ -736,7 +736,7 @@
<h1 id="getting-start">Getting Start</h1> <h1 id="getting-start">Getting Start</h1>
<h3 id="install">install</h3> <h3 id="install">install</h3>
<p>To Debian and Ubuntu users, you may need to install <code>nodejs-legacy</code> at the same time</p> <p>To Debian and Ubuntu users, you may need to install <code>nodejs-legacy</code> at the same time</p>
<pre><code class="lang-bash">sudo apg-get install nodejs-legacy <pre><code class="lang-bash">sudo apt-get install nodejs-legacy
</code></pre> </code></pre>
<p>Then install the AnyProxy</p> <p>Then install the AnyProxy</p>
<pre><code class="lang-bash">npm install -g anyproxy@beta <span class="hljs-comment"># 4.x is in beta now</span> <pre><code class="lang-bash">npm install -g anyproxy@beta <span class="hljs-comment"># 4.x is in beta now</span>
@ -1592,7 +1592,7 @@ You can change the request with rule of course. For this scenario, all you need
<script> <script>
var gitbook = gitbook || []; var gitbook = gitbook || [];
gitbook.push(function() { gitbook.push(function() {
gitbook.page.hasChanged({"page":{"title":"Getting-Start","level":"1.2","depth":1,"next":{"title":"Install","level":"1.2.1","depth":2,"anchor":"#install","path":"doc.md","ref":"doc.md#install","articles":[]},"previous":{"title":"Introduction","level":"1.1","depth":1,"path":"README.md","ref":"README.md","articles":[]},"dir":"ltr"},"config":{"plugins":[],"styles":{"website":"styles/website.css"},"pluginsConfig":{"livereload":{},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"AnyProxy","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"AnyProxy","language":"en","gitbook":"*","description":"A fully configurable http/https proxy in NodeJS"},"file":{"path":"doc.md","mtime":"2017-12-01T11:51:40.356Z","type":"markdown"},"gitbook":{"version":"3.2.2","time":"2017-12-01T13:25:58.040Z"},"basePath":".","book":{"language":"en"}}); gitbook.page.hasChanged({"page":{"title":"Getting-Start","level":"1.2","depth":1,"next":{"title":"Install","level":"1.2.1","depth":2,"anchor":"#install","path":"doc.md","ref":"doc.md#install","articles":[]},"previous":{"title":"Introduction","level":"1.1","depth":1,"path":"README.md","ref":"README.md","articles":[]},"dir":"ltr"},"config":{"plugins":[],"styles":{"website":"styles/website.css"},"pluginsConfig":{"livereload":{},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"AnyProxy","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"AnyProxy","language":"en","gitbook":"*","description":"A fully configurable http/https proxy in NodeJS"},"file":{"path":"doc.md","mtime":"2017-12-01T13:39:03.080Z","type":"markdown"},"gitbook":{"version":"3.2.2","time":"2017-12-01T13:58:02.250Z"},"basePath":".","book":{"language":"en"}});
}); });
</script> </script>
</div> </div>

View File

@ -754,7 +754,7 @@
<h1 id="getting-start">Getting Start</h1> <h1 id="getting-start">Getting Start</h1>
<h3 id="install">install</h3> <h3 id="install">install</h3>
<p>To Debian and Ubuntu users, you may need to install <code>nodejs-legacy</code> at the same time</p> <p>To Debian and Ubuntu users, you may need to install <code>nodejs-legacy</code> at the same time</p>
<pre><code class="lang-bash">sudo apg-get install nodejs-legacy <pre><code class="lang-bash">sudo apt-get install nodejs-legacy
</code></pre> </code></pre>
<p>Then install the AnyProxy</p> <p>Then install the AnyProxy</p>
<pre><code class="lang-bash">npm install -g anyproxy <pre><code class="lang-bash">npm install -g anyproxy
@ -957,20 +957,11 @@ anyproxy --intercept <span class="hljs-comment">#launch anyproxy and intercept a
<li><p>Step 1&#xFF0C;Write the rule file, save as sample.js</p> <li><p>Step 1&#xFF0C;Write the rule file, save as sample.js</p>
<pre><code class="lang-js"><span class="hljs-comment">// file: sample.js</span> <pre><code class="lang-js"><span class="hljs-comment">// file: sample.js</span>
<span class="hljs-built_in">module</span>.exports = { <span class="hljs-built_in">module</span>.exports = {
summary: <span class="hljs-string">&apos;a rule to modify response&apos;</span>, summary: <span class="hljs-string">&apos;a rule to hack response&apos;</span>,
*beforeSendResponse(requestDetail, responseDetail) { *beforeSendResponse(requestDetail, responseDetail) {
<span class="hljs-keyword">if</span> (requestDetail.url === <span class="hljs-string">&apos;http://httpbin.org/user-agent&apos;</span>) { <span class="hljs-keyword">if</span> (requestDetail.url === <span class="hljs-string">&apos;http://httpbin.org/user-agent&apos;</span>) {
<span class="hljs-keyword">const</span> newResponse = responseDetail.response; <span class="hljs-keyword">const</span> newResponse = responseDetail.response;
newResponse.body += <span class="hljs-string">&apos;- AnyProxy Hacked!&apos;</span>;
newResponse.body += <span class="hljs-string">&apos;&lt;br/&gt;&lt;span style=&quot;color:blue&quot;&gt;-- AnyProxy Hacked! --&lt;/span&gt;&apos;</span>;
newResponse.body += <span class="hljs-string">`&lt;script&gt;
setTimeout(
function (){
window.alert(&quot;Sorry, You Are Hacked...&quot;)
}, 300);
&lt;/script&gt;`</span>;
newResponse.header[<span class="hljs-string">&apos;Content-Type&apos;</span>] = <span class="hljs-string">&apos;text/html&apos;</span>;
<span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Promise</span>((resolve, reject) =&gt; { <span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Promise</span>((resolve, reject) =&gt; {
setTimeout(() =&gt; { <span class="hljs-comment">// delay</span> setTimeout(() =&gt; { <span class="hljs-comment">// delay</span>
@ -1620,7 +1611,7 @@ You can change the request with rule of course. For this scenario, all you need
<script> <script>
var gitbook = gitbook || []; var gitbook = gitbook || [];
gitbook.push(function() { gitbook.push(function() {
gitbook.page.hasChanged({"page":{"title":"Introduction","level":"1.1","depth":1,"next":{"title":"Getting-Start","level":"1.2","depth":1,"anchor":"#getting-start","path":"doc.md","ref":"doc.md#getting-start","articles":[{"title":"Install","level":"1.2.1","depth":2,"anchor":"#install","path":"doc.md","ref":"doc.md#install","articles":[]},{"title":"Launch","level":"1.2.2","depth":2,"anchor":"#launch","path":"doc.md","ref":"doc.md#launch","articles":[]},{"title":"Options","level":"1.2.3","depth":2,"anchor":"#options","path":"doc.md","ref":"doc.md#options","articles":[]},{"title":"As Node Module","level":"1.2.4","depth":2,"anchor":"#use-anyproxy-as-an-npm-module","path":"doc.md","ref":"doc.md#use-anyproxy-as-an-npm-module","articles":[]}]},"dir":"ltr"},"config":{"plugins":[],"styles":{"website":"styles/website.css"},"pluginsConfig":{"livereload":{},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"AnyProxy","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"AnyProxy","language":"en","gitbook":"*","description":"A fully configurable http/https proxy in NodeJS"},"file":{"path":"README.md","mtime":"2017-12-01T13:25:56.899Z","type":"markdown"},"gitbook":{"version":"3.2.2","time":"2017-12-01T13:25:58.040Z"},"basePath":".","book":{"language":"en"}}); gitbook.page.hasChanged({"page":{"title":"Introduction","level":"1.1","depth":1,"next":{"title":"Getting-Start","level":"1.2","depth":1,"anchor":"#getting-start","path":"doc.md","ref":"doc.md#getting-start","articles":[{"title":"Install","level":"1.2.1","depth":2,"anchor":"#install","path":"doc.md","ref":"doc.md#install","articles":[]},{"title":"Launch","level":"1.2.2","depth":2,"anchor":"#launch","path":"doc.md","ref":"doc.md#launch","articles":[]},{"title":"Options","level":"1.2.3","depth":2,"anchor":"#options","path":"doc.md","ref":"doc.md#options","articles":[]},{"title":"As Node Module","level":"1.2.4","depth":2,"anchor":"#use-anyproxy-as-an-npm-module","path":"doc.md","ref":"doc.md#use-anyproxy-as-an-npm-module","articles":[]}]},"dir":"ltr"},"config":{"plugins":[],"styles":{"website":"styles/website.css"},"pluginsConfig":{"livereload":{},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"AnyProxy","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"AnyProxy","language":"en","gitbook":"*","description":"A fully configurable http/https proxy in NodeJS"},"file":{"path":"README.md","mtime":"2017-12-01T13:58:00.991Z","type":"markdown"},"gitbook":{"version":"3.2.2","time":"2017-12-01T13:58:02.250Z"},"basePath":".","book":{"language":"en"}});
}); });
</script> </script>
</div> </div>

File diff suppressed because one or more lines are too long

View File

@ -29,7 +29,7 @@ Change Logs since 3.x:
To Debian and Ubuntu users, you may need to install `nodejs-legacy` at the same time To Debian and Ubuntu users, you may need to install `nodejs-legacy` at the same time
```bash ```bash
sudo apg-get install nodejs-legacy sudo apt-get install nodejs-legacy
``` ```
Then install the AnyProxy Then install the AnyProxy
@ -222,20 +222,11 @@ Rule module could do the following stuff:
```js ```js
// file: sample.js // file: sample.js
module.exports = { module.exports = {
summary: 'a rule to modify response', summary: 'a rule to hack response',
*beforeSendResponse(requestDetail, responseDetail) { *beforeSendResponse(requestDetail, responseDetail) {
if (requestDetail.url === 'http://httpbin.org/user-agent') { if (requestDetail.url === 'http://httpbin.org/user-agent') {
const newResponse = responseDetail.response; const newResponse = responseDetail.response;
newResponse.body += '- AnyProxy Hacked!';
newResponse.body += '<br/><span style="color:blue">-- AnyProxy Hacked! --</span>';
newResponse.body += `<script>
setTimeout(
function (){
window.alert("Sorry, You Are Hacked...")
}, 300);
</script>`;
newResponse.header['Content-Type'] = 'text/html';
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
setTimeout(() => { // delay setTimeout(() => { // delay

File diff suppressed because one or more lines are too long