java.lang.Object
net.i2p.router.web.FormHandler
net.i2p.router.web.helpers.ConfigBanHandler
Handler to deal with form submissions from the ban configuration form.
Nested Class Summary
Nested classes/interfaces inherited from class FormHandler
FormHandler.MessageModifier and TypeClassDescriptionstatic classMessage class to encapsulate the message text and the canClose flag.Field Summary
FieldsModifier and TypeFieldDescriptionprivate StringForm value for the bad packet ban duration, in minutes.private booleanForm flag for banning the next hop as well.private StringForm value for the custom capability bans.private StringForm value for the custom country codes.private booleanForm flag for the bad packet ban.private booleanForm flag for the blocklist.private booleanForm flag for blocking our own country.private booleanForm flag for the corrupt connection ban.private booleanForm flag for the country ban.private booleanForm flag for the excessive tunnel requests ban.private booleanForm flag for the introducer ban.private booleanForm flag for the invalid version ban.private booleanForm flag for the LU ban.private booleanForm flag for the missing version ban.private booleanForm flag for the port hopping ban.private booleanForm flag for the publish date ban.private booleanForm flag for the restricted usage caps ban.private booleanForm flag for the Tor blocklist.private booleanForm flag for the unresponsive floodfill ban.private booleanForm flag for the Xfer-Gosset ban.private StringForm value for the maximum offenses before a ban.private StringForm value for the offense window, in minutes.private StringForm value for the startup grace period, in minutes.private static final PatternSplits the form's comma-separated lists.private static final PatternMatches one two-letter country code.private static final StringRecognized characters in capability ban patterns.Fields inherited from class FormHandler
_action, _context, _log, _method, _out, _requestWrapper, _session, _settingsModifier and TypeFieldDescriptionprotected StringForm action.protected RouterContextRouter context.protected LogClass logger.protected StringRequest method.protected WriterOutput writer.protected RequestWrapperOnly for multipart/form-data.protected HttpSessionHTTP session for nonce validation.protected MapNot for multipart/form-data, will be null.Constructor Summary
ConstructorsMethod Summary
Modifier and TypeMethodDescriptionprivate voidTurns every ban setting off.private static booleanChecks the custom capability list is well formed.protected voidImplement this to perform the final processing (in turn, adding formNotice and formError messages, etc)private voidSets every ban setting back to its default.private voidSave ban configuration settings.voidSet the bad packet ban duration.voidsetBanNextHop(String val) Enable or disable banning of next-hop peers.voidSet custom capability bans.voidSet custom country codes.voidEnable or disable bad packet banning.voidsetEnableBlocklist(String val) Enable or disable the blocklist.voidEnable or disable blocking of the router's own country.voidEnable or disable corrupt connection banning.voidEnable or disable country banning.voidEnable or disable excessive tunnel requests banning.voidEnable or disable banning of routers advertising more introducers on one address than the SSU2 spec allows.voidEnable or disable banning RouterInfos that publish a version above every released version, which only a hand-built RouterInfo can do.voidsetEnableLuBan(String val) Enable or disable LU banning.voidEnable or disable no-version banning.voidEnable or disable port hopping banning.voidEnable or disable banning RouterInfos with an invalid publication date.voidsetEnableRUCapsBan(String val) Enable or disable banning routers that publish both the reachable and the unreachable flag at once.voidEnable or disable the Tor blocklist.voidEnable or disable unresponsive floodfill banning.voidsetEnableXgBan(String val) Enable or disable XG banning.voidsetMaxOffenses(String val) Set the maximum offenses.voidsetOffenseWindow(String val) Set the offense window.voidsetStartupGrace(String val) Set the startup grace period.private StringvalidateCapabilityBans(String input) Validate custom capability ban patterns.private StringvalidateCountryCodes(String input) Validate country codes - only allow valid 2-letter codes.Methods inherited from class FormHandler
_t, _t, _t, _x, addFormError, addFormError, addFormErrorNoEscape, addFormErrorNoEscape, addFormNotice, addFormNotice, addFormNoticeNoEscape, addFormNoticeNoEscape, getAllMessages, getErrors, getJettyString, getNotices, isAdvanced, resolveEffectiveAction, setAction, setContextId, setNonce, setRequestWrapper, setSettings, storeMethod, storeSession, storeWriterModifier and TypeMethodDescriptionTranslate a string.Translate a string with a parameter This is a lot more expensive than _t(s), so use sparingly.Translate a string with two parameters.static StringMark a string for extraction by xgettext and translation.protected voidaddFormError(String errorMsg) Add an error message to display Use if it does not include a link.protected voidaddFormError(String errorMsg, boolean canClose) Add an error message to display Use if it does not include a link.protected voidAdd an error message to display Use if it includes a link or other formatting.protected voidaddFormErrorNoEscape(String msg, boolean canClose) Add an error message to display Use if it includes a link or other formatting.protected voidaddFormNotice(String msg) Add a non-error message to display Use if it does not include a link.protected voidaddFormNotice(String msg, boolean canClose) Add a non-error message to display Use if it does not include a link.protected voidAdd a non-error message to display Use if it includes a link or other formatting.protected voidaddFormNoticeNoEscape(String msg, boolean canClose) Add a non-error message to display Use if it includes a link or other formatting.Display everything, wrap it in a div for consistent presentation.Display any error messages (processing the form if it hasn't been yet).protected StringgetJettyString(String key) FormHandler.setSettings(Map)must have been called previously Curses Jetty for returning arrays.Display any non-error messages (processing the form if it hasn't been yet).booleanSame as HelperBase.static StringresolveEffectiveAction(String action, Map<?, ?> settings) Resolve which operation the user actually requested.voidAction value.voidsetContextId(String contextId) Configure this bean to query a particular router context.voidNonce value.voidOnly set by formhandler.jsi for multipart/form-data.voidsetSettings(Map settings) For many forms, it's easiest just to put all the parameters here.voidstoreMethod(String val) Call this to prevent changes using GET.voidstoreSession(HttpSession session) For nonce validation.voidstoreWriter(Writer out) Store the output writer for inline form processing.
Field Details
_maxOffenses
Form value for the maximum offenses before a ban._offenseWindow
Form value for the offense window, in minutes._startupGrace
Form value for the startup grace period, in minutes._badPacketDuration
Form value for the bad packet ban duration, in minutes._enableBadPacketBan
private boolean _enableBadPacketBanForm flag for the bad packet ban._enableCorruptConnectionBan
private boolean _enableCorruptConnectionBanForm flag for the corrupt connection ban._enablePortHoppingBan
private boolean _enablePortHoppingBanForm flag for the port hopping ban._enableBlocklist
private boolean _enableBlocklistForm flag for the blocklist._enableTorBlocklist
private boolean _enableTorBlocklistForm flag for the Tor blocklist._enableCountryBan
private boolean _enableCountryBanForm flag for the country ban._enableXgBan
private boolean _enableXgBanForm flag for the Xfer-Gosset ban._enableLuBan
private boolean _enableLuBanForm flag for the LU ban._enableIntroducerBan
private boolean _enableIntroducerBanForm flag for the introducer ban._enableInvalidVersionBan
private boolean _enableInvalidVersionBanForm flag for the invalid version ban._enablePubDateBan
private boolean _enablePubDateBanForm flag for the publish date ban._enableRUCapsBan
private boolean _enableRUCapsBanForm flag for the restricted usage caps ban._enableBlockMyCountry
private boolean _enableBlockMyCountryForm flag for blocking our own country._enableUnresponsiveFloodfillBan
private boolean _enableUnresponsiveFloodfillBanForm flag for the unresponsive floodfill ban._enableNoVersionBan
private boolean _enableNoVersionBanForm flag for the missing version ban._enableExcessiveTunnelRequestsBan
private boolean _enableExcessiveTunnelRequestsBanForm flag for the excessive tunnel requests ban._banNextHop
private boolean _banNextHopForm flag for banning the next hop as well._customCapabilityBans
Form value for the custom capability bans._customCountryCodes
Form value for the custom country codes.COMMA_SPLIT
Splits the form's comma-separated lists.COUNTRY_CODE
Matches one two-letter country code.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:FormHandlerImplement 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:
processFormin classFormHandler
clearAllBans
private void clearAllBans()Turns every ban setting off.resetToDefaults
private void resetToDefaults()Sets every ban setting back to its default.setMaxOffenses
Set the maximum offenses.- Parameters:
val- the maximum number of offenses
setOffenseWindow
Set the offense window.- Parameters:
val- the offense window in minutes
setStartupGrace
Set the startup grace period.- Parameters:
val- the grace period in minutes
setBadPacketDuration
Set the bad packet ban duration.- Parameters:
val- the duration in minutes
setEnableBadPacketBan
Enable or disable bad packet banning.- Parameters:
val- the value
setEnableCorruptConnectionBan
Enable or disable corrupt connection banning.- Parameters:
val- the value
setEnablePortHoppingBan
Enable or disable port hopping banning.- Parameters:
val- the value
setEnableBlocklist
Enable or disable the blocklist.- Parameters:
val- the value
setEnableTorBlocklist
Enable or disable the Tor blocklist.- Parameters:
val- the value
setEnableCountryBan
Enable or disable country banning.- Parameters:
val- the value
setEnableXgBan
setEnableLuBan
setEnableIntroducerBan
Enable or disable banning of routers advertising more introducers on one address than the SSU2 spec allows.- Parameters:
val- the value
setEnableInvalidVersionBan
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
Enable or disable banning RouterInfos with an invalid publication date.- Parameters:
val- the value
setEnableRUCapsBan
Enable or disable banning routers that publish both the reachable and the unreachable flag at once.- Parameters:
val- the value
setEnableBlockMyCountry
Enable or disable blocking of the router's own country.- Parameters:
val- the value
setEnableUnresponsiveFloodfillBan
Enable or disable unresponsive floodfill banning.- Parameters:
val- the value
setEnableNoVersionBan
Enable or disable no-version banning.- Parameters:
val- the value
setEnableExcessiveTunnelRequestsBan
Enable or disable excessive tunnel requests banning.- Parameters:
val- the value
setBanNextHop
Enable or disable banning of next-hop peers.- Parameters:
val- the value
setCustomCapabilityBans
Set custom capability bans.- Parameters:
val- the capability patterns
setCustomCountryCodes
Set custom country codes.- Parameters:
val- the country codes
saveChanges
private void saveChanges()Save ban configuration settings.validateCapabilityBans
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
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