Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add guide to separate configuration files #389

Merged
merged 5 commits into from
Dec 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
123 changes: 123 additions & 0 deletions docs/en/configuration/separate-config.md
Original file line number Diff line number Diff line change
@@ -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
```