treewide: remove rendundant proto handler options
[project/luci.git] / protocols / luci-proto-ipv6 / htdocs / luci-static / resources / protocol / dslite.js
1 'use strict';
2 'require form';
3 'require network';
4 'require tools.widgets as widgets';
5
6 network.registerPatternVirtual(/^ds-.+$/);
7 network.registerErrorCode('AFTR_DNS_FAIL', _('Unable to resolve AFTR host name'));
8
9 return network.registerProtocol('dslite', {
10 getI18n: function() {
11 return _('Dual-Stack Lite (RFC6333)');
12 },
13
14 getIfname: function() {
15 return this._ubus('l3_device') || 'ds-%s'.format(this.sid);
16 },
17
18 getOpkgPackage: function() {
19 return 'ds-lite';
20 },
21
22 isFloating: function() {
23 return true;
24 },
25
26 isVirtual: function() {
27 return true;
28 },
29
30 getDevices: function() {
31 return null;
32 },
33
34 containsDevice: function(ifname) {
35 return (network.getIfnameOf(ifname) == this.getIfname());
36 },
37
38 renderFormOptions: function(s) {
39 var o;
40
41 o = s.taboption('general', form.Value, 'peeraddr', _('DS-Lite AFTR address'));
42 o.rmempty = false;
43 o.datatype = 'or(hostname,ip6addr("nomask"))';
44
45 o = s.taboption('general', form.Value, 'ip6addr', _('Local IPv6 address'), _('Leave empty to use the current WAN address'));
46 o.datatype = 'ip6addr("nomask")';
47 o.load = function(section_id) {
48 return network.getWAN6Networks().then(L.bind(function(nets) {
49 if (Array.isArray(nets) && nets.length)
50 this.placeholder = nets[0].getIP6Addr();
51 return form.Value.prototype.load.apply(this, [section_id]);
52 }, this));
53 };
54
55 o = s.taboption('advanced', widgets.NetworkSelect, 'tunlink', _('Tunnel Link'));
56 o.nocreate = true;
57 o.exclude = s.section;
58
59 o = s.taboption('advanced', form.ListValue, 'encaplimit', _('Encapsulation limit'));
60 o.rmempty = false;
61 o.default = 'ignore';
62 o.datatype = 'or("ignore",range(0,255))';
63 o.value('ignore', _('ignore'));
64 for (var i = 0; i < 256; i++)
65 o.value(i);
66
67 o = s.taboption('advanced', form.Value, 'mtu', _('Use MTU on tunnel interface'));
68 o.placeholder = '1280';
69 o.datatype = 'max(9200)';
70 }
71 });