whitequark / ipaddr.js

IP address manipulation library in JavaScript
MIT License
570 stars 92 forks source link

Ipv4 match range error #139

Closed sunsjgit closed 4 years ago

sunsjgit commented 4 years ago

node version : 10.16.3 ipaddr.js version: 1.9.1

      const range = ipaddr.IPv4.parseCIDR('192.168.1.0/24');
      const ip = ipaddr.IPv4.parse('192.168.1.20');

      console(ip.match(range, 32));

error

  TypeError: other.kind is not a function
      at IPv4.ipaddr.IPv4.IPv4.match (D:\GMYM\nodejsworkspace\gm-data-agency\node_modules\ipaddr.js\lib\ipaddr.js:92:17)
sunsjgit commented 4 years ago

I solved the problem using the following methods

var range = ipaddr.parseCIDR('191.168.1.0/24');
var ip = ipaddr.process('192.168.1.168');
var result = ip.match(range);