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

public class TunnelControllerextends 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 Details

    • _log

      private final Log _log
      Logger for the tunnel controller.
    • _config

      private Properties _config
      The tunnel's configuration properties.
    • _configFile

      private File _configFile
      File the configuration is saved to.
    • _tunnel

      private final I2PTunnel _tunnel
      The tunnel object being controlled.
    • _messages

      private final List<String> _messages
      Status messages shown on the tunnel page.
    • _sessions

      private List<I2PSession> _sessions
      The tunnel's open I2CP sessions.
    • _state

      private volatile TunnelController.TunnelState _state
      Current state of the tunnel.
    • _pkfc

      private volatile SimpleTimer2.TimedEvent _pkfc
      The queued private key file check event.
    • _startupDelayEndTime

      private volatile long _startupDelayEndTime
      When the startup delay ends, zero while running.
    • _suppressLog

      private boolean _suppressLog
      Suppress log messages during tunnel restart.
    • KEY_BACKUP_DIR

      public static final String KEY_BACKUP_DIR
      Key backup directory name.
      See Also:
    • PROP_DESCR

      public static final String PROP_DESCR
      Human-readable description, shown in the tunnel list.
      See Also:
    • PROP_DEST

      public static final String PROP_DEST
      Base64-encoded I2P destination, for the client types that require one.
      See Also:
    • PROP_I2CP_HOST

      public static final String PROP_I2CP_HOST
      Host the router's I2CP listener is on.
      See Also:
    • PROP_I2CP_PORT

      public static final String PROP_I2CP_PORT
      Port the router's I2CP listener is on.
      See Also:
    • PROP_INTFC

      public static final String PROP_INTFC
      Local interface the tunnel binds its localhost side to.
      See Also:
    • PROP_FILE

      public static final String PROP_FILE
      Path to the private key file, which may be relative.
      See Also:
    • PROP_LISTEN_PORT

      public static final String PROP_LISTEN_PORT
      Local port the tunnel's localhost side listens on.
      See Also:
    • PROP_NAME

      public static final String PROP_NAME
      Display name of the tunnel.
      See Also:
    • PROP_PROXIES

      public static final String PROP_PROXIES
      Comma-separated proxy list to chain a client tunnel through.
      See Also:
    • PROP_SHARED

      public static final String PROP_SHARED
      "true" to let client tunnels share tunnels with each other.
      See Also:
    • PROP_SPOOFED_HOST

      public static final String PROP_SPOOFED_HOST
      Host sent in the HTTP Host header while spoofing.
      See Also:
    • PROP_START

      public static final String PROP_START
      "true" to start the tunnel when the router starts.
      See Also:
    • PROP_TARGET_HOST

      public static final String PROP_TARGET_HOST
      Host or IP address of the target on the localhost side.
      See Also:
    • PROP_TARGET_PORT

      public static final String PROP_TARGET_PORT
      Port of the target on the localhost side.
      See Also:
    • PROP_TYPE

      public static final String PROP_TYPE
      Tunnel type, one of the TYPE_ values below.
      See Also:
    • PROP_FILTER

      public static final String PROP_FILTER
      Path to the streaming filter definition file.
      See Also:
    • PROP_CONFIG_FILE

      public static final String PROP_CONFIG_FILE
      Configuration file property.
      See Also:
    • PROP_TUN_GZIP

      public static final String PROP_TUN_GZIP
      Tunnel gzip property.
      See Also:
    • PROP_STARTUP_DELAY_MIN

      public static final String PROP_STARTUP_DELAY_MIN
      Configuration property for the minimum startup delay in seconds. Only applies to server tunnels.
      See Also:
    • PROP_STARTUP_DELAY_MAX

      public static final String PROP_STARTUP_DELAY_MAX
      Configuration property for the maximum startup delay in seconds. Only applies to server tunnels.
      See Also:
    • DEFAULT_STARTUP_DELAY_MIN

      public static final int DEFAULT_STARTUP_DELAY_MIN
      Default minimum startup delay in seconds.
      See Also:
    • DEFAULT_STARTUP_DELAY_MAX

      public static final int DEFAULT_STARTUP_DELAY_MAX
      Default maximum startup delay in seconds.
      See Also:
    • PROP_SHUTDOWN_DELAY_MIN

      public static final String PROP_SHUTDOWN_DELAY_MIN
      Configuration property for the minimum shutdown delay in seconds. Only applies to server tunnels.
      See Also:
    • PROP_SHUTDOWN_DELAY_MAX

      public static final String PROP_SHUTDOWN_DELAY_MAX
      Configuration property for the maximum shutdown delay in seconds. Only applies to server tunnels.
      See Also:
    • DEFAULT_SHUTDOWN_DELAY_MIN

      public static final int DEFAULT_SHUTDOWN_DELAY_MIN
      Default minimum shutdown delay in seconds.
      See Also:
    • DEFAULT_SHUTDOWN_DELAY_MAX

      public static final int DEFAULT_SHUTDOWN_DELAY_MAX
      Default maximum shutdown delay in seconds.
      See Also:
    • PROP_MAX_CONNS_MIN

      public static final String PROP_MAX_CONNS_MIN
      Per-source connection limit over a one-minute window.
      See Also:
    • PROP_MAX_CONNS_HOUR

      public static final String PROP_MAX_CONNS_HOUR
      Per-source connection limit over a one-hour window.
      See Also:
    • PROP_MAX_CONNS_DAY

      public static final String PROP_MAX_CONNS_DAY
      Per-source connection limit over a one-day window.
      See Also:
    • PROP_MAX_TOTAL_CONNS_MIN

      public static final String PROP_MAX_TOTAL_CONNS_MIN
      Connection limit summed over all sources over a one-minute window.
      See Also:
    • PROP_MAX_TOTAL_CONNS_HOUR

      public static final String PROP_MAX_TOTAL_CONNS_HOUR
      Connection limit summed over all sources over a one-hour window.
      See Also:
    • PROP_MAX_TOTAL_CONNS_DAY

      public static final String PROP_MAX_TOTAL_CONNS_DAY
      Connection limit summed over all sources over a one-day window.
      See Also:
    • PROP_MAX_STREAMS

      public static final String PROP_MAX_STREAMS
      Maximum streams open on the tunnel at once.
      See Also:
    • PROP_LIMITS_SET

      public static final String PROP_LIMITS_SET
      Set "true" once the user has chosen a limit, so the defaults are not written over it.
      See Also:
    • DEFAULT_MAX_CONNS_MIN

      public static final int DEFAULT_MAX_CONNS_MIN
      Per-source connection limit over a one-minute window, used when unset.
      See Also:
    • DEFAULT_MAX_CONNS_HOUR

      public static final int DEFAULT_MAX_CONNS_HOUR
      Per-source connection limit over a one-hour window, used when unset.
      See Also:
    • DEFAULT_MAX_CONNS_DAY

      public static final int DEFAULT_MAX_CONNS_DAY
      Per-source connection limit over a one-day window, used when unset.
      See Also:
    • DEFAULT_MAX_TOTAL_CONNS_MIN

      public static final int DEFAULT_MAX_TOTAL_CONNS_MIN
      All-source connection limit over a one-minute window, used when unset.
      See Also:
    • DEFAULT_MAX_TOTAL_CONNS_HOUR

      public static final int DEFAULT_MAX_TOTAL_CONNS_HOUR
      All-source connection limit over a one-hour window, used when unset.
      See Also:
    • DEFAULT_MAX_TOTAL_CONNS_DAY

      public static final int DEFAULT_MAX_TOTAL_CONNS_DAY
      All-source connection limit over a one-day window, used when unset.
      See Also:
    • DEFAULT_MAX_STREAMS

      public static final int DEFAULT_MAX_STREAMS
      Maximum concurrent streams used when unset.
      See Also:
    • PROP_LIMIT_ACTION

      public static final String PROP_LIMIT_ACTION
      Streaming limit action property.
      See Also:
    • PFX_OPTION

      public static final String PFX_OPTION
      Option prefix.
      See Also:
    • OPT_PERSISTENT

      private static final String OPT_PERSISTENT
      Option keeping the client key across restarts.
      See Also:
    • OPT_BUNDLE_REPLY

      public static final String OPT_BUNDLE_REPLY
      Config key to bundle reply keys.
      See Also:
    • OPT_TAGS_SEND

      private static final String OPT_TAGS_SEND
      Option setting the transient tags sent per session.
      See Also:
    • OPT_LOW_TAGS

      private static final String OPT_LOW_TAGS
      Option setting the low tag replenishment threshold.
      See Also:
    • OPT_SIG_TYPE

      private static final String OPT_SIG_TYPE
      Option setting the signature type of the tunnel key.
      See Also:
    • OPT_ALT_PKF

      private static final String OPT_ALT_PKF
      Option naming an alternate private key file.
      See Also:
    • OPT_MAX_CONNS_MIN

      private static final String OPT_MAX_CONNS_MIN
      Streaming connection limit options.
      See Also:
    • OPT_MAX_CONNS_HOUR

      private static final String OPT_MAX_CONNS_HOUR
      Option limiting connections per hour.
      See Also:
    • OPT_MAX_CONNS_DAY

      private static final String OPT_MAX_CONNS_DAY
      Option limiting connections per day.
      See Also:
    • OPT_MAX_TOTAL_CONNS_MIN

      private static final String OPT_MAX_TOTAL_CONNS_MIN
      Option limiting all connections per minute.
      See Also:
    • OPT_MAX_TOTAL_CONNS_HOUR

      private static final String OPT_MAX_TOTAL_CONNS_HOUR
      Option limiting all connections per hour.
      See Also:
    • OPT_MAX_TOTAL_CONNS_DAY

      private static final String OPT_MAX_TOTAL_CONNS_DAY
      Option limiting all connections per day.
      See Also:
    • OPT_MAX_STREAMS

      private static final String OPT_MAX_STREAMS
      Option limiting simultaneous streams.
      See Also:
    • OPT_LIMITS_SET

      private static final String OPT_LIMITS_SET
      Option marking the connection limits as set.
      See Also:
    • OPT_POST_MAX

      public static final String OPT_POST_MAX
      Config key for max posts (delegated to HTTPServer).
      See Also:
    • OPT_POST_TOTAL_MAX

      public static final String OPT_POST_TOTAL_MAX
      Config key for max total posts (delegated to HTTPServer).
      See Also:
    • OPT_LIMIT_ACTION

      private static final String OPT_LIMIT_ACTION
      Option choosing the action when limits are hit.
      See Also:
    • OPT_I2CP_GZIP

      private static final String OPT_I2CP_GZIP
      Option turning I2CP gzip compression on or off.
      See Also:
    • OPT_ENCTYPE

      private static final String OPT_ENCTYPE
      Option listing the lease set encryption types.
      See Also:
    • OPT_PRIORITY

      private static final String OPT_PRIORITY
      Option setting the outbound message priority.
      See Also:
    • TYPE_CONNECT

      public static final String TYPE_CONNECT
      Outbound HTTP CONNECT proxy for tunnelling, optionally via an outproxy.
      See Also:
    • TYPE_HTTP_BIDIR_SERVER

      public static final String TYPE_HTTP_BIDIR_SERVER
      HTTP server that also runs a proxy port on the same destination.
      See Also:
    • TYPE_HTTP_CLIENT

      public static final String TYPE_HTTP_CLIENT
      Outbound HTTP proxy.
      See Also:
    • TYPE_HTTP_SERVER

      public static final String TYPE_HTTP_SERVER
      HTTP server forwarding requests to a localhost target, spoofing the Host header.
      See Also:
    • TYPE_IRC_CLIENT

      public static final String TYPE_IRC_CLIENT
      Outbound IRC client.
      See Also:
    • TYPE_IRC_SERVER

      public static final String TYPE_IRC_SERVER
      IRC server forwarding to a localhost target.
      See Also:
    • TYPE_SOCKS

      public static final String TYPE_SOCKS
      Outbound SOCKS4a/5 proxy.
      See Also:
    • TYPE_SOCKS_IRC

      public static final String TYPE_SOCKS_IRC
      Outbound SOCKS proxy that also runs the IRC filters over the connection.
      See Also:
    • TYPE_STD_CLIENT

      public static final String TYPE_STD_CLIENT
      Client listening on a local port and forwarding to a fixed destination.
      See Also:
    • TYPE_STD_SERVER

      public static final String TYPE_STD_SERVER
      Server forwarding incoming streams to a localhost host and port.
      See Also:
    • 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:
    • 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:
    • PREFERRED_SIGTYPE

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

    • 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)

      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-null
      prefix - beginning of key values that are relevant to this tunnel
    • TunnelController

      public TunnelController(Properties config, String prefix, boolean createKey)
      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-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 Details

    • getTunnel

      public I2PTunnel getTunnel()
      The I2PTunnel

      for advanced plugin usage.

      Returns:
      the I2PTunnel client built around this controller, which holds the I2CP session and runs the tunnel on startTunnel()
    • createPrivateKey

      private boolean createPrivateKey()
      Create a new private key, if no filename is specified or creation fails.
      Returns:
      true if the key file already existed or a new one was written
    • createAltPrivateKey

      private boolean createAltPrivateKey()
      Creates alternate Destination with the same encryption keys as the primary Destination, but a different signing key.

      Must have already called createPrivateKey() successfully. Does nothing unless option OPT_ALT_PKF is set with the privkey file name. Does nothing if the file already exists.

      Returns:
      true if the alternate key file already existed or a new one was written, false if the option or signature type disallows it
    • startTunnelBackground

      public void startTunnelBackground()
      Starts the tunnel in a background thread.

      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.

      See Also:
    • startTunnel

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

      private void doStartTunnel()
      Configures and controls a single tunnel.

      Contains persistent configuration (loaded/saved from config file) and runtime state. Used to start, stop, and monitor individual tunnels. Generally one TunnelController per user-configured tunnel, though some (e.g. shared clients) may have multiple.

      Bundled under TunnelControllerGroup for storage/loading from single config file. Used by plugins to create tunnels - maintain public methods as stable API.

    • startHttpClient

      private void startHttpClient()
      Starts an http proxy client tunnel.
    • startConnectClient

      private void startConnectClient()
      Starts a connect client tunnel.
    • startIrcClient

      private void startIrcClient()
      Starts an IRC client tunnel.
    • startSocksClient

      private void startSocksClient()
      Starts a SOCKS proxy client tunnel.
    • startSocksIRCClient

      private void startSocksIRCClient()
      Starts a combined SOCKS and IRC client tunnel.
    • startStreamrClient

      private void startStreamrClient()
      Starts a streaming client tunnel.
    • startStreamrServer

      private void startStreamrServer()
      Streamr server is a UDP client, use the targetPort field for listenPort.
    • acquire

      private void acquire()
      Note the fact that we are using some sessions, so that they don't get closed by some other tunnels.
    • release

      private void release(Collection<I2PSession> sessions)
      Note the fact that we are no longer using some sessions, and if no other tunnels are using them, close them.
      Parameters:
      sessions - the sessions to release, empty for none
    • getAllSessions

      private Collection<I2PSession> getAllSessions()
      Get all the sessions we may be using.
      Returns:
      a copy, non-null
    • startClient

      private void startClient()
      Starts a generic client tunnel.
    • startServer

      private void startServer()
      Starts a generic server tunnel.
    • startHttpServer

      private void startHttpServer()
      Starts an http server tunnel.
    • startHttpBidirServer

      private void startHttpBidirServer()
      Starts a bidirectional http server tunnel.
    • startIrcServer

      private void startIrcServer()
      Starts an IRC server tunnel.
    • setListenOn

      private void setListenOn()
      Sets the local address the tunnel listens on.
    • 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 Much better than getClientOptions()
    • setSessionOptions

      private void setSessionOptions()
      Applies the session-level options to the tunnel.
    • setI2CPOptions

      private void setI2CPOptions()
      Applies the I2CP options from the config to the tunnel.
    • 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.
    • getStartupDelayMin

      public int getStartupDelayMin()
      When combined with a greater startupDelayMax, the tunnel will start with a random delay between min and max seconds.
      Returns:
      the minimum startup delay in seconds for server tunnels.
    • getStartupDelayMax

      public 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.
      Returns:
      the maximum startup delay in seconds for server tunnels.
    • getShutdownDelayMin

      public int getShutdownDelayMin()
      When combined with a greater shutdownDelayMax, the tunnel will stop with a random delay between min and max seconds during router shutdown.
      Returns:
      the minimum shutdown delay in seconds for server tunnels.
    • getShutdownDelayMax

      public 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.
      Returns:
      the maximum shutdown delay in seconds for server tunnels.
    • getDelay

      private int getDelay(String key, int def)
      Read a delay option, clamped to non-negative.
      Parameters:
      key - the config key
      def - the default when unset or unparsable
      Returns:
      the delay in seconds
    • getRemainingStartupDelay

      public int getRemainingStartupDelay()
      Get the remaining startup delay time for tunnels with delayed startup.
      Returns:
      remaining delay in seconds, or 0 if not in delayed startup state or delay has passed
    • setStartupDelayEndTime

      void setStartupDelayEndTime(long delayMs)
      Set the startup delay end time. Called by TunnelControllerGroup when setting up delayed startup.
      Parameters:
      delayMs - the delay in milliseconds
    • destroyTunnel

      public void destroyTunnel()
      May NOT be restarted with restartTunnel() or startTunnel() later. This should release all resources.
    • restartTunnel

      public void restartTunnel()
      Stops and restarts the tunnel.

      This method stops the tunnel if running, waits briefly, then starts the tunnel again. The restart is performed synchronously, blocking until complete.

      See Also:
    • setConfig

      public void setConfig(Properties config, String prefix)
      Update the options on an existing session.
      Parameters:
      config - key=value mapping for all tunnels; only the entries whose key starts with prefix are taken
      prefix - tunnel's key prefix, stripped from the keys it matched; an empty prefix takes config as-is
    • filterProperties

      private static Properties filterProperties(Properties config, String prefix)
      Copy the properties with the given prefix stripped, or return the given properties unchanged if the prefix is empty.
      Parameters:
      config - the incoming properties
      prefix - the key prefix to strip
      Returns:
      the filtered properties
    • setServerDefaults

      private void setServerDefaults(String type)
      Apply the default options for web server tunnels, including gzip and bundle-reply handling.
      Parameters:
      type - the tunnel type
    • setIrcDefaults

      private void setIrcDefaults(String type)
      Apply the default session tags, enctype, and priority for IRC and streaming tunnels.
      Parameters:
      type - the tunnel type
    • setSignatureDefault

      private void setSignatureDefault(String type)
      Apply the default signature type for tunnels that support it, mirroring EditBean.getSigType(int, String) and GeneralHelper.getSigType(int, String) .
      Parameters:
      type - the tunnel type
    • setConnectionLimitsDefaults

      private void setConnectionLimitsDefaults(String type)
      Apply the default connection and post limits, plus the filter definition and profile, for server tunnels.
      Parameters:
      type - the tunnel type
    • setClientDefaults

      private void setClientDefaults(String type)
      Apply the default encryption type for HTTP proxy and shared client tunnels.
      Parameters:
      type - the tunnel type
    • configChanged

      private static boolean configChanged(Properties p1, Properties p2, String p)
      Is property p different in p1 and p2?
      Parameters:
      p1 - the old properties
      p2 - the new properties
      p - the property key to compare
      Returns:
      true if the value changed or was newly set
    • getConfig

      public Properties getConfig(String prefix)
      The tunnel config, with each key prefixed, or a copy if the prefix is empty.
      Parameters:
      prefix - prepended to every key; an empty prefix copies the keys as-is
      Returns:
      a new Properties, never the live config
    • getConfigFile

      public File getConfigFile()
      The config file as passed into the constructor via the "configFile" property, or as set later.
      Returns:
      the config file, or null
    • setConfigFile

      public void setConfigFile(File file)
      Set the config file. Only do this if previously null.
      Parameters:
      file - where this tunnel's config was loaded from, for saving later
    • getType

      public String getType()
      Returns the tunnel's type as configured.
      Returns:
      the type name from the config
    • getName

      public String getName()
      Returns the tunnel's display name.
      Returns:
      the name from the config
    • getDescription

      public String getDescription()
      Returns the tunnel's description.
      Returns:
      the free-text description from the config
    • getI2CPHost

      public String getI2CPHost()
      The I2CP host the router is on.
      Returns:
      the I2CP host
    • getI2CPPort

      public String getI2CPPort()
      The I2CP port the router is on.
      Returns:
      the I2CP port
    • getFilter

      public String getFilter()
      Absolute path to filter definition file.
      Returns:
      the configured filter definition path, or null if no filter is set
    • isClient

      public boolean isClient()
      Whether this tunnel is a client type in the UI and I2P side.
      Returns:
      true if this tunnel is a client type
    • isClient

      public static boolean isClient(String type)
      Whether the given type is a client type 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.
      Parameters:
      type - one of the TYPE_ values, or null when unset
      Returns:
      false if type == null
    • getListenOnInterface

      public String getListenOnInterface()
      The interface the tunnel listens on.
      Returns:
      the listen interface
    • getTargetHost

      public String getTargetHost()
      The hostname or IP address of the target.
      Returns:
      the target host
    • getTargetPort

      public String getTargetPort()
      The port number of the target.
      Returns:
      the target port
    • getSpoofedHost

      public String getSpoofedHost()
      The hostname sent in the HTTP Host header when spoofing is enabled.
      Returns:
      the spoofed host
    • getPrivKeyFile

      public String getPrivKeyFile()
      Probably not absolute. May be null. getPrivateKeyFile() recommended.
      Returns:
      the priv key file
    • getListenPort

      public String getListenPort()
      The port the tunnel listens on.
      Returns:
      the listen port
    • getTargetDestination

      public String getTargetDestination()
      The base64-encoded target destination.
      Returns:
      the target destination
    • getProxyList

      public String getProxyList()
      The comma-separated list of proxies for the tunnel.
      Returns:
      the proxy list
    • getSharedClient

      public String getSharedClient()
      Whether this tunnel shares its tunnels with other client tunnels.
      Returns:
      "true" or "false" as a string, never null; server types always report "false" and a client with the property unset reports "true"
    • getStartOnLoad

      public boolean getStartOnLoad()
      Whether this tunnel is configured to start when the router starts. Defaults to true when unset.
      Returns:
      true if this tunnel starts on router startup
    • getPersistentClientKey

      public boolean getPersistentClientKey()
      Whether a persistent client key is used.
      Returns:
      true if persistent client key is enabled
    • getPrivateKeyFile

      public File getPrivateKeyFile()
      Does not necessarily exist.
      Returns:
      absolute path or null if unset
    • getAlternatePrivateKeyFile

      public File getAlternatePrivateKeyFile()
      Does not necessarily exist.
      Returns:
      absolute path or null if unset
    • filenameToFile

      static File filenameToFile(String f)
      Does not necessarily exist.
      Parameters:
      f - relative or absolute path, may be null
      Returns:
      absolute path or null
    • getMyDestination

      public String getMyDestination()
      Get my destination as a Base64 string.
      Returns:
      Base64 or null
    • getMyDestHashBase32

      public String getMyDestHashBase32()
      Get my destination's base32 address.
      Returns:
      "{52 chars}.b32.i2p" or null
    • getDestination

      public Destination getDestination()
      Get the destination from the first session that has one.
      Returns:
      Destination or null
    • getIsOfflineKeys

      public boolean getIsOfflineKeys()
      Check whether the primary session uses offline keys.
      Returns:
      true if the primary session has offline keys
    • getIsOfflineKeysAnySession

      private boolean getIsOfflineKeysAnySession()
      Check whether any session or subsession uses offline keys.
      Returns:
      true if ANY session or subsession has offline keys
    • getIsRunning

      public boolean getIsRunning()
      Checks if the tunnel is currently running.
      Returns:
      true if the tunnel state is RUNNING
    • getIsStarting

      public boolean getIsStarting()
      Checks if the tunnel is starting or starting on load.
      Returns:
      true if the tunnel is in the process of starting
    • getState

      public TunnelController.TunnelState getState()
      The current state of this tunnel.
      Returns:
      the current TunnelState
    • getIsStandby

      public boolean getIsStandby()
      Checks if the tunnel is in standby mode.

      A tunnel is in standby when it is running but has no open sessions.

      Returns:
      true if the tunnel is running but has no active sessions
    • changeState

      public void changeState(TunnelController.TunnelState state)
      Changes the tunnel state and notifies any waiting threads.
      Parameters:
      state - the new value for getState()
    • log

      public void log(String s)
      Logs a message unless suppressed, keeping only the most recent 10.
      Specified by:
      log in interface Logging
      Parameters:
      s - the message to log
    • suppressLog

      public void suppressLog()
      Suppress log messages during tunnel restart.
    • restoreLog

      public void restoreLog()
      Restore log messages after restart.
    • 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