Socket
Socket
Sign inDemoInstall

futoin-ipset

Package Overview
Dependencies
4
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.2.0 to 1.3.0

4

CHANGELOG.txt
=== 1.3.0 (2018-03-04) ===
CHANGED: redesigned of IPv4-mapped IPv6 support
- only IPv4 ipset is used
=== 1.2.0 (2018-03-02) ===

@@ -3,0 +7,0 @@ NEW: support for IPv4-mapped IPv6 addresses

56

IPSet.js

@@ -43,11 +43,8 @@ 'use strict';

add( addr, value ) {
try {
const v4_addr = this._v4.add( addr, value );
this._v6.add( this._4to6( v4_addr ), value );
} catch ( _ ) {
const v6_addr = this._v6.add( addr, value );
const addr_obj = this.convertAddress( addr, true );
if ( v6_addr.v4 ) {
this._v4.add( this._6to4( v6_addr ), value );
}
if ( addr_obj.v4 ) {
this._v4.add( addr_obj, value );
} else {
this._v6.add( addr_obj, value );
}

@@ -61,11 +58,8 @@ }

remove( addr ) {
try {
const v4_addr = this._v4.remove( addr );
this._v6.remove( this._4to6( v4_addr ) );
} catch ( _ ) {
const v6_addr = this._v6.remove( addr );
const addr_obj = this.convertAddress( addr, true );
if ( v6_addr.v4 ) {
this._v4.remove( this._6to4( v6_addr ) );
}
if ( addr_obj.v4 ) {
this._v4.remove( addr_obj );
} else {
this._v6.remove( addr_obj );
}

@@ -80,6 +74,8 @@ }

match( addr ) {
try {
return this._v4.match( addr );
} catch ( _ ) {
return this._v6.match( addr );
const addr_obj = this.convertAddress( addr, true );
if ( addr_obj.v4 ) {
return this._v4.match( addr_obj );
} else {
return this._v6.match( addr_obj );
}

@@ -91,9 +87,25 @@ }

* @param {string|object} addr - instance implementing *ip-address* interface or string representation
* @param {boolean} ipv6to4 - control if IPv4-in-IPv6 should be converted to plain IPv4
* @return {object} instance of address implementation
*/
convertAddress( addr ) {
convertAddress( addr, ipv6to4=false ) {
try {
return this._v4.convertAddress( addr );
} catch ( _ ) {
return this._v6.convertAddress( addr );
const res = this._v6.convertAddress( addr );
const groups = res.parsedAddress;
if ( ipv6to4 &&
( res.subnetMask >= IPV4INV6_PREFIX ) &&
!parseInt( groups[0], 16 ) &&
!parseInt( groups[1], 16 ) &&
!parseInt( groups[2], 16 ) &&
!parseInt( groups[3], 16 ) &&
!parseInt( groups[4], 16 ) &&
( parseInt( groups[5], 16 ) === 0xFFFF )
) {
return this._v4.convertAddress( this._6to4( res ) );
}
return res;
}

@@ -100,0 +112,0 @@ }

{
"name": "futoin-ipset",
"version": "1.2.0",
"version": "1.3.0",
"description": "Pure JS large IP set matching",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -24,2 +24,3 @@

* Associate any value for classification of match
* Transparent IPv4-mapped IPv6 conversion to plain IPv4

@@ -142,3 +143,3 @@

* [.match(addr)](#IPSet+match) ⇒ <code>any</code>
* [.convertAddress(addr)](#IPSet+convertAddress) ⇒ <code>object</code>
* [.convertAddress(addr, ipv6to4)](#IPSet+convertAddress) ⇒ <code>object</code>

@@ -182,3 +183,3 @@ <a name="IPSet+add"></a>

### ipSet.convertAddress(addr) ⇒ <code>object</code>
### ipSet.convertAddress(addr, ipv6to4) ⇒ <code>object</code>
Convert raw string or object to implementation instance

@@ -189,5 +190,6 @@

| Param | Type | Description |
| --- | --- | --- |
| addr | <code>string</code> \| <code>object</code> | instance implementing *ip-address* interface or string representation |
| Param | Type | Default | Description |
| --- | --- | --- | --- |
| addr | <code>string</code> \| <code>object</code> | | instance implementing *ip-address* interface or string representation |
| ipv6to4 | <code>boolean</code> | <code>false</code> | control if IPv4-in-IPv6 should be converted to plain IPv4 |

@@ -194,0 +196,0 @@ <a name="IPSet4"></a>

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc