java.lang.Object
net.i2p.i2ptunnel.ui.GeneralHelper

public class GeneralHelperextends Object
General helper functions used by all UIs.

This class is also used by Android. Maintain as a stable API and take care not to break Android.

  • Field Details

    • RUNNING

      public static final int RUNNING
      Tunnel is fully operational.
      See Also:
    • STARTING

      public static final int STARTING
      Tunnel is in the process of starting up.
      See Also:
    • NOT_RUNNING

      public static final int NOT_RUNNING
      Tunnel is not running.
      See Also:
    • STANDBY

      public static final int STANDBY
      Tunnel is alive but idle, ready for activity.
      See Also:
    • PROP_ENABLE_ACCESS_LIST

      protected static final String PROP_ENABLE_ACCESS_LIST
      Property key for enabling access list filtering.
      See Also:
    • PROP_ENABLE_BLACKLIST

      protected static final String PROP_ENABLE_BLACKLIST
      Property key for enabling blacklist filtering.
      See Also:
    • OPT

      private static final String OPT
      Prefix of a tunnel option's property name.
      See Also:
    • _context

      private final I2PAppContext _context
      The context the tunnel settings live in.
    • _group

      protected final TunnelControllerGroup _group
      The group of tunnel controllers, or null if the helper was constructed without one.
    • SHARED_OPTIONS

      private static final String[] SHARED_OPTIONS
      I2CP/Dest/LS options affecting shared client tunnels. Streaming options should not be here, each client gets its own SocketManger. All must be prefixed with "option.".
  • Constructor Details

    • GeneralHelper

      public GeneralHelper(TunnelControllerGroup tcg)
      Construct a new helper with the global context.
      Parameters:
      tcg - the group of tunnel controllers, may be null
    • GeneralHelper

      public GeneralHelper(I2PAppContext context, TunnelControllerGroup tcg)
      Construct a new helper with a specific context.
      Parameters:
      context - the I2P app context to use
      tcg - the group of tunnel controllers, may be null
  • Method Details

    • getController

      public TunnelController getController(int tunnel)
      Retrieve a tunnel controller by index.
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      Returns:
      the controller, or null if not found
    • getController

      public static TunnelController getController(TunnelControllerGroup tcg, int tunnel)
      Get the controller for the given tunnel index.
      Parameters:
      tcg - may be null
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      Returns:
      null if not found or tcg is null
    • saveTunnel

      public List<String> saveTunnel(int tunnel, TunnelConfig config)
      Save the configuration for a new or existing tunnel to disk. For new tunnels, adds to controller and (if configured) starts it.
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      config - the configuration to apply
      Returns:
      list of status messages
    • saveTunnel

      public static List<String> saveTunnel(I2PAppContext context, TunnelControllerGroup tcg, int tunnel, TunnelConfig config)
      Save the configuration for a new or existing tunnel to disk. For new tunnels, adds to controller and (if configured) starts it.
      Parameters:
      context - unused, taken from tcg
      tcg - the group of tunnel controllers, may be null
      tunnel - the index of the tunnel in the controller group, or -1 to create a new tunnel
      config - the configuration to apply
      Returns:
      the status and error messages generated by the update and save, for display to the user
    • updateTunnelConfig

      protected static List<String> updateTunnelConfig(TunnelControllerGroup tcg, int tunnel, TunnelConfig config)
      Update the config and if shared, adjust and save the config of other shared clients. If a new tunnel, this will call tcg.addController(), and start it if so configured. This does NOT save this tunnel's config. Caller must call saveConfig(I2PAppContext, TunnelControllerGroup, int) also.
      Parameters:
      tcg - the group of tunnel controllers, may be null
      tunnel - the index of the tunnel in the controller group, or -1 to create a new tunnel
      config - the configuration to apply
      Returns:
      the status messages generated by the update, for display to the user
    • updateTunnelConfig

      private static TunnelController updateTunnelConfig(TunnelControllerGroup tcg, int tunnel, TunnelConfig config, List<String> msgs)
      Update the config and if shared, adjust and save the config of other shared clients. If a new tunnel, this will call tcg.addController(), and start it if so configured. This does NOT save this tunnel's config. Caller must call saveConfig() also.
      Parameters:
      tcg - the group of tunnel controllers to update or add to
      tunnel - the tunnel number being updated
      config - the new configuration read from the form
      msgs - out parameter, messages will be added
      Returns:
      the old or new controller, non-null.
    • copySharedOptions

      private static void copySharedOptions(TunnelConfig fromConfig, Properties from, TunnelController to)
      Copy relevant options over.
      Parameters:
      fromConfig - source tunnel config, supplies the tunnel quantities
      from - source properties holding the option.* keys to copy
      to - the shared client controller to receive the options
    • saveConfig

      protected static List<String> saveConfig(I2PAppContext context, TunnelControllerGroup tcg, int tunnel)
      Save the configuration for an existing tunnel to disk. New tunnels must use saveConfig(..., TunnelController).
      Parameters:
      context - unused, taken from tcg
      tcg - the group of tunnel controllers, may be null
      tunnel - must already exist
      Returns:
      the status and error messages generated by the save, for display to the user
    • saveConfig

      private static List<String> saveConfig(TunnelControllerGroup tcg, TunnelController cur)
      Save the configuration to disk. For new and existing tunnels. Does NOT call tcg.addController() for new tunnels. See udpateConfig().
      Parameters:
      tcg - the group that writes the config file and clears messages
      cur - the controller whose configuration is written
      Returns:
      the status and error messages generated by the save, for display
    • deleteTunnel

      public List<String> deleteTunnel(int tunnel, String privKeyFile)
      Stop and delete the tunnel, remove its configuration, and rename the private key file if it uses a default name in the default directory.
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      privKeyFile - the private key file name from the edit form, may be null
      Returns:
      list of status messages
    • deleteTunnel

      public static List<String> deleteTunnel(I2PAppContext context, TunnelControllerGroup tcg, int tunnel, String privKeyFile)
      Stop the tunnel, delete from config, rename the private key file if in the default directory.
      Parameters:
      context - the I2P app context, used to locate the config directory for the key file rename
      tcg - the group of tunnel controllers, may be null
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      privKeyFile - The priv key file name from the tunnel edit form. Can be null if not known.
      Returns:
      the status and error messages generated by the deletion, for display to the user
    • getTunnelType

      public String getTunnelType(int tunnel)
      Return the tunnel type string (e.g. "httpclient", "httpserver").
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      Returns:
      the type string, or empty string if tunnel not found
    • getTunnelName

      public String getTunnelName(int tunnel)
      Return the tunnel name.
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      Returns:
      null if unset
    • getTunnelName

      public static String getTunnelName(TunnelControllerGroup tcg, int tunnel)
      Return the tunnel name from a specific group.
      Parameters:
      tcg - the controller group, may be null
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      Returns:
      null if unset
    • getTunnelDescription

      public String getTunnelDescription(int tunnel)
      Return the tunnel description.
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      Returns:
      the description, or empty string if not found
    • getTargetHost

      public String getTargetHost(int tunnel)
      Return the target host for the tunnel.
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      Returns:
      the target host, defaults to "127.0.0.1"
    • getTargetPort

      public int getTargetPort(int tunnel)
      Return the target port for the tunnel.
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      Returns:
      the port number, or -1 if unset or invalid
    • getSpoofedHost

      public String getSpoofedHost(int tunnel)
      Return the spoofed HTTP host header.
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      Returns:
      the spoofed host, or empty string if not set
    • getPrivateKeyFile

      public String getPrivateKeyFile(int tunnel)
      Return the private key file path for the tunnel.
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      Returns:
      path, non-null, non-empty
    • getPrivateKeyFile

      public String getPrivateKeyFile(TunnelControllerGroup tcg, int tunnel)
      Return the private key file path, computing a default if none is configured.
      Parameters:
      tcg - the controller group, may be null
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      Returns:
      path, non-null, non-empty
    • getAltPrivateKeyFile

      public String getAltPrivateKeyFile(int tunnel)
      Return the alternate private key file path.
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      Returns:
      path or ""
    • getAltPrivateKeyFile

      public String getAltPrivateKeyFile(TunnelControllerGroup tcg, int tunnel)
      Return the alternate private key file path from a specific group.
      Parameters:
      tcg - the controller group, may be null
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      Returns:
      path or ""
    • getClientInterface

      public String getClientInterface(int tunnel)
      Return the interface address the client tunnel listens on.
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      Returns:
      the interface address, defaults to "127.0.0.1"
    • getClientPort

      public int getClientPort(int tunnel)
      Return the port the client tunnel listens on.
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      Returns:
      the port number, or -1 if unset or invalid
    • getTunnelStatus

      public int getTunnelStatus(int tunnel)
      Return the operational status of the tunnel.
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      Returns:
      RUNNING, STARTING, NOT_RUNNING, or STANDBY
    • getRemainingStartupDelay

      public int getRemainingStartupDelay(int tunnel)
      Get the remaining startup delay time for tunnels with delayed startup.
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      Returns:
      remaining delay in seconds, or 0 if not applicable
    • getClientDestination

      public String getClientDestination(int tunnel)
      Return the client destination (base64) or proxy list for the tunnel.
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      Returns:
      the destination string or proxy list, never null
    • getDestination

      public Destination getDestination(int tunnel)
      Retrieve the tunnel Destination, reading from the key file if the tunnel is not running.
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      Returns:
      Destination or null
    • getAltDestination

      public Destination getAltDestination(int tunnel)
      Retrieve the alternate tunnel Destination from the key file.
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      Returns:
      Destination or null
    • isOfflineKeys

      public boolean isOfflineKeys(int tunnel)
      Check whether the tunnel uses offline keys.
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      Returns:
      true if offline keys
    • shouldStartAutomatically

      public boolean shouldStartAutomatically(int tunnel)
      Check whether the tunnel is configured to start automatically.
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      Returns:
      true if auto-start is enabled
    • isSharedClient

      public boolean isSharedClient(int tunnel)
      Check whether this tunnel shares its I2CP session with other clients.
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      Returns:
      true if it is a shared client
    • shouldDelayConnect

      public boolean shouldDelayConnect(int tunnel)
      Check whether the tunnel has a streaming connect delay configured.
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      Returns:
      true if connect delay is positive
    • isInteractive

      public boolean isInteractive(int tunnel)
      Check whether the tunnel is configured for interactive streaming (small window).
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      Returns:
      true if max window size is 16
    • getTunnelDepth

      public int getTunnelDepth(int tunnel, int defaultLength)
      Return the inbound tunnel depth (applies to both in/out if not split).
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      defaultLength - default value if not configured
      Returns:
      tunnel depth in hops
    • getTunnelQuantity

      public int getTunnelQuantity(int tunnel, int defaultQuantity)
      Return the inbound tunnel quantity (applies to both in/out if not split).
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      defaultQuantity - default value if not configured
      Returns:
      number of tunnels
    • getTunnelBackupQuantity

      public int getTunnelBackupQuantity(int tunnel, int defaultBackupQuantity)
      Return the inbound backup tunnel quantity (applies to both in/out if not split).
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      defaultBackupQuantity - default value if not configured
      Returns:
      number of backup tunnels
    • getTunnelVariance

      public int getTunnelVariance(int tunnel, int defaultVariance)
      Return the inbound tunnel length variance (applies to both in/out if not split).
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      defaultVariance - default value if not configured
      Returns:
      length variance in hops
    • getTunnelDepthOut

      public int getTunnelDepthOut(int tunnel, int defaultLength)
      Return the outbound tunnel depth.
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      defaultLength - default value if not configured
      Returns:
      tunnel depth in hops
    • getTunnelQuantityOut

      public int getTunnelQuantityOut(int tunnel, int defaultQuantity)
      Return the outbound tunnel quantity.
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      defaultQuantity - default value if not configured
      Returns:
      number of tunnels
    • getTunnelBackupQuantityOut

      public int getTunnelBackupQuantityOut(int tunnel, int defaultBackupQuantity)
      Return the outbound backup tunnel quantity.
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      defaultBackupQuantity - default value if not configured
      Returns:
      number of backup tunnels
    • getTunnelVarianceOut

      public int getTunnelVarianceOut(int tunnel, int defaultVariance)
      Return the outbound tunnel length variance.
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      defaultVariance - default value if not configured
      Returns:
      length variance in hops
    • getReduceOnIdle

      public boolean getReduceOnIdle(int tunnel, boolean def)
      Check whether I2CP session reduction on idle is enabled.
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      def - default value if not configured
      Returns:
      true if reduction on idle is enabled
    • getReduceCount

      public int getReduceCount(int tunnel, int def)
      Return the I2CP reduce quantity (target number of tunnels when idle).
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      def - default value if not configured
      Returns:
      the target number of tunnels to leave running when idle
    • getReduceTime

      public int getReduceTime(int tunnel, int def)
      Return the I2CP idle reduction time threshold.
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      def - default idle time in minutes
      Returns:
      idle time in minutes
    • getCert

      public int getCert(int tunnel)
      Return the certificate type for the tunnel (currently unused, always 0).
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      Returns:
      0, since the certificate type is not configurable
    • getEffort

      public int getEffort(int tunnel)
      Return the proof-of-work effort for blinded leases (currently unused, always 23).
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      Returns:
      23, since the proof-of-work effort is not configurable
    • getSigner

      public String getSigner(int tunnel)
      Return the signer for blinded leases (currently unused, always empty).
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      Returns:
      the empty string, since the signer is not configurable
    • getEncrypt

      public boolean getEncrypt(int tunnel)
      Check whether the lease set should be encrypted.
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      Returns:
      true if encryption is enabled
    • getEncryptMode

      public int getEncryptMode(int tunnel)
      Determine the encryption mode for the tunnel's lease set.
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      Returns:
      encryption mode code (0=none, 1=full, 2=blinded, etc.)
    • getBlindedPassword

      public String getBlindedPassword(int tunnel)
      Return the blinded password for the tunnel's lease set.
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      Returns:
      the decoded blinded password, or empty string
    • getClientAuths

      public List<String> getClientAuths(int tunnel, boolean isDH)
      Return the list of authorized client authentications for the lease set. Each entry is a base64-encoded name:key pair.
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      isDH - true for DH public keys, false for PSK private keys
      Returns:
      non-null list of auth entries
    • getSigType

      public int getSigType(int tunnel, String newTunnelType)
      Return the signature type code for the tunnel.
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      newTunnelType - used if tunnel < 0 to determine default
      Returns:
      the current type if a destination exists, else the default for that tunnel type
    • hasEncType

      public boolean hasEncType(int tunnel, int encType)
      Check whether the tunnel supports a given encryption type.
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      encType - encryption type code
      Returns:
      true if the encryption type is in the configured list
    • getInboundRandomKey

      public String getInboundRandomKey(int tunnel)
      Return the inbound random key (used for testing LS encryption).
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      Returns:
      the key, or empty string if not set
    • getOutboundRandomKey

      public String getOutboundRandomKey(int tunnel)
      Return the outbound random key (used for testing LS encryption).
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      Returns:
      the key, or empty string if not set
    • getLeaseSetSigningPrivateKey

      public String getLeaseSetSigningPrivateKey(int tunnel)
      Return the lease set signing private key.
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      Returns:
      the key, or empty string if not set
    • getLeaseSetPrivateKey

      public String getLeaseSetPrivateKey(int tunnel)
      Return the lease set private key (for encrypted LS).
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      Returns:
      the key, or empty string if not set
    • getDCC

      public boolean getDCC(int tunnel)
      Check whether DCC (direct client-to-client) is enabled for IRC tunnels.
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      Returns:
      true if DCC is enabled
    • isSSLEnabled

      public boolean isSSLEnabled(int tunnel)
      Check whether SSL is enabled for the server tunnel.
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      Returns:
      true if SSL is enabled
    • getEncryptKey

      public String getEncryptKey(int tunnel)
      Return the lease set encryption key.
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      Returns:
      the key, or empty string if not set
    • getAccessMode

      public int getAccessMode(int tunnel)
      Return the access control mode for the tunnel.
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      Returns:
      0=none, 1=whitelist, 2=blacklist
    • getAccessList

      public String getAccessList(int tunnel)
      Return the access control list (comma-separated destinations), newline-delimited.
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      Returns:
      the access list entries, one per line
    • getFilterDefinition

      public String getFilterDefinition(int tunnel)
      Return the connect filter definition for the tunnel.
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      Returns:
      the filter definition, or empty string if not set
    • getJumpList

      public String getJumpList(int tunnel)
      Return the jump server list for HTTP clients (one per line).
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      Returns:
      the jump server list, newline-delimited
    • getCloseOnIdle

      public boolean getCloseOnIdle(int tunnel, boolean def)
      Check whether I2CP close-on-idle is enabled.
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      def - default value if not configured
      Returns:
      true if close-on-idle is enabled
    • getCloseTime

      public int getCloseTime(int tunnel, int def)
      Return the I2CP close-on-idle timeout in minutes.
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      def - default value in minutes
      Returns:
      idle timeout in minutes
    • getNewDest

      public boolean getNewDest(int tunnel)
      Check whether the tunnel should get a new destination on resume.
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      Returns:
      true if a new destination will be created on resume
    • getPersistentClientKey

      public boolean getPersistentClientKey(int tunnel)
      Check whether the tunnel uses a persistent client key file.
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      Returns:
      true if the key is persistent
    • getDelayOpen

      public boolean getDelayOpen(int tunnel)
      Check whether I2CP delay-open is enabled.
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      Returns:
      true if delay-open is enabled
    • getAllowUserAgent

      public boolean getAllowUserAgent(int tunnel)
      Check whether the HTTP client allows custom User-Agent headers.
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      Returns:
      true if custom User-Agent is allowed
    • getAllowReferer

      public boolean getAllowReferer(int tunnel)
      Check whether the HTTP client allows custom Referer headers.
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      Returns:
      true if custom Referer is allowed
    • getAllowAccept

      public boolean getAllowAccept(int tunnel)
      Check whether the HTTP client allows custom Accept headers.
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      Returns:
      true if custom Accept is allowed
    • getAllowInternalSSL

      public boolean getAllowInternalSSL(int tunnel)
      Check whether internal SSL connections are allowed through the HTTP client. As of 0.9.35, defaults to true unless explicitly disabled.
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      Returns:
      true if internal SSL is allowed
    • getMultihome

      public boolean getMultihome(int tunnel)
      Check whether the tunnel should bundle reply information (multihome mode).
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      Returns:
      true if bundling is enabled
    • getProxyAuth

      public String getProxyAuth(int tunnel)
      Return the proxy authentication mode.
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      Returns:
      "false", "true", or "basic"
    • getOutproxyAuth

      public boolean getOutproxyAuth(int tunnel)
      Check whether outproxy authentication is required.
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      Returns:
      true if outproxy auth is enabled
    • getOutproxyUsername

      public String getOutproxyUsername(int tunnel)
      Return the outproxy username.
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      Returns:
      the username, or empty string
    • getOutproxyPassword

      public String getOutproxyPassword(int tunnel)
      Return the outproxy password (only if a username is set).
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      Returns:
      the password, or empty string
    • getSslProxies

      public String getSslProxies(int tunnel)
      Return the list of SSL outproxies.
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      Returns:
      comma-separated SSL outproxy list
    • getUseOutproxyPlugin

      public boolean getUseOutproxyPlugin(int tunnel)
      Check whether the outproxy plugin is enabled.
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      Returns:
      true if the outproxy plugin is used, defaults to true
    • getOutproxyType

      public String getOutproxyType(int tunnel)
      Return the outproxy connection type.
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      Returns:
      "connect" or "socks", default depends on tunnel type
    • getLimitMinute

      public int getLimitMinute(int tunnel)
      Return the per-minute connection limit.
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      Returns:
      max connections per minute
    • getLimitHour

      public int getLimitHour(int tunnel)
      Return the per-hour connection limit.
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      Returns:
      max connections per hour
    • getLimitDay

      public int getLimitDay(int tunnel)
      Return the per-day connection limit.
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      Returns:
      max connections per day
    • getTotalMinute

      public int getTotalMinute(int tunnel)
      Return the per-minute total connection limit across all sources.
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      Returns:
      max total connections per minute
    • getTotalHour

      public int getTotalHour(int tunnel)
      Return the per-hour total connection limit across all sources.
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      Returns:
      max total connections per hour
    • getTotalDay

      public int getTotalDay(int tunnel)
      Return the per-day total connection limit across all sources.
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      Returns:
      max total connections per day
    • getMaxStreams

      public int getMaxStreams(int tunnel)
      Return the maximum concurrent streams for the tunnel.
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      Returns:
      the maximum concurrent streams, or the tunnel default if unconfigured
    • getPostMax

      public int getPostMax(int tunnel)
      Return the maximum POST request size in bytes.
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      Returns:
      max POST size in bytes
    • getPostTotalMax

      public int getPostTotalMax(int tunnel)
      Return the maximum total POST request size for the window.
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      Returns:
      max total POST size in bytes
    • getPostCheckTime

      public int getPostCheckTime(int tunnel)
      Return the POST check window size in minutes.
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      Returns:
      check window in minutes
    • getPostBanTime

      public int getPostBanTime(int tunnel)
      Return the POST ban duration in minutes.
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      Returns:
      ban time in minutes
    • getPostTotalBanTime

      public int getPostTotalBanTime(int tunnel)
      Return the total POST ban duration in minutes.
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      Returns:
      total ban time in minutes
    • getRejectInproxy

      public boolean getRejectInproxy(int tunnel)
      Check whether inproxy connections are rejected.
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      Returns:
      true if inproxy connections are rejected
    • getRejectReferer

      public boolean getRejectReferer(int tunnel)
      Check whether connections with a Referer header are rejected.
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      Returns:
      true if Referer connections are rejected
    • getRejectUserAgents

      public boolean getRejectUserAgents(int tunnel)
      Check whether connections with known bad User-Agents are rejected.
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      Returns:
      true if User-Agent rejection is enabled
    • getUserAgents

      public String getUserAgents(int tunnel)
      Return the blocked User-Agent list.
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      Returns:
      comma-separated user agents to block
    • getUniqueLocal

      public boolean getUniqueLocal(int tunnel)
      Check whether the server tunnel uses unique local addresses for each client.
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      Returns:
      true if unique local addressing is enabled
    • getCustomOptionsString

      public String getCustomOptionsString(int tunnel)
      Return the custom client options as a single URL-parameter-style string.
      Parameters:
      tunnel - the index of the tunnel in the controller group, or -1 if there is none
      Returns:
      the options string, HTML-escaped, or empty string
    • getProperty

      private int getProperty(int tunnel, String prop, int def)
      Reads one numeric tunnel option.
      Parameters:
      tunnel - which tunnel's option to read
      prop - the option's name
      def - the value to use when it is not set
      Returns:
      the option's value
    • getProperty

      private String getProperty(int tunnel, String prop, String def)
      Reads one text tunnel option.
      Parameters:
      tunnel - which tunnel's option to read
      prop - the option's name
      def - the value to use when it is not set
      Returns:
      the option's value
    • getBooleanProperty

      private boolean getBooleanProperty(int tunnel, String prop)
      Default is false.
      Parameters:
      tunnel - the tunnel number whose client options are read
      prop - the client option key to parse
      Returns:
      true only when the option is set to a parseable true value
    • getBooleanProperty

      private boolean getBooleanProperty(int tunnel, String prop, boolean def)
      Reads one true/false tunnel option.
      Parameters:
      tunnel - which tunnel's option to read
      prop - the option's name
      def - the value to use when it is not set
      Returns:
      the option's value
    • _t

      protected static String _t(String key, I2PAppContext context)
      Translate a string using the given context.
      Parameters:
      key - the untranslated string
      context - the app context for translation
      Returns:
      the translated string