b167e6f9441f1574f592664d4f752fe59e8d63a7
[project/luci.git] / protocols / luci-proto-ipv6 / luasrc / model / cbi / admin_network / proto_6in4.lua
1 -- Copyright 2011 Jo-Philipp Wich <xm@subsignal.org>
2 -- Licensed to the public under the Apache License 2.0.
3
4 local map, section, net = ...
5
6 local ipaddr, peeraddr, ip6addr, tunnelid, username, password
7 local defaultroute, metric, ttl, mtu
8
9
10 ipaddr = s:taboption("general", Value, "ipaddr",
11         translate("Local IPv4 address"),
12         translate("Leave empty to use the current WAN address"))
13
14 ipaddr.datatype = "ip4addr"
15
16
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"))
20
21 peeraddr.rmempty  = false
22 peeraddr.datatype = "ip4addr"
23
24
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>"))
28
29 ip6addr.datatype = "ip6addr"
30
31
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"))
35
36 ip6prefix.datatype = "ip6addr"
37
38
39 local update = section:taboption("general", Flag, "_update",
40         translate("Dynamic tunnel"),
41         translate("Enable HE.net dynamic endpoint update"))
42
43 update.enabled  = "1"
44 update.disabled = "0"
45
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
51 end
52
53
54 tunnelid = section:taboption("general", Value, "tunnelid", translate("Tunnel ID"))
55 tunnelid.datatype = "uinteger"
56 tunnelid:depends("_update", update.enabled)
57
58
59 username = section:taboption("general", Value, "username",
60         translate("HE.net username"),
61         translate("This is the plain username for logging into the account"))
62
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!")
67         end
68         return val
69 end
70
71
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"))
75
76 password.password = true
77 password:depends("_update", update.enabled)
78
79
80 defaultroute = section:taboption("advanced", Flag, "defaultroute",
81         translate("Default gateway"),
82         translate("If unchecked, no default route is configured"))
83
84 defaultroute.default = defaultroute.enabled
85
86
87 metric = section:taboption("advanced", Value, "metric",
88         translate("Use gateway metric"))
89
90 metric.placeholder = "0"
91 metric.datatype    = "uinteger"
92 metric:depends("defaultroute", defaultroute.enabled)
93
94
95 ttl = section:taboption("advanced", Value, "ttl", translate("Use TTL on tunnel interface"))
96 ttl.placeholder = "64"
97 ttl.datatype    = "range(1,255)"
98
99
100 mtu = section:taboption("advanced", Value, "mtu", translate("Use MTU on tunnel interface"))
101 mtu.placeholder = "1280"
102 mtu.datatype    = "max(9200)"