BadVPN – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | include_guard "unbound" |
2 | |||
3 | template unbound { |
||
4 | alias("_arg0") unique_id; |
||
5 | alias("_arg1") access_control_rules; |
||
6 | |||
7 | # Create a temporary directory. |
||
8 | concat("/run/ncd-unbound-", unique_id) run_dir; |
||
9 | run({"/bin/rm", "-rf", run_dir}, {}); |
||
10 | run({"/bin/mkdir", run_dir}, {"/bin/rm", "-rf", run_dir}); |
||
11 | |||
12 | # Compute path for unbound.conf. |
||
13 | concat(run_dir, "/unbound.conf") unbound_conf_path; |
||
14 | |||
15 | # This is a template for unbound.conf. |
||
16 | value(" |
||
17 | server: |
||
18 | verbosity: 1 |
||
19 | do-ip4: yes |
||
20 | do-ip6: no |
||
21 | do-udp: yes |
||
22 | do-tcp: no |
||
23 | interface: 0.0.0.0 |
||
24 | access-control: 127.0.0.0/8 allow |
||
25 | " ) config; |
||
26 | |||
27 | # Append access control rules. |
||
28 | Foreach (access_control_rules As rule) { |
||
29 | value(rule) rule; |
||
30 | rule->get("0") network; |
||
31 | rule->get("1") prefix; |
||
32 | rule->get("2") action; |
||
33 | concat(" access-control: ", network, "/", prefix, " ", action, "\n") line; |
||
34 | config->append(line); |
||
35 | }; |
||
36 | |||
37 | # Write unbound.conf. |
||
38 | file_write(unbound_conf_path, config); |
||
39 | |||
40 | # Start unbound. |
||
41 | daemon({"/usr/sbin/unbound", "-d", "-c", unbound_conf_path}); |
||
42 | } |