Overview
Script Shortcuts expose reusable script snippets for advanced routing logic. They reduce repetition when multiple script rules need the same helper behavior.
Usage pattern
Keep shortcuts small and predictable. Treat them as logic helpers, not as a place to hide large routing policies that would be clearer as normal rules.
Safety notes
Scripts can be powerful and hard to debug. Avoid copying unknown scripts into a production profile, and test with a limited rule set before enabling them globally.
Support Checks
When a script rule misroutes traffic, log the input fields, confirm DNS resolution behavior and compare with a simple DOMAIN or IP-CIDR rule.
Related pages
Reference examples
These examples mirror the corresponding Chinese documentation page so the English page carries the same configuration material.
mode: Rule
script:
engine: expr # or starlark (10x to 20x slower)
shortcuts:
quic: network == 'udp' and dst_port == 443
curl: resolve_process_name() == 'curl'
# curl: resolve_process_path() == '/usr/bin/curl'
rules:
- SCRIPT,quic,REJECTtype resolve_ip = (host: string) => string // ip string
type in_cidr = (ip: string, cidr: string) => boolean // ip in cidr
type in_ipset = (name: string, ip: string) => boolean // ip in ipset
type geoip = (ip: string) => string // country code
type match_provider = (name: string) => boolean // in rule provider
type resolve_process_name = () => string // find process name (curl .e.g)
type resolve_process_path = () => string // find process path (/usr/bin/curl .e.g)