Bug: Neutralino.computer.getNetworkInterfaces() returns mismatched schemas across platforms and overwrites all MAC addresses on Linux/macOS

Author: anushkagupta200615-jpgCreated Sep 16, 2026Updated Sep 16, 2026
Labelsbug

Description

Neutralino.computer.getNetworkInterfaces() has two bugs causing data corruption and cross-platform incompatibility:

  1. All interfaces receive the same MAC address on Linux and macOS: In api/computer/computer.cpp, the __updateMac lambda takes (const string &name, const string &mac) but ignores the name argument completely. It iterates over the entire interfaces map and sets every interface's MAC to the MAC of the last interface evaluated in the list.
  2. Inconsistent schema on Windows vs Linux/macOS: According to the official documentation, each entry should contain { address, family, isInternal, mac }. On Linux/macOS this is respected, but on Windows the fields address and family are missing and replaced by ipv4 / ipv6. This causes cross-platform code accessing iface.address or iface.family to be undefined on Windows.

Steps to Reproduce

  1. Run this in any Neutralinojs app:
javascript
const ifaces = await Neutralino.computer.getNetworkInterfaces();
console.log(JSON.stringify(ifaces, null, 2));
  1. On Linux or macOS (with multiple interfaces like eth0 and wlan0, or en0 and lo0): Observe that all interfaces in the object share the exact same mac address.
  2. On Windows: Observe that the returned objects lack address and family properties, returning { ipv4: "..." } instead.

Expected Behavior

  • Each interface should receive its own corresponding MAC address.
  • The return schema should be consistent across all operating systems:
json
{
  "address": "192.168.1.5",
  "family": "ipv4",
  "isInternal": false,
  "mac": "xx:xx:xx:xx:xx:xx"
}

Actual Behavior

  • In api/computer/computer.cpp (lines 703–709):
cpp
auto __updateMac = [&](const string &name, const string &mac) {
    for(const auto &[key, arr]: interfaces.items()) {
        for(auto &item: arr) {
            item["mac"] = mac;
        }
    }
};

The name parameter is unused, and all interfaces are overwritten with the MAC of the last interface.

  • In api/computer/computer.cpp (lines 775–780) on Windows:
cpp
if(sa->sa_family == AF_INET) {
    interfaceInfo["ipv4"] = string(ip);
}
else if(sa->sa_family == AF_INET6) {
    interfaceInfo["ipv6"] = string(ip);
}

Properties are named ipv4/ipv6 instead of address and family.


Proposed Fix

  1. Update only the matching interface name in __updateMac:
cpp
auto __updateMac = [&](const string &name, const string &mac) {
    if(interfaces.contains(name)) {
        for(auto &item: interfaces[name]) {
            item["mac"] = mac;
        }
    }
};
  1. Standardize the Windows output to match Linux and macOS:
cpp
if(sa->sa_family == AF_INET) {
    interfaceInfo["address"] = string(ip);
    interfaceInfo["family"] = "ipv4";
}
else if(sa->sa_family == AF_INET6) {
    interfaceInfo["address"] = string(ip);
    interfaceInfo["family"] = "ipv6";
}

Source: neutralinojs/neutralinojs