public class I2PSnarkUtil extends Object implements I2PSocketManager.DisconnectListener
This class provides I2P network integration and serves as a context object for I2PSnark operations. It handles:
This class acts as a singleton-like context that allows multiple individual Snark instances to run while sharing common I2P configuration and resources. Note that while multiple Snarks can share one I2PSnarkUtil instance, multiple SnarkManagers are not supported due to static resources.
| Modifier and Type | Field and Description |
|---|---|
static boolean |
DEFAULT_COLLAPSE_PANELS |
static boolean |
DEFAULT_ENABLE_ADDCREATE |
static boolean |
DEFAULT_ENABLE_LIGHTBOX |
static boolean |
DEFAULT_SHOW_STATUSFILTER |
static int |
DEFAULT_STARTUP_DELAY |
static boolean |
DEFAULT_USE_DHT |
static boolean |
DEFAULT_USE_OPENTRACKERS |
static boolean |
DEFAULT_VARY_INBOUND_HOPS |
static boolean |
DEFAULT_VARY_OUTBOUND_HOPS |
static String |
EEPGET_USER_AGENT |
static int |
MAX_CONNECTIONS |
static String |
PROP_MAX_BW |
| Constructor and Description |
|---|
I2PSnarkUtil(I2PAppContext ctx) |
I2PSnarkUtil(I2PAppContext ctx,
String baseName,
I2PSocketManager.DisconnectListener discon) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
collapsePanels() |
boolean |
commentsEnabled() |
boolean |
connect()
Connect to the router, if we aren't already
|
(package private) I2PSocket |
connect(PeerID peer)
Connect to the given destination
|
boolean |
connected() |
void |
disconnect()
Destroy the destination itself
|
boolean |
enableAddCreate() |
boolean |
enableLightbox() |
boolean |
enableVaryInboundHops() |
boolean |
enableVaryOutboundHops() |
File |
get(String url)
Fetch the given URL, returning the file it is stored in, or null on error.
|
File |
get(String url,
boolean rewrite) |
File |
get(String url,
boolean rewrite,
int retries) |
byte[] |
get(String url,
boolean rewrite,
int retries,
int initialSize,
int maxSize)
Fetch to memory
|
File |
get(String url,
int retries) |
String |
getAPIKey() |
String |
getAPITarget() |
List<String> |
getBackupTrackers()
List of open tracker announce URLs to use as backups even if disabled
|
String |
getCommentsName() |
I2PAppContext |
getContext() |
(package private) Destination |
getDestination(String ip)
Base64 Hash or Hash.i2p or name.i2p using naming service
|
(package private) static Destination |
getDestinationFromBase64(String ip)
Base64 only - static (no naming service)
|
DHT |
getDHT() |
String |
getEepProxyHost() |
int |
getEepProxyPort() |
boolean |
getEepProxySet() |
boolean |
getFilesPublic() |
String |
getI2CPHost() |
Map<String,String> |
getI2CPOptions() |
int |
getI2CPPort() |
int |
getMaxConnections() |
int |
getMaxFilesPerTorrent() |
int |
getMaxUpBW() |
int |
getMaxUploaders() |
(package private) Destination |
getMyDestination() |
List<String> |
getOpenTrackers()
List of open tracker announce URLs to use as backups
|
String |
getOurIPString()
Full Base64 of Destination
|
boolean |
getPreallocateFiles() |
I2PServerSocket |
getServerSocket() |
I2PSocketManager |
getSocketManager()
For FetchAndAdd
|
long |
getStartedTime()
When did we connect to the network? For RPC
|
int |
getStartupDelay() |
String |
getString(int n,
String s,
String p)
ngettext @since 0.7.14
|
String |
getString(String key)
lang in routerconsole.lang property, else current locale
|
String |
getString(String s,
Object o)
Translate a string with a parameter This is a lot more expensive than getString(s, ctx), so
use sparingly.
|
String |
getString(String s,
Object o,
Object o2)
{0} and {1}
|
File |
getTempDir() |
UDPTrackerClient |
getUDPTrackerClient() |
boolean |
getVaryInboundHops() |
boolean |
getVaryOutboundHops() |
boolean |
hasAPIKey() |
boolean |
isConnecting() |
boolean |
isKnownOpenTracker(String url)
Is this announce URL probably for an open tracker?
|
(package private) static void |
loadProps(Properties props,
File f)
Same as DataHelper.loadProps() but allows '#' in values, so we can have filenames with '#' in
them in torrent config files.
|
String |
lookup(String name) |
boolean |
ratingsEnabled() |
(package private) String |
rewriteAnnounce(String origAnnounce)
Given http://KEY.i2p/foo/announce turn it into http://i2p/KEY/foo/announce Given
http://tracker.blah.i2p/foo/announce leave it alone
|
void |
sessionDisconnected()
DisconnectListener interface
|
void |
setAPI(String target,
String key) |
void |
setCollapsePanels(boolean yes) |
void |
setCommentsEnabled(boolean yes) |
void |
setCommentsName(String name) |
void |
setEnableAddCreate(boolean yes) |
void |
setEnableLightbox(boolean yes) |
void |
setEnableVaryInboundHops(boolean yes) |
void |
setEnableVaryOutboundHops(boolean yes) |
void |
setFilesPublic(boolean yes) |
void |
setI2CPConfig(String i2cpHost,
int i2cpPort,
Map opts) |
void |
setMaxConnections(int limit) |
void |
setMaxFilesPerTorrent(int max) |
void |
setMaxUpBW(int limit)
This updates ALL the session options (not just the bw) and tells the router
|
void |
setMaxUploaders(int limit) |
void |
setOpenTrackers(List<String> ot) |
void |
setPreallocateFiles(boolean yes) |
void |
setRatingsEnabled(boolean yes) |
void |
setShowStatusFilter(boolean yes) |
void |
setStartupDelay(int minutes) |
void |
setUDPEnabled(boolean yes) |
void |
setUseDHT(boolean yes) |
void |
setUseOpenTrackers(boolean yes) |
void |
setVaryInboundHops(boolean yes) |
void |
setVaryOutboundHops(boolean yes) |
boolean |
shouldUseDHT() |
boolean |
shouldUseOpenTrackers() |
boolean |
showStatusFilter() |
(package private) static void |
storeProps(Properties props,
File file)
Same as DataHelper.loadProps() but allows '#' in values, so we can have filenames with '#' in
them in torrent config files.
|
static String |
toHex(byte[] b)
Like DataHelper.toHexString but ensures no loss of leading zero bytes
|
boolean |
udpEnabled() |
boolean |
utCommentsEnabled() |
public static final boolean DEFAULT_COLLAPSE_PANELS
public static final boolean DEFAULT_ENABLE_ADDCREATE
public static final boolean DEFAULT_ENABLE_LIGHTBOX
public static final boolean DEFAULT_SHOW_STATUSFILTER
public static final int DEFAULT_STARTUP_DELAY
public static final boolean DEFAULT_USE_DHT
public static final boolean DEFAULT_USE_OPENTRACKERS
public static final boolean DEFAULT_VARY_INBOUND_HOPS
public static final boolean DEFAULT_VARY_OUTBOUND_HOPS
public static final String EEPGET_USER_AGENT
public static final int MAX_CONNECTIONS
public static final String PROP_MAX_BW
public I2PSnarkUtil(I2PAppContext ctx)
public I2PSnarkUtil(I2PAppContext ctx, String baseName, I2PSocketManager.DisconnectListener discon)
baseName - generally "i2psnark"public boolean collapsePanels()
public boolean commentsEnabled()
public boolean connect()
I2PSocket connect(PeerID peer) throws IOException
IOExceptionpublic boolean connected()
public void disconnect()
public boolean enableAddCreate()
public boolean enableLightbox()
public boolean enableVaryInboundHops()
public boolean enableVaryOutboundHops()
public File get(String url)
public File get(String url, boolean rewrite)
rewrite - if true, convert http://KEY.i2p/foo/announce to http://i2p/KEY/foo/announcepublic File get(String url, boolean rewrite, int retries)
retries - if > 0, set timeout to a few secondspublic byte[] get(String url, boolean rewrite, int retries, int initialSize, int maxSize)
retries - if < 0, set timeout to a few secondsinitialSize - buffer sizemaxSize - fails if greaterpublic File get(String url, int retries)
retries - if > 0, set timeout to a few secondspublic String getAPIKey()
public String getAPITarget()
public List<String> getBackupTrackers()
public String getCommentsName()
public I2PAppContext getContext()
Destination getDestination(String ip)
static Destination getDestinationFromBase64(String ip)
public DHT getDHT()
public String getEepProxyHost()
public int getEepProxyPort()
public boolean getEepProxySet()
public boolean getFilesPublic()
public String getI2CPHost()
public int getI2CPPort()
public int getMaxConnections()
public int getMaxFilesPerTorrent()
public int getMaxUpBW()
public int getMaxUploaders()
Destination getMyDestination()
public List<String> getOpenTrackers()
public String getOurIPString()
public boolean getPreallocateFiles()
public I2PServerSocket getServerSocket()
public I2PSocketManager getSocketManager()
public long getStartedTime()
public int getStartupDelay()
public String getString(String key)
public String getString(String s, Object o)
s - string to be translated containing {0} The {0} will be replaced by the parameter.
Single quotes must be doubled, i.e. ' -> '' in the string.o - parameter, not translated. To translate parameter also, use _t("foo {0} bar",
_t("baz")) Do not double the single quotes in the parameter. Use autoboxing to call with
ints, longs, floats, etc.public File getTempDir()
public UDPTrackerClient getUDPTrackerClient()
public boolean getVaryInboundHops()
public boolean getVaryOutboundHops()
public boolean hasAPIKey()
public boolean isConnecting()
public boolean isKnownOpenTracker(String url)
static void loadProps(Properties props, File f) throws IOException
IOExceptionpublic boolean ratingsEnabled()
String rewriteAnnounce(String origAnnounce)
public void sessionDisconnected()
sessionDisconnected in interface I2PSocketManager.DisconnectListenerpublic void setCollapsePanels(boolean yes)
public void setCommentsEnabled(boolean yes)
public void setCommentsName(String name)
public void setEnableAddCreate(boolean yes)
public void setEnableLightbox(boolean yes)
public void setEnableVaryInboundHops(boolean yes)
public void setEnableVaryOutboundHops(boolean yes)
public void setFilesPublic(boolean yes)
public void setI2CPConfig(String i2cpHost, int i2cpPort, Map opts)
i2cpHost - may be null for no changei2cpPort - may be 0 for no changeopts - may be null for no changepublic void setMaxConnections(int limit)
public void setMaxFilesPerTorrent(int max)
public void setMaxUpBW(int limit)
limit - KBpspublic void setMaxUploaders(int limit)
public void setOpenTrackers(List<String> ot)
ot - non-null list of announce URLspublic void setPreallocateFiles(boolean yes)
public void setRatingsEnabled(boolean yes)
public void setShowStatusFilter(boolean yes)
public void setStartupDelay(int minutes)
public void setUDPEnabled(boolean yes)
public void setUseDHT(boolean yes)
public void setUseOpenTrackers(boolean yes)
public void setVaryInboundHops(boolean yes)
public void setVaryOutboundHops(boolean yes)
public boolean shouldUseDHT()
public boolean shouldUseOpenTrackers()
public boolean showStatusFilter()
static void storeProps(Properties props, File file) throws IOException
IOExceptionpublic static String toHex(byte[] b)
public boolean udpEnabled()
public boolean utCommentsEnabled()