From cab1e4290967340923d7d5ca52b80f781711c18e Mon Sep 17 00:00:00 2001 From: Epmty ICU <155220865+epmtyicu@users.noreply.github.com> Date: Sat, 30 Dec 2023 21:17:07 +0800 Subject: [PATCH] docs: add guide to separate configuration files (#389) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Sumire (菫) <151038614+sumire88@users.noreply.github.com> --- docs/en/configuration/separate-config.md | 123 +++++++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 docs/en/configuration/separate-config.md diff --git a/docs/en/configuration/separate-config.md b/docs/en/configuration/separate-config.md new file mode 100644 index 000000000..be77ca72a --- /dev/null +++ b/docs/en/configuration/separate-config.md @@ -0,0 +1,123 @@ +# Separate Configuration Files + +Sometimes you want to break your configuration file into several files. It may be useful in the following cases: + +1. You want to switch nodes via modify the config file using tools like `sed`. +2. You copy other's configuration file and you want to overwrite some parts of it. + +## Example + +Directory Structure: + +```sh +# tree /etc/dae +/etc/dae +├── config.d +│ ├── dns.dae +│ ├── node.dae +│ └── route.dae +└── config.dae +``` + +Config files: + +```jsonc +# config.dae + +# load all dae files placed in ./config.d/ +include { + config.d/*.dae +} +global { + tproxy_port: 12345 + + log_level: warn + + tcp_check_url: 'http://cp.cloudflare.com' + udp_check_dns: 'dns.google.com:53' + check_interval: 600s + check_tolerance: 50ms + + #lan_interface: eth0 + wan_interface: eth0 + allow_insecure: false + + dial_mode: domain + disable_waiting_network: false + auto_config_kernel_parameter: true + sniffing_timeout: 100ms +} +``` + +```jsonc +# dns.dae +dns { + upstream { + alidns: 'udp://dns.alidns.com:53' + googledns: 'tcp+udp://dns.google.com:53' + } + + routing { + request { + qname(geosite:category-ads) -> reject + qname(geosite:category-ads-all) -> reject + fallback: alidns + } + response { + upstream(googledns) -> accept + !qname(geosite:cn) && ip(geoip:private) -> googledns + fallback: accept + } + } +} +``` + +```jsonc +# node.dae +node { + node1: 'xxx' + node2: 'xxx' +} + +subscription { + my_sub: 'https://www.example.com/subscription/link' +} + +group { + my_group { + filter: subtag(my_sub) && !name(keyword: 'ExpireAt:') + policy: min_moving_avg + } + + local_group { + filter: name(node1, node2) + policy: fixed(0) + } +} +``` + +```jsonc +# route.dae +routing { + pname(NetworkManager) -> direct + dip(224.0.0.0/3, 'ff00::/8') -> direct + dip(geoip:private) -> direct + + dip(1.14.5.14) -> direct + + domain(geosite:openai) -> local_group + dip(geoip:cn) -> direct + domain(geosite:cn) -> direct + domain(geosite:category-scholar-cn) -> direct + domain(geosite:geolocation-cn) -> direct + + + fallback: my_group +} +``` + +Then run `dae` via: + +```sh +dae run -c /etc/dae/config.dae +```