Merge pull request #1735 from sumpfralle/olsr-jsoninfo-parser-handle-empty-result
[oweals/luci.git] / protocols / luci-proto-ppp / htdocs / luci-static / resources / protocol / l2tp.js
1 'use strict';
2 'require uci';
3 'require form';
4 'require network';
5
6 network.registerPatternVirtual(/^l2tp-.+$/);
7
8 return network.registerProtocol('l2tp', {
9         getI18n: function() {
10                 return _('L2TP');
11         },
12
13         getIfname: function() {
14                 return this._ubus('l3_device') || 'l2tp-%s'.format(this.sid);
15         },
16
17         getOpkgPackage: function() {
18                 return 'xl2tpd';
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 dev = this.getL3Device() || this.getDevice(), o;
39
40                 o = s.taboption('general', form.Value, 'server', _('L2TP Server'));
41                 o.datatype = 'or(host(1), hostport(1))';
42
43                 s.taboption('general', form.Value, 'username', _('PAP/CHAP username'));
44
45                 o = s.taboption('general', form.Value, 'password', _('PAP/CHAP password'));
46                 o.password = true;
47
48                 if (L.hasSystemFeature('ipv6')) {
49                         o = s.taboption('advanced', form.ListValue, 'ipv6', _('Obtain IPv6-Address'), _('Enable IPv6 negotiation on the PPP link'));
50                         o.value('auto', _('Automatic'));
51                         o.value('0', _('Disabled'));
52                         o.value('1', _('Manual'));
53                         o.default = 'auto';
54                 }
55
56                 o = s.taboption('advanced', form.Flag, 'defaultroute', _('Use default gateway'), _('If unchecked, no default route is configured'));
57                 o.default = o.enabled;
58
59                 o = s.taboption('advanced', form.Flag, 'peerdns', _('Use DNS servers advertised by peer'), _('If unchecked, the advertised DNS server addresses are ignored'));
60                 o.default = o.enabled;
61
62                 o = s.taboption('advanced', form.DynamicList, 'dns', _('Use custom DNS servers'));
63                 o.depends('peerdns', '0');
64                 o.datatype = 'ipaddr';
65                 o.cast     = 'string';
66
67                 o = s.taboption('advanced', form.Value, 'metric', _('Use gateway metric'));
68                 o.placeholder = '0';
69                 o.datatype    = 'uinteger';
70
71                 o = s.taboption('advanced', form.Value, 'mtu', _('Override MTU'));
72                 o.placeholder = dev ? (dev.getMTU() || '1500') : '1500';
73                 o.datatype    = 'max(9200)';
74         }
75 });