How to use the range_check.validIp function in range_check

To help you get started, we’ve selected a few range_check examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github colearnr / colearnr / lib / pass.js View on Github external
function ensureInternalAccess (req, res, next) {
  let ip = req.ip || req.connection.remoteAddress || req.socket.remoteAddress || req.connection.socket.remoteAddress
  ip = ip.replace('::ffff:', '')
  let serverIp = ipLib.address('public', 'ipv4')
  if (ip === serverIp || (rangeCheck.validIp(ip) && rangeCheck.inRange(ip, config.internal_ip))) {
    next()
  } else {
    logger.warn(ip, 'is not an internal ip. Access denied')
    res.end()
  }
}

range_check

This is a simple module to validate IP address, check ip address version, check if ip is within a range.

BSD-2-Clause
Latest version published 5 months ago

Package Health Score

64 / 100
Full package analysis