public class I2PSnarkUtil extends Object
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_STARTUP_DELAY |
static boolean |
DEFAULT_USE_DHT |
static boolean |
DEFAULT_USE_OPENTRACKERS |
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) |
Modifier and Type | Method and Description |
---|---|
boolean |
configured() |
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
|
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) |
List<String> |
getBackupTrackers()
List of open tracker announce URLs to use as backups even if disabled
|
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 |
getMaxUpBW() |
int |
getMaxUploaders() |
(package private) Destination |
getMyDestination() |
List<String> |
getOpenTrackers()
List of open tracker announce URLs to use as backups
|
String |
getOurIPString() |
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() |
boolean |
isConnecting() |
boolean |
isKnownOpenTracker(String url)
Is this announce URL probably for an open tracker?
|
String |
lookup(String name) |
(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 |
setFilesPublic(boolean yes) |
void |
setI2CPConfig(String i2cpHost,
int i2cpPort,
Map opts) |
void |
setMaxConnections(int limit) |
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 |
setStartupDelay(int minutes) |
void |
setUseDHT(boolean yes) |
void |
setUseOpenTrackers(boolean yes) |
boolean |
shouldUseDHT() |
boolean |
shouldUseOpenTrackers() |
static String |
toHex(byte[] b)
Like DataHelper.toHexString but ensures no loss of leading zero bytes
|
public static final int DEFAULT_STARTUP_DELAY
public static final boolean DEFAULT_USE_OPENTRACKERS
public static final int MAX_CONNECTIONS
public static final String PROP_MAX_BW
public static final boolean DEFAULT_USE_DHT
public static final String EEPGET_USER_AGENT
public I2PSnarkUtil(I2PAppContext ctx)
public I2PSnarkUtil(I2PAppContext ctx, String baseName)
baseName
- generally "i2psnark"public I2PAppContext getContext()
public boolean configured()
public void setMaxUploaders(int limit)
public void setMaxUpBW(int limit)
limit
- KBpspublic void setMaxConnections(int limit)
public void setStartupDelay(int minutes)
public String getI2CPHost()
public int getI2CPPort()
public String getEepProxyHost()
public int getEepProxyPort()
public boolean getEepProxySet()
public int getMaxUploaders()
public int getMaxUpBW()
public int getMaxConnections()
public int getStartupDelay()
public boolean getFilesPublic()
public void setFilesPublic(boolean yes)
public File getTempDir()
public boolean connect()
public DHT getDHT()
public boolean connected()
public boolean isConnecting()
public I2PSocketManager getSocketManager()
public void disconnect()
public long getStartedTime()
I2PSocket connect(PeerID peer) throws IOException
IOException
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, int retries)
retries
- if < 0, set timeout to a few secondspublic 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 I2PServerSocket getServerSocket()
public String getOurIPString()
Destination getMyDestination()
static Destination getDestinationFromBase64(String ip)
Destination getDestination(String ip)
String rewriteAnnounce(String origAnnounce)
public void setOpenTrackers(List<String> ot)
ot
- non-null list of announce URLspublic List<String> getOpenTrackers()
public boolean isKnownOpenTracker(String url)
public List<String> getBackupTrackers()
public void setUseOpenTrackers(boolean yes)
public boolean shouldUseOpenTrackers()
public void setUseDHT(boolean yes)
public boolean shouldUseDHT()
public static String toHex(byte[] b)
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.