1 -- Copyright 2011-2012 Jo-Philipp Wich <xm@subsignal.org>
2 -- Licensed to the public under the Apache License 2.0.
4 local map, section, net = ...
6 local server, username, password
7 local defaultroute, metric, peerdns, dns,
8 keepalive_failure, keepalive_interval, demand, mtu
11 server = section:taboption("general", Value, "server", translate("VPN Server"))
12 server.datatype = "host"
15 username = section:taboption("general", Value, "username", translate("PAP/CHAP username"))
18 password = section:taboption("general", Value, "password", translate("PAP/CHAP password"))
19 password.password = true
22 defaultroute = section:taboption("advanced", Flag, "defaultroute",
23 translate("Use default gateway"),
24 translate("If unchecked, no default route is configured"))
26 defaultroute.default = defaultroute.enabled
29 metric = section:taboption("advanced", Value, "metric",
30 translate("Use gateway metric"))
32 metric.placeholder = "0"
33 metric.datatype = "uinteger"
34 metric:depends("defaultroute", defaultroute.enabled)
37 peerdns = section:taboption("advanced", Flag, "peerdns",
38 translate("Use DNS servers advertised by peer"),
39 translate("If unchecked, the advertised DNS server addresses are ignored"))
41 peerdns.default = peerdns.enabled
44 dns = section:taboption("advanced", DynamicList, "dns",
45 translate("Use custom DNS servers"))
47 dns:depends("peerdns", "")
48 dns.datatype = "ipaddr"
52 keepalive_failure = section:taboption("advanced", Value, "_keepalive_failure",
53 translate("LCP echo failure threshold"),
54 translate("Presume peer to be dead after given amount of LCP echo failures, use 0 to ignore failures"))
56 function keepalive_failure.cfgvalue(self, section)
57 local v = m:get(section, "keepalive")
59 return tonumber(v:match("^(%d+)[ ,]+%d+") or v)
63 keepalive_failure.placeholder = "0"
64 keepalive_failure.datatype = "uinteger"
67 keepalive_interval = section:taboption("advanced", Value, "_keepalive_interval",
68 translate("LCP echo interval"),
69 translate("Send LCP echo requests at the given interval in seconds, only effective in conjunction with failure threshold"))
71 function keepalive_interval.cfgvalue(self, section)
72 local v = m:get(section, "keepalive")
74 return tonumber(v:match("^%d+[ ,]+(%d+)"))
78 function keepalive_interval.write(self, section, value)
79 local f = tonumber(keepalive_failure:formvalue(section)) or 0
80 local i = tonumber(value) or 5
81 if i < 1 then i = 1 end
83 m:set(section, "keepalive", "%d %d" %{ f, i })
85 m:del(section, "keepalive")
89 keepalive_interval.remove = keepalive_interval.write
90 keepalive_failure.write = keepalive_interval.write
91 keepalive_failure.remove = keepalive_interval.write
92 keepalive_interval.placeholder = "5"
93 keepalive_interval.datatype = "min(1)"
96 demand = section:taboption("advanced", Value, "demand",
97 translate("Inactivity timeout"),
98 translate("Close inactive connection after the given amount of seconds, use 0 to persist connection"))
100 demand.placeholder = "0"
101 demand.datatype = "uinteger"
104 mtu = section:taboption("advanced", Value, "mtu", translate("Override MTU"))
105 mtu.placeholder = "1500"
106 mtu.datatype = "max(9200)"