The project is in a healthy, maintained state
Simple gem to check if provided URL is mapped to local IP address
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
 Dependencies

Development

~> 13.0
~> 3.0
 Project Readme

Local IP Checker

Simple ruby gem that provides checking if given URL resolves to local IP address.

Abstract

If your system makes HTTP requests to 3rd-party provided URL it's required to check if this URL maps to some kind of local IP address. This gem performs checks against following types of local IP addresses:

  1. IPv4 and IPv6 localhost addresses.
  2. IPv4 0.0.0.0 and IPv6 :: addresses.
  3. IPv4 private address ranges (e. g. 10.0.0.0/8).
  4. IPv6 unique local addresses (fc00::/7).
  5. IPv6 site-local address (fec0::/10)
  6. IPv4 and IPv6 link-local addresses.

Usage

Example:

require "local_ip_checker"

LocalIPChecker.local?("google.com") # => false
LocalIPChecker.nonlocal?("google.com") => true
LocalIPChecker.local?("localhost") => true
LocalIPChecker.local?("::") # => true