luci-proto-sstp: proto add
[project/luci.git] / protocols / luci-proto-sstp / htdocs / luci-static / resources / protocol / sstp.js
1 'use strict';
2 'require form';
3 'require network';
4
5 network.registerPatternVirtual(/^sstp-.+$/);
6
7 return network.registerProtocol('sstp', {
8 getI18n: function() {
9 return _('SSTP');
10 },
11
12 getIfname: function() {
13 return this._ubus('l3_device') || 'sstp-%s'.format(this.sid);
14 },
15
16 getOpkgPackage: function() {
17 return 'sstp-client';
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 dev = this.getL3Device() || this.getDevice(), o;
38
39 // -- general ---------------------------------------------------------------------
40
41 o = s.taboption('general', form.Value, 'server', _('SSTP Server'));
42 o.datatype = 'host';
43
44 o = s.taboption('general', form.Value, 'username', _('PAP/CHAP username'));
45
46 o = s.taboption('general', form.Value, 'password', _('PAP/CHAP password'));
47 o.password = true;
48
49 // -- advanced --------------------------------------------------------------------
50
51 o = s.taboption('advanced', form.Flag, 'ipv6', _('IPv6 support'), _('If checked, adds "+ipv6" to the pppd options'));
52
53 o = s.taboption('advanced', form.ListValue, 'log_level', _('sstpc Log-level'));
54 o.value('0', _('0', 'sstp log level value'));
55 o.value('1', _('1', 'sstp log level value'));
56 o.value('2', _('2', 'sstp log level value'));
57 o.value('3', _('3', 'sstp log level value'));
58 o.value('4', _('4', 'sstp log level value'));
59 o.default = '0';
60
61 var defaultroute = s.taboption('advanced', form.Flag, 'defaultroute', _('Use default gateway'), _('If unchecked, no default route is configured'));
62 defaultroute.default = defaultroute.enabled;
63
64 o = s.taboption('advanced', form.Value, 'metric', _('Use gateway metric'));
65 o.placeholder = '0';
66 o.datatype = 'uinteger';
67 o.depends('defaultroute', defaultroute.enabled);
68
69 o = s.taboption('advanced', form.Flag, 'peerdns', _('Use DNS servers advertised by peer'), _('If unchecked, the advertised DNS server addresses are ignored'));
70 o.default = o.enabled;
71
72 o = s.taboption('advanced', form.DynamicList, 'dns', _('Use custom DNS servers'));
73 o.depends('peerdns', '0');
74 o.datatype = 'ipaddr';
75 o.cast = 'string';
76
77 o = s.taboption('advanced', form.Value, 'mtu', _('Override MTU'));
78 o.placeholder = dev ? (dev.getMTU() || '1500') : '1500';
79 o.datatype = 'max(9200)';
80
81 o = s.taboption('advanced', form.Value, 'sstp_options', _('Extra sstpc options'), _('e.g: --proxy 10.10.10.10'));
82
83 o = s.taboption('advanced', form.Value, 'pppd_options', _('Extra pppd options'), _('e.g: dump'));
84 }
85 });