Shadowrocket Guide

Shadowrocket Rules: Rule Types and How to Test Them

On this page
  1. What a rule is
  2. Supported rule types
  3. Add and edit rules
  4. Check with Test Rule
  5. Things to watch

What a rule is

Every rule has two parts: what it matches, and what to do with a match (send it through the proxy, connect directly, or block it). Rule-based proxy tools generally check rules from top to bottom and apply the first one that matches; we haven’t yet confirmed Shadowrocket’s exact matching order.

Rules live in the config file; see Shadowrocket config files.

Supported rule types

The App Store description says rules can match on:

Type Matches Example
Domain The exact domain www.example.com
Domain suffix Every domain ending in it example.com matches a.example.com
Domain keyword Any domain containing the word example
IP range (CIDR) Destination IPs in the range 192.168.0.0/16
GeoIP The destination IP’s country or region A country or region code

The App Store description also mentions blocking ads with User Agent rules, and importing rule files from a URL or iCloud Drive.

We’ll add the exact syntax of rules in the config file (line format and action names) once we’ve tested it. Until then we’d rather leave it out than get it wrong.

Add and edit rules

These menus come from the US App Store screenshots and may differ in your version (untested).

  1. On the Config tab, tap the config file in use (for example default.conf).
  2. The number next to Rule is how many rules it has; tap it to see them.
  3. To add one, tap Add Rule, choose the type, enter what to match, choose the action and save.

The config file also has Replace Policy, which appears to change the action of many rules at once (untested).

Check with Test Rule

When you’re not sure where a site will go, use Test Rule: enter a URL and the app shows which rule it matches. It’s on the Config tab and on the config file’s own screen.

After changing rules, test a few sites you use often to make sure you haven’t sent the wrong ones through the proxy (for example your bank or local services).

Things to watch

  • One site can match several rules; Test Rule shows which one actually applies.
  • If your rules get messed up, use Restore Default Config on the Config tab.
  • Before importing a rule file from the web, make sure the source is trustworthy.

Last updated · For Shadowrocket 2.2.93

Language

Appearance

Appearance