whistle 帮助文档

260课时
737学过
8分

3. 命令行操作

4. 手动更新

9. 匹配原则

13. 注意事项

14. 常见问题

16. 协议列表

协议列表

@ 功能

设置UI样式

设置hosts

设代理

延迟请求

修改请求URL

修改请求方法

修改请求头

延迟响应

修改请求内容

修改响应状态码

修改响应头

修改响应内容

过滤配置

启用或禁用一些配置

获取抓包数据

动态设置规则

开发调试工具

@

host

保留传统的hosts语法规则

灵活强大的whistle匹配模式

host-例子

host-过滤规则

响应规则列表

请求替换

请求替换-过滤规则

file (xfile)

file (xfile)-过滤规则

xfile

xfile-过滤规则

tpl

tpl-过滤规则

xtpl

rawfile

rawfile-过滤规则

xrawfile

自定义

style

style-过滤规则

pipe

pipe-过滤规则

44 plugin

plugin-过滤规则

weinre

weinre-过滤规则

log

log-快速上手

不同页面 log 切换

嵌入自定义脚本

log-过滤规则

proxy(http-proxy)

proxy(http-proxy)-过滤规则

https-proxy

https-proxy-过滤规则

socks

socks-过滤规则

pac

pac-过滤规则

filter (excludeFilter includeFilter)

filter (excludeFilter includeFilter)-例子

ignore

ignore-配置规则

ignore-忽略规则

enable

enable-过滤规则

disable

disable-过滤规则

delete

delete-过滤规则

urlParams

urlParams-过滤规则

pathReplace

pathReplace-过滤规则

method

method-过滤规则

statusCode

statusCode-过滤规则

replaceStatus

replaceStatus-过滤规则

referer

referer-过滤规则

auth

auth-过滤规则

ua

ua-过滤规则

cache

cache-过滤规则

redirect

redirect-过滤规则

attachment

attachment-过滤规则

forwardedFor-过滤规则

responseFor

responseFor-过滤规则

reqMerge

reqMerge-例子

reqMerge-过滤规则

resMerge

resMerge-例子

resMerge-过滤规则

reqScript (reqRules)

reqScript (reqRules)-静态规则列表

reqScript (reqRules)-通过脚本动态设置规则

reqScript (reqRules)-过滤规则

resScript (resRules)

resScript (resRules)-静态规则列表

resScript (resRules)-通过脚本动态设置规则

resScript (resRules)-过滤规则

reqDelay

reqDelay-过滤规则

resDelay

resDelay-过滤规则

reqSpeed

reqSpeed-过滤规则

resSpeed

resSpeed-过滤规则

reqType

reqType-过滤规则

resType

resType-过滤规则

reqCharset

reqCharset-过滤规则

resCharset

resCharset-过滤规则

reqCookies

reqCookies-过滤规则

resCookies

resCookies-过滤规则

reqCors

reqCors-过滤规则

resCors

resCors-过滤规则

reqHeaders

reqHeaders-过滤规则

resHeaders

resHeaders-过滤规则

reqPrepend

reqPrepend-过滤规则

resPrepend

resPrepend-过滤规则

reqBody

reqBody-过滤规则

resBody

resBody-过滤规则

reqAppend

reqAppend-过滤规则

resAppend

resAppend-过滤规则

headerReplace

headerReplace-过滤规则

reqReplace

reqReplace-过滤规则

resReplace

resReplace-过滤规则

htmlPrepend

htmlPrepend-过滤规则

cssPrepend

cssPrepend-过滤规则

jsPrepend

jsPrepend-过滤规则

htmlBody

htmlBody-过滤规则

cssBody

cssBody-过滤规则

jsBody

jsBody-过滤规则

htmlAppend

htmlAppend-过滤规则

cssAppend

cssAppend-过滤规则

jsAppend

jsAppend-过滤规则

reqWrite

reqWrite-过滤规则

resWrite

resWrite-过滤规则

reqWriteRaw

reqWriteRaw-过滤规则

resWriteRaw

resWriteRaw-过滤规则

课程评价 (0)

请对课程作出评价:
0/300

学员评价

暂无精选评价
5分钟

匹配原则

whistle的协议比较多,具体参见:协议列表,这些协议的匹配优先级及同时可匹配规则个数遵循以下四个原则:

  1. 相同协议规则的默认优先级从上到下,即前面的规则优先级匹配高于后面,如:
www.test.com 127.0.0.1:9999
www.test.com/xxx 127.0.0.1:8080

请求 https://www.test.com/xxx/index.html 按从上到下的匹配顺序,只会匹配 www.test.com 127.0.0.1:9999,这个与传统的hosts配置后面优先的顺序相反。

如果想跟系统hosts匹配顺序一致,可以在界面通过 Rules -> Settings -> Back rules first 修改,但这个规则只对在页面里面配置的规则生效,对插件里面自带的规则及通过@方式内联的远程规则不生效。

  1. 除rule及proxy对应规则除外,可以同时匹配不同协议的规则
www.test.com 127.0.0.1:9999
www.test.com/xxx 127.0.0.1:8080
www.test.com proxy://127.0.0.1:8888
www.test.com/xxx socks://127.0.0.1:1080
www.test.com pac://http://www.pac-server.com/test.pac
www.test.com/xxx http://www.abc.com
www.test.com file:///User/xxx/test

请求https://www.test.com/xxx/index.html按从上到下的匹配顺序,及第二点原则,会匹配以下规则:

www.test.com 127.0.0.1:9999
www.test.com proxy://127.0.0.1:8888
www.test.com pac://http://www.pac-server.com/test.pac
www.test.com/xxx http://www.abc.com

proxy、http-proxy、https-proxy、socks都属于proxy,html、file等都属于rule,所以这两个对应的协议只能各种匹配其中优先级最高的一个。

  1. 一些属于不同协议,但功能有冲突的规则,如rule、host、proxy,按常用优先级为rule > host > proxy,如:
www.test.com 127.0.0.1:9999
www.test.com/xxx 127.0.0.1:8080
www.test.com proxy://127.0.0.1:8888
www.test.com/xxx socks://127.0.0.1:1080
www.test.com file:///User/xxx/test
www.test.com/xxx http://www.abc.com

上述同时匹配file、host、proxy,但只会执行本地替换file。

  1. 部分相同协议会匹配及合并所有可以匹配的规则,如:
www.test.com 127.0.0.1:9999
www.test.com/xxx 127.0.0.1:8080
www.test.com proxy://127.0.0.1:8888
www.test.com/xxx socks://127.0.0.1:1080
www.test.com pac://http://www.pac-server.com/test.pac
www.test.com/xxx http://www.abc.com
www.test.com file:///User/xxx/test
www.test.com/xxx reqHeaders://{test.json}
www.test.com reqHeaders:///User/xxx/test.json
www.test.com/xxx htmlAppend:///User/xxx/test.html
www.test.com htmlAppend://{test.html}
www.test.com/xxx reqHeaders:///User/xxx/test2.json
www.test.com htmlAppend://{test2.html}

请求 https://www.test.com/xxx/index.html会匹配以下规则:

www.test.com 127.0.0.1:9999
www.test.com proxy://127.0.0.1:8888
www.test.com pac://http://www.pac-server.com/test.pac
www.test.com/xxx http://www.abc.com
www.test.com/xxx reqHeaders://{test.json}
www.test.com reqHeaders:///User/xxx/test.json
www.test.com/xxx htmlAppend:///User/xxx/test.html
www.test.com htmlAppend://{test.html}
www.test.com/xxx reqHeaders:///User/xxx/test2.json
www.test.com htmlAppend://{test2.html}

其中,所有匹配的reqHeaders协议的规则会将其对应的json合并后再合并到请求headers里,而所有匹配htmlAppend的html内容会通过换行符\n合并并追加到响应的html内容里面,其它可以合并的协议如下(主要涉及json、注入内容、属性设置对应的协议):

  • ignore
  • enable
  • filter
  • disable
  • plugin
  • delete
  • urlParams
  • params
  • reqHeaders
  • resHeaders
  • reqCors
  • resCors
  • reqCookies
  • resCookies
  • reqReplace
  • urlReplace
  • resReplace
  • resMerge
  • reqBody
  • reqPrepend
  • resPrepend
  • reqAppend
  • resAppend
  • resBody
  • htmlAppend
  • jsAppend
  • cssAppend
  • htmlBody
  • jsBody
  • cssBody
  • htmlPrepend
  • jsPrepend
  • cssPrepend