net.i2p.router.util

## Class MaskedIPSet

- java.lang.Object
- - java.util.AbstractCollection<E>
  - - java.util.AbstractSet<E>
    - - java.util.HashSet<String>
      - - net.i2p.router.util.MaskedIPSet

- All Implemented Interfaces:
    Serializable, Cloneable, Iterable<String>, Collection<String>, Set<String>

      public class MaskedIPSet
      extends HashSet<String>

  IP address masking utility for router family and network detection.

  Provides IP address masking functionality to detect routers with matching IP addresses or belonging to the same network family. Used for network topology analysis and peer relationship identification in distributed hash table operations.

  Supports configurable masking levels (1-4 bytes) and includes both communication system records and network database addresses for comprehensive matching. Optimized for efficiency with local lookup operations to avoid deadlocks.

  As of 0.9.24, returned set includes netdb family as well as IP-based matches for broader detection capabilities.

  See Also:
    Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `MaskedIPSet()`
    `MaskedIPSet(int initialCapacity)`
    `MaskedIPSet(RouterContext ctx, Hash peer, int mask)` The Set of IPs for this peer, with a given mask.
    `MaskedIPSet(RouterContext ctx, Hash peer, RouterInfo pinfo, int mask)` The Set of IPs for this peer, with a given mask.
    `MaskedIPSet(RouterContext ctx, RouterInfo pinfo, int mask)` The Set of IPs for this peer, with a given mask.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `containsAny(Set<String> b)` does this contain any of the elements in b?

    - ### Methods inherited from class java.util.HashSet

      `add, clear, clone, contains, isEmpty, iterator, remove, size, spliterator`

    - ### Methods inherited from class java.util.AbstractSet

      `equals, hashCode, removeAll`

    - ### Methods inherited from class java.util.AbstractCollection

      `addAll, containsAll, retainAll, toArray, toArray, toString`

    - ### Methods inherited from class java.lang.Object

      `finalize, getClass, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface java.util.Set

      `addAll, containsAll, equals, hashCode, removeAll, retainAll, toArray, toArray`

    - ### Methods inherited from interface java.util.Collection

      `parallelStream, removeIf, stream`

    - ### Methods inherited from interface java.lang.Iterable

      `forEach`

- - ### Constructor Detail

    - #### MaskedIPSet

          public MaskedIPSet()

    - #### MaskedIPSet

          public MaskedIPSet(int initialCapacity)

    - #### MaskedIPSet

          public MaskedIPSet(RouterContext ctx,
                             Hash peer,
                             int mask)

      The Set of IPs for this peer, with a given mask. Includes the comm system's record of the IP, and all netDb addresses. As of 0.9.24, returned set will include netdb family as well. This gets the peer from the netdb without validation, for efficiency and to avoid deadlocks. Peers are presumed to be validated elsewhere.
      Parameters:
        `peer` - non-null
        `mask` - is 1-4 (number of bytes to match)

    - #### MaskedIPSet

          public MaskedIPSet(RouterContext ctx,
                             Hash peer,
                             RouterInfo pinfo,
                             int mask)

      The Set of IPs for this peer, with a given mask. Includes the comm system's record of the IP, and all netDb addresses. As of 0.9.24, returned set will include netdb family as well.
      Parameters:
        `pinfo` - may be null
        `mask` - is 1-4 (number of bytes to match)

    - #### MaskedIPSet

          public MaskedIPSet(RouterContext ctx,
                             RouterInfo pinfo,
                             int mask)

      The Set of IPs for this peer, with a given mask. Includes the comm system's record of the IP, and all netDb addresses. As of 0.9.24, returned set will include netdb family as well.
      Parameters:
        `pinfo` - may be null
        `mask` - is 1-4 (number of bytes to match)

  - ### Method Detail

    - #### containsAny

          public boolean containsAny(Set<String> b)

      does this contain any of the elements in b?