function isPrivateIP(ip) {
  if (net.isIPv6(ip)) {
    const prefix = ip.split(":")[0];

    return (
      (prefix.startsWith("fd") && prefix.length === 4) || prefix === "fe80"
    );
  }

  // IPv4
  const exploded = ip.split(".").map((s) => Number.parseInt(s));

  return (
    exploded[0] === 10 ||
    (exploded[0] === 172 && exploded[1] >= 16 && exploded[1] <= 31) ||
    (exploded[0] === 192 && exploded[1] === 168)
  );
}
Test an IP address and determine if it's in the public or private range.

@param  {String}  ip
@return {Boolean}