jetersen/express-ipfilter

IPv4/IPv6 Namespace ::ffff:

rx2347 opened this issue · 1 comments

For those who come accross this: express returns IP4 addresses with ::ffff: prefixes, so '127.0.0.1' from the examples won't match anything, while '::ffff:127.0.0.1' does.

Maybe add this as a customDetection example?

const customDetection = (req) => {
  let ip = req.headers["x-forwarded-for"] || req.connection.remoteAddress;
  ip = ip.replace("::ffff:", "");

  return ip;
};

More information:
https://stackoverflow.com/questions/29411551/express-js-req-ip-is-returning-ffff127-0-0-1

Feel free to update the readme in a pull request!