-
Notifications
You must be signed in to change notification settings - Fork 23
/
example.yaml
61 lines (51 loc) · 1.34 KB
/
example.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
---
verbosity: "info"
address: 0.0.0.0:2053
script: |
pub async fn route(upstreams, inited, ctx, query) {
// A few constants are predefined:
// - query: the incoming query received
// - ctx: the query context, e.g. client IP
// - inited: the value returned by init()
// - upstreams: the upstreams API
if query.first_question?.qtype.to_str() == "AAAA" {
return blackhole(query);
}
let resp = upstreams.send_default("domestic", query).await?;
for ans in resp.answer? {
match ans.rtype.to_str() {
"A" if !inited.geoip.0.contains(ans.to_a()?.ip, "CN") => { return upstreams.send_default("secure", query).await; }
"AAAA" if !inited.geoip.0.contains(ans.to_aaaa()?.ip, "CN") => { return upstreams.send_default("secure", query).await; }
_ => continue,
}
}
Ok(resp)
}
pub async fn init() {
Ok(#{"geoip": Utils::GeoIp(GeoIp::create_default()?)})
}
upstreams:
114DNS:
udp:
addr: 114.114.114.114:53
Ali:
udp:
addr: 223.6.6.6:53
domestic:
hybrid:
- 114DNS
- Ali
cloudflare:
https:
uri: https://cloudflare-dns.com/dns-query
ratelimit: 3000
addr: 1.0.0.1
quad9:
https:
uri: https://quad9.net/dns-query
ratelimit: 3000
addr: 9.9.9.9
secure:
hybrid:
- cloudflare
- quad9