bb651848540f46c29d46cf1aedc92fff7a881415
[project/luci2/ui.git] / luci2 / htdocs / luci2 / proto / 6in4.js
1 L.NetworkModel.Protocol.extend({
2         protocol:    '6in4',
3         description: L.tr('IPv6-in-IPv4 (RFC4213)'),
4         tunnel:      true,
5         virtual:     true,
6
7         populateForm: function(section, iface)
8         {
9                 var wan = L.NetworkModel.findWAN();
10
11                 section.taboption('general', L.cbi.InputValue, 'ipaddr', {
12                         caption:     L.tr('Local IPv4 address'),
13                         description: L.tr('Leave empty to use the current WAN address'),
14                         datatype:    'ip4addr',
15                         placeholder: wan ? wan.getIPv4Addrs()[0] : undefined,
16                         optional:    true
17                 });
18
19                 section.taboption('general', L.cbi.InputValue, 'peeraddr', {
20                         caption:     L.tr('Remote IPv4 address'),
21                         description: L.tr('This is usually the address of the nearest PoP optional by the tunnel broker'),
22                         datatype:    'ip4addr',
23                         optional:    false
24                 });
25
26                 section.taboption('general', L.cbi.InputValue, 'ip6addr', {
27                         caption:     L.tr('Local IPv6 address'),
28                         description: L.tr('This is the local endpoint address assigned by the tunnel broker, it usually ends with :2'),
29                         datatype:    'ip6addr',
30                         optional:    false
31                 });
32
33                 section.taboption('general', L.cbi.InputValue, 'ip6prefix', {
34                         caption:     L.tr('IPv6 routed prefix'),
35                         description: L.tr('This is the prefix routed to you by the tunnel broker for use by clients'),
36                         datatype:    'cidr6',
37                         optional:    true
38                 });
39
40                 var update = section.taboption('general', L.cbi.CheckboxValue, '_update', {
41                         caption:     L.tr('Dynamic tunnel'),
42                         description: L.tr('Enable HE.net dynamic endpoint update'),
43                         enabled:     '1',
44                         disabled:    '0'
45                 });
46
47                 update.save = function(sid) { };
48                 update.ucivalue = function(sid) {
49                         var n = parseInt(this.ownerMap.get('network', sid, 'tunnelid'));
50                         return !isNaN(n);
51                 };
52
53                 section.taboption('general', L.cbi.InputValue, 'tunnelid', {
54                         caption:     L.tr('Tunnel ID'),
55                         datatype:    'uinteger',
56                         optional:    false,
57                         keep:        false
58                 }).depends('_update', true);
59
60                 section.taboption('general', L.cbi.InputValue, 'username', {
61                         caption:     L.tr('HE.net user ID'),
62                         description: L.tr('This is the 32 byte hex encoded user ID, not the login name'),
63                         datatype:    'rangelength(32, 32)',
64                         optional:    false,
65                         keep:        false
66                 }).depends('_update', true);
67
68                 section.taboption('general', L.cbi.PasswordValue, 'password', {
69                         caption:     L.tr('HE.net password'),
70                         optional:    false,
71                         keep:        false
72                 }).depends('_update', true);
73
74                 section.taboption('advanced', L.cbi.CheckboxValue, 'defaultroute', {
75                         caption:     L.tr('Default route'),
76                         description: L.tr('Create IPv6 default route via tunnel'),
77                         optional:    true,
78                         initial:     true
79                 });
80
81                 section.taboption('advanced', L.cbi.InputValue, 'ttl', {
82                         caption:     L.tr('Override TTL'),
83                         description: L.tr('Specifies the Time-to-Live on the tunnel interface'),
84                         datatype:    'range(1,255)',
85                         placeholder: 64,
86                         optional:    true
87                 });
88         }
89 });