java.lang.Object
net.i2p.i2pcontrol.SocketController
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate classHandles one connected client.Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ConfigurationManagerThe configuration manager used.private final RouterContextThe router context, never null.private final KeyStoreProviderThe key store provider used.The sockets of the connected clients.private final LogLogger for the control socket.private final ClientAppManagerThe manager that starts the app.private final StringDirectory of the installed plugins.private final SecurityManagerThe security manager used.private ServerSocketThe listening socket, while running.private ClientAppStateCurrent state of the app.private static final intDefault control socket port.(package private) static final StringAllowed hosts config propertyprivate static final StringService name of the control port.Constructor Summary
ConstructorsMethod Summary
Modifier and TypeMethodDescriptionBuilds a new server.private voidchangeState(ClientAppState state) Changes the app state with no result or error.private voidchangeState(ClientAppState state, String msg, Exception e) Changes the app state and notifies listeners.Display name of the client app.getName()Unique name of the client app.getState()Current state of the managed client app.voidStop the socket serverprivate voidstart()Opens the control socket and accepts clients.voidstartup()Start the socket serverprivate voidstop()Closes the control socket and the clients.private voidStop it
Field Details
_context
The router context, never null._mgr
The manager that starts the app._log
Logger for the control socket._pluginDir
Directory of the installed plugins._conf
The configuration manager used._ksp
The key store provider used._secMan
The security manager used._server
The listening socket, while running._listeners
_state
Current state of the app.PROP_ALLOWED_HOSTS
SVC_SKT_I2PCONTROL
Service name of the control port.- See Also:
DEFAULT_PORT
Constructor Details
SocketController
RouterApp (new way)- Parameters:
ctx- the router context supplying the log manager and config directorymgr- the client app manager notified of state changes, or null when run outside the client app framework- Throws:
IOException- declared by the client app instantiation contract, though this constructor body performs no failing I/O
Method Details
startup
shutdown
getState
Current state of the managed client app.getName
getDisplayName
Display name of the client app.- Specified by:
getDisplayNamein interfaceClientApp- Returns:
- "I2PControl-Socket"
changeState
Changes the app state with no result or error.- Parameters:
state- the new state of the client app
changeState
Changes the app state and notifies listeners.- Parameters:
state- the new statemsg- the message for the listenerse- the exception, null if none
start
buildServer
Builds a new server. Used for changing ports during operation and such. Does NOT start the server. Must callstart()on the returned server.- Returns:
- Server - A new server built from current configuration.
- Throws:
IOException- if the configured listen address cannot be resolved, the configured port is already bound, or the configuration file cannot be written back
stopServer
private void stopServer()Stop itstop
private void stop()Closes the control socket and the clients.