Rework LuCI build system
[project/luci.git] / protocols / luci-proto-ppp / luasrc / model / cbi / admin_network / proto_pptp.lua
1 --[[
2 LuCI - Lua Configuration Interface
3
4 Copyright 2011-2012 Jo-Philipp Wich <xm@subsignal.org>
5
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
9
10 http://www.apache.org/licenses/LICENSE-2.0
11 ]]--
12
13 local map, section, net = ...
14
15 local server, username, password
16 local defaultroute, metric, peerdns, dns,
17 keepalive_failure, keepalive_interval, demand, mtu
18
19
20 server = section:taboption("general", Value, "server", translate("VPN Server"))
21 server.datatype = "host"
22
23
24 username = section:taboption("general", Value, "username", translate("PAP/CHAP username"))
25
26
27 password = section:taboption("general", Value, "password", translate("PAP/CHAP password"))
28 password.password = true
29
30
31 defaultroute = section:taboption("advanced", Flag, "defaultroute",
32 translate("Use default gateway"),
33 translate("If unchecked, no default route is configured"))
34
35 defaultroute.default = defaultroute.enabled
36
37
38 metric = section:taboption("advanced", Value, "metric",
39 translate("Use gateway metric"))
40
41 metric.placeholder = "0"
42 metric.datatype = "uinteger"
43 metric:depends("defaultroute", defaultroute.enabled)
44
45
46 peerdns = section:taboption("advanced", Flag, "peerdns",
47 translate("Use DNS servers advertised by peer"),
48 translate("If unchecked, the advertised DNS server addresses are ignored"))
49
50 peerdns.default = peerdns.enabled
51
52
53 dns = section:taboption("advanced", DynamicList, "dns",
54 translate("Use custom DNS servers"))
55
56 dns:depends("peerdns", "")
57 dns.datatype = "ipaddr"
58 dns.cast = "string"
59
60
61 keepalive_failure = section:taboption("advanced", Value, "_keepalive_failure",
62 translate("LCP echo failure threshold"),
63 translate("Presume peer to be dead after given amount of LCP echo failures, use 0 to ignore failures"))
64
65 function keepalive_failure.cfgvalue(self, section)
66 local v = m:get(section, "keepalive")
67 if v and #v > 0 then
68 return tonumber(v:match("^(%d+)[ ,]+%d+") or v)
69 end
70 end
71
72 function keepalive_failure.write() end
73 function keepalive_failure.remove() end
74
75 keepalive_failure.placeholder = "0"
76 keepalive_failure.datatype = "uinteger"
77
78
79 keepalive_interval = section:taboption("advanced", Value, "_keepalive_interval",
80 translate("LCP echo interval"),
81 translate("Send LCP echo requests at the given interval in seconds, only effective in conjunction with failure threshold"))
82
83 function keepalive_interval.cfgvalue(self, section)
84 local v = m:get(section, "keepalive")
85 if v and #v > 0 then
86 return tonumber(v:match("^%d+[ ,]+(%d+)"))
87 end
88 end
89
90 function keepalive_interval.write(self, section, value)
91 local f = tonumber(keepalive_failure:formvalue(section)) or 0
92 local i = tonumber(value) or 5
93 if i < 1 then i = 1 end
94 if f > 0 then
95 m:set(section, "keepalive", "%d %d" %{ f, i })
96 else
97 m:del(section, "keepalive")
98 end
99 end
100
101 keepalive_interval.remove = keepalive_interval.write
102 keepalive_interval.placeholder = "5"
103 keepalive_interval.datatype = "min(1)"
104
105
106 demand = section:taboption("advanced", Value, "demand",
107 translate("Inactivity timeout"),
108 translate("Close inactive connection after the given amount of seconds, use 0 to persist connection"))
109
110 demand.placeholder = "0"
111 demand.datatype = "uinteger"
112
113
114 mtu = section:taboption("advanced", Value, "mtu", translate("Override MTU"))
115 mtu.placeholder = "1500"
116 mtu.datatype = "max(9200)"