Packages that use Snark
Package
Description
I2P version of the Snark BitTorrent client, enhanced for I2P: peers are I2P destinations, torrents can be served anonymously as hidden services, and metadata carries I2P-specific comment fields.
The I2PSnark web interface (i2psnark.war): servlets and helpers for torrent management, file browsing and configuration.
Uses of Snark in org.klomp.snark
Fields in org.klomp.snark declared as SnarkModifier and TypeFieldDescriptionprivate SnarkUpdateRunner._snarkThe download doing the work.private final SnarkPeerCoordinator.snarkThe download we coordinate peers for.private final SnarkSnarkManager.ThreadedRechecker.snarkThe torrent to recheck.private final SnarkSnarkManager.ThreadedStarter.snarkThe torrent to start.private final SnarkTrackerClient.snarkThe snark downloading this torrent.Fields in org.klomp.snark with type parameters of type SnarkModifier and TypeFieldDescriptionSnarkManager._filteredBaseNameToSnarkSnarks by filtered base name; synchronize on _snarks.SnarkManager._infoHashToSnarkSnarks by info hash; synchronize on _snarks.SnarkManager.PoolStarter._membersThe torrents to start in sequence.SnarkManager.DestCycleRestart._runningThe torrents to restart.SnarkManager._snarksMap of (canonical) filename of the .torrent file to Snark instance.Methods in org.klomp.snark that return SnarkModifier and TypeMethodDescriptionSnarkManager.addMagnet(String name, byte[] ih, String trackerURL, boolean updateStatus, boolean autoStart, File dataDir, CompleteListener listener) Add a torrent with the info hash alone (magnet / maggot) External use is for UpdateRunner.SnarkManager.getTorrent(String filename) Grab the torrent given the (canonical) filename of the .torrent file.SnarkManager.getTorrentByBaseName(String filename) Grab the torrent given the base name of the storage.SnarkManager.getTorrentByInfoHash(byte[] infohash) Grab the torrent given the info hash.private SnarkSnarkManager.removeSnark(String torrentFile) Remove the snark.SnarkManager.stopTorrent(String filename, boolean shouldRemove) Stop the torrent, leaving it on the list of torrents unless told to remove it.Methods in org.klomp.snark that return types with arguments of type SnarkModifier and TypeMethodDescriptionSnarkManager.getTorrents()Snapshot of the loaded torrents as an unmodifiable collection.SnarkManager.monitorTorrents(File dir) Add torrents found in the given directory.SnarkManager.previouslyRunning(List<Snark> batch) Filters a candidate start batch down to the torrents that were running when last saved.Methods in org.klomp.snark with parameters of type SnarkModifier and TypeMethodDescriptionvoidSnarkManager.addDownloader(Snark torrent) Add and start a FetchAndAdd task.voidCompleteListener.addMessage(Snark snark, String message) Called to display a status or error message in the torrent's UI.voidSnarkManager.addMessage(Snark snark, String message) A Snark.CompleteListener method.voidUpdateRunner.addMessage(Snark snark, String message) Add a message to the console.voidSnarkManager.deleteMagnet(Snark snark) Stop and delete a torrent running in magnet mode.voidCalled when the torrent hits an unrecoverable error and has stopped.voidA Snark.CompleteListener method.voidHandle a fatal error.private PropertiesThe config for a torrent.long[]SnarkManager.getSavedAddedAndCompleted(Snark snark) Setting for a torrent from the metadata file.CompleteListener.getSavedComments(Snark snark) The saved comments.SnarkManager.getSavedComments(Snark snark) The comments for a torrent.UpdateRunner.getSavedComments(Snark snark) Add a message from the torrent to the console.booleanSnarkManager.getSavedCommentsEnabled(Snark snark) Setting for comments enabled from the metadata file.CompleteListener.getSavedTorrentBitField(Snark snark) Returns the saved bitfield for the torrent.SnarkManager.getSavedTorrentBitField(Snark snark) Saved bitfield for a torrent from the metadata file.UpdateRunner.getSavedTorrentBitField(Snark snark) The saved torrent bit field.longCompleteListener.getSavedTorrentTime(Snark snark) Returns the saved time for the torrent's last modification.longSnarkManager.getSavedTorrentTime(Snark snark) Timestamp for a torrent from the metadata file.longUpdateRunner.getSavedTorrentTime(Snark snark) The saved torrent time.longCompleteListener.getSavedUploaded(Snark snark) The saved uploaded bytes.longSnarkManager.getSavedUploaded(Snark snark) Setting for a torrent from the metadata file.longUpdateRunner.getSavedUploaded(Snark snark) The saved uploaded bytes.private StringSnarkManager.getSnarkName(Snark snark) Returns the Snark name with URL-encoded spaces replaced by regular spaces.CompleteListener.gotMetaInfo(Snark snark) We transitioned from magnet mode, we have now initialized our metainfo and storage.SnarkManager.gotMetaInfo(Snark snark) We transitioned from magnet mode, we have now initialized our metainfo and storage.UpdateRunner.gotMetaInfo(Snark snark) Handle received metainfo.voidCalled each time a single piece is downloaded and verified.voidA Snark.CompleteListener method.voidHandle a received piece.private StringAn HTML link to the file if complete and a single file, to the directory if not complete or not a single file, or simply the unlinkified name of the snark if a magnet.voidSnarkManager.loadSavedFilePriorities(Snark snark) Saved priorities for a torrent from the metadata file.voidCompleteListener.locked_saveComments(Snark snark, CommentSet comments) Persist a comment set under the torrent's own lock, so a comment fetched from a tracker is not written concurrently with the torrenting thread.voidSnarkManager.locked_saveComments(Snark snark, CommentSet comments) Save the comments for a torrent.voidUpdateRunner.locked_saveComments(Snark snark, CommentSet comments) Save comments for the torrent.private voidUpdateRunner.processComplete(Snark snark) Handles a completed update download.private voidAdd the snark.voidSnarkManager.recheckTorrent(Snark snark) Threaded.private voidSnarkManager.removeSnark(Snark snark) Remove the snark.private voidSnarkManager.removeTorrentStatus(Snark snark) Remove the status of a torrent from the metadata file.voidSnarkManager.saveTorrentStatus(Snark snark) Save the completion status of a torrent and other data in the metadata file.private voidSnarkManager.saveTorrentStatus(Snark snark, Boolean comments) Save the completion status of a torrent and other data in the metadata file.voidSnarkManager.setSavedCommentsEnabled(Snark snark, boolean yes) Setting for comments enabled in the metadata file.voidSnarkManager.startTorrent(Snark snark) If not connected, thread it, otherwise inline.voidSnarkManager.stopTorrent(Snark torrent) Stop the torrent only, leaving it on the list of torrents.voidSnarkManager.stopTorrent(Snark torrent, boolean shouldRemove) Stop the torrent, leaving it on the list of torrents unless told to remove it.private intSnarkManager.stopTorrent(Snark snark, int count, boolean finalShutdown) Stop one torrent, notifying trackers per finalShutdown, and adding the "stopping all" message on the first stop.voidCompleteListener.torrentComplete(Snark snark) Called when all pieces of the torrent have been downloaded and verified.voidSnarkManager.torrentComplete(Snark snark) A Snark.CompleteListener method.voidUpdateRunner.torrentComplete(Snark snark) Handle torrent completion.voidCompleteListener.updateStatus(Snark snark) Called when the torrent status should be updated (e.g., peer count changed).voidSnarkManager.updateStatus(Snark snark) A Snark.CompleteListener method.voidUpdateRunner.updateStatus(Snark snark) This is called by stopTorrent() among others.Method parameters in org.klomp.snark with type arguments of type SnarkModifier and TypeMethodDescriptionSnarkManager.previouslyRunning(List<Snark> batch) Filters a candidate start batch down to the torrents that were running when last saved.private booleanSnarkManager.startBatch(List<Snark> batch) Start a batch of torrents, keeping pool-mates together.voidSnarkManager.startStoppedTorrents(List<Snark> batch) Start all currently-stopped torrents of the given batch in the background using the same pool-aware staggering and parallel pool startup asSnarkManager.startBatch(List).Constructors in org.klomp.snark with parameters of type SnarkModifierConstructorDescriptionPeerCoordinator(I2PSnarkUtil util, byte[] id, byte[] infohash, MetaInfo metainfo, Storage storage, CoordinatorListener listener, Snark torrent, BandwidthListener bwl) Create a peer coordinator for the torrent.Must have non-null storage.Starts one torrent on its own thread.TrackerClient(I2PSnarkUtil util, MetaInfo meta, String additionalTrackerURL, PeerCoordinator coordinator, Snark snark) Call start() to start it.Constructor parameters in org.klomp.snark with type arguments of type SnarkModifierConstructorDescriptionDestCycleRestart(List<Snark> running) Restarts the torrents sharing a cycled destination.PoolStarter(List<Snark> members) Starts a pool of torrents one at a time.Uses of Snark in org.klomp.snark.web
Subclasses of Snark in org.klomp.snark.webClasses in org.klomp.snark.web that implement interfaces with type arguments of type SnarkModifier and TypeClassDescriptionprivate static classForward or reverse sort, but the fallback is always forward.private static classSort alphabetically in current locale, ignore case, ignore leading articles such as "the" if the pattern is set by setPattern().Fields in org.klomp.snark.web declared as SnarkModifier and TypeFieldDescription(package private) final SnarkI2PSnarkServlet.CommentsContext.snarkThe torrent whose comments are being rendered.(package private) final SnarkI2PSnarkServlet.PeerRowContext.snarkThe torrent the peer belongs to.(package private) final SnarkI2PSnarkServlet.RowContext.snarkThe torrent whose row is being drawn.Methods in org.klomp.snark.web that return SnarkModifier and TypeMethodDescriptionprivate SnarkI2PSnarkServlet.resolveTorrentByToken(String token) Resolves a short action token to its torrent by unique-prefix match over the loaded torrents' base64 info-hash names.Methods in org.klomp.snark.web that return types with arguments of type SnarkModifier and TypeMethodDescriptionstatic Comparator<Snark> Sorters.getComparator(int type, String lang, I2PSnarkServlet servlet) Build the comparator that orders the torrent list by a details-page column.I2PSnarkServlet.getSortedSnarks(HttpServletRequest req) Returns the list of torrents sorted according to the current request's sort parameter.I2PSnarkServlet.search(String search, Collection<Snark> snarks) Search torrents for matching terms.Methods in org.klomp.snark.web with parameters of type SnarkModifier and TypeMethodDescriptionprivate voidI2PSnarkServlet.appendPeerRow(StringBuilder buf, Peer peer, Snark snark, MetaInfo meta, boolean noThinsp) Appends HTML for a single peer row to the given StringBuilder.private voidI2PSnarkServlet.appendTorrentActionButton(StringBuilder buf, String action, String token, Snark snark, String title) Append a Remove or Delete submit button for a torrent row.private voidI2PSnarkServlet.appendTorrentInfo(StringBuilder buf, Snark snark, String base, String tName, boolean showStopStart) Appends detailed torrent information as HTML to the provided StringBuilder buffer.private I2PSnarkServlet.BadgeInfoI2PSnarkServlet.badgeInfo(I2PSnarkServlet.RowContext rc, Snark snark) Look up (or compute) the badge values for a torrent.private I2PSnarkServlet.StatusResultI2PSnarkServlet.buildStatusString(Snark snark, int curPeers, int knownPeers, long downBps, long upBps, boolean isRunning, long remaining, long needed, boolean noThinsp) Generates HTML status string and status code for a Snark based on its state and peer info.(package private) static intCompare two torrents by status, with ties broken by swarm size for idle, inactive and magnet states, otherwise by active peer count.static intCompare two torrents by name.intintintintintintintintintintprotected abstract intCompare two torrents on the subclass's column, falling back to name order.intintintintprivate voidI2PSnarkServlet.deleteComments(Snark snark, Map<String, String[]> postParams) Delete comments for a torrent.private voidI2PSnarkServlet.displayComments(Snark snark, boolean er, boolean ec, boolean esc, StringBuilder buf) Display the ratings and comments section.private voidI2PSnarkServlet.displayTorrentEdit(Snark snark, String base, StringBuilder buf) Display the edit-torrent section.private static longEstimates when a download will finish.private voidI2PSnarkServlet.executeDirectoryPostAction(Snark snark, Map<String, String[]> postParams, String action) Performs the side effects of a validated directory-page POST command.(package private) static intGives the sort rank for a torrent's state.private static intSorters.StatusComparator.getStatusImpl(Snark snark) Computes the state rank, stopped torrents offset.private voidI2PSnarkServlet.handleDirectoryPost(Snark snark, Map<String, String[]> postParams) Dispatch a POST on the torrent directory page to its action, validating the anti-CSRF nonce first.private StringI2PSnarkServlet.injectPoolBadge(String statusHtml, Snark snark, I2PSnarkServlet.RowContext rc) Injects the multi-dest pool badge into the status cell HTML.private static longThe pool number of a torrent's shared destination, Long.MAX_VALUE when the torrent has no destination.private voidI2PSnarkServlet.renderCommentsSection(Snark snark, boolean er, boolean ec, boolean esc, String tabLabel, StringBuilder buf) Renders the collapsible comments/ratings section (opener div, toggle, tab label, body, close) when ratings or comments are enabled globally; renders nothing otherwise.private voidI2PSnarkServlet.saveComments(Snark snark, Map<String, String[]> postParams) Save comment changes for a torrent.private voidI2PSnarkServlet.saveCommentsSetting(Snark snark, Map<String, String[]> postParams) Save comment enabled setting for a torrent.private voidI2PSnarkServlet.savePriorities(Snark snark, Map<String, String[]> postParams) Save file priority changes for a torrent.private voidI2PSnarkServlet.saveTorrentEdit(Snark snark, Map<String, String[]> postParams) Save edits from the torrent edit form.private booleanI2PSnarkServlet.snarkMatchesFilter(Snark s, String filter, String snarkStatus) Checks whether a torrent matches the given filter based on its status string.private StringGives the torrent name used for the type comparison.private booleanI2PSnarkServlet.unlinkTorrentFile(Snark snark) Unlinks a torrent's .torrent file, reporting the outcome as user messages.Method parameters in org.klomp.snark.web with type arguments of type SnarkModifier and TypeMethodDescriptionprivate voidI2PSnarkServlet.appendActionsHeader(StringBuilder buf, List<Snark> snarks, boolean isConnected, boolean noSnarks, String txtStartAll, String txtStopAll, String txtStopAllTitle, String txtStartAllTitle, String txtStartStoppedTitle) Action column: Stop All always when connected; Start All variants depending on whether any listed torrent is stopped.private StringI2PSnarkServlet.appendSnarkHeader(HttpServletRequest req, List<Snark> snarks, int start, int pageSize, String filterParam, String peerParam, String currentSort, String contextPath) Builds the HTML table header row for the torrent list display, including sortable column headers, peer toggling links, and activity indicators.I2PSnarkServlet.scanTorrentActivity(List<Snark> snarks, int start, int pageSize, int total) Scans the page slice for peer/rate activity, exiting early once every flag is set.I2PSnarkServlet.search(String search, Collection<Snark> snarks) Search torrents for matching terms.Constructors in org.klomp.snark.web with parameters of type SnarkModifierConstructorDescription(package private)CommentsContext(Snark snark, boolean er, boolean ec, boolean esc, String authorName, boolean canRate) Captures the comment and rating settings in force for one torrent.(package private)PeerRowContext(Snark snark, MetaInfo meta, boolean noThinsp) Captures the torrent and metadata needed to render one peer row.(package private)RowContext(Snark snark, int index, boolean showPeers, long[] stats, boolean noThinsp, boolean canWrite, String filterParam, String sortParam, Map<ByteArray, I2PSnarkServlet.BadgeInfo> badgeCache, String token) Holds what one download row needs.