java.lang.Object
net.i2p.router.web.HelperBase
net.i2p.router.web.helpers.ConfigClientsHelper
Helper for clients configuration page rendering and form processing.
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classA client app config entry with display index.private classComparator for sorting client app configs by name.Field Summary
Modifier and TypeFieldDescriptionprivate StringName of the app selected for editing, if any.static final StringFrom ClientListenerRunner.static final StringFrom ClientMessageEventListener.static final StringFrom ClientManager.static final StringFrom ClientManager.static final StringEnable/disable client configuration changes in the web UI.static final StringEnable/disable plugin installation in the web UI.static final StringFrom ClientManager.private static final PatternSimple regex from https://stackoverflow.com/questions/8204680/java-regex-email not the massive RFC 822 compliant one modified so .i2p will work.Fields inherited from class HelperBase
_context, _log, _out, CHECKED, PROP_ADVANCED, SELECTEDModifier and TypeFieldDescriptionprotected RouterContextThe router context.protected LogThe log instance.protected WriterThe writer for output.static final StringChecked attribute for HTML checkboxes.static final StringProperty key for advanced mode.static final StringSelected attribute for HTML select options.Constructor Summary
ConstructorsConstructorDescriptionCreates a helper; the container calls it with no arguments before rendering the page.Method Summary
Modifier and TypeMethodDescriptiongetAuth()Whether I2CP authentication is enabled.Whether local-local loopback delivery is disabled.getForm1()Generate the clients configuration table HTML.getForm2()Generate the webapps configuration table HTML.getForm3()Generate the plugins configuration table HTML.getPort()Get the configured I2CP port.i2cpModeChecked(int mode) Get checked attribute for I2CP mode radio buttons.String[]Get available network interface addresses.booleanWhether client configuration changes are allowed.booleanisIFSelected(String addr) Whether the given address is the selected I2CP interface.booleanWhether plugin installation is enabled.booleanWhether any plugins have updates available.private voidrenderForm(StringBuilder buf, String index, String name, boolean urlify, boolean enabled, boolean ro, boolean preventDisable, String escapedDesc, boolean edit, boolean showEditButton, boolean showUpdateButton, boolean showStopButton, boolean showDeleteButton, boolean showStartButton) Misnamed, renders a single line in a table for a single client/webapp/plugin.voidSet the edit mode for a specific client or for adding a new client.booleanWhether plugins are enabled.static StringstripHTML(Properties props, String key) Like inDataHelperbut doesn't convert null to "" There's a lot worse things a plugin could do but...Methods inherited from class HelperBase
_t, _t, _t, _x, getChecked, isAdvanced, ngettext, setContextId, storeWriterModifier and TypeMethodDescriptionTranslate a string.Translate a string with a parameter.Translate a string with two parameters.static StringMark a string for extraction by xgettext and translation.protected StringgetChecked(String prop) Get the checked attribute for a boolean property.booleanCheck if advanced mode is enabled.Translate a string with plural forms (ngettext).voidsetContextId(String contextId) Configure this bean to query a particular router context.voidstoreWriter(Writer out) Store the writer for output.
Field Details
_edit
Name of the app selected for editing, if any.BIND_ALL_INTERFACES
From ClientListenerRunner.- See Also:
PROP_DISABLE_EXTERNAL
PROP_ENABLE_SSL
PROP_AUTH
PROP_DISABLE_LOOPBACK
PROP_ENABLE_CLIENT_CHANGE
Enable/disable client configuration changes in the web UI.- See Also:
PROP_ENABLE_PLUGIN_INSTALL
Enable/disable plugin installation in the web UI.- See Also:
VALID_EMAIL_ADDRESS_REGEX
Simple regex from https://stackoverflow.com/questions/8204680/java-regex-email not the massive RFC 822 compliant one modified so .i2p will work.
Constructor Details
ConfigClientsHelper
public ConfigClientsHelper()Creates a helper; the container calls it with no arguments before rendering the page.
Method Details
isClientChangeEnabled
public boolean isClientChangeEnabled()Whether client configuration changes are allowed.- Returns:
- true if enabled, false otherwise
isPluginInstallEnabled
public boolean isPluginInstallEnabled()Whether plugin installation is enabled.- Returns:
- true if enabled, false otherwise
isPluginUpdateEnabled
public boolean isPluginUpdateEnabled()Whether any plugins have updates available.- Returns:
- true if updates available, false otherwise
getPort
i2cpModeChecked
Get checked attribute for I2CP mode radio buttons.- Parameters:
mode- the mode number (0=disabled, 1=clear, 2=SSL)- Returns:
- CHECKED if this mode is selected, otherwise ""
getAuth
Whether I2CP authentication is enabled.- Returns:
- CHECKED if enabled, otherwise ""
getDisableLoopback
Whether local-local loopback delivery is disabled.- Returns:
- CHECKED if disabled, otherwise ""
intfcAddresses
Get available network interface addresses.- Returns:
- array of address strings
isIFSelected
Whether the given address is the selected I2CP interface.- Parameters:
addr- the address to check- Returns:
- true if selected, false otherwise
setEdit
Set the edit mode for a specific client or for adding a new client.- Parameters:
edit- the edit command string
getForm1
getForm2
showPlugins
public boolean showPlugins()Whether plugins are enabled.- Returns:
- true if plugins are enabled for this router
getForm3
renderForm
private void renderForm(StringBuilder buf, String index, String name, boolean urlify, boolean enabled, boolean ro, boolean preventDisable, String escapedDesc, boolean edit, boolean showEditButton, boolean showUpdateButton, boolean showStopButton, boolean showDeleteButton, boolean showStartButton) Misnamed, renders a single line in a table for a single client/webapp/plugin.- Parameters:
buf- the builder the table row is appended toindex- the client's config index, used to name its form fieldsname- will be escaped hereurlify- true to render the name as a link to the app instead of a labelenabled- true to check the enable checkboxro- trumps edit and showEditButtonpreventDisable- true to disable the enable checkbox so the app cannot be turned offescapedDesc- description, must be HTML escaped, except for pluginsedit- true when the row is being rendered as an editable formshowEditButton- true to offer the edit buttonshowUpdateButton- true to offer the update buttonshowStopButton- true to offer the stop buttonshowDeleteButton- true to offer the delete buttonshowStartButton- true to offer the start button
stripHTML
Like inDataHelperbut doesn't convert null to "" There's a lot worse things a plugin could do but...- Parameters:
props- the properties to retrieve fromkey- the property key- Returns:
- the stripped value, or null