java.lang.Object
net.i2p.router.web.FormHandler
net.i2p.router.web.helpers.ConfigBanHandler

public class ConfigBanHandlerextends FormHandler
Handler to deal with form submissions from the ban configuration form.
  • Field Details

    • _maxOffenses

      private String _maxOffenses
      Form value for the maximum offenses before a ban.
    • _offenseWindow

      private String _offenseWindow
      Form value for the offense window, in minutes.
    • _startupGrace

      private String _startupGrace
      Form value for the startup grace period, in minutes.
    • _badPacketDuration

      private String _badPacketDuration
      Form value for the bad packet ban duration, in minutes.
    • _enableBadPacketBan

      private boolean _enableBadPacketBan
      Form flag for the bad packet ban.
    • _enableCorruptConnectionBan

      private boolean _enableCorruptConnectionBan
      Form flag for the corrupt connection ban.
    • _enablePortHoppingBan

      private boolean _enablePortHoppingBan
      Form flag for the port hopping ban.
    • _enableBlocklist

      private boolean _enableBlocklist
      Form flag for the blocklist.
    • _enableTorBlocklist

      private boolean _enableTorBlocklist
      Form flag for the Tor blocklist.
    • _enableCountryBan

      private boolean _enableCountryBan
      Form flag for the country ban.
    • _enableXgBan

      private boolean _enableXgBan
      Form flag for the Xfer-Gosset ban.
    • _enableLuBan

      private boolean _enableLuBan
      Form flag for the LU ban.
    • _enableIntroducerBan

      private boolean _enableIntroducerBan
      Form flag for the introducer ban.
    • _enableInvalidVersionBan

      private boolean _enableInvalidVersionBan
      Form flag for the invalid version ban.
    • _enablePubDateBan

      private boolean _enablePubDateBan
      Form flag for the publish date ban.
    • _enableRUCapsBan

      private boolean _enableRUCapsBan
      Form flag for the restricted usage caps ban.
    • _enableBlockMyCountry

      private boolean _enableBlockMyCountry
      Form flag for blocking our own country.
    • _enableUnresponsiveFloodfillBan

      private boolean _enableUnresponsiveFloodfillBan
      Form flag for the unresponsive floodfill ban.
    • _enableNoVersionBan

      private boolean _enableNoVersionBan
      Form flag for the missing version ban.
    • _enableExcessiveTunnelRequestsBan

      private boolean _enableExcessiveTunnelRequestsBan
      Form flag for the excessive tunnel requests ban.
    • _banNextHop

      private boolean _banNextHop
      Form flag for banning the next hop as well.
    • _customCapabilityBans

      private String _customCapabilityBans
      Form value for the custom capability bans.
    • _customCountryCodes

      private String _customCountryCodes
      Form value for the custom country codes.
    • COMMA_SPLIT

      private static final Pattern COMMA_SPLIT
      Splits the form's comma-separated lists.
    • COUNTRY_CODE

      private static final Pattern COUNTRY_CODE
      Matches one two-letter country code.
    • VALID_CAP_CHARS

      private static final String VALID_CAP_CHARS
      Recognized characters in capability ban patterns. Case-sensitive: lowercase 'f' = floodfill. Includes '!' for exclusion group separator (e.g. "G!f").
      See Also:
  • Constructor Details

    • ConfigBanHandler

      public ConfigBanHandler()
      Constructs the handler.
  • Method Details

    • processForm

      protected void processForm()
      Description copied from class: FormHandler
      Implement this to perform the final processing (in turn, adding formNotice and formError messages, etc)

      Will only be called if _action is non-null and the nonce is valid.

      Specified by:
      processForm in class FormHandler
    • clearAllBans

      private void clearAllBans()
      Turns every ban setting off.
    • resetToDefaults

      private void resetToDefaults()
      Sets every ban setting back to its default.
    • setMaxOffenses

      public void setMaxOffenses(String val)
      Set the maximum offenses.
      Parameters:
      val - the maximum number of offenses
    • setOffenseWindow

      public void setOffenseWindow(String val)
      Set the offense window.
      Parameters:
      val - the offense window in minutes
    • setStartupGrace

      public void setStartupGrace(String val)
      Set the startup grace period.
      Parameters:
      val - the grace period in minutes
    • setBadPacketDuration

      public void setBadPacketDuration(String val)
      Set the bad packet ban duration.
      Parameters:
      val - the duration in minutes
    • setEnableBadPacketBan

      public void setEnableBadPacketBan(String val)
      Enable or disable bad packet banning.
      Parameters:
      val - the value
    • setEnableCorruptConnectionBan

      public void setEnableCorruptConnectionBan(String val)
      Enable or disable corrupt connection banning.
      Parameters:
      val - the value
    • setEnablePortHoppingBan

      public void setEnablePortHoppingBan(String val)
      Enable or disable port hopping banning.
      Parameters:
      val - the value
    • setEnableBlocklist

      public void setEnableBlocklist(String val)
      Enable or disable the blocklist.
      Parameters:
      val - the value
    • setEnableTorBlocklist

      public void setEnableTorBlocklist(String val)
      Enable or disable the Tor blocklist.
      Parameters:
      val - the value
    • setEnableCountryBan

      public void setEnableCountryBan(String val)
      Enable or disable country banning.
      Parameters:
      val - the value
    • setEnableXgBan

      public void setEnableXgBan(String val)
      Enable or disable XG banning.
      Parameters:
      val - the value
    • setEnableLuBan

      public void setEnableLuBan(String val)
      Enable or disable LU banning.
      Parameters:
      val - the value
    • setEnableIntroducerBan

      public void setEnableIntroducerBan(String val)
      Enable or disable banning of routers advertising more introducers on one address than the SSU2 spec allows.
      Parameters:
      val - the value
    • setEnableInvalidVersionBan

      public void setEnableInvalidVersionBan(String val)
      Enable or disable banning RouterInfos that publish a version above every released version, which only a hand-built RouterInfo can do.
      Parameters:
      val - the value
    • setEnablePubDateBan

      public void setEnablePubDateBan(String val)
      Enable or disable banning RouterInfos with an invalid publication date.
      Parameters:
      val - the value
    • setEnableRUCapsBan

      public void setEnableRUCapsBan(String val)
      Enable or disable banning routers that publish both the reachable and the unreachable flag at once.
      Parameters:
      val - the value
    • setEnableBlockMyCountry

      public void setEnableBlockMyCountry(String val)
      Enable or disable blocking of the router's own country.
      Parameters:
      val - the value
    • setEnableUnresponsiveFloodfillBan

      public void setEnableUnresponsiveFloodfillBan(String val)
      Enable or disable unresponsive floodfill banning.
      Parameters:
      val - the value
    • setEnableNoVersionBan

      public void setEnableNoVersionBan(String val)
      Enable or disable no-version banning.
      Parameters:
      val - the value
    • setEnableExcessiveTunnelRequestsBan

      public void setEnableExcessiveTunnelRequestsBan(String val)
      Enable or disable excessive tunnel requests banning.
      Parameters:
      val - the value
    • setBanNextHop

      public void setBanNextHop(String val)
      Enable or disable banning of next-hop peers.
      Parameters:
      val - the value
    • setCustomCapabilityBans

      public void setCustomCapabilityBans(String val)
      Set custom capability bans.
      Parameters:
      val - the capability patterns
    • setCustomCountryCodes

      public void setCustomCountryCodes(String val)
      Set custom country codes.
      Parameters:
      val - the country codes
    • saveChanges

      private void saveChanges()
      Save ban configuration settings.
    • validateCapabilityBans

      private String validateCapabilityBans(String input)
      Validate custom capability ban patterns.

      Capability letters are case-sensitive: lowercase 'f' is floodfill, uppercase letters are the remaining tiers and flags. Input is validated per character and passed through as entered - no sorting, no case folding.

      Separates multiple patterns with comma or space. A pattern may carry an exclusion group after '!': "G!f" bans G routers unless floodfill; exclusions require at least one required character.

      Parameters:
      input - the patterns as entered, comma or space separated, may be null or empty
      Returns:
      the valid patterns joined with commas, invalid patterns dropped
    • isValidCaps

      private static boolean isValidCaps(String s)
      Checks the custom capability list is well formed.
      Parameters:
      s - the capability list from the form
      Returns:
      true if the list may be saved
    • validateCountryCodes

      private String validateCountryCodes(String input)
      Validate country codes - only allow valid 2-letter codes.
      Parameters:
      input - the codes as entered, comma or space separated, may be null or empty
      Returns:
      the valid codes lower-cased and joined with commas, invalid codes dropped