Class IpAllowlist

java.lang.Object
eu.cloudnetservice.node.impl.util.IpAllowlist

public final class IpAllowlist extends Object
An allowlist for IP addresses that is able to parse and process subnets and static IP addresses.
Since:
4.0
  • Field Details

  • Constructor Details

  • Method Details

    • parse

      @NonNull public static @NonNull IpAllowlist parse(@NonNull @NonNull Collection<String> allowlist)
      Parses an allowlist from the given collection of subnets or static ip addresses. All null entries are ignored, for invalid entries a warning log message is printed.
      Parameters:
      allowlist - the allowlist to parse.
      Returns:
      a new allowlist instance based on the parsed given allowlist.
      Throws:
      NullPointerException - if the given allowlist is null.
    • updateIfNecessary

      Updates this allowlist instance if the given allowlist is different from the original allowlist that was used to construct this instance. If the given allowlist is the same as the original allowlist, this instance is returned. Otherwise, a new instance is created for the given allowlist and returned instead.
      Parameters:
      allowList - the allowlist to check for changes and return a new instance for, if necessary.
      Returns:
      a new allowlist if the given allowlist is different from the original allowlist, otherwise this instance.
      Throws:
      NullPointerException - if the given allowlist is null.
    • allows

      public boolean allows(@NonNull @NonNull InetAddress address)
      Checks if the given address is allowed by an entry of this allowlist.
      Parameters:
      address - the address to check.
      Returns:
      true if the given address is allowed, false otherwise.
      Throws:
      NullPointerException - if the given address is null.