java.lang.Object
i2p.susi.dns.BaseBean
i2p.susi.dns.AddressbookBean
i2p.susi.dns.NamingServiceBean
Talk to the NamingService API instead of modifying the hosts.txt files directly, except for the 'published' addressbook.
Field Summary
FieldsModifier and TypeFieldDescriptionprivate StringMessage from the cached load, null until the first successful load.private intCached book size, -1 until computed.private StringKey of the currently cached load (filter, search, category, pagination, book).private longWhen the cached load was performed.private static final LogLogger for this class.private booleanTrue when the last load applied skip/limit server-side; total is thentotalSize().private StringKey of the currently cached book size.private longWhen the cached book size was computed.private static final longHow long a cached addressbook load or book size is reused before the naming service is re-queried.private static final StringNaming service used when none is configured.private StringDetail line shown for the service on the page.private booleanTrue if the lookup through this service failed.private intHow many found entries the blacklist removed.private AddressBean[]The entries that survived filtering.private StringNotes shown for the service on the page.Fields inherited from class AddressbookBean
beginIndex, book, category, deletionMarks, destination, endIndex, entries, filter, hostname, search, sorterModifier and TypeFieldDescriptionprotected intBeginning index for pagination.protected StringThe address book name.protected StringThe category filter string.protected final LinkedList<String> List of entries marked for deletion.protected StringThe destination.protected intEnding index for pagination.protected AddressBean[]Array of address entries.protected StringThe filter string.protected StringThe hostname.protected StringThe search string.protected static final Comparator<AddressBean> Comparator for sorting addresses.Fields inherited from class BaseBean
_context, action, lastSerial, method, PROP_PW_ENABLE, properties, serialModifier and TypeFieldDescriptionprotected final I2PAppContextThe I2P application context.protected StringThe current action.protected StringThe last serial number for CSRF.protected StringThe HTTP method.static final StringProperty for password enable.protected final PropertiesThe configuration properties.protected StringThe serial number.Constructor Summary
ConstructorsConstructorDescriptionA fresh bean: the display range is initialised byAddressbookBeanand the cached load and book-size entries below are empty, so the first query repopulates them.Method Summary
Modifier and TypeMethodDescriptionprivate static StringGet the basename of a file path.private voidDrop cached load results and book size so the next access re-queries the naming service.voidExport address book entries to a writer.Returns the display name for the address book.Returns the address entries.Returns the file name for the address book.Load addressbook and apply filter, returning messages about this.Lookup a single destination by hostname.Lookup all destinations for a hostname.Perform actions, returning messages about this.private NamingServiceGet the NamingService for the current file name, or the root NamingService.protected intGets the total count of filtered results for pagination display.booleanCheck if the imagegen service is available.importFile(RequestWrapper wrequest) Import entries from a file upload.private booleanisDirect()Check if the published addressbook is in use (direct file access).booleanReturns whether the address book is not empty.protected booleanChecks if entries are pre-filtered.private StringloadKey()Key for the load cache; changes whenever an input that affects the displayed entries changes.protected intThe number of entries in the current result set.voidSave notes for a destination.private static NamingServicesearchNamingService(NamingService ns, String srch) Perform a depth-first search for a naming service by name.voidSets the hostname for lookup.voidSets the notes for the destination.private static StringstyleMessage(String message, boolean fail) Style a message for display in the UI.protected intThe total number of entries in the book.Methods inherited from class AddressbookBean
generateLoadMessage, getBegin, getBeginInt, getBook, getCategoryFilter, getDestination, getEnd, getEndInt, getFilter, getHostname, getPageBegin, getResultBegin, getResultEnd, getSearch, isHasFilter, isIsEmpty, isValidBook, setBegin, setBook, setDestination, setEnd, setFilter, setHostname, setMarkedForDeletion, setResetDeletionMarks, setSearchModifier and TypeMethodDescriptionprotected StringFormat a message about filtered addressbook size, and the number of displayed entries addressbook.jsp catches the case where the whole book is empty.getBegin()The clamped first displayed entry index, as a string for the JSP.protected intThe first displayed entry index, clamped to the result set.getBook()This always returns a valid book, non-null.The category filter, set when the search filter names a category.The destination for the add or edit form, as entered.getEnd()The clamped last displayed entry index, as a string for the JSP.protected intThe last displayed entry index, clamped to the result set.The search filter narrowing the displayed entries.The hostname for the add or edit form, as entered.intGets the beginning index into results for display purposes.The index of the first entry in the result set, as a string.The index of the last entry in the result set, as a string.Returns the search string.booleanReturns whether a filter is active.booleanReturns whether the address book is empty.booleanBecause the following from addressbook.jsp fails parsing in the new EL: javax.el.ELException: Failed to parse the expression Can't figure out why, so just replace it with book.validBook:voidSet the page start index from a form string, ignoring garbage.voidSet the address book to display, normalizing unknown names to "router".voidsetDestination(String destination) Set the destination for the add or edit form.voidSet the page end index from a form string, ignoring garbage.voidSet the search filter; "none" clears it, and a category name selects that category.voidsetHostname(String hostname) Set the hostname for the add or edit form.voidsetMarkedForDeletion(String name) Marks an entry for deletion.voidsetResetDeletionMarks(String dummy) Resets the deletion marks.voidSets the search string.Methods inherited from class BaseBean
_t, _t, _t, addressbookDir, configFile, debug, getAction, getSerial, getTheme, getThemeName, getThemes, isOverrideCssActive, loadConfig, ngettext, reload, setAction, setSerial, storeMethod, useSoraFont, warnModifier and TypeMethodDescriptionprotected static StringTranslate a string.protected static StringTranslate a string with one parameter.protected static StringTranslate a string with two parameters.protected FileReturns the addressbook directory.protected FileThe addressbook configuration file.protected voidLog a debug message.Get the action.Generate a new random serial for CSRF protection and clear the pending action.getTheme()Returns the theme path.The configured console theme name.String[]Get all themes.booleanDetermine if a user-provided override.css file is active.protected voidLoads the configuration if needed.protected static StringTranslate a string with plural form (ngettext).protected voidreload()Reloads the configuration from file.voidSets the action.voidSets the serial.voidstoreMethod(String method) Store the HTTP method.booleanChecks if Sora font should be used.protected voidLog a warning message.
Field Details
_log
Logger for this class.DEFAULT_NS
Naming service used when none is configured.- See Also:
detail
Detail line shown for the service on the page.notes
Notes shown for the service on the page.fail
private boolean failTrue if the lookup through this service failed.filteredCount
private int filteredCountHow many found entries the blacklist removed.fullFilteredEntries
The entries that survived filtering._serverPaginated
private boolean _serverPaginatedTrue when the last load applied skip/limit server-side; total is thentotalSize().CACHE_TTL
private static final long CACHE_TTLHow long a cached addressbook load or book size is reused before the naming service is re-queried.- See Also:
_loadKey
Key of the currently cached load (filter, search, category, pagination, book)._loadTime
private long _loadTimeWhen the cached load was performed._cachedLoadMessage
Message from the cached load, null until the first successful load._sizeKey
Key of the currently cached book size._sizeTime
private long _sizeTimeWhen the cached book size was computed._cachedSize
private int _cachedSizeCached book size, -1 until computed.
Constructor Details
NamingServiceBean
public NamingServiceBean()A fresh bean: the display range is initialised byAddressbookBeanand the cached load and book-size entries below are empty, so the first query repopulates them.
Method Details
isDirect
private boolean isDirect()Check if the published addressbook is in use (direct file access).- Returns:
- true if the book is "published"
isPrefiltered
protected boolean isPrefiltered()Checks if entries are pre-filtered.- Overrides:
isPrefilteredin classAddressbookBean- Returns:
- true when the entries came back already filtered by the naming service, so callers must not filter or paginate them again
resultSize
protected int resultSize()The number of entries in the current result set.- Overrides:
resultSizein classAddressbookBean- Returns:
- the size of the lookup result
getTotalFilteredCount
protected int getTotalFilteredCount()Gets the total count of filtered results for pagination display. Returns the count BEFORE manual pagination is applied.- Overrides:
getTotalFilteredCountin classAddressbookBean- Returns:
- the total count of filtered results
totalSize
protected int totalSize()The total number of entries in the book.- Overrides:
totalSizein classAddressbookBean- Returns:
- the total size of the address book
isNotEmpty
public boolean isNotEmpty()Returns whether the address book is not empty.- Overrides:
isNotEmptyin classAddressbookBean- Returns:
- whether not empty
getFileName
Returns the file name for the address book.- Overrides:
getFileNamein classAddressbookBean- Returns:
- the file name
getDisplayName
Returns the display name for the address book.- Overrides:
getDisplayNamein classAddressbookBean- Returns:
- the display name
searchNamingService
Perform a depth-first search for a naming service by name.- Parameters:
ns- the root naming service to search fromsrch- the name to search for- Returns:
- the matching NamingService, or null if not found
basename
getNamingService
Get the NamingService for the current file name, or the root NamingService.- Returns:
- the book matching the current file name, falling back to the root naming service when no book in the tree matches
loadKey
Key for the load cache; changes whenever an input that affects the displayed entries changes.- Returns:
- the cache key
clearCaches
private void clearCaches()Drop cached load results and book size so the next access re-queries the naming service. Called after actions that mutate the addressbook.getLoadBookMessages
Load addressbook and apply filter, returning messages about this. To control memory, don't load the whole addressbook if we can help it... only load what is searched for. Results are cached forCACHE_TTLand reused while the inputs (filter, search, category, pagination, book) are unchanged.- Overrides:
getLoadBookMessagesin classAddressbookBean- Returns:
- messages about loading the address book
getEntries
Returns the address entries. Returns the entries with blacklist filtering and the current filter, search, and pagination applied, loading or reusing the cached load.- Overrides:
getEntriesin classAddressbookBean- Returns:
- the filtered, searched, and paginated entries, or null if no load has succeeded yet
getMessages
Perform actions, returning messages about this.- Overrides:
getMessagesin classAddressbookBean- Returns:
- messages about the performed actions
saveNotes
public void saveNotes()Save notes for a destination.setH
setNofilter_notes
Sets the notes for the destination.- Parameters:
n- the notes to set
getLookup
Lookup a single destination by hostname.- Returns:
- the AddressBean for the destination, or null if not found
getLookupAll
Lookup all destinations for a hostname.- Returns:
- list of AddressBeans for all destinations, or null if not found
export
Export address book entries to a writer.- Parameters:
out- the writer to export to- Throws:
IOException- if an I/O error occurs
importFile
Import entries from a file upload.- Parameters:
wrequest- the request wrapper containing the file- Returns:
- messages about the import operation
- Throws:
IOException- if an I/O error occurs
styleMessage
haveImagegen
public boolean haveImagegen()Check if the imagegen service is available.- Returns:
- true if imagegen is registered