Closed sjorge closed 2 years ago
diff --git a/src/NetworkManager.ts b/src/NetworkManager.ts
index abe9812..a7083c3 100644
--- a/src/NetworkManager.ts
+++ b/src/NetworkManager.ts
@@ -754,11 +754,12 @@ export class NetworkManager extends EventEmitter {
return;
}
+ const interfaceArrayOffset = os.platform() === "sunos" ? 0 : 2;
const lines = stdout.split(os.EOL);
const names: InterfaceName[] = [];
for (let i = 1; i < lines.length - 1; i++) {
- const interfaceName = lines[i].trim().split(NetworkManager.SPACE_PATTERN)[2];
+ const interfaceName = lines[i].trim().split(NetworkManager.SPACE_PATTERN)[interfaceArrayOffset];
if (!interfaceName) {
debug(`${os.platform()}: Failed to read interface name from line ${i}: '${lines[i]}'`);
continue;
I think this should do the trick, but I can't get tests or tsc to work at all
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This is still an issue, a PR has also been opened
PR got merge into beta-1.1.5 branch, closing the issue.
Analysis
Took me a bit to track down but I noticed ciao wasn't working on illumos, but there was some SunOS handling and given illumos forked from SunOS a few years ago generally we're still rather compatible.
I spend a few hours hunting it down and it fumbles here: https://github.com/homebridge/ciao/blob/3ce9b350117206ee80234d6dbed9bc54003deff1/src/NetworkManager.ts#L761
The offset for illumos (and I verified via a friend who has access to an Oracle Solaris 11 box) is wrong, it should be
0
. If I monkey patch the offset from 2 -> 0 in the node_modules generate .js file it works as expected.Expected Behavior
CIAO should find and use the correct interface(s) instead of just lo0.
Steps To Reproduce
In my case I am using node-red-contrib-homekit-bridged with the advertiser set to CIAO, adding any Service and hitting deploy will trigger it.
Logs
Snippet from the node-red output with DEBUG=ciao:*, you can see it only ever selecting lo0 which is pretty useless.
Configuration
Environment
Process Supervisor
not applicable
Additional Context
arp -a -n
output from an illumos based distro:Output from on an Oracle Solaris system:
Output for as far as I could tell has not deviated between Oracle Solaris and illumos (both return a uname of SunOS) so that's good knows as fixing one will also fix the other.
I was able to verify this my monkey-patching the offset from
2
to0
and everything is working (include control of all my devices via home.app)The debug output now also states that the correct amethyst0 interface is used.
I guess a properly fix this
getOpenBSD_SUNOS_NetworkInterfaces()
would need to be split into a OpenBSd and SunOS variant, or the offset should somehow be toggled between2
and0
depending on which one we are. But my typescript knowledge was not sufficient to actually do this and get it to compile :(