java.lang.Object
net.i2p.router.web.FormHandler
net.i2p.router.web.helpers.NetDbHelper
Helper for network database page rendering and form processing. Handles router information searches, filtering, and display operations. Integrates with
NetDbRenderer and SybilRenderer for output generation. Extends FormHandler for form submission handling since 0.9.38.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 StringCapability string to filter on.private booleanTrue to show client-capable routers only.private intCost value to filter on.private StringCountry code to filter on.private longPublication date to filter on.private booleanTrue for extra search logging.private EncTypeEncryption type to filter on.private StringFamily name to filter on.private intNonzero to show the full summary view.private intNonzero to filter on high ports.private StringHostname to filter on.private intIntro key count to filter on.private StringIP address to filter on.private StringIPv6 flag to filter on.private booleanTrue to include lease sets in the search.private intRows shown per page.private intDisplay mode of the peer list.private StringMTU value to filter on.private intPage number being displayed.private intPort number to filter on.private booleanTrue when the POST values parsed cleanly.private StringRouter hash prefix to filter on.private StringColumn name to sort by.private StringSSU capability string to filter on.private StringSybil classification to filter on.private StringTransport name to filter on.private SigTypeSignature type to filter on.private StringVersion string to filter on.private static final intDefault rows shown per page.private static final String[]Column link targets of the netdb peer list.private static final String[]Column titles of the netdb peer list.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
ConstructorsConstructorDescriptionCreate the helper; all state arrives per request through the form handlers.Method Summary
Modifier and TypeMethodDescriptionRender the floodfill-filtered netdb summary; storeWriter() must be called previously.Get the navigation bar HTML.Render the full netdb summary; storeWriter() must be called previously.private StringgetNonce()Get a session-bound nonce for forms in this page.private intgetTab()Return the currently selected NetDb tab index.booleanWhether the router is a floodfill router.protected voidNow we're a FormHandler.private voidCreates a simplified search form: a select element listing all original fields as options with grouped signature, encryption and transport types, a single text input for the search value, and a submit button.voidrenderFragment(String id) Render a single named element for the contentonly fragment mode of the netdb page.private voidRender the NetDb search/lookup form.private StringRender the NetDb navigation bar.voidSet the capabilities filter.voidSet the client page.voidSet the cost filter.voidsetCountry(String c) Set the country filter.voidSet the date filter.voidSet the encryption type filter.voidSet the family filter.voidSet the full display mode.voidSet the intro count filter.voidSet the IP address filter.voidSet the IPv6 prefix filter.voidSet the lease display mode.voidSet the leaseset hostname for lookup.voidSet the result limit.voidSet the mode filter.voidSet the MTU filter.voidSet the page number.voidSet the port filter (single port or range).voidSet the router hash prefix for lookup.voidSet by show= param (alternative to f=N).voidSet the sort field.voidsetSsucaps(String f) Set the SSU capabilities filter.voidSet the Sybil analysis filter.voidFor form, same as above but with a length check.voidSet the transport filter.voidSet the signature type filter.voidsetVersion(String v) Set the router version filter.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
_routerPrefix
Router hash prefix to filter on._version
Version string to filter on._country
Country code to filter on._family
Family name to filter on._caps
Capability string to filter on._ip
IP address to filter on._sybil
Sybil classification to filter on._mtu
MTU value to filter on._ssucaps
SSU capability string to filter on._ipv6
IPv6 flag to filter on._transport
Transport name to filter on._hostname
Hostname to filter on._sort
Column name to sort by._full
private int _fullNonzero to show the full summary view._port
private int _portPort number to filter on._cost
private int _costCost value to filter on._page
private int _pagePage number being displayed._mode
private int _modeDisplay mode of the peer list._highPort
private int _highPortNonzero to filter on high ports._icount
private int _icountIntro key count to filter on._date
private long _datePublication date to filter on._limit
private int _limitRows shown per page._lease
private boolean _leaseTrue to include lease sets in the search._clientOnly
private boolean _clientOnlyTrue to show client-capable routers only._debug
private boolean _debugTrue for extra search logging._type
Signature type to filter on._etype
Encryption type to filter on._postOK
private boolean _postOKTrue when the POST values parsed cleanly.DEFAULT_LIMIT
private static final int DEFAULT_LIMITDefault rows shown per page.titles
Column titles of the netdb peer list.links
Column link targets of the netdb peer list.
Constructor Details
NetDbHelper
public NetDbHelper()Create the helper; all state arrives per request through the form handlers.
Method Details
isFloodfill
public boolean isFloodfill()Whether the router is a floodfill router.- Returns:
- true if this router is a floodfill
setRouter
Set the router hash prefix for lookup.- Parameters:
r- the router hash prefix
setVersion
setCountry
setFamily
setCaps
setIp
setSybil
Set the Sybil analysis filter.- Parameters:
c- the Sybil analysis target
setSybil2
For form, same as above but with a length check.- Parameters:
c- the Sybil analysis target
setPort
Set the port filter (single port or range).- Parameters:
f- the port string
setType
setEtype
Set the encryption type filter.- Parameters:
f- the encryption type string
setMtu
setIpv6
setSsucaps
Set the SSU capabilities filter.- Parameters:
f- the SSU capabilities string
setTransport
setCost
setMode
setDate
setFull
setShow
Set by show= param (alternative to f=N). Overrides _full if present.- Parameters:
show- the keyword selecting which entries to show, overriding setFull: "all", "all_debug", "sybils", "lookup", "client", "client_debug", "local", "ls_remote", "ls_debug" or "ls_local"; an unrecognized or null value changes nothing
setLease
setLeaseset
Set the leaseset hostname for lookup.- Parameters:
f- the hostname or b32
setLimit
setPage
setSort
setIntros
setClientPage
getNonce
Get a session-bound nonce for forms in this page.- Returns:
- the nonce to embed in this page's forms
processForm
getFloodfillNetDbSummary
Render the floodfill-filtered netdb summary; storeWriter() must be called previously.- Returns:
- the netdb summary HTML
getNetDbSummary
Render the full netdb summary; storeWriter() must be called previously.- Returns:
- the net db summary
renderFragment
Render a single named element for the contentonly fragment mode of the netdb page. Only the remote and local leasesets listings are currently fragmentable.- Parameters:
id- the element id to render
getTab
private int getTab()Return the currently selected NetDb tab index.- Returns:
- the index into the navigation bar's title and link arrays for the tab this request belongs to, or 0 if it belongs to none
renderLookupForm
Render the NetDb search/lookup form.- Throws:
IOException- if writing to the console output fails
renderCompactLookupForm
Creates a simplified search form: a select element listing all original fields as options with grouped signature, encryption and transport types, a single text input for the search value, and a submit button. Includes tooltips and option groups for signatures, encryption types and transport.- Throws:
IOException- on write error