Class GeneralHelper

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

public class GeneralHelper extends 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.
Since:
0.9.19
  • Field Details

  • Constructor Details

  • Method Details

    • getController

      public TunnelController getController(int tunnel)
    • getController

      public static TunnelController getController(TunnelControllerGroup tcg, int tunnel)
      Parameters:
      tcg - may be null
      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.
    • 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
    • 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() also.
    • 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
      tunnel - must already exist
      Since:
      0.9.49
    • deleteTunnel

      public List<String> deleteTunnel(int tunnel, String privKeyFile)
    • 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:
      privKeyFile - The priv key file name from the tunnel edit form. Can be null if not known.
    • getTunnelType

      public String getTunnelType(int tunnel)
    • getTunnelName

      public String getTunnelName(int tunnel)
      Returns:
      null if unset
    • getTunnelName

      public static String getTunnelName(TunnelControllerGroup tcg, int tunnel)
      Returns:
      null if unset
    • getTunnelDescription

      public String getTunnelDescription(int tunnel)
    • getTargetHost

      public String getTargetHost(int tunnel)
    • getTargetPort

      public int getTargetPort(int tunnel)
      Parameters:
      tunnel -
      Returns:
      -1 if unset or invalid
    • getSpoofedHost

      public String getSpoofedHost(int tunnel)
    • getPrivateKeyFile

      public String getPrivateKeyFile(int tunnel)
      Returns:
      path, non-null, non-empty
    • getPrivateKeyFile

      public String getPrivateKeyFile(TunnelControllerGroup tcg, int tunnel)
      Returns:
      path, non-null, non-empty
    • getAltPrivateKeyFile

      public String getAltPrivateKeyFile(int tunnel)
      Returns:
      path or ""
      Since:
      0.9.30
    • getAltPrivateKeyFile

      public String getAltPrivateKeyFile(TunnelControllerGroup tcg, int tunnel)
      Returns:
      path or ""
      Since:
      0.9.30
    • getClientInterface

      public String getClientInterface(int tunnel)
    • getClientPort

      public int getClientPort(int tunnel)
    • getTunnelStatus

      public int getTunnelStatus(int tunnel)
    • getClientDestination

      public String getClientDestination(int tunnel)
    • getDestination

      public Destination getDestination(int tunnel)
      Works even if tunnel is not running.
      Returns:
      Destination or null
    • getAltDestination

      public Destination getAltDestination(int tunnel)
      Works even if tunnel is not running.
      Returns:
      Destination or null
      Since:
      0.9.30
    • isOfflineKeys

      public boolean isOfflineKeys(int tunnel)
      Works even if tunnel is not running.
      Returns:
      true if offline keys
      Since:
      0.9.40
    • shouldStartAutomatically

      public boolean shouldStartAutomatically(int tunnel)
    • isSharedClient

      public boolean isSharedClient(int tunnel)
    • shouldDelayConnect

      public boolean shouldDelayConnect(int tunnel)
    • isInteractive

      public boolean isInteractive(int tunnel)
    • getTunnelDepth

      public int getTunnelDepth(int tunnel, int defaultLength)
      Inbound or both in/out
    • getTunnelQuantity

      public int getTunnelQuantity(int tunnel, int defaultQuantity)
      Inbound or both in/out
    • getTunnelBackupQuantity

      public int getTunnelBackupQuantity(int tunnel, int defaultBackupQuantity)
      Inbound or both in/out
    • getTunnelVariance

      public int getTunnelVariance(int tunnel, int defaultVariance)
      Inbound or both in/out
    • getTunnelDepthOut

      public int getTunnelDepthOut(int tunnel, int defaultLength)
      Since:
      0.9.33
    • getTunnelQuantityOut

      public int getTunnelQuantityOut(int tunnel, int defaultQuantity)
      Since:
      0.9.33
    • getTunnelBackupQuantityOut

      public int getTunnelBackupQuantityOut(int tunnel, int defaultBackupQuantity)
      Since:
      0.9.33
    • getTunnelVarianceOut

      public int getTunnelVarianceOut(int tunnel, int defaultVariance)
      Since:
      0.9.33
    • getReduceOnIdle

      public boolean getReduceOnIdle(int tunnel, boolean def)
    • getReduceCount

      public int getReduceCount(int tunnel, int def)
    • getReduceTime

      public int getReduceTime(int tunnel, int def)
      Parameters:
      tunnel -
      def - in minutes
      Returns:
      time in minutes
    • getCert

      public int getCert(int tunnel)
    • getEffort

      public int getEffort(int tunnel)
    • getSigner

      public String getSigner(int tunnel)
    • getEncrypt

      public boolean getEncrypt(int tunnel)
    • getEncryptMode

      public int getEncryptMode(int tunnel)
      Since:
      0.9.40
    • getBlindedPassword

      public String getBlindedPassword(int tunnel)
      Since:
      0.9.40
    • getClientAuths

      public List<String> getClientAuths(int tunnel, boolean isDH)
      List of b64 name : b64key Pubkeys for DH, privkeys for PSK
      Parameters:
      isDH - true for DH, false for PSK
      Returns:
      non-null
      Since:
      0.9.41
    • getSigType

      public int getSigType(int tunnel, String newTunnelType)
      Parameters:
      newTunnelType - used if tunnel < 0
      Returns:
      the current type if we have a destination already, else the default for that type of tunnel
    • hasEncType

      public boolean hasEncType(int tunnel, int encType)
      Parameters:
      encType - code
      Since:
      0.9.44
    • getInboundRandomKey

      public String getInboundRandomKey(int tunnel)
      Random keys
    • getOutboundRandomKey

      public String getOutboundRandomKey(int tunnel)
    • getLeaseSetSigningPrivateKey

      public String getLeaseSetSigningPrivateKey(int tunnel)
    • getLeaseSetPrivateKey

      public String getLeaseSetPrivateKey(int tunnel)
    • getDCC

      public boolean getDCC(int tunnel)
    • isSSLEnabled

      public boolean isSSLEnabled(int tunnel)
    • getEncryptKey

      public String getEncryptKey(int tunnel)
    • getAccessMode

      public int getAccessMode(int tunnel)
    • getAccessList

      public String getAccessList(int tunnel)
      Returns:
      entries sorted, converted to b32, separated by newlines, or ""
    • getFilterDefinition

      public String getFilterDefinition(int tunnel)
      Since:
      0.9.40
    • getJumpList

      public String getJumpList(int tunnel)
    • getCloseOnIdle

      public boolean getCloseOnIdle(int tunnel, boolean def)
    • getCloseTime

      public int getCloseTime(int tunnel, int def)
    • getNewDest

      public boolean getNewDest(int tunnel)
    • getPersistentClientKey

      public boolean getPersistentClientKey(int tunnel)
    • getDelayOpen

      public boolean getDelayOpen(int tunnel)
    • getAllowUserAgent

      public boolean getAllowUserAgent(int tunnel)
    • getAllowReferer

      public boolean getAllowReferer(int tunnel)
    • getAllowAccept

      public boolean getAllowAccept(int tunnel)
    • getAllowInternalSSL

      public boolean getAllowInternalSSL(int tunnel)
      As of 0.9.35, default true, and overridden to true unless PROP_SSL_SET is set
    • getMultihome

      public boolean getMultihome(int tunnel)
    • getProxyAuth

      public String getProxyAuth(int tunnel)
    • getOutproxyAuth

      public boolean getOutproxyAuth(int tunnel)
    • getOutproxyUsername

      public String getOutproxyUsername(int tunnel)
    • getOutproxyPassword

      public String getOutproxyPassword(int tunnel)
    • getSslProxies

      public String getSslProxies(int tunnel)
    • getUseOutproxyPlugin

      public boolean getUseOutproxyPlugin(int tunnel)
      Default true
    • getOutproxyType

      public String getOutproxyType(int tunnel)
      Returns:
      "connect" or "socks", default depends on tunnel type
      Since:
      0.9.57
    • getLimitMinute

      public int getLimitMinute(int tunnel)
      all of these are @since 0.8.3
    • getLimitHour

      public int getLimitHour(int tunnel)
    • getLimitDay

      public int getLimitDay(int tunnel)
    • getTotalMinute

      public int getTotalMinute(int tunnel)
    • getTotalHour

      public int getTotalHour(int tunnel)
    • getTotalDay

      public int getTotalDay(int tunnel)
    • getMaxStreams

      public int getMaxStreams(int tunnel)
    • getPostMax

      public int getPostMax(int tunnel)
      POST limits
      Since:
      0.9.9
    • getPostTotalMax

      public int getPostTotalMax(int tunnel)
    • getPostCheckTime

      public int getPostCheckTime(int tunnel)
    • getPostBanTime

      public int getPostBanTime(int tunnel)
    • getPostTotalBanTime

      public int getPostTotalBanTime(int tunnel)
    • getRejectInproxy

      public boolean getRejectInproxy(int tunnel)
    • getRejectReferer

      public boolean getRejectReferer(int tunnel)
      Since:
      0.9.25
    • getRejectUserAgents

      public boolean getRejectUserAgents(int tunnel)
      Since:
      0.9.25
    • getUserAgents

      public String getUserAgents(int tunnel)
      Since:
      0.9.25
    • getUniqueLocal

      public boolean getUniqueLocal(int tunnel)
    • getCustomOptionsString

      public String getCustomOptionsString(int tunnel)
    • _t

      protected static String _t(String key, I2PAppContext context)