6 network
.registerPatternVirtual(/^pppossh-.+$/);
8 function write_keepalive(section_id
, value
) {
9 var f_opt
= this.map
.lookupOption('_keepalive_failure', section_id
),
10 i_opt
= this.map
.lookupOption('_keepalive_interval', section_id
),
11 f
= (f_opt
!= null) ? +f_opt
[0].formvalue(section_id
) : null,
12 i
= (i_opt
!= null) ? +i_opt
[0].formvalue(section_id
) : null;
14 if (f
== null || f
== '' || isNaN(f
))
17 if (i
== null || i
== '' || isNaN(i
) || i
< 1)
21 uci
.set('network', section_id
, 'keepalive', '%d %d'.format(f
, i
));
23 uci
.unset('network', section_id
, 'keepalive');
26 return network
.registerProtocol('pppossh', {
31 getIfname: function() {
32 return this._ubus('l3_device') || 'pppossh-%s'.format(this.sid
);
35 getOpkgPackage: function() {
39 isFloating: function() {
43 isVirtual: function() {
47 getDevices: function() {
51 containsDevice: function(ifname
) {
52 return (network
.getIfnameOf(ifname
) == this.getIfname());
55 renderFormOptions: function(s
) {
58 o
= s
.taboption('general', form
.Value
, 'sshuser', _('SSH username'));
60 o
.validate = function(section_id
, value
) {
61 var id_opt
= this.section
.children
.filter(function(o
) { return o
.option
== 'identity' })[0];
62 if (id_opt
&& value
.length
) {
63 var input
= this.map
.findElement('id', id_opt
.cbid(section_id
)).querySelector('input[type="text"]');
65 input
.placeholder
= (value
== 'root' ? '/root' : '/home/' + value
) + '/.ssh/id_rsa';
70 o
= s
.taboption('general', form
.Value
, 'server', _('SSH server address'));
71 o
.datatype
= 'host(0)';
74 o
= s
.taboption('general', form
.Value
, 'port', _('SSH server port'));
79 o
= s
.taboption('general', form
.Value
, 'ssh_options', _('Extra SSH command options'));
82 o
= s
.taboption('general', form
.DynamicList
, 'identity', _('List of SSH key files for auth'));
86 o
= s
.taboption('general', form
.Value
, 'ipaddr', _('Local IP address to assign'));
87 o
.datatype
= 'ipaddr("nomask")';
89 o
= s
.taboption('general', form
.Value
, 'peeraddr', _('Peer IP address to assign'));
90 o
.datatype
= 'ipaddr("nomask")';
92 if (L
.hasSystemFeature('ipv6')) {
93 o
= s
.taboption('advanced', form
.Flag
, 'ipv6', _('Obtain IPv6-Address'), _('Enable IPv6 negotiation on the PPP link'));
94 o
.default = o
.disabled
;
97 o
= s
.taboption('advanced', form
.Flag
, 'defaultroute', _('Use default gateway'), _('If unchecked, no default route is configured'));
98 o
.default = o
.enabled
;
100 o
= s
.taboption('advanced', form
.Flag
, 'peerdns', _('Use DNS servers advertised by peer'), _('If unchecked, the advertised DNS server addresses are ignored'));
101 o
.default = o
.enabled
;
103 o
= s
.taboption('advanced', form
.DynamicList
, 'dns', _('Use custom DNS servers'));
104 o
.depends('peerdns', '0');
105 o
.datatype
= 'ipaddr';
108 o
= s
.taboption('advanced', form
.Value
, 'metric', _('Use gateway metric'));
110 o
.datatype
= 'uinteger';
112 o
= s
.taboption('advanced', form
.Value
, '_keepalive_failure', _('LCP echo failure threshold'), _('Presume peer to be dead after given amount of LCP echo failures, use 0 to ignore failures'));
114 o
.datatype
= 'uinteger';
115 o
.write
= write_keepalive
;
116 o
.remove
= write_keepalive
;
117 o
.cfgvalue = function(section_id
) {
118 var v
= uci
.get('network', section_id
, 'keepalive');
119 if (typeof(v
) == 'string' && v
!= '') {
120 var m
= v
.match(/^(\d+)[ ,]\d+$/);
125 o
= s
.taboption('advanced', form
.Value
, '_keepalive_interval', _('LCP echo interval'), _('Send LCP echo requests at the given interval in seconds, only effective in conjunction with failure threshold'));
127 o
.datatype
= 'min(1)';
128 o
.write
= write_keepalive
;
129 o
.remove
= write_keepalive
;
130 o
.cfgvalue = function(section_id
) {
131 var v
= uci
.get('network', section_id
, 'keepalive');
132 if (typeof(v
) == 'string' && v
!= '') {
133 var m
= v
.match(/^\d+[ ,](\d+)$/);
138 o
= s
.taboption('advanced', form
.Value
, 'demand', _('Inactivity timeout'), _('Close inactive connection after the given amount of seconds, use 0 to persist connection'));
140 o
.datatype
= 'uinteger';