public class GeneralHelper extends Object
| Modifier and Type | Field and Description |
|---|---|
protected TunnelControllerGroup | _group |
static int | NOT_RUNNINGTunnel is not running |
protected static String | PROP_ENABLE_ACCESS_LISTProperty key for enabling access list filtering |
protected static String | PROP_ENABLE_BLACKLISTProperty key for enabling blacklist filtering |
static int | RUNNINGTunnel is fully operational |
static int | STANDBYTunnel is alive but idle, ready for activity |
static int | STARTINGTunnel is in the process of starting up |
| Constructor and Description |
|---|
GeneralHelper(I2PAppContext context,
TunnelControllerGroup tcg)Construct a new helper with a specific context. |
GeneralHelper(TunnelControllerGroup tcg)Construct a new helper with the global context. |
| Modifier and Type | Method and Description |
|---|---|
protected static String | _t(String key,
I2PAppContext context)Translate a string using the given context. |
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 |
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. |
String | getAccessList(int tunnel)Return the access control list (comma-separated destinations), newline-delimited. |
int | getAccessMode(int tunnel)Return the access control mode for the tunnel. |
boolean | getAllowAccept(int tunnel)Check whether the HTTP client allows custom Accept headers. |
boolean | getAllowInternalSSL(int tunnel)Check whether internal SSL connections are allowed through the HTTP client. |
boolean | getAllowReferer(int tunnel)Check whether the HTTP client allows custom Referer headers. |
boolean | getAllowUserAgent(int tunnel)Check whether the HTTP client allows custom User-Agent headers. |
Destination | getAltDestination(int tunnel)Retrieve the alternate tunnel Destination from the key file. |
String | getAltPrivateKeyFile(int tunnel)Return the alternate private key file path. |
String | getAltPrivateKeyFile(TunnelControllerGroup tcg,
int tunnel)Return the alternate private key file path from a specific group. |
String | getBlindedPassword(int tunnel)Return the blinded password for the tunnel's lease set. |
int | getCert(int tunnel)Return the certificate type for the tunnel (currently unused, always 0). |
List<String> | getClientAuths(int tunnel,
boolean isDH)Return the list of authorized client authentications for the lease set. |
String | getClientDestination(int tunnel)Return the client destination (base64) or proxy list for the tunnel. |
String | getClientInterface(int tunnel)Return the interface address the client tunnel listens on. |
int | getClientPort(int tunnel)Return the port the client tunnel listens on. |
boolean | getCloseOnIdle(int tunnel,
boolean def)Check whether I2CP close-on-idle is enabled. |
int | getCloseTime(int tunnel,
int def)Return the I2CP close-on-idle timeout in minutes. |
TunnelController | getController(int tunnel)Retrieve a tunnel controller by index. |
static TunnelController | getController(TunnelControllerGroup tcg,
int tunnel) |
String | getCustomOptionsString(int tunnel)Return the custom client options as a single URL-parameter-style string. |
boolean | getDCC(int tunnel)Check whether DCC (direct client-to-client) is enabled for IRC tunnels. |
boolean | getDelayOpen(int tunnel)Check whether I2CP delay-open is enabled. |
Destination | getDestination(int tunnel)Retrieve the tunnel Destination, reading from the key file if the tunnel is not running. |
int | getEffort(int tunnel)Return the proof-of-work effort for blinded leases (currently unused, always 23). |
boolean | getEncrypt(int tunnel)Check whether the lease set should be encrypted. |
String | getEncryptKey(int tunnel)Return the lease set encryption key. |
int | getEncryptMode(int tunnel)Determine the encryption mode for the tunnel's lease set. |
String | getFilterDefinition(int tunnel)Return the connect filter definition for the tunnel. |
String | getInboundRandomKey(int tunnel)Return the inbound random key (used for testing LS encryption). |
String | getJumpList(int tunnel)Return the jump server list for HTTP clients (one per line). |
String | getLeaseSetPrivateKey(int tunnel)Return the lease set private key (for encrypted LS). |
String | getLeaseSetSigningPrivateKey(int tunnel)Return the lease set signing private key. |
int | getLimitDay(int tunnel)Return the per-day connection limit. |
int | getLimitHour(int tunnel)Return the per-hour connection limit. |
int | getLimitMinute(int tunnel)Return the per-minute connection limit. |
int | getMaxStreams(int tunnel)Return the maximum concurrent streams for the tunnel. |
boolean | getMultihome(int tunnel)Check whether the tunnel should bundle reply information (multihome mode). |
boolean | getNewDest(int tunnel)Check whether the tunnel should get a new destination on resume. |
String | getOutboundRandomKey(int tunnel)Return the outbound random key (used for testing LS encryption). |
boolean | getOutproxyAuth(int tunnel)Check whether outproxy authentication is required. |
String | getOutproxyPassword(int tunnel)Return the outproxy password (only if a username is set). |
String | getOutproxyType(int tunnel)Return the outproxy connection type. |
String | getOutproxyUsername(int tunnel)Return the outproxy username. |
boolean | getPersistentClientKey(int tunnel)Check whether the tunnel uses a persistent client key file. |
int | getPostBanTime(int tunnel)Return the POST ban duration in minutes. |
int | getPostCheckTime(int tunnel)Return the POST check window size in minutes. |
int | getPostMax(int tunnel)Return the maximum POST request size in bytes. |
int | getPostTotalBanTime(int tunnel)Return the total POST ban duration in minutes. |
int | getPostTotalMax(int tunnel)Return the maximum total POST request size for the window. |
String | getPrivateKeyFile(int tunnel)Return the private key file path for the tunnel. |
String | getPrivateKeyFile(TunnelControllerGroup tcg,
int tunnel)Return the private key file path, computing a default if none is configured. |
String | getProxyAuth(int tunnel)Return the proxy authentication mode. |
int | getReduceCount(int tunnel,
int def)Return the I2CP reduce quantity (target number of tunnels when idle). |
boolean | getReduceOnIdle(int tunnel,
boolean def)Check whether I2CP session reduction on idle is enabled. |
int | getReduceTime(int tunnel,
int def)Return the I2CP idle reduction time threshold. |
boolean | getRejectInproxy(int tunnel)Check whether inproxy connections are rejected. |
boolean | getRejectReferer(int tunnel)Check whether connections with a Referer header are rejected. |
boolean | getRejectUserAgents(int tunnel)Check whether connections with known bad User-Agents are rejected. |
int | getRemainingStartupDelay(int tunnel)Get the remaining startup delay time for tunnels with delayed startup. |
String | getSigner(int tunnel)Return the signer for blinded leases (currently unused, always empty). |
int | getSigType(int tunnel,
String newTunnelType)Return the signature type code for the tunnel. |
String | getSpoofedHost(int tunnel)Return the spoofed HTTP host header. |
String | getSslProxies(int tunnel)Return the list of SSL outproxies. |
String | getTargetHost(int tunnel)Return the target host for the tunnel. |
int | getTargetPort(int tunnel)Return the target port for the tunnel. |
int | getTotalDay(int tunnel)Return the per-day total connection limit across all sources. |
int | getTotalHour(int tunnel)Return the per-hour total connection limit across all sources. |
int | getTotalMinute(int tunnel)Return the per-minute total connection limit across all sources. |
int | getTunnelBackupQuantity(int tunnel,
int defaultBackupQuantity)Return the inbound backup tunnel quantity (applies to both in/out if not split). |
int | getTunnelBackupQuantityOut(int tunnel,
int defaultBackupQuantity)Return the outbound backup tunnel quantity. |
int | getTunnelDepth(int tunnel,
int defaultLength)Return the inbound tunnel depth (applies to both in/out if not split). |
int | getTunnelDepthOut(int tunnel,
int defaultLength)Return the outbound tunnel depth. |
String | getTunnelDescription(int tunnel)Return the tunnel description. |
String | getTunnelName(int tunnel)Return the tunnel name. |
static String | getTunnelName(TunnelControllerGroup tcg,
int tunnel)Return the tunnel name from a specific group. |
int | getTunnelQuantity(int tunnel,
int defaultQuantity)Return the inbound tunnel quantity (applies to both in/out if not split). |
int | getTunnelQuantityOut(int tunnel,
int defaultQuantity)Return the outbound tunnel quantity. |
int | getTunnelStatus(int tunnel)Return the operational status of the tunnel. |
String | getTunnelType(int tunnel)Return the tunnel type string (e.g. |
int | getTunnelVariance(int tunnel,
int defaultVariance)Return the inbound tunnel length variance (applies to both in/out if not split). |
int | getTunnelVarianceOut(int tunnel,
int defaultVariance)Return the outbound tunnel length variance. |
boolean | getUniqueLocal(int tunnel)Check whether the server tunnel uses unique local addresses for each client. |
boolean | getUseOutproxyPlugin(int tunnel)Check whether the outproxy plugin is enabled. |
String | getUserAgents(int tunnel)Return the blocked User-Agent list. |
boolean | hasEncType(int tunnel,
int encType)Check whether the tunnel supports a given encryption type. |
boolean | isInteractive(int tunnel)Check whether the tunnel is configured for interactive streaming (small window). |
boolean | isOfflineKeys(int tunnel)Check whether the tunnel uses offline keys. |
boolean | isSharedClient(int tunnel)Check whether this tunnel shares its I2CP session with other clients. |
boolean | isSSLEnabled(int tunnel)Check whether SSL is enabled for the server tunnel. |
protected static List<String> | saveConfig(I2PAppContext context,
TunnelControllerGroup tcg,
int tunnel)Save the configuration for an 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. |
List<String> | saveTunnel(int tunnel,
TunnelConfig config)Save the configuration for a new or existing tunnel to disk. |
boolean | shouldDelayConnect(int tunnel)Check whether the tunnel has a streaming connect delay configured. |
boolean | shouldStartAutomatically(int tunnel)Check whether the tunnel is configured to start automatically. |
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. |
protected final TunnelControllerGroup _group
public static final int NOT_RUNNING
protected static final String PROP_ENABLE_ACCESS_LIST
protected static final String PROP_ENABLE_BLACKLIST
public static final int RUNNING
public static final int STANDBY
public static final int STARTING
public GeneralHelper(I2PAppContext context, TunnelControllerGroup tcg)
context - the I2P app context to usetcg - the group of tunnel controllers, may be nullpublic GeneralHelper(TunnelControllerGroup tcg)
tcg - the group of tunnel controllers, may be nullprotected static String _t(String key, I2PAppContext context)
key - the untranslated stringcontext - the app context for translationpublic static List<String> deleteTunnel(I2PAppContext context, TunnelControllerGroup tcg, int tunnel, String privKeyFile)
privKeyFile - The priv key file name from the tunnel edit form. Can
be null if not known.public List<String> deleteTunnel(int tunnel, String privKeyFile)
tunnel - the tunnelprivKeyFile - the private key file name from the edit form, may be nullpublic String getAccessList(int tunnel)
tunnel - the tunnelpublic int getAccessMode(int tunnel)
tunnel - the tunnelpublic boolean getAllowAccept(int tunnel)
tunnel - the tunnelpublic boolean getAllowInternalSSL(int tunnel)
tunnel - the tunnelpublic boolean getAllowReferer(int tunnel)
tunnel - the tunnelpublic boolean getAllowUserAgent(int tunnel)
tunnel - the tunnelpublic Destination getAltDestination(int tunnel)
tunnel - the tunnelpublic String getAltPrivateKeyFile(int tunnel)
tunnel - the tunnelpublic String getAltPrivateKeyFile(TunnelControllerGroup tcg, int tunnel)
tcg - the controller group, may be nulltunnel - the tunnelpublic String getBlindedPassword(int tunnel)
tunnel - the tunnelpublic int getCert(int tunnel)
tunnel - the tunnelpublic List<String> getClientAuths(int tunnel, boolean isDH)
tunnel - the tunnelisDH - true for DH public keys, false for PSK private keyspublic String getClientDestination(int tunnel)
tunnel - the tunnelpublic String getClientInterface(int tunnel)
tunnel - the tunnelpublic int getClientPort(int tunnel)
tunnel - the tunnelpublic boolean getCloseOnIdle(int tunnel,
boolean def)tunnel - the tunneldef - default value if not configuredpublic int getCloseTime(int tunnel,
int def)tunnel - the tunneldef - default value in minutespublic TunnelController getController(int tunnel)
tunnel - the tunnelpublic static TunnelController getController(TunnelControllerGroup tcg, int tunnel)
tcg - may be nullpublic String getCustomOptionsString(int tunnel)
tunnel - the tunnelpublic boolean getDCC(int tunnel)
tunnel - the tunnelpublic boolean getDelayOpen(int tunnel)
tunnel - the tunnelpublic Destination getDestination(int tunnel)
tunnel - the tunnelpublic int getEffort(int tunnel)
tunnel - the tunnelpublic boolean getEncrypt(int tunnel)
tunnel - the tunnelpublic String getEncryptKey(int tunnel)
tunnel - the tunnelpublic int getEncryptMode(int tunnel)
tunnel - the tunnelpublic String getFilterDefinition(int tunnel)
tunnel - the tunnelpublic String getInboundRandomKey(int tunnel)
tunnel - the tunnelpublic String getJumpList(int tunnel)
tunnel - the tunnelpublic String getLeaseSetPrivateKey(int tunnel)
tunnel - the tunnelpublic String getLeaseSetSigningPrivateKey(int tunnel)
tunnel - the tunnelpublic int getLimitDay(int tunnel)
tunnel - the tunnelpublic int getLimitHour(int tunnel)
tunnel - the tunnelpublic int getLimitMinute(int tunnel)
tunnel - the tunnelpublic int getMaxStreams(int tunnel)
tunnel - the tunnelpublic boolean getMultihome(int tunnel)
tunnel - the tunnelpublic boolean getNewDest(int tunnel)
tunnel - the tunnelpublic String getOutboundRandomKey(int tunnel)
tunnel - the tunnelpublic boolean getOutproxyAuth(int tunnel)
tunnel - the tunnelpublic String getOutproxyPassword(int tunnel)
tunnel - the tunnelpublic String getOutproxyType(int tunnel)
tunnel - the tunnelpublic String getOutproxyUsername(int tunnel)
tunnel - the tunnelpublic boolean getPersistentClientKey(int tunnel)
tunnel - the tunnelpublic int getPostBanTime(int tunnel)
tunnel - the tunnelpublic int getPostCheckTime(int tunnel)
tunnel - the tunnelpublic int getPostMax(int tunnel)
tunnel - the tunnelpublic int getPostTotalBanTime(int tunnel)
tunnel - the tunnelpublic int getPostTotalMax(int tunnel)
tunnel - the tunnelpublic String getPrivateKeyFile(int tunnel)
tunnel - the tunnelpublic String getPrivateKeyFile(TunnelControllerGroup tcg, int tunnel)
tcg - the controller group, may be nulltunnel - the tunnelpublic String getProxyAuth(int tunnel)
tunnel - the tunnelpublic int getReduceCount(int tunnel,
int def)tunnel - the tunneldef - default value if not configuredpublic boolean getReduceOnIdle(int tunnel,
boolean def)tunnel - the tunneldef - default value if not configuredpublic int getReduceTime(int tunnel,
int def)tunnel - the tunneldef - default idle time in minutespublic boolean getRejectInproxy(int tunnel)
tunnel - the tunnelpublic boolean getRejectReferer(int tunnel)
tunnel - the tunnelpublic boolean getRejectUserAgents(int tunnel)
tunnel - the tunnelpublic int getRemainingStartupDelay(int tunnel)
tunnel - the tunnelpublic String getSigner(int tunnel)
tunnel - the tunnelpublic int getSigType(int tunnel,
String newTunnelType)tunnel - the tunnelnewTunnelType - used if tunnel < 0 to determine defaultpublic String getSpoofedHost(int tunnel)
tunnel - the tunnelpublic String getSslProxies(int tunnel)
tunnel - the tunnelpublic String getTargetHost(int tunnel)
tunnel - the tunnelpublic int getTargetPort(int tunnel)
tunnel - the tunnelpublic int getTotalDay(int tunnel)
tunnel - the tunnelpublic int getTotalHour(int tunnel)
tunnel - the tunnelpublic int getTotalMinute(int tunnel)
tunnel - the tunnelpublic int getTunnelBackupQuantity(int tunnel,
int defaultBackupQuantity)tunnel - the tunneldefaultBackupQuantity - default value if not configuredpublic int getTunnelBackupQuantityOut(int tunnel,
int defaultBackupQuantity)tunnel - the tunneldefaultBackupQuantity - default value if not configuredpublic int getTunnelDepth(int tunnel,
int defaultLength)tunnel - the tunneldefaultLength - default value if not configuredpublic int getTunnelDepthOut(int tunnel,
int defaultLength)tunnel - the tunneldefaultLength - default value if not configuredpublic String getTunnelDescription(int tunnel)
tunnel - the tunnelpublic String getTunnelName(int tunnel)
tunnel - the tunnelpublic static String getTunnelName(TunnelControllerGroup tcg, int tunnel)
tcg - the controller group, may be nulltunnel - the tunnelpublic int getTunnelQuantity(int tunnel,
int defaultQuantity)tunnel - the tunneldefaultQuantity - default value if not configuredpublic int getTunnelQuantityOut(int tunnel,
int defaultQuantity)tunnel - the tunneldefaultQuantity - default value if not configuredpublic int getTunnelStatus(int tunnel)
tunnel - the tunnelpublic String getTunnelType(int tunnel)
tunnel - the tunnelpublic int getTunnelVariance(int tunnel,
int defaultVariance)tunnel - the tunneldefaultVariance - default value if not configuredpublic int getTunnelVarianceOut(int tunnel,
int defaultVariance)tunnel - the tunneldefaultVariance - default value if not configuredpublic boolean getUniqueLocal(int tunnel)
tunnel - the tunnelpublic boolean getUseOutproxyPlugin(int tunnel)
tunnel - the tunnelpublic String getUserAgents(int tunnel)
tunnel - the tunnelpublic boolean hasEncType(int tunnel,
int encType)tunnel - the tunnelencType - encryption type codepublic boolean isInteractive(int tunnel)
tunnel - the tunnelpublic boolean isOfflineKeys(int tunnel)
tunnel - the tunnelpublic boolean isSharedClient(int tunnel)
tunnel - the tunnelpublic boolean isSSLEnabled(int tunnel)
tunnel - the tunnelprotected static List<String> saveConfig(I2PAppContext context, TunnelControllerGroup tcg, int tunnel)
context - unused, taken from tcgtunnel - must already existpublic static List<String> saveTunnel(I2PAppContext context, TunnelControllerGroup tcg, int tunnel, TunnelConfig config)
context - unused, taken from tcgpublic List<String> saveTunnel(int tunnel, TunnelConfig config)
tunnel - the tunnelconfig - the configuration to applypublic boolean shouldDelayConnect(int tunnel)
tunnel - the tunnelpublic boolean shouldStartAutomatically(int tunnel)
tunnel - the tunnelprotected static List<String> updateTunnelConfig(TunnelControllerGroup tcg, int tunnel, TunnelConfig config)