Skip to content

Routing rule ​

One entry of routing.rules: a match and an action.

Structure ​

json
{
  "match": {
    "network": "tcp",
    "any": [
      { "domain_suffix": ["ir"] },
      { "ip_in_dataset": ["ir-ips"] }
    ],
    "not": { "port": [22] }
  },
  "action": {
    "type": "route",
    "settings": { "outbound": "direct" }
  }
}

Match ​

Different fields must all hold; the values of one field are alternatives. An empty match matches every request. The example above matches TCP to an Iranian name or address, except to port 22.

Logic ​

FieldFormatHolds when
anylist of matchesat least one holds
alllist of matchesevery one holds
notmatchit does not hold

Request ​

FieldFormatCompares
inboundlist of tagsthe inbound the request arrived on
network"tcp" or "udp"the network
userlist of namesthe user who logged in
sniffed_protocollist: tls, httpwhat a sniff recognised
sniffed_request_headerobject: header → regexheaders of a sniffed HTTP request
sniffed_browser_familylist: chromium, firefox, safarithe browser a sniffed ClientHello looks like

sniffed_request_header holds when every header it names matches its Go regular expression, such as { "user-agent": "^curl/" }. Names are lowercase; :method and :path are included. "" only requires the header to exist.

sniffed_browser_family is a guess, empty when the sniffer is unsure.

Domain ​

Domain fields read the sniffed name if there is one, else the destination's domain. The destination itself is never changed.

FieldFormatMatches
domainlistexactly this name
domain_suffixlistthis name and every name under it
domain_keywordlistnames containing it
domain_regexlistnames a Go regular expression matches
domain_in_datasetlist of tagsnames in a domain dataset

Address and port ​

IP fields read a destination that is an IP, or the addresses a resolve found; the router never resolves by itself.

FieldFormatCompares
iplist of IPs or CIDRsthe destination IP
ip_in_datasetlist of tagsthe destination IP, in an IP dataset
ip_is_privatebooleanwhether the destination IP is private or reserved
ip_versionlist: 4, 6the destination IP's version
portlist of numbersthe destination port
port_rangelist of "first-last"the destination port
source_iplist of IPs or CIDRsthe client's IP
source_ip_in_datasetlist of tagsthe client's IP, in an IP dataset
source_ip_is_privatebooleanwhether the client's IP is private or reserved
source_portlist of numbersthe client's port
source_port_rangelist of "first-last"the client's port
inbound_local_iplist of IPs or CIDRsthe address of this machine the client reached
inbound_local_portlist of numbersthe port the client reached
inbound_local_port_rangelist of "first-last"the port the client reached

"Private or reserved" covers private, loopback, link-local, multicast and unspecified addresses, and the reserved IPv4 ranges such as 100.64.0.0/10 and 198.18.0.0/15.