ts-lambda-api - v2.5.2
    Preparing search index...

    Class BlockList

    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.

    v15.0.0, v14.18.0

    Index

    Constructors

    Properties

    rules: readonly string[]

    The list of rules added to the blocklist.

    v15.0.0, v14.18.0

    Methods

    • Adds a rule to block the given IP address.

      Parameters

      • address: string

        An IPv4 or IPv6 address.

      • Optionaltype: IPVersion

        Either 'ipv4' or 'ipv6'.

      Returns void

      v15.0.0, v14.18.0

    • Adds a rule to block the given IP address.

      Parameters

      Returns void

      v15.0.0, v14.18.0

    • Adds a rule to block a range of IP addresses from start (inclusive) toend (inclusive).

      Parameters

      • start: string

        The starting IPv4 or IPv6 address in the range.

      • end: string

        The ending IPv4 or IPv6 address in the range.

      • Optionaltype: IPVersion

        Either 'ipv4' or 'ipv6'.

      Returns void

      v15.0.0, v14.18.0

    • Adds a rule to block a range of IP addresses from start (inclusive) toend (inclusive).

      Parameters

      • start: SocketAddress

        The starting IPv4 or IPv6 address in the range.

      • end: SocketAddress

        The ending IPv4 or IPv6 address in the range.

      Returns void

      v15.0.0, v14.18.0

    • Adds a rule to block a range of IP addresses specified as a subnet mask.

      Parameters

      • net: SocketAddress

        The network IPv4 or IPv6 address.

      • prefix: number

        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.

      Returns void

      v15.0.0, v14.18.0

    • Adds a rule to block a range of IP addresses specified as a subnet mask.

      Parameters

      • net: string

        The network IPv4 or IPv6 address.

      • prefix: number

        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.

      • Optionaltype: IPVersion

        Either 'ipv4' or 'ipv6'.

      Returns void

      v15.0.0, v14.18.0

    • 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

      Returns boolean

      v15.0.0, v14.18.0

    • 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: string

        The IP address to check

      • Optionaltype: IPVersion

        Either 'ipv4' or 'ipv6'.

      Returns boolean

      v15.0.0, v14.18.0

    • Returns true if the value is a net.BlockList.

      Parameters

      • value: unknown

        Any JS value

      Returns value is BlockList

      v22.13.0