Skip to main content
BlockList.prototype.check - net - Node documentation
method BlockList.prototype.check

Usage in Deno

import { BlockList } from "node:net";
BlockList.prototype.check(address: SocketAddress): boolean

Returns true if the given IP address matches any of the rules added to theBlockList.

const blockList = new net.BlockList();
blockList.addAddress('123.123.123.123');
blockList.addRange('10.0.0.1', '10.0.0.10');
blockList.addSubnet('8592:757c:efae:4e45::', 64, 'ipv6');

console.log(blockList.check('123.123.123.123'));  // Prints: true
console.log(blockList.check('10.0.0.3'));  // Prints: true
console.log(blockList.check('222.111.111.222'));  // Prints: false

// IPv6 notation for IPv4 addresses works:
console.log(blockList.check('::ffff:7b7b:7b7b', 'ipv6')); // Prints: true
console.log(blockList.check('::ffff:123.123.123.123', 'ipv6')); // Prints: true

Parameters

address: SocketAddress

The IP address to check

Return Type

boolean
BlockList.prototype.check(
address: string,
type?: IPVersion,
): boolean

Parameters

address: string
optional
type: IPVersion

Return Type

boolean