diff --git a/.DS_Store b/.DS_Store index 5f3d46b..8d71766 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/4.x/assets/css/custom.css b/4.x/assets/css/custom.css index 5658f6d..b8f01c6 100644 --- a/4.x/assets/css/custom.css +++ b/4.x/assets/css/custom.css @@ -30,7 +30,9 @@ body{ .toc-container{ width: 200px; position: fixed; - top: 42px; + top: 20px; + height: 95vh; + overflow-y: auto; } .toc-container ul{ diff --git a/4.x/assets/css/hljs-github.min.css b/4.x/assets/css/hljs-github.min.css deleted file mode 100644 index cb2cc27..0000000 --- a/4.x/assets/css/hljs-github.min.css +++ /dev/null @@ -1,96 +0,0 @@ -/* - -Atom One Light by Daniel Gamage -Original One Light Syntax theme from https://github.com/atom/one-light-syntax - -base: #fafafa -mono-1: #383a42 -mono-2: #686b77 -mono-3: #a0a1a7 -hue-1: #0184bb -hue-2: #4078f2 -hue-3: #a626a4 -hue-4: #50a14f -hue-5: #e45649 -hue-5-2: #c91243 -hue-6: #986801 -hue-6-2: #c18401 - -*/ - -.hljs { - display: block; - overflow-x: auto; - padding: 0.5em; - color: #383a42; - background: #fafafa; -} - -.hljs-comment, -.hljs-quote { - color: #a0a1a7; - font-style: italic; -} - -.hljs-doctag, -.hljs-keyword, -.hljs-formula { - color: #a626a4; -} - -.hljs-section, -.hljs-name, -.hljs-selector-tag, -.hljs-deletion, -.hljs-subst { - color: #e45649; -} - -.hljs-literal { - color: #0184bb; -} - -.hljs-string, -.hljs-regexp, -.hljs-addition, -.hljs-attribute, -.hljs-meta-string { - color: #50a14f; -} - -.hljs-built_in, -.hljs-class .hljs-title { - color: #c18401; -} - -.hljs-attr, -.hljs-variable, -.hljs-template-variable, -.hljs-type, -.hljs-selector-class, -.hljs-selector-attr, -.hljs-selector-pseudo, -.hljs-number { - color: #986801; -} - -.hljs-symbol, -.hljs-bullet, -.hljs-link, -.hljs-meta, -.hljs-selector-id, -.hljs-title { - color: #4078f2; -} - -.hljs-emphasis { - font-style: italic; -} - -.hljs-strong { - font-weight: bold; -} - -.hljs-link { - text-decoration: underline; -} \ No newline at end of file diff --git a/4.x/index.html b/4.x/index.html index 3d22551..3ee1e84 100644 --- a/4.x/index.html +++ b/4.x/index.html @@ -29,11 +29,19 @@ - + + + + + + + + + @@ -170,7 +178,11 @@ anyproxy --intercept #启动AnyProxy,并解析所

处理流程

+

+ -

如何引用

如下几种方案都可以用来引用规则模块:

-

接口详解

-

规则模块应该符合cmd规范,一个典型的规则模块代码结构如下

+

规则接口文档

+

规则模块应该符合cmd规范,一个典型的规则模块代码结构如下。模块中所有方法都是可选的,只需实现业务感兴趣的部分即可。

module.exports = {
-  summary() { return 'my customized rule for AnyProxy'; },
-  *beforeSendRequest(requestDetail) { /* ... */ },
-  *beforeSendResponse(requestDetail, responseDetail) { /* ... */ },
-  *beforeDealHttpsRequest(requestDetail) { /* ... */ }
-};

summary()

+ // 模块介绍 + summary() { return 'my customized rule for AnyProxy'; }, + // 发送请求前拦截处理 + *beforeSendRequest(requestDetail) { /* ... */ }, + // 发送响应前处理 + *beforeSendResponse(requestDetail, responseDetail) { /* ... */ }, + // 是否处理https请求 + *beforeDealHttpsRequest(requestDetail) { /* ... */ }, + // 请求出错的事件 + *onError(requestDetail, error) { /* ... */ }, + // https连接服务器出错 + *onConnectError(requestDetail, error) { /* ... */ } +};

summary

+

summary()

+

beforeSendRequest

beforeSendRequest(requestDetail)

+

beforeSendResponse

beforeSendResponse(requestDetail, responseDetail)

-
  • 举例,请求www.qq.com时,responseDetail参数内容大致如下
  • +
  • 举例,请求 anyproxy.io 时,responseDetail参数内容大致如下

    +
    { 
    +  response: { 
    +    statusCode: 200,
    +    header: { 
    +      'Content-Type': 'image/gif',
    +      Connection: 'close',
    +      'Cache-Control': '...'
    +    },
    +    body: '...'
    +  },
    +  _res: { /* ... */ }
    +}
  • 以下几种返回都是合法的

    +

    beforeDealHttpsRequest

    beforeDealHttpsRequest(requestDetail)

  • 返回值
  • +

    onError

    +

    onError(requestDetail, error)

    + +

    onConnectError

    +

    onConnectError(requestDetail, error)

    +

    FAQ