### Configuration Example for responseFor Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/responseFor.md An example demonstrating how to configure the responseFor rule to set custom ServerIPs for a specific domain. Multiple IPs can be provided, separated by commas. ```txt www.example.com/path responseFor://1.1.1.1,2.2.2.2 ``` -------------------------------- ### Remote Rule File Example Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/attachment.md This example shows how to load attachment rules from a remote URL by referencing a rule file containing multiple attachment configurations. ```txt @https://remote-url/xxx.txt ``` -------------------------------- ### Delete Rule Configuration Example Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/delete.md Provides examples of how to configure the delete rule for different scenarios, such as deleting cookies and response body content based on URL patterns. ```txt https://www.example.com/path delete://reqCookies.token|resCookies.token https://raw.githubusercontent.com/avwo/whistle/refs/heads/master/package.json delete://resBody.name resType://json ``` -------------------------------- ### Basic Attachment Rule Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/attachment.md This basic example configures a rule to automatically download a file named 'example.html' when a user visits the homepage of example.com. ```txt https://www.example.com/ attachment://example.html ``` -------------------------------- ### HTTP/HTTPS Conversion Example Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/inherit.md Demonstrates how to convert HTTP and HTTPS requests to a different domain, showing automatic path concatenation by default. ```txt http://www.example.com/path1 www.test.com/path/xxx https://www.example.com/path2 www.abc.com/path3/yyy ``` -------------------------------- ### Example Remote Rule File Content Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/@.md This is an example of the content expected within an external rule file imported using the @ symbol. It follows standard Whistle rule syntax. ```txt # Example of a remote rule file www.example.com proxy://127.0.0.1:8080 api.example.com resCors://* static.example.com cache://3600 ``` -------------------------------- ### Attachment Rule with Filters Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/attachment.md This example demonstrates how to trigger a PDF download only when a specific query parameter 'download=true' is present in the request URL. ```txt https://api.example.com/document attachment://User-Manual.pdf includeFilter:///[?&]download=true/ ``` -------------------------------- ### Detailed Configuration Mode with JSON File Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/resCors.md Applies detailed CORS settings defined in a JSON file. This example also shows how to exclude OPTIONS requests. ```cors.json origin: * methods: POST headers: x-test credentials: true maxAge: 300000 ``` ```txt www.example.com/path resCors://{cors.json} # Do not process OPTIONS requests www.example.com/path2 resCors://{cors.json} excludeFilter://m:options ``` -------------------------------- ### WebSocket Rule Configuration Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/frameScript.md Example configuration applying a frameScript rule to a WebSocket connection. The script 'test-frame.js' is loaded to handle frame manipulation. ```txt wss://echo.websocket.org/ frameScript://{test-frame.js} ``` -------------------------------- ### Manually Install Root Certificate on Alpine Linux Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/cli.md On Alpine Linux, install the 'ca-certificates' package, then manually install the Whistle root certificate by copying the 'rootCA.crt' file and updating the system's CA certificates. ```bash sudo apk add ca-certificates sudo cp rootCA.crt /usr/local/share/ca-certificates/ sudo update-ca-certificates ``` -------------------------------- ### resReplace Inline Mode Example Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/resReplace.md Demonstrates inline replacement using a simple key-value pair and a regular expression for dynamic replacement. The request URL is matched, and the response body is transformed. ```txt www.example.com/path file://(00user-11test-22user-33test) resReplace://user=abc&/\d+/g=number ``` -------------------------------- ### Verify Root Certificate Installation with curl Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/cli.md After installing the root certificate, verify its functionality by setting the HTTPS proxy and making a curl request to an HTTPS URL. ```bash # Set proxy and test HTTPS request export https_proxy=http://127.0.0.1:8899 curl https://example.com ``` -------------------------------- ### Basic Socks Proxy Configuration Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/socks.md Examples of configuring a SOCKS5 proxy using IP addresses or domain names. The default port 443 is used if not specified. ```txt # Proxy requests to a SOCKS5 proxy: `127.0.0.1:443` www.example.com/path socks://127.0.0.1 # Default port 443 # Proxy all requests for the current domain to the SOCKS5 proxy: `127.0.0.1:8080` www.example.com socks://127.0.0.1:8080 # You can also use a domain name. www.example.com/path socks://test.proxy.com # Default port 443 www.example.com socks://test.proxy.com:8080 ``` -------------------------------- ### Install Whistle Root Certificate with w2 CLI Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/cli.md Use 'w2 ca' to manage the Whistle root certificate. This command can install the certificate locally, download it from a specified port and IP/domain, from a URL, or from a local file path. ```bash w2 ca ``` ```bash w2 ca 8080 ``` ```bash w2 ca www.test.com:8080 ``` ```bash w2 ca certUrl ``` ```bash w2 ca localCertPath ``` -------------------------------- ### Inline HTML Body Content Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/htmlBody.md Example of using the htmlBody rule with inline content for different paths. ```txt www.example.com/path htmlBody://(Hello) file://(-test-) www.example.com/path2 htmlBody://(Hello) file://(-test-) resType://js ``` -------------------------------- ### Manually Install Root Certificate on Ubuntu/Debian Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/cli.md On Ubuntu/Debian systems, manually install the Whistle root certificate by copying the 'rootCA.crt' file and updating the system's CA certificates. ```bash sudo cp rootCA.crt /usr/local/share/ca-certificates/ sudo update-ca-certificates ``` -------------------------------- ### CORS Object Structure Example Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/resCors.md Illustrates the structure of a CORS object, defining various CORS-related parameters. ```text origin: * methods: POST headers: x-test credentials: true maxAge: 300000 ``` -------------------------------- ### Manually Install Root Certificate on CentOS/RHEL/Fedora Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/cli.md On CentOS/RHEL/Fedora systems, manually install the Whistle root certificate by copying the 'rootCA.crt' file to the anchors directory and updating the system's CA trust. ```bash sudo cp rootCA.crt /etc/pki/ca-trust/source/anchors/ sudo update-ca-trust ``` -------------------------------- ### Setting Multiple Request Headers from JSON Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/reqHeaders.md Configures multiple request headers by referencing a JSON file. This is useful for managing a collection of headers efficiently. The JSON content is directly embedded in the example. ```json x-test1: 1 x-test2: x-test3: abc ``` ```txt www.example.com/path2 reqHeaders://{test.json} ``` -------------------------------- ### Combining Multiple Filter Conditions Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/gui/network.md Combine multiple filter conditions using 'AND' logic to narrow down search results. This example demonstrates filtering by body content, request method, status code, and host header. ```txt b:/"success":false/ m:POST s:200 H:api.example.com ``` -------------------------------- ### JavaScript Frame Manipulation Script Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/frameScript.md Example JavaScript code for frameScript. It demonstrates sending preset data to the server and client, and processing incoming frames. ```javascript // Send preset data ctx.sendToServer('1 = 0x12300000'); ctx.sendToClient('1 = 0x1236666666'); // Process the data frame sent to the server ctx.handleSendToServerFrame = function(buf, opts) { // Can return empty, null, undefined, etc. return (buf + '').replace(/1/g, '***'); }; // Process the data frame sent to the client ctx.handleSendToClientFrame = function(buf, opts) { // Can return empty, null, undefined, etc. return (buf + '').replace(/1/g, '+++'); }; ``` -------------------------------- ### Setting Script Tag Attributes Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/jsBody.md Use the lineProps parameter to set attributes for injected script tags. Examples include nomodule, module, defer, async, and crossorigin. ```txt www.example.com/path1 jsBody://https://www.xxx.com/xxx/params.js lineProps://nomodule www.example.com/path2 jsBody://https://www.xxx.com/xxx/params.js lineProps://module www.example.com/path3 jsBody://https://www.xxx.com/xxx/params.js lineProps://defer www.example.com/path4 jsBody://https://www.xxx.com/xxx/params.js lineProps://async www.example.com/path5 jsBody://https://www.xxx.com/xxx/params.js lineProps://crossorigin ``` -------------------------------- ### Configure Display Text and Help Links for Hints Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/plugin-vars.md Enhance hints by providing `displayText` for custom display and an optional `help` URL for additional information, accessible via F1. ```json { "name": "@scope/whistle.test-plugin-vars", ... "whistleConfig": { "pluginVars": { "hintList": [ { "text": "test1", "displayText": "displayText1" }, { "text": "test2", "displayText": "displayText2" }, { "text": "test3", "displayText": "displayText3", "help": "https://www.example.com/path" } ] } } ... ``` -------------------------------- ### Import Local Project Rules with @ Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/@.md Import rules from local file paths. Supports absolute paths and paths relative to the user's home directory using '~'. ```txt @C:/whistle/rules.txt ``` ```txt @D:\config\proxy.rules ``` ```txt @/Users/username/projects/my-app/whistle-config.txt ``` ```txt @~/dev/configs/rules.txt ``` -------------------------------- ### Load from File Path for resPrepend Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/resPrepend.md Load content to prepend from a local file path. Ensure the path is correctly specified. ```txt # Load from a local file pattern resPrepend:///User/xxx/header.html ``` -------------------------------- ### Basic resHeaders Configuration Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/resHeaders.md Adds a single response header 'x-proxy' with the value 'Whistle' to requests matching 'www.example.com/path'. ```txt www.example.com/path resHeaders://x-proxy=Whistle ``` -------------------------------- ### Loading Response Headers from Local or Remote Resources Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/resHeaders.md Demonstrates using local file paths, remote URLs, or temporary files to define response headers. ```txt www.example.com/path1 resHeaders:///User/xxx/test.json ``` ```txt www.example.com/path2 resHeaders://https://www.xxx.com/xxx/params.json ``` ```txt # Editing a temporary file www.example.com/path3 resHeaders://temp/blank.json ``` -------------------------------- ### Use Backend Interface for Hints Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/plugin-vars.md Configure `hintUrl` in `whistleConfig.pluginVars` to fetch hints dynamically from a backend API, offering a more flexible way to manage suggestions. ```json { "name": "@scope/whistle.test-plugin-vars", ... "whistleConfig": { "pluginVars": { "hintSuffix": [ "=", ".key1=123", ".key2" ], "hintUrl": "/cgi-bin/plugin-vars" } } ... ``` -------------------------------- ### Load CORS Configuration from Local or Remote Resources Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/resCors.md Demonstrates loading CORS configurations from local file paths or remote URLs, including temporary files. ```txt www.example.com/path1 resCors:///User/xxx/test.json www.example.com/path2 resCors://https://www.xxx.com/xxx/params.json # Editing a temporary file www.example.com/path3 resCors://temp/blank.json ``` -------------------------------- ### Basic Request Header Configuration Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/reqHeaders.md Sets a single request header 'x-proxy' with the value 'Whistle' for matching URLs. Use this for simple header injections. ```txt www.example.com/path reqHeaders://x-proxy=Whistle ``` -------------------------------- ### resReplace Local and Remote Resources Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/resReplace.md Illustrates how to configure resReplace to use replacement rules defined in local files or fetched from remote URLs. It also shows the usage of a temporary file for configuration. ```txt www.example.com/path1 resReplace:///User/xxx/test.json ``` ```txt www.example.com/path2 resReplace://https://www.xxx.com/xxx/params.json ``` ```txt www.example.com/path3 resReplace://temp/blank.json ``` -------------------------------- ### Configure Hint Suffixes for Key Names Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/plugin-vars.md Use `hintSuffix` to define common suffixes that can be appended to a plugin variable key, providing quick access to related configurations. ```json { "name": "@scope/whistle.test-plugin-vars", ... "whistleConfig": { "pluginVars": { "hintList": [ { "text": "test1", "displayText": "displayText1" }, { "text": "test2", "displayText": "displayText2" }, { "text": "test3", "displayText": "displayText3", "help": "https://www.example.com/path" } ], "hintSuffix": [ "=", ".key1=123", ".key2" ] } } ... ``` -------------------------------- ### Filter Conditions Syntax Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/gui/network.md Demonstrates the syntax for various filter conditions supported in the settings, including matching request URLs, methods, headers, and client IPs. ```txt .example.com ``` ```txt m:POST ``` ```txt h:/cookie:[^\r\n]*test=123/ ``` ```txt H:example.com H:/test/i ``` ```txt i:11.2 i:/^11\.2/ ``` -------------------------------- ### HTML Body from File Content Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/htmlBody.md Demonstrates using the htmlBody rule with content defined in a separate file, supporting different response types. ```txt body.txt Hello world. www.example.com/path htmlBody://{body.txt} file://(-test-) www.example.com/path2 htmlBody://{body.txt} file://(-test-) resType://css ``` -------------------------------- ### Referencing Local and Remote Header Resources Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/reqHeaders.md Demonstrates how to specify request headers using local file paths or remote URLs. Supports direct file paths, absolute URLs, and temporary file references. ```txt www.example.com/path1 reqHeaders:///User/xxx/test.json www.example.com/path2 reqHeaders://https://www.xxx.com/xxx/params.json # Editing a temporary file www.example.com/path3 reqHeaders://temp/blank.json ``` -------------------------------- ### Load from Remote URL for resPrepend Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/resPrepend.md Load content to prepend from a remote URL. This is useful for including external scripts or resources. ```txt # Load from a remote URL pattern resPrepend://https://cdn.example.com/analytics-script.js ``` -------------------------------- ### Equivalent ResHeaders Rule Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/attachment.md This demonstrates how the attachment protocol is equivalent to manually setting the 'content-disposition' header using the resHeaders protocol. ```txt https://www.example.com/ resHeaders://content-disposition=attachment;filename="example.html" ``` -------------------------------- ### HTML Body from Local and Remote Resources Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/htmlBody.md Shows how to use the htmlBody rule to load content from local file paths or remote URLs. ```txt www.example.com/path1 htmlBody:///User/xxx/test.txt www.example.com/path2 htmlBody://https://www.xxx.com/xxx/params.txt # Editing a temporary file www.example.com/path3 htmlBody://temp/blank.txt ``` -------------------------------- ### Quick Mode: Allow All Origins Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/resCors.md Sets the Access-Control-Allow-Origin header to '*' for all requests matching the pattern. This configuration does not support cookies. ```txt www.example.com/path resCors://* ``` -------------------------------- ### Quick Mode: Allow Cookies Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/resCors.md Enables cookies for cross-origin requests by setting Access-Control-Allow-Origin to the request's origin and Access-Control-Allow-Credentials to true. ```txt # `enable` sets `access-control-allow-origin: http://reqOrigin` based on the request header `origin` # and settings access-control-allow-credentials: true www.example.com/path2 resCors://enable ``` -------------------------------- ### Load from Temporary File for resPrepend Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/resPrepend.md Use Whistle's temporary file feature to load content that may require frequent editing. Content is entered via a pop-up dialog. ```txt pattern resPrepend://temp/blank.txt ``` -------------------------------- ### Configure Anonymous Key Value Hints Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/plugin-vars.md Provide a `hintList` in `whistleConfig.pluginVars` to offer predefined values when a plugin variable is prompted. ```json { "name": "@scope/whistle.test-plugin-vars", ... "whistleConfig": { "pluginVars": { "hintList": [ "test1", "test2", "test3" ] } }, ... } ``` -------------------------------- ### Mixed Usage of @ Symbol for Rule Imports Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/@.md Combine multiple rule sources, including remote URLs and local files, to create a comprehensive set of proxy rules. ```txt # Import team-shared base rules @https://team.example.com/configs/base-rules.txt # Import personal project-specific rules @~/projects/my-app/whistle-overrides.txt ``` -------------------------------- ### Set System Proxy with w2 CLI Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/cli.md Use 'w2 proxy' to set the system proxy. Specify the IP and port, or a domain with a port. If Whistle is not running, the default port 8899 is used. ```bash w2 proxy ``` ```bash w2 proxy 0 ``` ```bash w2 proxy 8100 ``` ```bash w2 proxy www.test.com:8100 ``` -------------------------------- ### Socks Rule Application with URL Substitution Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/socks.md Illustrates how the socks rule applies to the Final URL after substitution. If the Final URL is empty, it applies to the original request URL. Multiple rules may be needed for chained substitutions. ```txt www.example.com/api www.example.com proxy://127.0.0.1:1234 # To ensure the rule also applies to the substituted request: www.example.com/api www.example.com www.example.com proxy://127.0.0.1:1234 ``` -------------------------------- ### reqType Shortcut Commands Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/reqType.md Use shortcut commands for common media types without specifying the full MIME type. The charset can be optionally appended. ```plaintext www.example.com/path reqType://form # Without encoding, the `content-type` request header becomes `application/x-www-form-urlencoded` ``` ```plaintext www.example.com/path reqType://json;charset=utf8 # With encoding, the `content-type` request header becomes `application/json;charset=utf8` ``` -------------------------------- ### resType Shortcut Commands Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/resType.md Uses shortcut commands for common media types, automatically inferring the full type based on mime lookup. The charset can be specified directly. ```txt # The `content-type` response header without encoding becomes `text/html` www.example.com/path resType://html ``` ```txt # The `content-type` response header with encoding becomes `application/json;charset=utf8` www.example.com/path resType://json;charset=utf8 ``` -------------------------------- ### Local and Remote CSS Body Replacement Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/cssBody.md Illustrates replacing the response body with content from a local file path or a remote URL, specifically for CSS resources. ```txt www.example.com/path1 cssBody:///User/xxx/test.css www.example.com/path2 cssBody://https://www.xxx.com/xxx/params.css # Editing a temporary file www.example.com/path3 cssBody://temp/blank.css ``` -------------------------------- ### Rule Syntax for responseFor Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/responseFor.md Defines the basic syntax for the responseFor rule, including pattern matching and custom IP specification. Loading data from files or remote URLs for the IP is not supported. ```txt pattern responseFor://ip [filters...] ``` -------------------------------- ### Test Authentication and Authorization Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/replaceStatus.md Simulate unauthenticated access (401) or insufficient permissions (403). Note that 401 may trigger browser authentication popups unless disabled. ```txt # Test unauthenticated access. www.example.com/protected replaceStatus://401 ``` ```txt # Test insufficient permissions. www.example.com/admin replaceStatus://403 ``` -------------------------------- ### Reference Value from Panel for resPrepend Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/resPrepend.md Reference content stored in the Values panel using a key. This is suitable for large or frequently reused content. ```txt pattern resPrepend://{key-of-values} [lineProps...] [filters...] ``` -------------------------------- ### Test Maintenance Mode Source: https://github.com/avwo/whistle/blob/master/docs/en/docs/rules/replaceStatus.md Simulate a system under maintenance page by returning a 503 status code with custom response body content. ```txt # Test maintenance page. www.example.com replaceStatus://503 resBody://(