Security News
The Unpaid Backbone of Open Source: Solo Maintainers Face Increasing Security Demands
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
is-my-ip-valid
Advanced tools
The is-my-ip-valid npm package is a utility for validating IP addresses. It supports both IPv4 and IPv6 formats and provides simple methods to check if an IP address is valid.
Validate IPv4
This feature allows you to validate if a given string is a valid IPv4 address.
const isMyIpValid = require('is-my-ip-valid');
const ipv4 = '192.168.1.1';
const isValidIPv4 = isMyIpValid(ipv4);
console.log(`Is ${ipv4} a valid IPv4 address?`, isValidIPv4);
Validate IPv6
This feature allows you to validate if a given string is a valid IPv6 address.
const isMyIpValid = require('is-my-ip-valid');
const ipv6 = '2001:0db8:85a3:0000:0000:8a2e:0370:7334';
const isValidIPv6 = isMyIpValid(ipv6);
console.log(`Is ${ipv6} a valid IPv6 address?`, isValidIPv6);
Custom Validation
This feature allows you to create a custom validator for specific IP address formats, such as IPv4 with CIDR notation.
const isMyIpValid = require('is-my-ip-valid');
const customValidator = isMyIpValid({ version: 4, cidr: true });
const ip = '192.168.1.1/24';
const isValid = customValidator(ip);
console.log(`Is ${ip} a valid IPv4 CIDR address?`, isValid);
The 'ip' package provides utilities for IP address manipulation, including validation, conversion, and subnet calculations. It offers more comprehensive functionality compared to is-my-ip-valid, such as converting IP addresses to different formats and performing subnet calculations.
The 'ipaddr.js' package is a library for manipulating IPv4 and IPv6 addresses in JavaScript. It provides validation, parsing, and comparison functions. It is more feature-rich than is-my-ip-valid, offering detailed parsing and manipulation capabilities.
The 'netmask' package is used for IP address and network mask calculations. It allows for validation, subnet calculations, and IP range checks. It is more focused on network-related calculations compared to is-my-ip-valid.
A small lib to validate IP addresses.
npm install --save is-my-ip-valid
const validator = require('is-my-ip-valid')
const validate = validator()
const validate4 = validator({ version: 4 })
const validate6 = validator({ version: 6 })
console.log(validate('127.0.0.1'))
//=> true
console.log(validate4('127.0.0.1'))
//=> true
console.log(validate6('127.0.0.1'))
//=> false
console.log(validate('2001:0db8:85a3:0000:0000:8a2e:0370:7334'))
//=> true
console.log(validate4('2001:0db8:85a3:0000:0000:8a2e:0370:7334'))
//=> false
console.log(validate6('2001:0db8:85a3:0000:0000:8a2e:0370:7334'))
//=> true
The code is mostly based on this wonderful library: beaugunderson/ip-address
All regexes used are audited for catastrophic backtracking by this module: substack/safe-regex
FAQs
A small lib to validate IP addresses.
The npm package is-my-ip-valid receives a total of 405,397 weekly downloads. As such, is-my-ip-valid popularity was classified as popular.
We found that is-my-ip-valid demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Security News
License exceptions modify the terms of open source licenses, impacting how software can be used, modified, and distributed. Developers should be aware of the legal implications of these exceptions.
Security News
A developer is accusing Tencent of violating the GPL by modifying a Python utility and changing its license to BSD, highlighting the importance of copyleft compliance.