BadVPN – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | process main { |
2 | call("make_dhcp_config", {"192.168.1.1", "24", "192.168.1.100", "192.168.1.199", {"192.168.1.1"}, {"192.168.1.1", "4.4.4.4"}, "dhcpd.conf.template", "dhcpd.conf"}) config; |
||
3 | exit("0"); |
||
4 | } |
||
5 | |||
6 | template make_dhcp_config { |
||
7 | alias("_arg0") addr; |
||
8 | alias("_arg1") prefix; |
||
9 | alias("_arg2") range_start; |
||
10 | alias("_arg3") range_end; |
||
11 | alias("_arg4") routers; |
||
12 | alias("_arg5") dns_servers; |
||
13 | alias("_arg6") template_file; |
||
14 | alias("_arg7") output_file; |
||
15 | |||
16 | ipv4_net_from_addr_and_prefix(addr, prefix) network; |
||
17 | ipv4_prefix_to_mask(prefix) netmask; |
||
18 | implode(", ", routers) routers_str; |
||
19 | implode(", ", dns_servers) dns_servers_str; |
||
20 | |||
21 | var({"<LOCAL_ADDRESS>", "<NETWORK>", "<NETMASK>", "<RANGE_START>", "<RANGE_END>", "<ROUTERS>", "<DNS_SERVERS>"}) regex; |
||
22 | var({addr, network, netmask, range_start, range_end, routers_str, dns_servers_str}) replace; |
||
23 | |||
24 | file_read(template_file) template_data; |
||
25 | regex_replace(template_data, regex, replace) replaced_data; |
||
26 | file_write(output_file, replaced_data); |
||
27 | } |