Skip to content

Commit

Permalink
luci-proto-3g/ppp/pppossh: fix setting of keepalive
Browse files Browse the repository at this point in the history
Fix regressions from f3d26a2:

1) It is now possible again to leave the keepalive option empty.

2) It is possible now to set an interval different from 1 without the
   need to explicitly set the failure threshold.

Signed-off-by: Erik Karlsson <[email protected]>
  • Loading branch information
Erik Karlsson authored and systemcrash committed Jan 9, 2025
1 parent 7f6c727 commit a88d4af
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ network.registerPatternVirtual(/^3g-.+$/);
function write_keepalive(section_id, value) {
var f_opt = this.map.lookupOption('_keepalive_failure', section_id),
i_opt = this.map.lookupOption('_keepalive_interval', section_id),
f = (f_opt != null) ? +f_opt[0].formvalue(section_id) : null,
i = (i_opt != null) ? +i_opt[0].formvalue(section_id) : null;
f = parseInt(f_opt?.[0]?.formvalue(section_id), 10),
i = parseInt(i_opt?.[0]?.formvalue(section_id), 10);

if (f === '' || isNaN(f))
f = null;

if (i == null || i == '' || isNaN(i) || i < 1)
if (isNaN(i))
i = 1;

if (isNaN(f))
f = (i == 1) ? null : 5;

if (f !== null)
uci.set('network', section_id, 'keepalive', '%d %d'.format(f, i));
else
Expand Down Expand Up @@ -142,7 +142,7 @@ return network.registerProtocol('3g', {

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'));
o.placeholder = '1';
o.datatype = 'min(1)';
o.datatype = 'and(uinteger,min(1))';
o.write = write_keepalive;
o.remove = write_keepalive;
o.cfgvalue = function(section_id) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ network.registerPatternVirtual(/^ppp-.+$/);
function write_keepalive(section_id, value) {
var f_opt = this.map.lookupOption('_keepalive_failure', section_id),
i_opt = this.map.lookupOption('_keepalive_interval', section_id),
f = (f_opt != null) ? +f_opt[0].formvalue(section_id) : null,
i = (i_opt != null) ? +i_opt[0].formvalue(section_id) : null;
f = parseInt(f_opt?.[0]?.formvalue(section_id), 10),
i = parseInt(i_opt?.[0]?.formvalue(section_id), 10);

if (f === '' || isNaN(f))
f = null;

if (i == null || i == '' || isNaN(i) || i < 1)
if (isNaN(i))
i = 1;

if (isNaN(f))
f = (i == 1) ? null : 5;

if (f !== null)
uci.set('network', section_id, 'keepalive', '%d %d'.format(f, i));
else
Expand Down Expand Up @@ -114,7 +114,7 @@ return network.registerProtocol('ppp', {

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'));
o.placeholder = '1';
o.datatype = 'min(1)';
o.datatype = 'and(uinteger,min(1))';
o.write = write_keepalive;
o.remove = write_keepalive;
o.cfgvalue = function(section_id) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ network.registerPatternVirtual(/^pppoa-.+$/);
function write_keepalive(section_id, value) {
var f_opt = this.map.lookupOption('_keepalive_failure', section_id),
i_opt = this.map.lookupOption('_keepalive_interval', section_id),
f = (f_opt != null) ? +f_opt[0].formvalue(section_id) : null,
i = (i_opt != null) ? +i_opt[0].formvalue(section_id) : null;
f = parseInt(f_opt?.[0]?.formvalue(section_id), 10),
i = parseInt(i_opt?.[0]?.formvalue(section_id), 10);

if (f === '' || isNaN(f))
f = null;

if (i == null || i == '' || isNaN(i) || i < 1)
if (isNaN(i))
i = 1;

if (isNaN(f))
f = (i == 1) ? null : 5;

if (f !== null)
uci.set('network', section_id, 'keepalive', '%d %d'.format(f, i));
else
Expand Down Expand Up @@ -100,7 +100,7 @@ return network.registerProtocol('pppoa', {

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'));
o.placeholder = '1';
o.datatype = 'min(1)';
o.datatype = 'and(uinteger,min(1))';
o.write = write_keepalive;
o.remove = write_keepalive;
o.cfgvalue = function(section_id) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ network.registerPatternVirtual(/^pppoe-.+$/);
function write_keepalive(section_id, value) {
var f_opt = this.map.lookupOption('_keepalive_failure', section_id),
i_opt = this.map.lookupOption('_keepalive_interval', section_id),
f = (f_opt != null) ? +f_opt[0].formvalue(section_id) : null,
i = (i_opt != null) ? +i_opt[0].formvalue(section_id) : null;
f = parseInt(f_opt?.[0]?.formvalue(section_id), 10),
i = parseInt(i_opt?.[0]?.formvalue(section_id), 10);

if (f === '' || isNaN(f))
f = null;

if (i == null || i == '' || isNaN(i) || i < 1)
if (isNaN(i))
i = 1;

if (isNaN(f))
f = (i == 1) ? null : 5;

if (f !== null)
uci.set('network', section_id, 'keepalive', '%d %d'.format(f, i));
else
Expand Down Expand Up @@ -74,7 +74,7 @@ return network.registerProtocol('pppoe', {

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'));
o.placeholder = '1';
o.datatype = 'min(1)';
o.datatype = 'and(uinteger,min(1))';
o.write = write_keepalive;
o.remove = write_keepalive;
o.cfgvalue = function(section_id) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ network.registerPatternVirtual(/^pptp-.+$/);
function write_keepalive(section_id, value) {
var f_opt = this.map.lookupOption('_keepalive_failure', section_id),
i_opt = this.map.lookupOption('_keepalive_interval', section_id),
f = (f_opt != null) ? +f_opt[0].formvalue(section_id) : null,
i = (i_opt != null) ? +i_opt[0].formvalue(section_id) : null;
f = parseInt(f_opt?.[0]?.formvalue(section_id), 10),
i = parseInt(i_opt?.[0]?.formvalue(section_id), 10);

if (f === '' || isNaN(f))
f = null;

if (i == null || i == '' || isNaN(i) || i < 1)
if (isNaN(i))
i = 1;

if (isNaN(f))
f = (i == 1) ? null : 5;

if (f !== null)
uci.set('network', section_id, 'keepalive', '%d %d'.format(f, i));
else
Expand Down Expand Up @@ -87,7 +87,7 @@ return network.registerProtocol('pptp', {

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'));
o.placeholder = '1';
o.datatype = 'min(1)';
o.datatype = 'and(uinteger,min(1))';
o.write = write_keepalive;
o.remove = write_keepalive;
o.cfgvalue = function(section_id) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ network.registerPatternVirtual(/^pppossh-.+$/);
function write_keepalive(section_id, value) {
var f_opt = this.map.lookupOption('_keepalive_failure', section_id),
i_opt = this.map.lookupOption('_keepalive_interval', section_id),
f = (f_opt != null) ? +f_opt[0].formvalue(section_id) : null,
i = (i_opt != null) ? +i_opt[0].formvalue(section_id) : null;
f = parseInt(f_opt?.[0]?.formvalue(section_id), 10),
i = parseInt(i_opt?.[0]?.formvalue(section_id), 10);

if (f === '' || isNaN(f))
f = null;

if (i == null || i == '' || isNaN(i) || i < 1)
if (isNaN(i))
i = 1;

if (isNaN(f))
f = (i == 1) ? null : 5;

if (f !== null)
uci.set('network', section_id, 'keepalive', '%d %d'.format(f, i));
else
Expand Down Expand Up @@ -110,7 +110,7 @@ return network.registerProtocol('pppossh', {

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'));
o.placeholder = '1';
o.datatype = 'min(1)';
o.datatype = 'and(uinteger,min(1))';
o.write = write_keepalive;
o.remove = write_keepalive;
o.cfgvalue = function(section_id) {
Expand Down

0 comments on commit a88d4af

Please sign in to comment.