1 -- Copyright 2011 Jo-Philipp Wich <jow@openwrt.org>
2 -- Licensed to the public under the Apache License 2.0.
4 local map, section, net = ...
6 local ipaddr, peeraddr, ip6addr, tunnelid, username, password
7 local defaultroute, metric, ttl, mtu
10 ipaddr = s:taboption("general", Value, "ipaddr",
11 translate("Local IPv4 address"),
12 translate("Leave empty to use the current WAN address"))
14 ipaddr.datatype = "ip4addr"
17 peeraddr = s:taboption("general", Value, "peeraddr",
18 translate("Remote IPv4 address"),
19 translate("This is usually the address of the nearest PoP operated by the tunnel broker"))
21 peeraddr.rmempty = false
22 peeraddr.datatype = "ip4addr"
25 ip6addr = s:taboption("general", Value, "ip6addr",
26 translate("Local IPv6 address"),
27 translate("This is the local endpoint address assigned by the tunnel broker, it usually ends with <code>:2</code>"))
29 ip6addr.datatype = "ip6addr"
32 local ip6prefix = s:taboption("general", Value, "ip6prefix",
33 translate("IPv6 routed prefix"),
34 translate("This is the prefix routed to you by the tunnel broker for use by clients"))
36 ip6prefix.datatype = "ip6addr"
39 local update = section:taboption("general", Flag, "_update",
40 translate("Dynamic tunnel"),
41 translate("Enable HE.net dynamic endpoint update"))
46 function update.write() end
47 function update.remove() end
48 function update.cfgvalue(self, section)
49 return (tonumber(m:get(section, "tunnelid")) ~= nil)
50 and self.enabled or self.disabled
54 tunnelid = section:taboption("general", Value, "tunnelid", translate("Tunnel ID"))
55 tunnelid.datatype = "uinteger"
56 tunnelid:depends("_update", update.enabled)
59 username = section:taboption("general", Value, "username",
60 translate("HE.net username"),
61 translate("This is the plain username for logging into the account"))
63 username:depends("_update", update.enabled)
64 username.validate = function(self, val, sid)
65 if type(val) == "string" and #val == 32 and val:match("^[a-fA-F0-9]+$") then
66 return nil, translate("The HE.net endpoint update configuration changed, you must now use the plain username instead of the user ID!")
72 password = section:taboption("general", Value, "password",
73 translate("HE.net password"),
74 translate("This is either the \"Update Key\" configured for the tunnel or the account password if no update key has been configured"))
76 password.password = true
77 password:depends("_update", update.enabled)
80 defaultroute = section:taboption("advanced", Flag, "defaultroute",
81 translate("Default gateway"),
82 translate("If unchecked, no default route is configured"))
84 defaultroute.default = defaultroute.enabled
87 metric = section:taboption("advanced", Value, "metric",
88 translate("Use gateway metric"))
90 metric.placeholder = "0"
91 metric.datatype = "uinteger"
92 metric:depends("defaultroute", defaultroute.enabled)
95 ttl = section:taboption("advanced", Value, "ttl", translate("Use TTL on tunnel interface"))
96 ttl.placeholder = "64"
97 ttl.datatype = "range(1,255)"
100 mtu = section:taboption("advanced", Value, "mtu", translate("Use MTU on tunnel interface"))
101 mtu.placeholder = "1280"
102 mtu.datatype = "max(9200)"