java.lang.Object
org.klomp.snark.UpdateHandler
All Implemented Interfaces:
Updater

class UpdateHandlerextends Object implements Updater
Handles the request to update the router by firing up a magnet. EepGet calls to download the latest signed update file and displaying the status to anyone who asks.

After the download completes the signed update file is verified with TrustedUpdate, and if it's authentic the payload of the signed update file is unpacked and the router is restarted to complete the update process. This does not do any checking, that is handled by the NewsFetcher.

  • Field Details

    • _context

      private final I2PAppContext _context
      The context the update manager runs in.
    • _umgr

      private final UpdateManager _umgr
      The manager that checks and installs updates.
    • _smgr

      private final SnarkManager _smgr
      The torrents paused while an update is installed.
  • Constructor Details

    • UpdateHandler

      public UpdateHandler(I2PAppContext ctx, UpdateManager umgr, SnarkManager smgr)
      Wire an updater to the router's update manager and the torrent client.
      Parameters:
      ctx - the application context used by the download and the torrent client
      umgr - the update manager that tracks and cancels running update tasks
      smgr - the torrent client that fetches the signed update file by magnet
  • Method Details

    • update

      public UpdateTask update(UpdateType type, UpdateMethod method, List<URI> updateSources, String id, String newVersion, long maxTime)
      Start a download and return a handle to the download task. Should not block.
      Specified by:
      update in interface Updater
      Parameters:
      type - selects what is being fetched, e.g. UpdateType.ROUTER_SIGNED
      method - how it is fetched, e.g. UpdateMethod.HTTP over I2P
      updateSources - Where to get the new version from
      id - plugin name or ignored
      newVersion - new version to download
      maxTime - how long you have
      Returns:
      active task or null if unable to download