treewide: remove rendundant proto handler options
[project/luci.git] / protocols / luci-proto-ipv6 / htdocs / luci-static / resources / protocol / 6rd.js
1 'use strict';
2 'require form';
3 'require network';
4
5 network.registerPatternVirtual(/^6rd-.+$/);
6
7 return network.registerProtocol('6rd', {
8 getI18n: function() {
9 return _('IPv6-over-IPv4 (6rd)');
10 },
11
12 getIfname: function() {
13 return this._ubus('l3_device') || '6rd-%s'.format(this.sid);
14 },
15
16 getOpkgPackage: function() {
17 return '6rd';
18 },
19
20 isFloating: function() {
21 return true;
22 },
23
24 isVirtual: function() {
25 return true;
26 },
27
28 getDevices: function() {
29 return null;
30 },
31
32 containsDevice: function(ifname) {
33 return (network.getIfnameOf(ifname) == this.getIfname());
34 },
35
36 renderFormOptions: function(s) {
37 var o;
38
39 o = s.taboption('general', form.Value, 'ipaddr', _('Local IPv4 address'), _('Leave empty to use the current WAN address'));
40 o.datatype = 'ip4addr("nomask")';
41 o.load = function(section_id) {
42 return network.getWANNetworks().then(L.bind(function(nets) {
43 if (nets.length)
44 this.placeholder = nets[0].getIPAddr();
45 return form.Value.prototype.load.apply(this, [section_id]);
46 }, this));
47 };
48
49 o = s.taboption('general', form.Value, 'peeraddr', _('Remote IPv4 address'), _('This IPv4 address of the relay'));
50 o.rmempty = false;
51 o.datatype = 'ip4addr("nomask")';
52
53 o = s.taboption('general', form.Value, 'ip6prefix', _('IPv6 prefix'), _('The IPv6 prefix assigned to the provider, usually ends with <code>::</code>'));
54 o.rmempty = false;
55 o.datatype = 'ip6addr';
56
57 o = s.taboption('general', form.Value, 'ip6prefixlen', _('IPv6 prefix length'), _('The length of the IPv6 prefix in bits'));
58 o.placeholder = '16';
59 o.datatype = 'range(0,128)';
60
61 o = s.taboption('general', form.Value, 'ip4prefixlen', _('IPv4 prefix length'), _('The length of the IPv4 prefix in bits, the remainder is used in the IPv6 addresses.'));
62 o.placeholder = '0';
63 o.datatype = 'range(0,32)';
64
65 o = s.taboption('advanced', form.Value, 'ttl', _('Use TTL on tunnel interface'));
66 o.placeholder = '64';
67 o.datatype = 'range(1,255)';
68
69 o = s.taboption('advanced', form.Value, 'mtu', _('Use MTU on tunnel interface'));
70 o.placeholder = '1280';
71 o.datatype = 'max(9200)';
72 }
73 });