All Projects → tinovyatkin → is-localhost-ip

tinovyatkin / is-localhost-ip

Licence: MIT license
Checks whether given host/DNS name or IPv4/IPv6 address belongs to the local machine

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to is-localhost-ip

go-external-ip
a Golang library to get your external ip from multiple services
Stars: ✭ 55 (+189.47%)
Mutual labels:  ipv6, ipv4
vertx-ddns
基于 Vert.x 的 DDNS 解决方案。自动更新域名解析到本机IP, 支持的DNS服务商: Alidns(阿里云) 、 Dnspod(腾讯云) 、Cloudflare、华为云
Stars: ✭ 126 (+563.16%)
Mutual labels:  ipv6, ipv4
netcalc
Advanced network calculator and address planning helper
Stars: ✭ 20 (+5.26%)
Mutual labels:  ipv6, ipv4
Netpwn
Tool made to automate tasks of pentesting.
Stars: ✭ 152 (+700%)
Mutual labels:  ipv6, ipv4
fakeroute
IPv4 and IPv6 traceroute fake hop generator through IP spoofing
Stars: ✭ 75 (+294.74%)
Mutual labels:  ipv6, ipv4
Php Ip Tools
Useful tools for IP manipulations
Stars: ✭ 152 (+700%)
Mutual labels:  ipv6, ipv4
Netlink
Socket and Networking Library using msgpack.org[C++11]
Stars: ✭ 197 (+936.84%)
Mutual labels:  ipv6, ipv4
Exabgp
The BGP swiss army knife of networking
Stars: ✭ 1,713 (+8915.79%)
Mutual labels:  ipv6, ipv4
Iptools
PHP Library for manipulating network addresses (IPv4 and IPv6)
Stars: ✭ 163 (+757.89%)
Mutual labels:  ipv6, ipv4
Ddns
🚩 自动更新域名解析到本机IP(支持dnspod,阿里DNS,CloudFlare,华为云,DNSCOM...)
Stars: ✭ 2,582 (+13489.47%)
Mutual labels:  ipv6, ipv4
Nftlb
nftables load balancer
Stars: ✭ 147 (+673.68%)
Mutual labels:  ipv6, ipv4
private-ip
Check if IP address is private.
Stars: ✭ 26 (+36.84%)
Mutual labels:  ipv6, ipv4
Pytricia
A library for fast IP address lookup in Python.
Stars: ✭ 140 (+636.84%)
Mutual labels:  ipv6, ipv4
ip-finder-cli
The official command line client for IPFinder
Stars: ✭ 11 (-42.11%)
Mutual labels:  ipv6, ipv4
Aliddns
aliyun ddns for golang【阿里云DDNS服务,用来将自己的动态IP同步到自己的域名解析服务器,安装方便,配置简单,默认支持Linux和MacOS以后台服务方式持续运行】
Stars: ✭ 136 (+615.79%)
Mutual labels:  ipv6, ipv4
Ipaddress
Java library for handling IP addresses and subnets, both IPv4 and IPv6
Stars: ✭ 197 (+936.84%)
Mutual labels:  ipv6, ipv4
Cidrchk
CLI tool for CIDR range operations (check, generate)
Stars: ✭ 103 (+442.11%)
Mutual labels:  ipv6, ipv4
Ip Num
A TypeScript/JavaScript library for working with ASN, IPv4, and IPv6 numbers. It provides representations of these internet protocol numbers with the ability to perform various IP related operations like parsing, validating etc. on them
Stars: ✭ 113 (+494.74%)
Mutual labels:  ipv6, ipv4
Firewall
ASP.NET Core middleware for IP address filtering.
Stars: ✭ 159 (+736.84%)
Mutual labels:  ipv6, ipv4
Jool
SIIT and NAT64 for Linux
Stars: ✭ 172 (+805.26%)
Mutual labels:  ipv6, ipv4

codecov node

is-localhost-ip

Comprehensive and robust library to checks whether given host name or IPv4/IPv6 address belongs to the local machine

Main difference from other libraries here is comprehensiveness: we start from strict RegExp checks (for IP address first, and then for correctness to be a host name), then fallback to DNS resolver (so it works with something like john.dev remapped locally in hosts or with local resolver).

All this in just ~100 lines of code without external dependencies.

Installation

npm i is-localhost-ip
# or
yarn add is-localhost-ip

Example

const isLocalhost = require('is-localhost-ip');

(async () => {
  await isLocalhost('127.0.0.1'); // true
  await isLocalhost('::ffff:127.0.0.1'); // true
  await isLocalhost('192.168.0.12'); // true
  await isLocalhost('192.168.0.12', true); // true only if the local machine has an interface with that address
  await isLocalhost('184.55.123.2'); // false

  await isLocalhost('tino.local'); // true
  await isLocalhost('localhost'); // true
  await isLocalhost('microsoft.com'); // false
})();

Caveats

Doesn't work with internationalized (RFC 3492 or RFC 5891) domain names. If you need that please use wonderful Punycode.js to convert the string before passing to this library:

const isLocalhost = require('is-localhost-ip');
const punycode = require('punycode');

(async () => {
  await isLocalhost(punycode.toASCII('свобода.рф')); // false
  await isLocalhost(punycode.toASCII('私の.家')); // true
})();

License

is-localhost-ip is available under the MIT license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].