public class TunnelController extends Object implements Logging
| Modifier and Type | Class and Description |
|---|---|
static class | TunnelController.TunnelStateThe tunnel state. |
| Modifier and Type | Field and Description |
|---|---|
static int | DEFAULT_MAX_CONNS_DAY |
static int | DEFAULT_MAX_CONNS_HOUR |
static int | DEFAULT_MAX_CONNS_MIN |
static int | DEFAULT_MAX_STREAMS |
static int | DEFAULT_MAX_TOTAL_CONNS_DAY |
static int | DEFAULT_MAX_TOTAL_CONNS_HOUR |
static int | DEFAULT_MAX_TOTAL_CONNS_MIN |
static int | DEFAULT_SHUTDOWN_DELAY_MAXDefault maximum shutdown delay in seconds |
static int | DEFAULT_SHUTDOWN_DELAY_MINDefault minimum shutdown delay in seconds |
static int | DEFAULT_STARTUP_DELAY_MAXDefault maximum startup delay in seconds |
static int | DEFAULT_STARTUP_DELAY_MINDefault minimum startup delay in seconds |
static String | KEY_BACKUP_DIRKey backup directory name. |
static String | OPT_BUNDLE_REPLYConfig key to bundle reply keys. |
static String | OPT_POST_MAXConfig key for max posts (delegated to HTTPServer). |
static String | OPT_POST_TOTAL_MAXConfig key for max total posts (delegated to HTTPServer). |
static String | PFX_OPTIONP f x o p t i o n |
static SigType | PREFERRED_SIGTYPEThis is guaranteed to be available. |
static String | PROP_CONFIG_FILEP r o p c o n f i g f i l e |
static String | PROP_DESCRall of these |
static String | PROP_DEST |
static String | PROP_FILE |
static String | PROP_FILTER |
static String | PROP_I2CP_HOST |
static String | PROP_I2CP_PORT |
static String | PROP_INTFC |
static String | PROP_LIMIT_ACTIONP r o p l i m i t a c t i o n |
static String | PROP_LIMITS_SET |
static String | PROP_LISTEN_PORT |
static String | PROP_MAX_CONNS_DAY |
static String | PROP_MAX_CONNS_HOUR |
static String | PROP_MAX_CONNS_MINall of these are (moved from TunnelConfig) |
static String | PROP_MAX_STREAMS |
static String | PROP_MAX_TOTAL_CONNS_DAY |
static String | PROP_MAX_TOTAL_CONNS_HOUR |
static String | PROP_MAX_TOTAL_CONNS_MIN |
static String | PROP_NAME |
static String | PROP_PROXIES |
static String | PROP_SHARED |
static String | PROP_SHUTDOWN_DELAY_MAXConfiguration property for the maximum shutdown delay in seconds. |
static String | PROP_SHUTDOWN_DELAY_MINConfiguration property for the minimum shutdown delay in seconds. |
static String | PROP_SPOOFED_HOST |
static String | PROP_START |
static String | PROP_STARTUP_DELAY_MAXConfiguration property for the maximum startup delay in seconds. |
static String | PROP_STARTUP_DELAY_MINConfiguration property for the minimum startup delay in seconds. |
static String | PROP_TARGET_HOST |
static String | PROP_TARGET_PORT |
static String | PROP_TUN_GZIPP r o p t u n g z i p |
static String | PROP_TYPE |
static String | TYPE_CONNECTall of these |
static String | TYPE_HTTP_BIDIR_SERVER |
static String | TYPE_HTTP_CLIENT |
static String | TYPE_HTTP_SERVER |
static String | TYPE_IRC_CLIENT |
static String | TYPE_IRC_SERVER |
static String | TYPE_SOCKS |
static String | TYPE_SOCKS_IRC |
static String | TYPE_STD_CLIENT |
static String | TYPE_STD_SERVER |
static String | TYPE_STREAMR_CLIENTClient in the UI and I2P side but a server on the localhost side |
static String | TYPE_STREAMR_SERVERServer in the UI and I2P side but a client on the localhost side |
| Constructor and Description |
|---|
TunnelController(Properties config,
String prefix)Create a new controller for a tunnel out of the specific config options. |
TunnelController(Properties config,
String prefix,
boolean createKey)Create a new controller for a tunnel out of the specific config options. |
| Modifier and Type | Method and Description |
|---|---|
void | changeState(TunnelController.TunnelState state)Void |
List<String> | clearMessages()Pull off any messages that the I2PTunnel has produced |
void | destroyTunnel()May NOT be restarted with restartTunnel() or startTunnel() later. |
(package private) static File | filenameToFile(String f)Does not necessarily exist. |
File | getAlternatePrivateKeyFile()Does not necessarily exist. |
Properties | getClientOptionProps()These are the ones stored with a prefix of "option."
Defaults in config properties are not honored. |
Properties | getConfig(String prefix) |
File | getConfigFile() |
String | getDescription() |
Destination | getDestination()Returns null if not running. |
String | getFilter()Absolute path to filter definition file |
String | getI2CPHost() |
String | getI2CPPort() |
boolean | getIsOfflineKeys()Returns false if not running. |
boolean | getIsRunning()Checks if the tunnel is currently running. |
boolean | getIsStandby()Checks if the tunnel is in standby mode. |
boolean | getIsStarting()Checks if the tunnel is starting or starting on load. |
String | getListenOnInterface() |
String | getListenPort() |
String | getMyDestHashBase32()Returns null if not running. |
String | getMyDestination()Returns null if not running. |
String | getName() |
boolean | getPersistentClientKey() |
File | getPrivateKeyFile()Does not necessarily exist. |
String | getPrivKeyFile()Probably not absolute. |
String | getProxyList() |
int | getRemainingStartupDelay()Get the remaining startup delay time for tunnels with delayed startup. |
String | getSharedClient()default true for clients, always false for servers |
int | getShutdownDelayMax()When combined with a positive shutdownDelayMin less than this value,
the tunnel will stop with a random delay between min and max seconds during router shutdown. |
int | getShutdownDelayMin()When combined with a greater shutdownDelayMax, the tunnel will stop
with a random delay between min and max seconds during router shutdown. |
String | getSpoofedHost() |
boolean | getStartOnLoad() |
int | getStartupDelayMax()When combined with a positive startupDelayMin less than this value,
the tunnel will start with a random delay between min and max seconds. |
int | getStartupDelayMin()When combined with a greater startupDelayMax, the tunnel will start
with a random delay between min and max seconds. |
TunnelController.TunnelState | getState()Gets the current tunnel state. |
String | getTargetDestination() |
String | getTargetHost() |
String | getTargetPort() |
I2PTunnel | getTunnel()The I2PTunnel
for advanced plugin usage |
String | getType() |
boolean | isClient()Is it a client or server in the UI and I2P side?
Note that a streamr client is a UI and I2P client but a server on the localhost side. |
static boolean | isClient(String type)Is it a client or server in the UI and I2P side?
Note that a streamr client is a UI and I2P client but a server on the localhost side. |
void | log(String s)Log a message. |
void | restartTunnel()Stops and restarts the tunnel. |
void | restoreLog()Restore log messages after restart |
void | setConfig(Properties config,
String prefix)As of 0.9.1, updates the options on an existing session |
void | setConfigFile(File file)Set the config file. |
(package private) void | setStartupDelayEndTime(long delayMs)Set the startup delay end time. |
void | startTunnel()Start up the tunnel (if it isn't already running) |
void | startTunnelBackground()Starts the tunnel in a background thread. |
void | stopTunnel()May be restarted with restartTunnel() or startTunnel() later. |
void | suppressLog()Suppress log messages during restart |
String | toString() |
public static final int DEFAULT_MAX_CONNS_DAY
public static final int DEFAULT_MAX_CONNS_HOUR
public static final int DEFAULT_MAX_CONNS_MIN
public static final int DEFAULT_MAX_STREAMS
public static final int DEFAULT_MAX_TOTAL_CONNS_DAY
public static final int DEFAULT_MAX_TOTAL_CONNS_HOUR
public static final int DEFAULT_MAX_TOTAL_CONNS_MIN
public static final int DEFAULT_SHUTDOWN_DELAY_MAX
public static final int DEFAULT_SHUTDOWN_DELAY_MIN
public static final int DEFAULT_STARTUP_DELAY_MAX
public static final int DEFAULT_STARTUP_DELAY_MIN
public static final String KEY_BACKUP_DIR
public static final String OPT_BUNDLE_REPLY
public static final String OPT_POST_MAX
public static final String OPT_POST_TOTAL_MAX
public static final String PFX_OPTION
public static final SigType PREFERRED_SIGTYPE
public static final String PROP_CONFIG_FILE
public static final String PROP_DESCR
public static final String PROP_DEST
public static final String PROP_FILE
public static final String PROP_FILTER
public static final String PROP_I2CP_HOST
public static final String PROP_I2CP_PORT
public static final String PROP_INTFC
public static final String PROP_LIMIT_ACTION
public static final String PROP_LIMITS_SET
public static final String PROP_LISTEN_PORT
public static final String PROP_MAX_CONNS_DAY
public static final String PROP_MAX_CONNS_HOUR
public static final String PROP_MAX_CONNS_MIN
public static final String PROP_MAX_STREAMS
public static final String PROP_MAX_TOTAL_CONNS_DAY
public static final String PROP_MAX_TOTAL_CONNS_HOUR
public static final String PROP_MAX_TOTAL_CONNS_MIN
public static final String PROP_NAME
public static final String PROP_PROXIES
public static final String PROP_SHARED
public static final String PROP_SHUTDOWN_DELAY_MAX
public static final String PROP_SHUTDOWN_DELAY_MIN
public static final String PROP_SPOOFED_HOST
public static final String PROP_START
public static final String PROP_STARTUP_DELAY_MAX
public static final String PROP_STARTUP_DELAY_MIN
public static final String PROP_TARGET_HOST
public static final String PROP_TARGET_PORT
public static final String PROP_TUN_GZIP
public static final String PROP_TYPE
public static final String TYPE_CONNECT
public static final String TYPE_HTTP_BIDIR_SERVER
public static final String TYPE_HTTP_CLIENT
public static final String TYPE_HTTP_SERVER
public static final String TYPE_IRC_CLIENT
public static final String TYPE_IRC_SERVER
public static final String TYPE_SOCKS
public static final String TYPE_SOCKS_IRC
public static final String TYPE_STD_CLIENT
public static final String TYPE_STD_SERVER
public static final String TYPE_STREAMR_CLIENT
public static final String TYPE_STREAMR_SERVER
public TunnelController(Properties config, String prefix)
config - original key=value mapping non-nullprefix - beginning of key values that are relevant to this tunnelpublic TunnelController(Properties config, String prefix, boolean createKey)
config - original key=value mapping non-nullprefix - beginning of key values that are relevant to this tunnelcreateKey - for servers, whether we want to create a brand new destination
with private keys at the location specified or not (does not
overwrite existing ones)public void changeState(TunnelController.TunnelState state)
public List<String> clearMessages()
public void destroyTunnel()
static File filenameToFile(String f)
f - relative or absolute path, may be nullpublic File getAlternatePrivateKeyFile()
public Properties getClientOptionProps()
public Properties getConfig(String prefix)
public File getConfigFile()
public String getDescription()
public Destination getDestination()
public String getFilter()
public String getI2CPHost()
public String getI2CPPort()
public boolean getIsOfflineKeys()
public boolean getIsRunning()
public boolean getIsStandby()
A tunnel is in standby when it is running but has no open sessions.
public boolean getIsStarting()
public String getListenOnInterface()
public String getListenPort()
public String getMyDestHashBase32()
public String getMyDestination()
public String getName()
public boolean getPersistentClientKey()
public File getPrivateKeyFile()
public String getPrivKeyFile()
public String getProxyList()
public int getRemainingStartupDelay()
public String getSharedClient()
public int getShutdownDelayMax()
public int getShutdownDelayMin()
public String getSpoofedHost()
public boolean getStartOnLoad()
public int getStartupDelayMax()
public int getStartupDelayMin()
public TunnelController.TunnelState getState()
public String getTargetDestination()
public String getTargetHost()
public String getTargetPort()
public I2PTunnel getTunnel()
public String getType()
public boolean isClient()
public static boolean isClient(String type)
public void restartTunnel()
This method stops the tunnel if running, waits briefly, then starts the tunnel again. The restart is performed synchronously, blocking until complete.
startTunnel(),
stopTunnel()public void restoreLog()
public void setConfig(Properties config, String prefix)
public void setConfigFile(File file)
void setStartupDelayEndTime(long delayMs)
delayMs - the delay in millisecondspublic void startTunnel()
public void startTunnelBackground()
This method spawns a new thread to start the tunnel, allowing the calling thread to return immediately. The tunnel state transitions to STARTING, and the actual startup is performed in the background thread.
startTunnel()public void stopTunnel()
public void suppressLog()