mirror of
https://github.com/openwrt/luci.git
synced 2025-12-21 21:24:35 +04:00
luci-mod-status: routes: prevent null error if the commands don't resolve
Closes #8026 Signed-off-by: Paul Donald <newtwen+github@gmail.com>
This commit is contained in:
@@ -39,12 +39,12 @@ return view.extend({
|
|||||||
load() {
|
load() {
|
||||||
return Promise.all([
|
return Promise.all([
|
||||||
callNetworkInterfaceDump(),
|
callNetworkInterfaceDump(),
|
||||||
L.resolveDefault(fs.exec('/sbin/ip', [ '-4', 'neigh', 'show' ]), {}),
|
L.resolveDefault(fs.exec('/sbin/ip', [ '-4', 'neigh', 'show' ]), { stdout: '' }),
|
||||||
L.resolveDefault(fs.exec('/sbin/ip', [ '-4', 'route', 'show', 'table', 'all' ]), {}),
|
L.resolveDefault(fs.exec('/sbin/ip', [ '-4', 'route', 'show', 'table', 'all' ]), { stdout: '' }),
|
||||||
L.resolveDefault(fs.exec('/sbin/ip', [ '-4', 'rule', 'show' ]), {}),
|
L.resolveDefault(fs.exec('/sbin/ip', [ '-4', 'rule', 'show' ]), { stdout: '' }),
|
||||||
L.resolveDefault(fs.exec('/sbin/ip', [ '-6', 'neigh', 'show' ]), {}),
|
L.resolveDefault(fs.exec('/sbin/ip', [ '-6', 'neigh', 'show' ]), { stdout: '' }),
|
||||||
L.resolveDefault(fs.exec('/sbin/ip', [ '-6', 'route', 'show', 'table', 'all' ]), {}),
|
L.resolveDefault(fs.exec('/sbin/ip', [ '-6', 'route', 'show', 'table', 'all' ]), { stdout: '' }),
|
||||||
L.resolveDefault(fs.exec('/sbin/ip', [ '-6', 'rule', 'show' ]), {}),
|
L.resolveDefault(fs.exec('/sbin/ip', [ '-6', 'rule', 'show' ]), { stdout: '' }),
|
||||||
L.hasSystemFeature('ufpd') ? callUfpList() : null
|
L.hasSystemFeature('ufpd') ? callUfpList() : null
|
||||||
]);
|
]);
|
||||||
},
|
},
|
||||||
@@ -81,6 +81,7 @@ return view.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
parseNeighbs(nbs, macs, networks, v6) {
|
parseNeighbs(nbs, macs, networks, v6) {
|
||||||
|
if (!nbs) return [];
|
||||||
const res = [];
|
const res = [];
|
||||||
|
|
||||||
for (const line of nbs.trim().split(/\n/)) {
|
for (const line of nbs.trim().split(/\n/)) {
|
||||||
@@ -115,6 +116,7 @@ return view.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
parseRoutes(routes, networks, v6) {
|
parseRoutes(routes, networks, v6) {
|
||||||
|
if (!routes) return [];
|
||||||
const res = [];
|
const res = [];
|
||||||
|
|
||||||
for (const line of routes.trim().split(/\n/)) {
|
for (const line of routes.trim().split(/\n/)) {
|
||||||
@@ -145,7 +147,7 @@ return view.extend({
|
|||||||
return res;
|
return res;
|
||||||
},
|
},
|
||||||
|
|
||||||
parseRules: rules => rules.trim().split('\n').map(l => {
|
parseRules: rules => rules?.trim()?.split('\n')?.map(l => {
|
||||||
const [, prio=null, rule=null] = l.match(/^(\d+):\s+(.+)$/) || [];
|
const [, prio=null, rule=null] = l.match(/^(\d+):\s+(.+)$/) || [];
|
||||||
return [prio, rule];
|
return [prio, rule];
|
||||||
}),
|
}),
|
||||||
|
|||||||
Reference in New Issue
Block a user