whistle 帮助文档

260课时
731学过
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

学员评价

暂无精选评价
3分钟

启动多个whistle

如果你想在同一台机器启动多个whistle,方便多个浏览器或者供多人使用,有两种方式:

  1. 切换到不同的系统用户,在每个系统用户启动一个whistle代理服务(每个服务的端口号可以用命令行参数w2 start -p xxxx来指定)
  2. 也可以通过切换规则目录和端口号的方式来解决(注意SC都是大写, newStorageDir为空表示使用当前配置)
w2 start -S newStorageDir -p newPort

# 系统默认目录的配置拷贝到新的目录
w2 start -S newStorageDir -C -p newPort

# 也可以指定要拷贝的目录
w2 start -S newStorageDir -C storageDir -p newPort

Note: 这种拷贝是覆盖式的,会替换目标目录里面原有文件,启动时设置了新的存储目录,关闭或重启时也要把目录参数带上(端口号不要带上):w2 stop -S newStorageDirw2 restart -S newStorageDir

比如分别在889988887788端口上开启3个实例:

# 默认端口8899,系统默认存储目录
w2 start

# 端口号为8888,存储目录为8888,并把系统默认目录的配置copy到8888目录
w2 start -S 8888 -C

# 端口号为7788,存储目录为7788,并把8888目录的配置copy到7788目录
w2 start -S 7788 -C 8888

Note: 不同实例要配置不同的代理

w2 add [filepath]

也可以用 w2 use [filepath],通过filepath对应的js文件获取规则配置,filepath可选,默认为当前目录的 .whistle.js

如项目根目录文件 .whistle.js

const pkg = require('./package.json');

exports.name = `[${pkg.name}]本地环境配置`;
exports.rules = `
test.example.com http://127.0.0.1:5566
# cgi走现网
test.example.com/cgi-bin ignore://http
`;

在该目录下支持 w2 add (或 w2 use),这时如果本地whistle里面没有同名的规则且不为空,则会自动创建一个并自动启用,如果存在则会提醒:

The rule already exists, to override it, you must add CLI option --force.

可以通过 w2 add --force 强制覆盖当前同名规则。

也可以异步获取规则 .whistle.js

const assert = require('assert);
const path = require('path');
const pkg = require('./package.json');

module.exports = (cb, util) => {
  // 如果依赖插件,可以检查插件
  assert(util.existsPlugin('@tnpm/whistle.tianma')
    || util.existsPlugin('whistle.combo'), '请先安装插件npm i -g whisltle.combo');
  // 也可以远程获取规则
  // do sth
  cb({
    name: `[${pkg.name}]本地环境配置`,
    rules:  `
      test.example.com/combo whisle.combo://${path.join(__dirname, 'dev')}
      test.example.com http://127.0.0.1:5566
      # cgi走现网
      test.example.com/cgi-bin ignore://http
      `
  });
};