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 ipaddr, peeraddr, ip6addr, tunnelid, username, password
16 local defaultroute, metric, ttl, mtu
19 ipaddr = s:taboption("general", Value, "ipaddr",
20 translate("Local IPv4 address"),
21 translate("Leave empty to use the current WAN address"))
23 ipaddr.datatype = "ip4addr"
26 peeraddr = s:taboption("general", Value, "peeraddr",
27 translate("Remote IPv4 address"),
28 translate("This is usually the address of the nearest PoP operated by the tunnel broker"))
30 peeraddr.rmempty = false
31 peeraddr.datatype = "ip4addr"
34 ip6addr = s:taboption("general", Value, "ip6addr",
35 translate("Local IPv6 address"),
36 translate("This is the local endpoint address assigned by the tunnel broker, it usually ends with <code>:2</code>"))
38 ip6addr.datatype = "ip6addr"
41 local ip6prefix = s:taboption("general", Value, "ip6prefix",
42 translate("IPv6 routed prefix"),
43 translate("This is the prefix routed to you by the tunnel broker for use by clients"))
45 ip6prefix.datatype = "ip6addr"
48 local update = section:taboption("general", Flag, "_update",
49 translate("Dynamic tunnel"),
50 translate("Enable HE.net dynamic endpoint update"))
55 function update.write() end
56 function update.remove() end
57 function update.cfgvalue(self, section)
58 return (tonumber(m:get(section, "tunnelid")) ~= nil)
59 and self.enabled or self.disabled
63 tunnelid = section:taboption("general", Value, "tunnelid", translate("Tunnel ID"))
64 tunnelid.datatype = "uinteger"
65 tunnelid:depends("_update", update.enabled)
68 username = section:taboption("general", Value, "username",
69 translate("HE.net username"),
70 translate("This is the plain username for logging into the account"))
72 username:depends("_update", update.enabled)
73 username.validate = function(self, val, sid)
74 if type(val) == "string" and #val == 32 and val:match("^[a-fA-F0-9]+$") then
75 return nil, translate("The HE.net endpoint update configuration changed, you must now use the plain username instead of the user ID!")
81 password = section:taboption("general", Value, "password",
82 translate("HE.net password"),
83 translate("This is either the \"Update Key\" configured for the tunnel or the account password if no update key has been configured"))
85 password.password = true
86 password:depends("_update", update.enabled)
89 defaultroute = section:taboption("advanced", Flag, "defaultroute",
90 translate("Default gateway"),
91 translate("If unchecked, no default route is configured"))
93 defaultroute.default = defaultroute.enabled
96 metric = section:taboption("advanced", Value, "metric",
97 translate("Use gateway metric"))
99 metric.placeholder = "0"
100 metric.datatype = "uinteger"
101 metric:depends("defaultroute", defaultroute.enabled)
104 ttl = section:taboption("advanced", Value, "ttl", translate("Use TTL on tunnel interface"))
105 ttl.placeholder = "64"
106 ttl.datatype = "range(1,255)"
109 mtu = section:taboption("advanced", Value, "mtu", translate("Use MTU on tunnel interface"))
110 mtu.placeholder = "1280"
111 mtu.datatype = "max(9200)"