Whistle is a network packet capture tool built on Node.js, used for monitoring, intercepting, and modifying HTTP(S) and WebSocket requests and responses. It provides a plugin system to extend its functionality by installing various plugins. Below are some commonly used Whistle plugins and their usage methods:
1. whistle.script
- Functionality: Allows users to dynamically modify requests and responses using JavaScript scripts.
- Usage:
- Install the plugin: Run the command
npm install -g whistle.script. - Configure in Whistle rules: Add a rule
pattern whistle.script://scriptPath, wherepatternis the matching request pattern andscriptPathis the path to the script file. - Write JavaScript scripts to modify requests or responses.
- Install the plugin: Run the command
2. whistle.proxy
- Functionality: Enables setting up proxies to forward requests.
- Usage:
- Install the plugin: Run the command
npm install -g whistle.proxy. - Configure in Whistle rules: Add a rule
pattern proxy://proxyHost:port, wherepatternis the matching request pattern andproxyHost:portis the address and port of the proxy server.
- Install the plugin: Run the command
3. whistle.mock
- Functionality: Used for simulating server responses.
- Usage:
- Install the plugin:
npm install -g whistle.mock. - Configure in Whistle rules: Add a rule
pattern mock://{json}, wherepatternis the matching request pattern and{json}is a JSON object representing the simulated response data.
- Install the plugin:
4. whistle.rproxy
- Functionality: Implements reverse proxy functionality, mapping local services to the public internet.
- Usage:
- Install the plugin:
npm install -g whistle.rproxy. - Configure in Whistle rules: Add a rule
pattern rproxy://localAddress, wherepatternis the matching request pattern andlocalAddressis the address of the local server.
- Install the plugin:
5. whistle.autosave
- Functionality: Automatically saves request and response data.
- Usage:
- Install the plugin:
npm install -g whistle.autosave. - Configure in Whistle rules: Add a rule
pattern autosave://filePath, wherepatternis the matching request pattern andfilePathis the file path to save the data.
- Install the plugin:
By installing and configuring these plugins, users can flexibly extend Whistle's functionality to meet various network debugging and development needs. For example, using the whistle.script plugin can dynamically modify API requests to test different server responses, while using whistle.proxy can test location-specific features through specific proxy servers.
2024年7月28日 20:19 回复