Skip to content

Commit

Permalink
fix: ipAddressHelper uncatched error when running on raspberry pi, ha…
Browse files Browse the repository at this point in the history
…ving interfaces without any ip. (#44)
  • Loading branch information
Supergiovane authored Dec 30, 2024
1 parent bdfda25 commit a9e46ee
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 24 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"name": "knxultimate",
"description": "KNX IP protocol implementation for Node. This is the ENGINE of Node-Red KNX-Ultimate node.",
"version": "4.1.0-beta.4",
"version": "4.1.0-beta.6",
"main": "./build/index.js",
"engines": {
"node": ">=16"
},
"private": false,
"repository": {
"type": "git",
"url": "https://github.com/Supergiovane/KNXUltimate"
"url": "git+https://github.com/Supergiovane/KNXUltimate.git"
},
"scripts": {
"build": "npm run clean && tsc -p tsconfig.build.json",
Expand Down Expand Up @@ -103,4 +103,4 @@
"sinon": "^19.0.2",
"typescript": "^5.4.5"
}
}
}
46 changes: 25 additions & 21 deletions src/util/ipAddressHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,29 +24,34 @@ export function getIPv4Interfaces(): { [key: string]: NetworkInterfaceInfo } {
],
}
}

for (const iface in interfaces) {
for (const intf of interfaces[iface]) {
for (let index = 0; index < interfaces[iface].length; index++) {
let intf
try {
logger.debug('parsing interface: %s (%j)', iface, intf)
if (
intf.family !== undefined &&
(intf.family.toString().includes('4') ||
(intf as any).family === 4) &&
!intf.internal
) {
logger.debug(
'Found suitable interface: %s (%j)',
iface,
intf,
)
candidateInterfaces[iface] = intf
intf = interfaces[iface][index]
if (intf === undefined) {
logger.debug('intf is null: control point 1')
} else {
logger.debug(
'Found NOT suitable interface: %s (%j)',
iface,
intf,
)
logger.debug('parsing interface: %s (%j)', iface, intf)
if (
intf.family !== undefined &&
(intf.family.toString().includes('4') ||
intf.family === 4) &&
!intf.internal
) {
logger.debug(
'Found suitable interface: %s (%j)',
iface,
intf,
)
candidateInterfaces[iface] = intf
} else {
logger.debug(
'Found NOT suitable interface: %s (%j)',
iface,
intf,
)
}
}
} catch (error) {
logger.error(
Expand All @@ -57,7 +62,6 @@ export function getIPv4Interfaces(): { [key: string]: NetworkInterfaceInfo } {
}
}
}

return candidateInterfaces
}

Expand Down

0 comments on commit a9e46ee

Please sign in to comment.