BlockList
[<Interface>]
type BlockList =
abstract member rules: string array with get, set
abstract member addAddress (address: SocketAddress) : unit
abstract member addAddress (address: string, ?type: IPVersion) : unit
abstract member addRange (start: SocketAddress, end: SocketAddress) : unit
abstract member addRange (start: string, end: string, ?type: IPVersion) : unit
abstract member addSubnet (net: string, prefix: float, ?type: IPVersion) : unit
abstract member addSubnet (net: SocketAddress, prefix: float) : unit
abstract member check (address: string, ?type: IPVersion) : bool
abstract member check (address: SocketAddress) : bool
abstract member fromJSON (data: U2<string,string array>) : unit
static member isBlockList (value: obj) : bool
abstract member toJSON () : string array| Assembly | Xantham.Fable.Node |
| Attributes | [<Interface>] |
The 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.
@since v15.0.0, v14.18.0
Properties
abstract member rules: string array with get, set
abstract member rules: string array with get, setThe list of rules added to the blocklist.
@since v15.0.0, v14.18.0
Methods
abstract member addAddress (address: SocketAddress) : unit
abstract member addAddress (address: SocketAddress) : unitAdds a rule to block the given IP address.
@since v15.0.0, v14.18.0
| Parameter | |
|---|---|
address | An IPv4 or IPv6 address. |
type | Either 'ipv4' or 'ipv6'. |
abstract member addAddress (address: string, ?type: IPVersion) : unit
abstract member addAddress (address: string, ?type: IPVersion) : unitAdds a rule to block the given IP address.
@since v15.0.0, v14.18.0
| Parameter | |
|---|---|
address | An IPv4 or IPv6 address. |
type | Either 'ipv4' or 'ipv6'. |
abstract member addRange (start: SocketAddress, end: SocketAddress) : unit
abstract member addRange (start: SocketAddress, end: SocketAddress) : unitAdds a rule to block a range of IP addresses from start (inclusive) toend (inclusive).
@since v15.0.0, v14.18.0
| Parameter | |
|---|---|
start | The starting IPv4 or IPv6 address in the range. |
end | The ending IPv4 or IPv6 address in the range. |
type | Either 'ipv4' or 'ipv6'. |
abstract member addRange (start: string, end: string, ?type: IPVersion) : unit
abstract member addRange (start: string, end: string, ?type: IPVersion) : unitAdds a rule to block a range of IP addresses from start (inclusive) toend (inclusive).
@since v15.0.0, v14.18.0
| Parameter | |
|---|---|
start | The starting IPv4 or IPv6 address in the range. |
end | The ending IPv4 or IPv6 address in the range. |
type | Either 'ipv4' or 'ipv6'. |
abstract member addSubnet (net: string, prefix: float, ?type: IPVersion) : unit
abstract member addSubnet (net: string, prefix: float, ?type: IPVersion) : unitAdds a rule to block a range of IP addresses specified as a subnet mask.
@since v15.0.0, v14.18.0
| Parameter | |
|---|---|
net | The network IPv4 or IPv6 address. |
prefix | The 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. |
type | Either 'ipv4' or 'ipv6'. |
abstract member addSubnet (net: SocketAddress, prefix: float) : unit
abstract member addSubnet (net: SocketAddress, prefix: float) : unitAdds a rule to block a range of IP addresses specified as a subnet mask.
@since v15.0.0, v14.18.0
| Parameter | |
|---|---|
net | The network IPv4 or IPv6 address. |
prefix | The 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. |
type | Either 'ipv4' or 'ipv6'. |
abstract member check (address: string, ?type: IPVersion) : bool
abstract member check (address: string, ?type: IPVersion) : boolReturns 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
@since v15.0.0, v14.18.0
| Parameter | |
|---|---|
address | The IP address to check |
type | Either 'ipv4' or 'ipv6'. |
abstract member check (address: SocketAddress) : bool
abstract member check (address: SocketAddress) : boolReturns 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
@since v15.0.0, v14.18.0
| Parameter | |
|---|---|
address | The IP address to check |
type | Either 'ipv4' or 'ipv6'. |
abstract member fromJSON (data: U2<string,string array>) : unit
abstract member fromJSON (data: U2<string,string array>) : unitconst 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));
@since v22.19.0
static member isBlockList (value: obj) : bool
static member isBlockList (value: obj) : boolReturns true if the value is a net.BlockList.
@since v22.13.0
| Parameter | |
|---|---|
value | Any JS value |