Class IPFilterImpl

java.lang.Object
com.biglybt.pifimpl.local.ipfilter.IPFilterImpl
All Implemented Interfaces:
IPFilter

public class IPFilterImpl extends Object implements IPFilter
  • Field Details

  • Constructor Details

    • IPFilterImpl

      public IPFilterImpl()
  • Method Details

    • getFile

      public File getFile()
      Description copied from interface: IPFilter
      Gets the file name used for persistent ranges
      Specified by:
      getFile in interface IPFilter
      Returns:
    • reload

      public void reload() throws IPFilterException
      Description copied from interface: IPFilter
      Reloads the ip filter from the config file (obtainable using "getFile")
      Specified by:
      reload in interface IPFilter
      Throws:
      IPFilterException
    • save

      public void save() throws IPFilterException
      Description copied from interface: IPFilter
      saves current setting to file given by getFile
      Specified by:
      save in interface IPFilter
      Throws:
      IPFilterException
    • getRanges

      public IPRange[] getRanges()
      Description copied from interface: IPFilter
      Gets the current set of defined IP ranges
      Specified by:
      getRanges in interface IPFilter
      Returns:
    • getNumberOfRanges

      public int getNumberOfRanges()
      Description copied from interface: IPFilter
      returns length of ranges list
      Specified by:
      getNumberOfRanges in interface IPFilter
      Returns:
    • getNumberOfBlockedIPs

      public int getNumberOfBlockedIPs()
      Description copied from interface: IPFilter
      returns length of blocked ip list
      Specified by:
      getNumberOfBlockedIPs in interface IPFilter
      Returns:
    • getNumberOfBannedIPs

      public int getNumberOfBannedIPs()
      Description copied from interface: IPFilter
      returns length of banned ip list
      Specified by:
      getNumberOfBannedIPs in interface IPFilter
      Returns:
    • isInRange

      public boolean isInRange(String IPAddress)
      Description copied from interface: IPFilter
      Checks an address to see if its in an allowed range
      Specified by:
      isInRange in interface IPFilter
      Parameters:
      IPAddress -
      Returns:
    • createRange

      public IPRange createRange(int address_type, boolean this_session_only)
      Description copied from interface: IPFilter
      creates a new range but *doesn't* add it to the list. Use the add method to add it
      Specified by:
      createRange in interface IPFilter
      Parameters:
      address_type - - 1= ipv4, 2=ipv6
      this_session_only - // not persisted if "this_session_only" is true
      Returns:
    • addRange

      public void addRange(IPRange range)
      Description copied from interface: IPFilter
      Adds a range. Only ranges created with "create" above can be added
      Specified by:
      addRange in interface IPFilter
      Parameters:
      range -
    • createAndAddRange

      public IPRange createAndAddRange(String description, String start_ip, String end_ip, boolean this_session_only)
      Description copied from interface: IPFilter
      Creates, validates and adds a range
      Specified by:
      createAndAddRange in interface IPFilter
      Parameters:
      description -
      start_ip -
      end_ip -
      this_session_only - not persisted if true
      Returns:
      new range or null if invalid
    • removeRange

      public void removeRange(IPRange range)
      Description copied from interface: IPFilter
      Remove a range
      Specified by:
      removeRange in interface IPFilter
      Parameters:
      range -
    • getBlockedIPs

      public IPBlocked[] getBlockedIPs()
      Description copied from interface: IPFilter
      Gets the current list of blocked addresses
      Specified by:
      getBlockedIPs in interface IPFilter
      Returns:
    • block

      public void block(String IPAddress)
      Description copied from interface: IPFilter
      Explicitly blocks an address
      Specified by:
      block in interface IPFilter
      Parameters:
      IPAddress -
    • getBannedIPs

      public IPBanned[] getBannedIPs()
      Description copied from interface: IPFilter
      Gets the current list of b addresses
      Specified by:
      getBannedIPs in interface IPFilter
      Returns:
    • ban

      public void ban(String IPAddress, String text)
      Description copied from interface: IPFilter
      Explicitly bans an address
      Specified by:
      ban in interface IPFilter
      Parameters:
      IPAddress -
    • unban

      public void unban(String IPAddress)
      Description copied from interface: IPFilter
      Removes a ban on an address
      Specified by:
      unban in interface IPFilter
      Parameters:
      IPAddress -
    • isEnabled

      public boolean isEnabled()
      Description copied from interface: IPFilter
      Test if ipfilter is enabled or not
      Specified by:
      isEnabled in interface IPFilter
      Returns:
    • setEnabled

      public void setEnabled(boolean enabled)
      Description copied from interface: IPFilter
      change the enabled status
      Specified by:
      setEnabled in interface IPFilter
      Parameters:
      enabled -
    • getInRangeAddressesAreAllowed

      public boolean getInRangeAddressesAreAllowed()
      Description copied from interface: IPFilter
      The filter either allows defined ranges to be allowed or denied access
      Specified by:
      getInRangeAddressesAreAllowed in interface IPFilter
      Returns:
    • setInRangeAddressesAreAllowed

      public void setInRangeAddressesAreAllowed(boolean b)
      Description copied from interface: IPFilter
      Set the behaviour of the filter to either allow or deny access for defined ranges
      Specified by:
      setInRangeAddressesAreAllowed in interface IPFilter
      Parameters:
      b -
    • getLastUpdateTime

      public long getLastUpdateTime()
      Description copied from interface: IPFilter
      Gets the last time the filter set was updated or marked as up to date
      Specified by:
      getLastUpdateTime in interface IPFilter
      Returns: