Package net.i2p.i2ptunnel
Class TunnelController
java.lang.Object
net.i2p.i2ptunnel.TunnelController
- All Implemented Interfaces:
Logging
Coordinate the runtime operation and configuration of a single I2PTunnel.
An I2PTunnel tracks one or more I2PTunnelTasks and one or more I2PSessions.
Usually one of each.
These objects are bundled together under a TunnelControllerGroup where the
entire group is stored / loaded from a single config file.
This is the class used by several plugins to create tunnels, so
take care to maintain the public methods as a stable API.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
static final int
static final int
static final int
static final int
static final int
static final int
static final String
static final String
static final String
static final String
static final String
static final SigType
This is guaranteed to be available.static final String
static final String
all of these @since 0.9.14static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
all of these are @since 0.9.33 (moved from TunnelConfig)static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
all of these @since 0.9.14static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
Client in the UI and I2P side but a server on the localhost sidestatic final String
Server in the UI and I2P side but a client on the localhost side -
Constructor Summary
ConstructorDescriptionTunnelController
(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. -
Method Summary
Modifier and TypeMethodDescriptionPull off any messages that the I2PTunnel has producedvoid
May NOT be restarted with restartTunnel() or startTunnel() later.(package private) static File
Does not necessarily exist.Does not necessarily exist.These are the ones stored with a prefix of "option." Defaults in config properties are not honored.Deprecated.why would you want this? Use getClientOptionProps() insteadReturns null if not running.Absolute path to filter definition fileboolean
Returns false if not running.boolean
boolean
if running but no open sessions, we are in standbyboolean
Returns null if not running.Returns null if not running.getName()
boolean
Does not necessarily exist.Probably not absolute.default true for clients, always false for serversboolean
default truevoid
getSummary
(StringBuilder buf) Deprecated.unusedThe I2PTunnelgetType()
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
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
void
void
setConfig
(Properties config, String prefix) As of 0.9.1, updates the options on an existing sessionvoid
setConfigFile
(File file) Set the config file.void
Start up the tunnel (if it isn't already running)void
void
May be restarted with restartTunnel() or startTunnel() later.toString()
-
Field Details
-
KEY_BACKUP_DIR
- See Also:
-
PROP_DESCR
all of these @since 0.9.14- See Also:
-
PROP_DEST
- See Also:
-
PROP_I2CP_HOST
- See Also:
-
PROP_I2CP_PORT
- See Also:
-
PROP_INTFC
- See Also:
-
PROP_FILE
- See Also:
-
PROP_LISTEN_PORT
- See Also:
-
PROP_NAME
- See Also:
-
PROP_PROXIES
- See Also:
-
PROP_SHARED
- See Also:
-
PROP_SPOOFED_HOST
- See Also:
-
PROP_START
- See Also:
-
PROP_TARGET_HOST
- See Also:
-
PROP_TARGET_PORT
- See Also:
-
PROP_TYPE
- See Also:
-
PROP_FILTER
- See Also:
-
PROP_CONFIG_FILE
- Since:
- 0.9.42
- See Also:
-
PROP_TUN_GZIP
- Since:
- 0.9.46
- See Also:
-
PROP_MAX_CONNS_MIN
all of these are @since 0.9.33 (moved from TunnelConfig)- See Also:
-
PROP_MAX_CONNS_HOUR
- See Also:
-
PROP_MAX_CONNS_DAY
- See Also:
-
PROP_MAX_TOTAL_CONNS_MIN
- See Also:
-
PROP_MAX_TOTAL_CONNS_HOUR
- See Also:
-
PROP_MAX_TOTAL_CONNS_DAY
- See Also:
-
PROP_MAX_STREAMS
- See Also:
-
PROP_LIMITS_SET
- See Also:
-
DEFAULT_MAX_CONNS_MIN
public static final int DEFAULT_MAX_CONNS_MIN- See Also:
-
DEFAULT_MAX_CONNS_HOUR
public static final int DEFAULT_MAX_CONNS_HOUR- See Also:
-
DEFAULT_MAX_CONNS_DAY
public static final int DEFAULT_MAX_CONNS_DAY- See Also:
-
DEFAULT_MAX_TOTAL_CONNS_MIN
public static final int DEFAULT_MAX_TOTAL_CONNS_MIN- See Also:
-
DEFAULT_MAX_TOTAL_CONNS_HOUR
public static final int DEFAULT_MAX_TOTAL_CONNS_HOUR- See Also:
-
DEFAULT_MAX_TOTAL_CONNS_DAY
public static final int DEFAULT_MAX_TOTAL_CONNS_DAY- See Also:
-
DEFAULT_MAX_STREAMS
public static final int DEFAULT_MAX_STREAMS- See Also:
-
PROP_LIMIT_ACTION
- Since:
- 0.9.34
- See Also:
-
PFX_OPTION
- Since:
- 0.9.14
- See Also:
-
OPT_BUNDLE_REPLY
- See Also:
-
OPT_POST_MAX
- See Also:
-
OPT_POST_TOTAL_MAX
- See Also:
-
TYPE_CONNECT
all of these @since 0.9.14- See Also:
-
TYPE_HTTP_BIDIR_SERVER
- See Also:
-
TYPE_HTTP_CLIENT
- See Also:
-
TYPE_HTTP_SERVER
- See Also:
-
TYPE_IRC_CLIENT
- See Also:
-
TYPE_IRC_SERVER
- See Also:
-
TYPE_SOCKS
- See Also:
-
TYPE_SOCKS_IRC
- See Also:
-
TYPE_STD_CLIENT
- See Also:
-
TYPE_STD_SERVER
- See Also:
-
TYPE_STREAMR_CLIENT
Client in the UI and I2P side but a server on the localhost side- See Also:
-
TYPE_STREAMR_SERVER
Server in the UI and I2P side but a client on the localhost side- See Also:
-
PREFERRED_SIGTYPE
This is guaranteed to be available.- Since:
- 0.9.17
-
-
Constructor Details
-
TunnelController
Create a new controller for a tunnel out of the specific config options. The config may contain a large number of options - only ones that begin in the prefix should be used (and, in turn, that prefix should be stripped off before being interpreted by this controller) If config contains the "configFile" property, it will be set as the config path and may be retrieved with getConfigFile(). Defaults in config properties are not recommended, they may or may not be honored.- Parameters:
config
- original key=value mapping non-nullprefix
- beginning of key values that are relevant to this tunnel
-
TunnelController
Create a new controller for a tunnel out of the specific config options. The config may contain a large number of options - only ones that begin in the prefix should be used (and, in turn, that prefix should be stripped off before being interpreted by this controller) If config contains the "configFile" property, it will be set as the config path and may be retrieved with getConfigFile(). Defaults in config properties are not recommended, they may or may not be honored.- Parameters:
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)
-
-
Method Details
-
getTunnel
The I2PTunnel- Since:
- 0.9.53 for advanced plugin usage
-
startTunnelBackground
public void startTunnelBackground() -
startTunnel
public void startTunnel()Start up the tunnel (if it isn't already running) -
getClientOptionProps
These are the ones stored with a prefix of "option." Defaults in config properties are not honored.- Returns:
- keys with the "option." prefix stripped, non-null
- Since:
- 0.9.1 Much better than getClientOptions()
-
stopTunnel
public void stopTunnel()May be restarted with restartTunnel() or startTunnel() later. This may not release all resources. In particular, the I2PSocketManager remains and it may have timer threads that continue running. -
destroyTunnel
public void destroyTunnel()May NOT be restarted with restartTunnel() or startTunnel() later. This should release all resources.- Since:
- 0.9.17
-
restartTunnel
public void restartTunnel() -
setConfig
As of 0.9.1, updates the options on an existing session -
getConfig
- Returns:
- a copy
-
getConfigFile
- Returns:
- the config file as passed into constructor via "configFile" property, or as set later, or null
- Since:
- 0.9.42
-
setConfigFile
Set the config file. Only do this if previously null.- Since:
- 0.9.42
-
getType
-
getName
-
getDescription
-
getI2CPHost
-
getI2CPPort
-
getFilter
Absolute path to filter definition file- Since:
- 0.9.40
-
isClient
public 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. Note that a streamr server is a UI and I2P server but a client on the localhost side.- Since:
- 0.9.17
-
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. Note that a streamr server is a UI and I2P server but a client on the localhost side.- Returns:
- false if type == null
- Since:
- 0.9.17 moved from IndexBean
-
getClientOptions
Deprecated.why would you want this? Use getClientOptionProps() insteadThese are the ones with a prefix of "option."- Returns:
- one big string of "key=val key=val ..."
-
getListenOnInterface
-
getTargetHost
-
getTargetPort
-
getSpoofedHost
-
getPrivKeyFile
Probably not absolute. May be null. getPrivateKeyFile() recommended. -
getListenPort
-
getTargetDestination
-
getProxyList
-
getStartOnLoad
public boolean getStartOnLoad()default true -
getPersistentClientKey
public boolean getPersistentClientKey() -
getPrivateKeyFile
Does not necessarily exist.- Returns:
- absolute path or null if unset
- Since:
- 0.9.17
-
getAlternatePrivateKeyFile
Does not necessarily exist.- Returns:
- absolute path or null if unset
- Since:
- 0.9.30
-
filenameToFile
Does not necessarily exist.- Parameters:
f
- relative or absolute path, may be null- Returns:
- absolute path or null
- Since:
- 0.9.30
-
getMyDestination
Returns null if not running.- Returns:
- Base64 or null
-
getMyDestHashBase32
Returns null if not running.- Returns:
- "{52 chars}.b32.i2p" or null
-
getDestination
Returns null if not running.- Returns:
- Destination or null
- Since:
- 0.9.17
-
getIsOfflineKeys
public boolean getIsOfflineKeys()Returns false if not running.- Returns:
- true if the primary session has offline keys
- Since:
- 0.9.40
-
getIsRunning
public boolean getIsRunning() -
getIsStarting
public boolean getIsStarting() -
getIsStandby
public boolean getIsStandby()if running but no open sessions, we are in standby -
getSummary
Deprecated.unusedA text description of the tunnel. -
log
-
clearMessages
Pull off any messages that the I2PTunnel has produced- Returns:
- list of messages pulled off (each is a String, earliest first)
-
toString
-