Package net.i2p.i2ptunnel.ui
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 Summary
Fields Modifier and Type Field Description protected TunnelControllerGroup
_group
static int
NOT_RUNNING
protected static String
PROP_ENABLE_ACCESS_LIST
protected static String
PROP_ENABLE_BLACKLIST
static int
RUNNING
static int
STANDBY
static int
STARTING
-
Constructor Summary
Constructors Constructor Description GeneralHelper(I2PAppContext context, TunnelControllerGroup tcg)
GeneralHelper(TunnelControllerGroup tcg)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static String
_t(String key, I2PAppContext context)
List<String>
deleteTunnel(int tunnel, String privKeyFile)
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 directoryString
getAccessList(int tunnel)
int
getAccessMode(int tunnel)
boolean
getAllowAccept(int tunnel)
boolean
getAllowInternalSSL(int tunnel)
As of 0.9.35, default true, and overridden to true unless PROP_SSL_SET is setboolean
getAllowReferer(int tunnel)
boolean
getAllowUserAgent(int tunnel)
Destination
getAltDestination(int tunnel)
Works even if tunnel is not running.String
getAltPrivateKeyFile(int tunnel)
String
getAltPrivateKeyFile(TunnelControllerGroup tcg, int tunnel)
String
getBlindedPassword(int tunnel)
int
getCert(int tunnel)
List<String>
getClientAuths(int tunnel, boolean isDH)
List of b64 name : b64key Pubkeys for DH, privkeys for PSKString
getClientDestination(int tunnel)
String
getClientInterface(int tunnel)
int
getClientPort(int tunnel)
boolean
getCloseOnIdle(int tunnel, boolean def)
int
getCloseTime(int tunnel, int def)
TunnelController
getController(int tunnel)
static TunnelController
getController(TunnelControllerGroup tcg, int tunnel)
String
getCustomOptionsString(int tunnel)
boolean
getDCC(int tunnel)
boolean
getDelayOpen(int tunnel)
Destination
getDestination(int tunnel)
Works even if tunnel is not running.int
getEffort(int tunnel)
boolean
getEncrypt(int tunnel)
String
getEncryptKey(int tunnel)
int
getEncryptMode(int tunnel)
String
getFilterDefinition(int tunnel)
String
getInboundRandomKey(int tunnel)
Random keysString
getJumpList(int tunnel)
String
getLeaseSetPrivateKey(int tunnel)
String
getLeaseSetSigningPrivateKey(int tunnel)
int
getLimitDay(int tunnel)
int
getLimitHour(int tunnel)
int
getLimitMinute(int tunnel)
all of these are @since 0.8.3int
getMaxStreams(int tunnel)
boolean
getMultihome(int tunnel)
boolean
getNewDest(int tunnel)
String
getOutboundRandomKey(int tunnel)
boolean
getOutproxyAuth(int tunnel)
String
getOutproxyPassword(int tunnel)
String
getOutproxyUsername(int tunnel)
boolean
getPersistentClientKey(int tunnel)
int
getPostBanTime(int tunnel)
int
getPostCheckTime(int tunnel)
int
getPostMax(int tunnel)
POST limitsint
getPostTotalBanTime(int tunnel)
int
getPostTotalMax(int tunnel)
String
getPrivateKeyFile(int tunnel)
String
getPrivateKeyFile(TunnelControllerGroup tcg, int tunnel)
String
getProxyAuth(int tunnel)
int
getReduceCount(int tunnel, int def)
boolean
getReduceOnIdle(int tunnel, boolean def)
int
getReduceTime(int tunnel, int def)
boolean
getRejectInproxy(int tunnel)
boolean
getRejectReferer(int tunnel)
boolean
getRejectUserAgents(int tunnel)
String
getSigner(int tunnel)
int
getSigType(int tunnel, String newTunnelType)
String
getSpoofedHost(int tunnel)
String
getSslProxies(int tunnel)
String
getTargetHost(int tunnel)
int
getTargetPort(int tunnel)
int
getTotalDay(int tunnel)
int
getTotalHour(int tunnel)
int
getTotalMinute(int tunnel)
int
getTunnelBackupQuantity(int tunnel, int defaultBackupQuantity)
Inbound or both in/outint
getTunnelBackupQuantityOut(int tunnel, int defaultBackupQuantity)
int
getTunnelDepth(int tunnel, int defaultLength)
Inbound or both in/outint
getTunnelDepthOut(int tunnel, int defaultLength)
String
getTunnelDescription(int tunnel)
String
getTunnelName(int tunnel)
static String
getTunnelName(TunnelControllerGroup tcg, int tunnel)
int
getTunnelQuantity(int tunnel, int defaultQuantity)
Inbound or both in/outint
getTunnelQuantityOut(int tunnel, int defaultQuantity)
int
getTunnelStatus(int tunnel)
String
getTunnelType(int tunnel)
int
getTunnelVariance(int tunnel, int defaultVariance)
Inbound or both in/outint
getTunnelVarianceOut(int tunnel, int defaultVariance)
boolean
getUniqueLocal(int tunnel)
boolean
getUseOutproxyPlugin(int tunnel)
Default trueString
getUserAgents(int tunnel)
boolean
hasEncType(int tunnel, int encType)
boolean
isInteractive(int tunnel)
boolean
isOfflineKeys(int tunnel)
Works even if tunnel is not running.boolean
isSharedClient(int tunnel)
boolean
isSSLEnabled(int tunnel)
protected static List<String>
saveConfig(I2PAppContext context, TunnelControllerGroup tcg, int tunnel)
Save the configuration for an existing tunnel to disk.List<String>
saveTunnel(int tunnel, TunnelConfig config)
Save the configuration for a new or existing tunnel to disk.static List<String>
saveTunnel(I2PAppContext context, TunnelControllerGroup tcg, int tunnel, TunnelConfig config)
Save the configuration for a new or existing tunnel to disk.boolean
shouldDelayConnect(int tunnel)
boolean
shouldStartAutomatically(int tunnel)
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.
-
-
-
Field Detail
-
RUNNING
public static final int RUNNING
- See Also:
- Constant Field Values
-
STARTING
public static final int STARTING
- See Also:
- Constant Field Values
-
NOT_RUNNING
public static final int NOT_RUNNING
- See Also:
- Constant Field Values
-
STANDBY
public static final int STANDBY
- See Also:
- Constant Field Values
-
PROP_ENABLE_ACCESS_LIST
protected static final String PROP_ENABLE_ACCESS_LIST
- See Also:
- Constant Field Values
-
PROP_ENABLE_BLACKLIST
protected static final String PROP_ENABLE_BLACKLIST
- See Also:
- Constant Field Values
-
_group
protected final TunnelControllerGroup _group
-
-
Constructor Detail
-
GeneralHelper
public GeneralHelper(TunnelControllerGroup tcg)
- Parameters:
tcg
- may be null ???
-
GeneralHelper
public GeneralHelper(I2PAppContext context, TunnelControllerGroup tcg)
- Parameters:
tcg
- may be null ???
-
-
Method Detail
-
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 tcgtunnel
- must already exist- Since:
- 0.9.49
-
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)
-
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
-
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)
-
-