java.lang.Object
net.i2p.router.web.UpdateHandler

public class UpdateHandlerextends Object

Handles the request to update the router by firing one or more EepGet calls to download the latest signed update file and display 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 is like a FormHandler but we don't extend it, as we don't have the message area, etc.

  • Field Details

    • _context

      protected RouterContext _context
      Router context backing this handler's update pages.
    • _log

      protected Log _log
      Log scoped to this handler's class.
    • _action

      private String _action
      What the form asked for.
    • _nonce

      private String _nonce
      Nonce proving the form came from this router.
    • _session

      private HttpSession _session
      Session the update is being checked on.
  • Constructor Details

    • UpdateHandler

      public UpdateHandler()
      Binds the router context taken from the servlet context.
    • UpdateHandler

      public UpdateHandler(RouterContext ctx)
      Binds the given router context and takes its log from it.
      Parameters:
      ctx - router context whose log manager backs this handler
  • Method Details

    • storeSession

      public void storeSession(HttpSession session)
      For form validation.
      Parameters:
      session - the console HTTP session the nonce is validated against
    • updateManager

      public static ConsoleUpdateManager updateManager(RouterContext ctx)
      Fetch the update manager that the update pages write to, without starting it.
      Parameters:
      ctx - router context whose client app manager holds the update manager
      Returns:
      null if not found
    • setContextId

      public void setContextId(String contextId)
      Configure this bean to query a particular router context.
      Parameters:
      contextId - beginning few characters of the routerHash, or null to pick the first one we come across.
    • setUpdateAction

      public void setUpdateAction(String val)
      These two can be set in either order, so call checkUpdateAction() twice.
      Parameters:
      val - the update action name submitted by the form
    • setUpdateNonce

      public void setUpdateNonce(String nonce)
      Records the submitted nonce and re-checks the pending action.
      Parameters:
      nonce - the nonce submitted by the form, checked against the issued one
    • setConsoleNonce

      public void setConsoleNonce(String nonce)
      Alias for setUpdateNonce for session-based nonce support.
      Parameters:
      nonce - the nonce submitted by the form, checked against the session
    • checkUpdateAction

      private void checkUpdateAction()
      These two can be set in either order, so call checkUpdateAction() twice storeSession(HttpSession) MUST be called first.
    • update

      private void update(UpdateType type)
      Starts an update of the given kind.
      Parameters:
      type - what to update