温馨提示:本站仅提供公开网络链接索引服务,不存储、不篡改任何第三方内容,所有内容版权归原作者所有
AI智能索引来源:http://www.bun.com/reference/node/net/BlockList
点击访问原文链接

Node net.BlockList class | API Reference | Bun

Node net.BlockList class | API Reference | BunBuildDocsReferenceGuidesBlogDiscord/node:net/BlockListMaddAddressMaddRangeMaddSubnetMcheckCoconstructorMfromJSONMisBlockListPrulesMtoJSON

Search the reference...

/

BuildDocsReferenceGuidesBlogDiscord/node:net/BlockListMaddAddressMaddRangeMaddSubnetMcheckCoconstructorMfromJSONMisBlockListPrulesMtoJSON

class

net.BlockListclass BlockListThe BlockList object can be used with some network APIs to specify rules for disabling inbound or outbound access to specific IP addresses, IP ranges, or IP subnets.

rules: readonly string[]The list of rules added to the blocklist.

addAddress(address: string,type?: IPVersion): void;Adds a rule to block the given IP address.

@param addressAn IPv4 or IPv6 address.

@param typeEither 'ipv4' or 'ipv6'.

addAddress(address: SocketAddress): void;Adds a rule to block the given IP address.

@param addressAn IPv4 or IPv6 address.

addRange(start: string,end: string,type?: IPVersion): void;Adds a rule to block a range of IP addresses from start (inclusive) toend (inclusive).

@param startThe starting IPv4 or IPv6 address in the range.

@param endThe ending IPv4 or IPv6 address in the range.

@param typeEither 'ipv4' or 'ipv6'.

addRange(start: SocketAddress,end: SocketAddress): void;Adds a rule to block a range of IP addresses from start (inclusive) toend (inclusive).

@param startThe starting IPv4 or IPv6 address in the range.

@param endThe ending IPv4 or IPv6 address in the range.

addSubnet(net: SocketAddress,prefix: number): void;Adds a rule to block a range of IP addresses specified as a subnet mask.

@param netThe network IPv4 or IPv6 address.

@param prefixThe number of CIDR prefix bits. For IPv4, this must be a value between 0 and 32. For IPv6, this must be between 0 and 128.

addSubnet(net: string,prefix: number,type?: IPVersion): void;Adds a rule to block a range of IP addresses specified as a subnet mask.

@param netThe network IPv4 or IPv6 address.

@param prefixThe number of CIDR prefix bits. For IPv4, this must be a value between 0 and 32. For IPv6, this must be between 0 and 128.

@param typeEither 'ipv4' or 'ipv6'.

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 @param addressThe IP address to check

check(address: string,type?: IPVersion): 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 @param addressThe IP address to check

@param typeEither 'ipv4' or 'ipv6'.

fromJSON(data: string | readonly string[]): void;const blockList = new net.BlockList(); const data = [ 'Subnet: IPv4 192.168.1.0/24', 'Address: IPv4 10.0.0.5', 'Range: IPv4 192.168.2.1-192.168.2.10', 'Range: IPv4 10.0.0.1-10.0.0.10', ]; blockList.fromJSON(data); blockList.fromJSON(JSON.stringify(data)); toJSON(): readonly string[];static isBlockList(value: unknown): value is BlockList;Returns true if the value is a net.BlockList.

@param valueAny JS value

Resources

ReferenceDocsGuidesDiscordMerch StoreGitHubBlog 

Toolkit

RuntimePackage managerTest runnerBundlerPackage runner

Project

Bun 1.0Bun 1.1Bun 1.2Bun 1.3RoadmapContributingLicenseBaked with ❤️ in San Francisco

We're hiring →

智能索引记录