diff --git a/docs/configuration/dns/index.md b/docs/configuration/dns/index.md index 693a070b..2434e3e6 100644 --- a/docs/configuration/dns/index.md +++ b/docs/configuration/dns/index.md @@ -23,7 +23,7 @@ #### final -Default dns server tag, the first one will be used if it is empty. +Default dns server tag. the first server will be used if empty. #### strategy diff --git a/docs/configuration/route/geoip.md b/docs/configuration/route/geoip.md new file mode 100644 index 00000000..cc92c089 --- /dev/null +++ b/docs/configuration/route/geoip.md @@ -0,0 +1,35 @@ +# geoip + +### Structure + +```json +{ + "route": { + "geoip": { + "path": "", + "download_url": "", + "download_detour": "" + } + } +} +``` + +### Fields + +#### path + +The path to the sing-geoip database. + +`geoip.db` will be used if empty. + +#### download_url + +The download URL of the sing-geoip database. + +Default is `https://github.com/SagerNet/sing-geoip/releases/latest/download/geoip.db`. + +#### download_detour + +The ag of the outbound to download the database. + +Default outbound will be used if empty. \ No newline at end of file diff --git a/docs/configuration/route/geosite.md b/docs/configuration/route/geosite.md new file mode 100644 index 00000000..f70540e0 --- /dev/null +++ b/docs/configuration/route/geosite.md @@ -0,0 +1,35 @@ +# geosite + +### Structure + +```json +{ + "route": { + "geosite": { + "path": "", + "download_url": "", + "download_detour": "" + } + } +} +``` + +### Fields + +#### path + +The path to the sing-geosite database. + +`geosite.db` will be used if empty. + +#### download_url + +The download URL of the sing-geoip database. + +Default is `https://github.com/SagerNet/sing-geosite/releases/latest/download/geosite.db`. + +#### download_detour + +The ag of the outbound to download the database. + +Default outbound will be used if empty. \ No newline at end of file diff --git a/docs/configuration/route/index.md b/docs/configuration/route/index.md new file mode 100644 index 00000000..041d1d9d --- /dev/null +++ b/docs/configuration/route/index.md @@ -0,0 +1,24 @@ +### Structure + +```json +{ + "route": { + "geoip": {}, + "geosite": {}, + "rules": [], + "final": "" + } +} +``` + +### Fields + +| Key | Format | +|-----------|------------------------------| +| `geoip` | [GeoIP](./geoip) | +| `geosite` | [Geosite](./geosite) | +| `rules` | List of [Route Rule](./rule) | + +#### final + +Default outbound tag. the first outbound will be used if empty. \ No newline at end of file diff --git a/docs/configuration/route/rule.md b/docs/configuration/route/rule.md new file mode 100644 index 00000000..7df53b56 --- /dev/null +++ b/docs/configuration/route/rule.md @@ -0,0 +1,150 @@ +### Structure + +```json +{ + "route": { + "rules": [ + { + "inbound": [ + "mixed-in" + ], + "network": "tcp", + "protocol": [ + "tls", + "http", + "quic" + ], + "domain": [ + "test.com" + ], + "domain_suffix": [ + ".cn" + ], + "domain_keyword": [ + "test" + ], + "domain_regex": [ + "^stun\\..+" + ], + "geosite": [ + "cn" + ], + "source_geoip": [ + "private" + ], + "geoip": [ + "cn" + ], + "source_ip_cidr": [ + "10.0.0.0/24" + ], + "ip_cidr": [ + "10.0.0.0/24" + ], + "source_port": [ + 12345 + ], + "port": [ + 80, + 443 + ], + "outbound": "direct" + }, + { + "type": "logical", + "mode": "and", + "rules": [], + "outbound": "direct" + } + ] + } +} + +``` + +!!! note "" + + You can ignore the JSON Array [] tag when the content is only one item + +### Default Fields + +!!! note "" + + The default rule uses the following matching logic: + (`domain` || `domain_suffix` || `domain_keyword` || `domain_regex` || `geosite` || `geoip` || `ip_cidr`) && + (`source_geoip` || `source_ip_cidr`) && + `other fields` + +#### inbound + +Tags of [inbound](../inbound). + +#### network + +`tcp` or `udp`. + +#### domain + +Match full domain. + +#### domain_suffix + +Match domain suffix. + +#### domain_keyword + +Match domain using keyword. + +#### domain_regex + +Match domain using regular expression. + +#### geosite + +Match geosite. + +#### source_geoip + +Match source geoip. + +#### geoip + +Match geoip. + +#### source_ip_cidr + +Match source ip cidr. + +#### ip_cidr + +Match ip cidr. + +#### source_port + +Match source port. + +#### port + +Match port. + +#### outbound + +Tag of the target outbound. + +### Logical Fields + +#### type + +`logical` + +#### mode + +`and` or `or` + +#### rules + +Included default rules. + +#### outbound + +Tag of the target outbound. diff --git a/mkdocs.yml b/mkdocs.yml index 29f71eaa..df1987bc 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -50,6 +50,11 @@ nav: - Socks: configuration/outbound/socks.md - HTTP: configuration/outbound/http.md - Shadowsocks: configuration/outbound/shadowsocks.md + - Route: + - configuration/route/index.md + - GeoIP: configuration/route/geoip.md + - Geosite: configuration/route/geosite.md + - Route Rule: configuration/route/rule.md markdown_extensions: - pymdownx.inlinehilite - pymdownx.snippets