java.lang.Object
net.i2p.router.sybil.PersistSybil
Store and retrieve analysis files from disk. Each file is named with a timestamp.
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final I2PAppContextThe router the analysis runs on.private final LogLogger for this class.private static final StringFile naming the routers blocked as sybils.private static final StringSubdirectory the result files are written to.private static final StringStart of a result file name.private static final StringDirectory the analysis data is kept in.private static final StringEnd of a result file name.Constructor Summary
ConstructorsMethod Summary
Modifier and TypeMethodDescriptionbooleandelete(long date) Delete the file for a particular date.voidDelete the blocklist.Get the blocklist path.load()The list of stored analysis sets, as a time stamp.load(long date) Load the analysis for a certain date.Load all the analysis for a certain hash.private voidnotifyVersion(long v) Notify the update manager of a new blocklist version.Read the blocklist.readBlocklist(File blFile) Read the blocklist.voidRemove all files older than configured threshold Inline for now, thread later if necessary.voidStore each entry.(package private) voidstoreBlocklist(Set<String> blocks, long blockUntil) Write the blocklist.
Field Details
_context
The router the analysis runs on._log
Logger for this class.SDIR
Directory the analysis data is kept in.- See Also:
DIR
Subdirectory the result files are written to.- See Also:
PFX
SFX
BLOCKLIST_SYBIL_FILE
File naming the routers blocked as sybils.- See Also:
Constructor Details
PersistSybil
Create a new PersistSybil instance.- Parameters:
ctx- the router context
Method Details
store
Store each entry.- Parameters:
date- the timestamp for the fileentries- each one should be "entry" at the root- Throws:
IOException- if an I/O error occurs
load
load
Load the analysis for a certain date.- Parameters:
date- the timestamp for the file- Returns:
- non-null, unsorted
- Throws:
IOException- if an I/O error occurs
load
Load all the analysis for a certain hash.- Parameters:
h- the hash to load- Returns:
- non-null, unsorted
- Throws:
IOException- if an I/O error occurs
removeOld
public void removeOld()Remove all files older than configured threshold Inline for now, thread later if necessary.delete
public boolean delete(long date) Delete the file for a particular date.- Parameters:
date- the timestamp for the file- Returns:
- true if the file was deleted
getBlocklistFile
deleteBlocklistFile
public void deleteBlocklistFile()Delete the blocklist.readBlocklist
readBlocklist
storeBlocklist
Write the blocklist. The format is different than other blocklists because we include an expiration. Format: One per line: ip or hash,expiration time (ms).- Parameters:
blocks- non-empty, will be merged with existing entriesblockUntil- the expiration time in ms
notifyVersion
private void notifyVersion(long v) Notify the update manager of a new blocklist version.- Parameters:
v- the newly installed blocklist version number