Merge pull request #1735 from sumpfralle/olsr-jsoninfo-parser-handle-empty-result
[oweals/luci.git] / protocols / luci-proto-ipv6 / htdocs / luci-static / resources / protocol / 6to4.js
1 'use strict';
2 'require form';
3 'require network';
4
5 network.registerPatternVirtual(/^6to4-.+$/);
6
7 return network.registerProtocol('6to4', {
8         getI18n: function() {
9                 return _('IPv6-over-IPv4 (6to4)');
10         },
11
12         getIfname: function() {
13                 return this._ubus('l3_device') || '6to4-%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('advanced', form.Flag, 'defaultroute', _('Default gateway'), _('If unchecked, no default route is configured'));
50                 o.default = o.enabled;
51
52                 o = s.taboption('advanced', form.Value, 'metric', _('Use gateway metric'));
53                 o.placeholder = '0';
54                 o.datatype    = 'uinteger';
55                 o.depends('defaultroute', '1');
56
57                 o = s.taboption('advanced', form.Value, 'ttl', _('Use TTL on tunnel interface'));
58                 o.placeholder = '64';
59                 o.datatype    = 'range(1,255)';
60
61                 o = s.taboption('advanced', form.Value, 'mtu', _('Use MTU on tunnel interface'));
62                 o.placeholder = '1280';
63                 o.datatype    = 'max(9200)';
64         }
65 });