treewide: remove rendundant proto handler options
[project/luci.git] / protocols / luci-proto-ipv6 / htdocs / luci-static / resources / protocol / 6in4.js
1 'use strict';
2 'require uci';
3 'require form';
4 'require network';
5
6 network.registerPatternVirtual(/^6in4-.+$/);
7
8 return network.registerProtocol('6in4', {
9 getI18n: function() {
10 return _('IPv6-in-IPv4 (RFC4213)');
11 },
12
13 getIfname: function() {
14 return this._ubus('l3_device') || '6in4-%s'.format(this.sid);
15 },
16
17 getOpkgPackage: function() {
18 return '6in4';
19 },
20
21 isFloating: function() {
22 return true;
23 },
24
25 isVirtual: function() {
26 return true;
27 },
28
29 getDevices: function() {
30 return null;
31 },
32
33 containsDevice: function(ifname) {
34 return (network.getIfnameOf(ifname) == this.getIfname());
35 },
36
37 renderFormOptions: function(s) {
38 var o;
39
40 o = s.taboption('general', form.Value, 'ipaddr', _('Local IPv4 address'), _('Leave empty to use the current WAN address'));
41 o.datatype = 'ip4addr("nomask")';
42 o.load = function(section_id) {
43 return network.getWANNetworks().then(L.bind(function(nets) {
44 if (nets.length)
45 this.placeholder = nets[0].getIPAddr();
46 return form.Value.prototype.load.apply(this, [section_id]);
47 }, this));
48 };
49
50 o = s.taboption('general', form.Value, 'peeraddr', _('Remote IPv4 address'), _('This is usually the address of the nearest PoP operated by the tunnel broker'));
51 o.rmempty = false;
52 o.datatype = 'ip4addr("nomask")';
53
54 o = s.taboption('general', form.Value, 'ip6addr', _('Local IPv6 address'), _('This is the local endpoint address assigned by the tunnel broker, it usually ends with <code>...:2/64</code>'));
55 o.datatype = 'cidr6';
56
57 o = s.taboption('general', form.DynamicList, 'ip6prefix', _('IPv6 routed prefix'), _('This is the prefix routed to you by the tunnel broker for use by clients'));
58 o.datatype = 'cidr6';
59
60 o = s.taboption('general', form.Flag, '_update', _('Dynamic tunnel'), _('Enable HE.net dynamic endpoint update'));
61 o.enabled = '1';
62 o.disabled = '0';
63 o.write = function() {};
64 o.remove = function() {};
65 o.cfgvalue = function(section_id) {
66 return !isNaN(+uci.get('network', section_id, 'tunnelid')) ? this.enabled : this.disabled;
67 };
68
69 o = s.taboption('general', form.Value, 'tunnelid', _('Tunnel ID'));
70 o.datatype = 'uinteger';
71 o.depends('_update', '1');
72
73 o = s.taboption('general', form.Value, 'username', _('HE.net username'), _('This is the plain username for logging into the account'));
74 o.depends('_update', '1');
75 o.validate = function(section_id, value) {
76 if (/^[a-fA-F0-9]{32}$/.test(value))
77 return _('The HE.net endpoint update configuration changed, you must now use the plain username instead of the user ID!');
78 return true;
79 };
80
81 o = s.taboption('general', form.Value, 'password', _('HE.net password'), _('This is either the "Update Key" configured for the tunnel or the account password if no update key has been configured'));
82 o.password = true;
83 o.depends('_update', '1');
84
85 o = s.taboption('advanced', form.Value, 'ttl', _('Use TTL on tunnel interface'));
86 o.placeholder = '64';
87 o.datatype = 'range(1,255)';
88
89 o = s.taboption('advanced', form.Value, 'mtu', _('Use MTU on tunnel interface'));
90 o.placeholder = '1280';
91 o.datatype = 'max(9200)';
92 }
93 });