function getIP({ family = "IPv4", interface: netInterface, ip } = {}) {
  const mustBePrivate = ip === "private";

  let interfaces = [];

  for (const [key, value] of Object.entries(os.networkInterfaces())) {
    for (const _interface of value) {
      interfaces.push({
        interface: key,
        ..._interface,
      });
    }
  }

  debug("Found interfaces %o", interfaces);

  interfaces = interfaces.filter((n) => {
    return (
      !n.internal &&
      !isInternalIP(n.address) &&
      n.family === family &&
      (!ip || mustBePrivate === isPrivateIP(n.address))
    );
  });

  debug("Filtered interfaces %o", interfaces);

  if (interfaces.length === 0) {
    return null;
  }

  // take the first IP from the list if no interface has been defined
  if (!netInterface) {
    return interfaces[0].address;
  }

  for (const i of interfaces) {
    if ([i.interface, i.address, i.mac].includes(netInterface)) {
      return i.address;
    }
  }

  return null;
}
Return the first IP address matching the provided configuration
@param  {Object} [options]
@param  {String} [options.family] IP family (IPv4 or IPv6)
@param  {String} [options.interface] Network interface/IP/MAC to use
@param  {String} [options.ip] Used to target public or private addresses
@return {String|null}