2 LuCI - Lua Configuration Interface
4 Copyright 2011 Jo-Philipp Wich <xm@subsignal.org>
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
10 http://www.apache.org/licenses/LICENSE-2.0
13 local map, section, net = ...
15 local username, password, ac, service
16 local ipv6, defaultroute, metric, peerdns, dns,
17 keepalive_failure, keepalive_interval, demand, mtu
20 username = section:taboption("general", Value, "username", translate("PAP/CHAP username"))
23 password = section:taboption("general", Value, "password", translate("PAP/CHAP password"))
24 password.password = true
27 ac = section:taboption("general", Value, "ac",
28 translate("Access Concentrator"),
29 translate("Leave empty to autodetect"))
31 ac.placeholder = translate("auto")
34 service = section:taboption("general", Value, "service",
35 translate("Service Name"),
36 translate("Leave empty to autodetect"))
38 service.placeholder = translate("auto")
41 if luci.model.network:has_ipv6() then
43 ipv6 = section:taboption("advanced", Flag, "ipv6",
44 translate("Enable IPv6 negotiation on the PPP link"))
46 ipv6.default = ipv6.disabled
51 defaultroute = section:taboption("advanced", Flag, "defaultroute",
52 translate("Use default gateway"),
53 translate("If unchecked, no default route is configured"))
55 defaultroute.default = defaultroute.enabled
58 metric = section:taboption("advanced", Value, "metric",
59 translate("Use gateway metric"))
61 metric.placeholder = "0"
62 metric.datatype = "uinteger"
63 metric:depends("defaultroute", defaultroute.enabled)
66 peerdns = section:taboption("advanced", Flag, "peerdns",
67 translate("Use DNS servers advertised by peer"),
68 translate("If unchecked, the advertised DNS server addresses are ignored"))
70 peerdns.default = peerdns.enabled
73 dns = section:taboption("advanced", DynamicList, "dns",
74 translate("Use custom DNS servers"))
76 dns:depends("peerdns", "")
77 dns.datatype = "ipaddr"
81 keepalive_failure = section:taboption("advanced", Value, "_keepalive_failure",
82 translate("LCP echo failure threshold"),
83 translate("Presume peer to be dead after given amount of LCP echo failures, use 0 to ignore failures"))
85 function keepalive_failure.cfgvalue(self, section)
86 local v = m:get(section, "keepalive")
88 return tonumber(v:match("^(%d+)[ ,]+%d+") or v)
92 function keepalive_failure.write() end
93 function keepalive_failure.remove() end
95 keepalive_failure.placeholder = "0"
96 keepalive_failure.datatype = "uinteger"
99 keepalive_interval = section:taboption("advanced", Value, "_keepalive_interval",
100 translate("LCP echo interval"),
101 translate("Send LCP echo requests at the given interval in seconds, only effective in conjunction with failure threshold"))
103 function keepalive_interval.cfgvalue(self, section)
104 local v = m:get(section, "keepalive")
106 return tonumber(v:match("^%d+[ ,]+(%d+)"))
110 function keepalive_interval.write(self, section, value)
111 local f = tonumber(keepalive_failure:formvalue(section)) or 0
112 local i = tonumber(value) or 5
113 if i < 1 then i = 1 end
115 m:set(section, "keepalive", "%d %d" %{ f, i })
117 m:del(section, "keepalive")
121 keepalive_interval.remove = keepalive_interval.write
122 keepalive_interval.placeholder = "5"
123 keepalive_interval.datatype = "min(1)"
126 demand = section:taboption("advanced", Value, "demand",
127 translate("Inactivity timeout"),
128 translate("Close inactive connection after the given amount of seconds, use 0 to persist connection"))
130 demand.placeholder = "0"
131 demand.datatype = "uinteger"
134 mtu = section:taboption("advanced", Value, "mtu", translate("Override MTU"))
135 mtu.placeholder = "1500"
136 mtu.datatype = "max(1500)"