Skip to content

Commit

Permalink
Allow localhost as ip address, fix valid port function
Browse files Browse the repository at this point in the history
:Release Notes:
Allow localhost as ip address, fix valid port function

:Detailed Notes:
Allow localhost as ip address, update valid port funtion for ares-setup-device cli

:Testing Performed:
1. Checked CLI unit test on OSE(rpi4)
2. Checked CLI unit test on OSE Emulator
3. Checked eslint
4. Check ares-setup-device using below command
   - $ares-setup-device > add/modify emulator ip as localhost
    > success
   - $ares-shel -d emulator
    > success

:Issues Addressed:
[WRQ-15468] [CLI-common] allow localhost as ip address, fix valid port function
  • Loading branch information
QUANG VAN NGUYEN/LGEDV webOS TEAM(quang13.nguyen@lge.com) committed Mar 29, 2024
1 parent f4a0261 commit 7ec3417
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/base/setup-device.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,12 @@ const async = require('async'),
}

function isValidIpv4(host) {
return host.match(/^(\d|[1-9]\d|1\d\d|2([0-4]\d|5[0-5]))\.(\d|[1-9]\d|1\d\d|2([0-4]\d|5[0-5]))\.(\d|[1-9]\d|1\d\d|2([0-4]\d|5[0-5]))\.(\d|[1-9]\d|1\d\d|2([0-4]\d|5[0-5]))$/);
return host === "localhost" || host.match(/^(\d|[1-9]\d|1\d\d|2([0-4]\d|5[0-5]))\.(\d|[1-9]\d|1\d\d|2([0-4]\d|5[0-5]))\.(\d|[1-9]\d|1\d\d|2([0-4]\d|5[0-5]))\.(\d|[1-9]\d|1\d\d|2([0-4]\d|5[0-5]))$/);
}

function isValidPort(port) {
return String(port).match(/^[0-9]+$/);
const intPort = Number(port);
return Number.isInteger(intPort) && intPort > 0 && intPort <= 65535;
}

devicetools.showDeviceList = function(next) {
Expand Down

0 comments on commit 7ec3417

Please sign in to comment.