java.lang.Object
net.i2p.router.web.FormHandler
net.i2p.router.web.helpers.ConfigNetHandler
Handler to deal with form submissions from the main config form and act upon the values.
Used for both /config and /confignet.
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 booleanForm flag for dynamic key re-creation.private booleanForm flag for hidden mode.private StringForm value for the inbound bandwidth limit.private booleanForm flag for forcing IPv4 firewalled.private booleanForm flag for forcing IPv6 firewalled.private StringForm value for the IPv6 mode.private booleanForm flag for the laptop mode.private StringForm value for the NTCP auto-detected IP.private booleanForm flag for picking a random NTCP port.private StringForm value for the NTCP bind address.private StringForm value for the NTCP port.private StringForm value for the outbound bandwidth limit.private booleanTrue to save the bandwidth limits only.private booleanForm flag for requiring introductions.private booleanTrue when the form was submitted to save.private StringForm value for the share percentage.private StringForm value for the UDP auto-detected IP.private booleanForm flag for disabling UDP.private StringForm value for the UDP bind address.private StringForm value for the UDP port.private booleanForm flag for enabling UPnP.Config changes to show after a save.(package private) static final intDefault burst percentage.(package private) static final intDefault burst time.private static final StringConfig key for hidden mode.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 voidA full restart is required to apply a hidden mode change.protected voidApplies the submitted form, saving when a save was requested.private voidThe user made changes to the network config and wants to save them, so lets go ahead and do so.voidsetDisableUDP(String foo) Set whether UDP transport is disabled.voidsetDynamicKeys(String moo) Set that the user wants dynamic keys.voidEnable load testing.voidsetInboundrate(String rate) Set the inbound rate.voidsetIPv4Firewalled(String moo) Set whether IPv4 is firewalled.voidSet the IPv6 mode configuration.voidsetIPv6Firewalled(String moo) Set whether IPv6 is firewalled.voidSet that the user wants laptop mode enabled.voidsetNtcpAutoIP(String mode) Set the NTCP auto IP mode.voidsetNtcpAutoPort(String mode) Set the NTCP auto port mode.voidsetNtcphost(String host) Set the NTCP hostname.voidsetNtcpport(String port) Set the NTCP port.voidsetOutboundrate(String rate) Set the outbound rate.voidsetRatesOnly(String foo) Set rates-only mode (skip IP/transport changes).voidSet that the user wants to require introducers.voidSet that the user wants to save.voidsetSharePercentage(String pct) Set the share percentage.voidsetUdpAutoIP(String mode) Set the UDP address detection mode and whether the address is withheld.voidsetUdpHost1(String host) Set the first UDP host.voidsetUdpPort(String port) Set the UDP port.voidSet that the user wants UPnP enabled.private booleanApply the new rate settings, returning whether they changed.private booleanverifyAddress(String addr) Do basic verification of address here to prevent problems later.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
_saveRequested
private boolean _saveRequestedTrue when the form was submitted to save._requireIntroductions
private boolean _requireIntroductionsForm flag for requiring introductions._dynamicKeys
private boolean _dynamicKeysForm flag for dynamic key re-creation._ntcpHostname
Form value for the NTCP bind address._ntcpPort
Form value for the NTCP port._udpHost1
Form value for the UDP bind address._udpPort
Form value for the UDP port._udpAutoIP
Form value for the UDP auto-detected IP._ntcpAutoIP
Form value for the NTCP auto-detected IP._ntcpAutoPort
private boolean _ntcpAutoPortForm flag for picking a random NTCP port._upnp
private boolean _upnpForm flag for enabling UPnP._laptop
private boolean _laptopForm flag for the laptop mode._inboundRate
Form value for the inbound bandwidth limit._outboundRate
Form value for the outbound bandwidth limit._ratesOnly
private boolean _ratesOnlyTrue to save the bandwidth limits only._udpDisabled
private boolean _udpDisabledForm flag for disabling UDP._ipv6Mode
Form value for the IPv6 mode._ipv4Firewalled
private boolean _ipv4FirewalledForm flag for forcing IPv4 firewalled._ipv6Firewalled
private boolean _ipv6FirewalledForm flag for forcing IPv6 firewalled.changes
PROP_HIDDEN
DEF_BURST_PCT
DEF_BURST_TIME
Constructor Details
ConfigNetHandler
public ConfigNetHandler()Create a new handler.
Method Details
processForm
protected void processForm()Applies the submitted form, saving when a save was requested.- Specified by:
processFormin classFormHandler
setSave
Set that the user wants to save.- Parameters:
moo- a placeholder for the setter signature; the value is never read
setRequireIntroductions
Set that the user wants to require introducers.- Parameters:
moo- a placeholder for the setter signature; the value is never read
setDynamicKeys
Set that the user wants dynamic keys.- Parameters:
moo- a placeholder for the setter signature; the value is never read
setEnableloadtesting
Enable load testing.- Parameters:
moo- a placeholder for the setter signature; the value is never read
setUdpAutoIP
Set the UDP address detection mode and whether the address is withheld.- Parameters:
mode- comma-separated list of IP address detection sources to use ("local", "upnp", "ssu"), "fixed" to use the manually entered address, or "hidden" to withhold our address from the NetDb
setNtcpAutoIP
setNtcpAutoPort
Set the NTCP auto port mode.- Parameters:
mode- the auto port mode
setUpnp
Set that the user wants UPnP enabled.- Parameters:
moo- a placeholder for the setter signature; the value is never read
setLaptop
Set that the user wants laptop mode enabled.- Parameters:
moo- a placeholder for the setter signature; the value is never read
setIPv4Firewalled
Set whether IPv4 is firewalled.- Parameters:
moo- a placeholder for the setter signature; the value is never read
setIPv6Firewalled
Set whether IPv6 is firewalled.- Parameters:
moo- a placeholder for the setter signature; the value is never read
setNtcphost
Set the NTCP hostname.- Parameters:
host- the hostname to store, trimmed of surrounding whitespace; null stores null
setNtcpport
setUdpHost1
Set the first UDP host.- Parameters:
host- the hostname to store, trimmed of surrounding whitespace; null stores null
setUdpPort
setInboundrate
setOutboundrate
setRatesOnly
Set rates-only mode (skip IP/transport changes).- Parameters:
foo- a placeholder for the setter signature; the value is never read
setDisableUDP
Set whether UDP transport is disabled.- Parameters:
foo- the disable UDP mode
setIpv6
saveChanges
private void saveChanges()The user made changes to the network config and wants to save them, so lets go ahead and do so.verifyAddress
Do basic verification of address here to prevent problems later.- Parameters:
addr- the address string to verify- Returns:
- true if the address parses and is publicly routable; false adds a form error describing which check failed
updateRates
private boolean updateRates()Apply the new rate settings, returning whether they changed.- Returns:
- true if any rate or share property was staged in the pending changes map, meaning a restart is needed to apply it