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:
- All interfaces receive the same MAC address on Linux and macOS: In
api/computer/computer.cpp, the__updateMaclambda takes(const string &name, const string &mac)but ignores thenameargument completely. It iterates over the entireinterfacesmap and sets every interface's MAC to the MAC of the last interface evaluated in the list. - 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 fieldsaddressandfamilyare missing and replaced byipv4/ipv6. This causes cross-platform code accessingiface.addressoriface.familyto beundefinedon Windows.
Steps to Reproduce
- Run this in any Neutralinojs app:
const ifaces = await Neutralino.computer.getNetworkInterfaces();
console.log(JSON.stringify(ifaces, null, 2));- On Linux or macOS (with multiple interfaces like
eth0andwlan0, oren0andlo0): Observe that all interfaces in the object share the exact samemacaddress. - On Windows:
Observe that the returned objects lack
addressandfamilyproperties, returning{ ipv4: "..." }instead.
Expected Behavior
- Each interface should receive its own corresponding MAC address.
- The return schema should be consistent across all operating systems:
{
"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):
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:
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
- Update only the matching interface name in
__updateMac:
auto __updateMac = [&](const string &name, const string &mac) {
if(interfaces.contains(name)) {
for(auto &item: interfaces[name]) {
item["mac"] = mac;
}
}
};- Standardize the Windows output to match Linux and macOS:
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