wangwenming / ip2long

ip2long and long2ip for Node.js
3 stars 3 forks source link

ipv6 支持 #2

Open haozi opened 2 years ago

haozi commented 2 years ago

大佬,看您好多年没更新了,bigint 出来了,用 bigint 支持下 ipv6 吧

Big Lao, your repo hasn't been updated for many years. bigint is comming. wish use bigint to support ipv6.

ArrayIterator commented 3 months ago

You can

大佬,看您好多年没更新了,bigint 出来了,用 bigint 支持下 ipv6 吧

Big Lao, your repo hasn't been updated for many years. bigint is comming. wish use bigint to support ipv6.

I was creating library that can help your case and maybe help you to validate & checking IP in here:

https://gist.github.com/ArrayIterator/092a07430b371f69f7e93b31773f3240

It contains:

const IPv4_REGEX: RegExp;
const IPv6_REGEX: RegExp;
const IPv4_BROADCAST_RANGE: "255.255.255.255/32";
const IPv6_RESERVED_RANGES: string[];
const IPv4_BOGON_RANGES: string[];
function is_bogon_ip(ip: any): boolean;
function is_broadcast_ip(ip: string): boolean;
function filter_ipv4(ip: string): string | false;
function filter_ipv6(ip: string): any | boolean;
function ip_version(ip: string): 4 | 6 | null;
function ip2long(ip: string): number | BigInt | boolean;
function long2ip(long: number): string | boolean;
function ip_in_range(ip: string, ip_ranges: string | Array<string>): boolean;