java.lang.Object
net.i2p.i2pcontrol.I2PControlController
All Implemented Interfaces:
ClientApp, RouterApp

public class I2PControlControllerextends Object implements RouterApp
This handles the starting and stopping of Jetty from a single static class so it can be called via clients.config. This makes installation of a new eepsite a turnkey operation. This class is NOT used for the webapp or the bare ServerSocket implementation.
  • Field Details

    • _appContext

      private final I2PAppContext _appContext
      The app context, never null.
    • _context

      private final RouterContext _context
      The router context, null when run standalone in an app context.
    • _mgr

      private final ClientAppManager _mgr
      The manager that starts the apps.
    • _log

      private final Log _log
      Logger for the I2PControl server.
    • _pluginDir

      private final String _pluginDir
      Directory holding the plugin configs.
    • _conf

      private final ConfigurationManager _conf
      The configuration manager.
    • _ksp

      private final KeyStoreProvider _ksp
      Provider of the TLS key store.
    • _secMan

      private final SecurityManager _secMan
      The jetty security manager.
    • _server

      private final Server _server
      The embedded jetty server.
    • _state

      private ClientAppState _state
      Current state of the app.
    • PROP_ALLOWED_HOSTS

      static final String PROP_ALLOWED_HOSTS
      Allowed hosts config property
      See Also:
    • SVC_HTTPS_I2PCONTROL

      private static final String SVC_HTTPS_I2PCONTROL
      Port mapper name of the HTTPS service.
      See Also:
    • DEFAULT_PORT

      private static final int DEFAULT_PORT
      Default HTTPS port of the API.
      See Also:
  • Constructor Details

    • I2PControlController

      public I2PControlController(RouterContext ctx, ClientAppManager mgr)
      RouterApp (new way)
      Parameters:
      ctx - the router context, also adopted as the application context
      mgr - the client app manager to register this service with
  • Method Details

    • startup

      public void startup()
      Start the Jetty server
      Specified by:
      startup in interface ClientApp
    • shutdown

      public void shutdown(String[] args)
      Stop the Jetty server
      Specified by:
      shutdown in interface ClientApp
      Parameters:
      args - generally null but could be stopArgs from clients.config
    • getState

      public ClientAppState getState()
      Current state of the managed client app.
      Specified by:
      getState in interface ClientApp
      Returns:
      the current state of this app
    • getName

      public String getName()
      Unique name of the client app.
      Specified by:
      getName in interface ClientApp
      Returns:
      "I2PControl"
    • getDisplayName

      public String getDisplayName()
      Display name of the client app.
      Specified by:
      getDisplayName in interface ClientApp
      Returns:
      "I2PControl"
    • changeState

      private void changeState(ClientAppState state)
      Change the app state and notify the update manager.
      Parameters:
      state - the new state of the app
    • changeState

      private void changeState(ClientAppState state, String msg, Exception e)
      Changes the app state and notifies listeners.
      Parameters:
      state - the new state
      msg - the message for the listeners
      e - the exception, null if none
    • start

      private void start() throws Exception
      Starts the jetty server.
      Throws:
      Exception - if the server cannot be started
    • buildDefaultListener

      private Connector buildDefaultListener(Server server)
      Builds the default SSL connector from the current configuration. The connector is neither added to a server nor started here; only buildServer() does that.
      Parameters:
      server - the server the connector is created for, may be null
      Returns:
      the new connector
    • buildServer

      public Server buildServer()
      Builds a new server. Used for changing ports during operation and such. Does NOT start the server. Must call start() on the returned server.
      Returns:
      Server - A new server built from current configuration.
    • buildSslListener

      private Connector buildSslListener(Server server, String address, int port)
      Creates a SSLListener with all the default options. The listener will use all the default options.
      Parameters:
      server - the server to add the connector to, may be null
      address - - The address the listener will listen to.
      port - - The port the listener will listen to.
      Returns:
      - Newly created listener
    • stopServer

      private void stopServer()
      Stop it
    • stop

      private void stop()
      Stops the jetty server.
    • getPluginDir

      public String getPluginDir()
      Report the directory the plugin subsystem was started with, where each plugin's own configuration and data are kept.
      Returns:
      plugin directory path