net.i2p.i2ptunnel
Class TunnelController

java.lang.Object
  extended by net.i2p.i2ptunnel.TunnelController
All Implemented Interfaces:
Logging

public class TunnelController
extends Object
implements 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
static String KEY_BACKUP_DIR
           
static String PFX_OPTION
           
static SigType PREFERRED_SIGTYPE
          This is guaranteed to be available.
static String PROP_DESCR
          all of these @since 0.9.14
static String PROP_DEST
           
static String PROP_FILE
           
static String PROP_I2CP_HOST
           
static String PROP_I2CP_PORT
           
static String PROP_INTFC
           
static String PROP_LISTEN_PORT
           
static String PROP_NAME
           
static String PROP_PROXIES
           
static String PROP_SHARED
           
static String PROP_SPOOFED_HOST
           
static String PROP_START
           
static String PROP_TARGET_HOST
           
static String PROP_TARGET_PORT
           
static String PROP_TYPE
           
static String TYPE_CONNECT
          all of these @since 0.9.14
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_CLIENT
          Client in the UI and I2P side but a server on the localhost side
static String TYPE_STREAMR_SERVER
          Server in the UI and I2P side but a client on the localhost side
 
Constructor Summary
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)
          Defaults in config properties are not recommended, they may or may not be honored.
 
Method Summary
 List<String> clearMessages()
          Pull off any messages that the I2PTunnel has produced
 void destroyTunnel()
          May NOT be restarted with restartTunnel() or startTunnel() later.
 Properties getClientOptionProps()
          These are the ones stored with a prefix of "option." Defaults in config properties are not honored.
 String getClientOptions()
          Deprecated. why would you want this? Use getClientOptionProps() instead
 Properties getConfig(String prefix)
           
 String getDescription()
           
 Destination getDestination()
          Returns null if not running.
 String getI2CPHost()
           
 String getI2CPPort()
           
 boolean getIsRunning()
           
 boolean getIsStandby()
          if running but no open sessions, we are in standby
 boolean getIsStarting()
           
 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()
           
 String getSharedClient()
          default true
 String getSpoofedHost()
           
 boolean getStartOnLoad()
          default true
 void getSummary(StringBuilder buf)
          Deprecated. unused
 String getTargetDestination()
           
 String getTargetHost()
           
 String getTargetPort()
           
 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)
           
 void restartTunnel()
           
 void setConfig(Properties config, String prefix)
          As of 0.9.1, updates the options on an existing session
 void startTunnel()
          Start up the tunnel (if it isn't already running)
 void startTunnelBackground()
           
 void stopTunnel()
          May be restarted with restartTunnel() or startTunnel() later.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

KEY_BACKUP_DIR

public static final String KEY_BACKUP_DIR
See Also:
Constant Field Values

PROP_DESCR

public static final String PROP_DESCR
all of these @since 0.9.14

See Also:
Constant Field Values

PROP_DEST

public static final String PROP_DEST
See Also:
Constant Field Values

PROP_I2CP_HOST

public static final String PROP_I2CP_HOST
See Also:
Constant Field Values

PROP_I2CP_PORT

public static final String PROP_I2CP_PORT
See Also:
Constant Field Values

PROP_INTFC

public static final String PROP_INTFC
See Also:
Constant Field Values

PROP_FILE

public static final String PROP_FILE
See Also:
Constant Field Values

PROP_LISTEN_PORT

public static final String PROP_LISTEN_PORT
See Also:
Constant Field Values

PROP_NAME

public static final String PROP_NAME
See Also:
Constant Field Values

PROP_PROXIES

public static final String PROP_PROXIES
See Also:
Constant Field Values

PROP_SHARED

public static final String PROP_SHARED
See Also:
Constant Field Values

PROP_SPOOFED_HOST

public static final String PROP_SPOOFED_HOST
See Also:
Constant Field Values

PROP_START

public static final String PROP_START
See Also:
Constant Field Values

PROP_TARGET_HOST

public static final String PROP_TARGET_HOST
See Also:
Constant Field Values

PROP_TARGET_PORT

public static final String PROP_TARGET_PORT
See Also:
Constant Field Values

PROP_TYPE

public static final String PROP_TYPE
See Also:
Constant Field Values

PFX_OPTION

public static final String PFX_OPTION
Since:
0.9.14
See Also:
Constant Field Values

TYPE_CONNECT

public static final String TYPE_CONNECT
all of these @since 0.9.14

See Also:
Constant Field Values

TYPE_HTTP_BIDIR_SERVER

public static final String TYPE_HTTP_BIDIR_SERVER
See Also:
Constant Field Values

TYPE_HTTP_CLIENT

public static final String TYPE_HTTP_CLIENT
See Also:
Constant Field Values

TYPE_HTTP_SERVER

public static final String TYPE_HTTP_SERVER
See Also:
Constant Field Values

TYPE_IRC_CLIENT

public static final String TYPE_IRC_CLIENT
See Also:
Constant Field Values

TYPE_IRC_SERVER

public static final String TYPE_IRC_SERVER
See Also:
Constant Field Values

TYPE_SOCKS

public static final String TYPE_SOCKS
See Also:
Constant Field Values

TYPE_SOCKS_IRC

public static final String TYPE_SOCKS_IRC
See Also:
Constant Field Values

TYPE_STD_CLIENT

public static final String TYPE_STD_CLIENT
See Also:
Constant Field Values

TYPE_STD_SERVER

public static final String TYPE_STD_SERVER
See Also:
Constant Field Values

TYPE_STREAMR_CLIENT

public static final String TYPE_STREAMR_CLIENT
Client in the UI and I2P side but a server on the localhost side

See Also:
Constant Field Values

TYPE_STREAMR_SERVER

public static final String TYPE_STREAMR_SERVER
Server in the UI and I2P side but a client on the localhost side

See Also:
Constant Field Values

PREFERRED_SIGTYPE

public static final SigType PREFERRED_SIGTYPE
This is guaranteed to be available.

Since:
0.9.17
Constructor Detail

TunnelController

public TunnelController(Properties config,
                        String prefix)
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) Defaults in config properties are not recommended, they may or may not be honored.

Parameters:
config - original key=value mapping non-null
prefix - beginning of key values that are relevant to this tunnel

TunnelController

public TunnelController(Properties config,
                        String prefix,
                        boolean createKey)
Defaults in config properties are not recommended, they may or may not be honored.

Parameters:
config - original key=value mapping non-null
prefix - beginning of key values that are relevant to this tunnel
createKey - 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 Detail

startTunnelBackground

public void startTunnelBackground()

startTunnel

public void startTunnel()
Start up the tunnel (if it isn't already running)


getClientOptionProps

public Properties 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

public void setConfig(Properties config,
                      String prefix)
As of 0.9.1, updates the options on an existing session


getConfig

public Properties getConfig(String prefix)
Returns:
a copy

getType

public String getType()

getName

public String getName()

getDescription

public String getDescription()

getI2CPHost

public String getI2CPHost()

getI2CPPort

public String getI2CPPort()

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

public 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. Note that a streamr server is a UI and I2P server but a client on the localhost side.

Since:
0.9.17 moved from IndexBean

getClientOptions

public String getClientOptions()
Deprecated. why would you want this? Use getClientOptionProps() instead

These are the ones with a prefix of "option."

Returns:
one big string of "key=val key=val ..."

getListenOnInterface

public String getListenOnInterface()

getTargetHost

public String getTargetHost()

getTargetPort

public String getTargetPort()

getSpoofedHost

public String getSpoofedHost()

getPrivKeyFile

public String getPrivKeyFile()
Probably not absolute. May be null. getPrivateKeyFile() recommended.


getListenPort

public String getListenPort()

getTargetDestination

public String getTargetDestination()

getProxyList

public String getProxyList()

getSharedClient

public String getSharedClient()
default true


getStartOnLoad

public boolean getStartOnLoad()
default true


getPersistentClientKey

public boolean getPersistentClientKey()

getPrivateKeyFile

public File getPrivateKeyFile()
Does not necessarily exist.

Returns:
absolute path or null if unset
Since:
0.9.17

getMyDestination

public String getMyDestination()
Returns null if not running.

Returns:
Base64 or null

getMyDestHashBase32

public String getMyDestHashBase32()
Returns null if not running.

Returns:
"{52 chars}.b32.i2p" or null

getDestination

public Destination getDestination()
Returns null if not running.

Returns:
Destination or null
Since:
0.9.17

getIsRunning

public boolean getIsRunning()

getIsStarting

public boolean getIsStarting()

getIsStandby

public boolean getIsStandby()
if running but no open sessions, we are in standby


getSummary

public void getSummary(StringBuilder buf)
Deprecated. unused

A text description of the tunnel.


log

public void log(String s)
Specified by:
log in interface Logging

clearMessages

public List<String> clearMessages()
Pull off any messages that the I2PTunnel has produced

Returns:
list of messages pulled off (each is a String, earliest first)

toString

public String toString()
Overrides:
toString in class Object
Since:
0.9.15