Package org.klomp.snark
Class I2PSnarkUtil
java.lang.Object
org.klomp.snark.I2PSnarkUtil
public class I2PSnarkUtil extends Object
I2P specific helpers for I2PSnark
We use this class as a sort of context for i2psnark
so we can run multiple instances of single Snarks
(but not multiple SnarkManagers, it is still static)
-
Field Summary
Fields Modifier and Type Field 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 String
EEPGET_USER_AGENT
static int
MAX_CONNECTIONS
static String
PROP_MAX_BW
-
Constructor Summary
Constructors Constructor Description I2PSnarkUtil(I2PAppContext ctx)
I2PSnarkUtil(I2PAppContext ctx, String baseName)
-
Method Summary
Modifier and Type Method 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 destinationboolean
connected()
void
disconnect()
Destroy the destination itselfboolean
enableAddCreate()
boolean
enableLightbox()
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 memoryFile
get(String url, int retries)
List<String>
getBackupTrackers()
List of open tracker announce URLs to use as backups even if disabledString
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
getMaxUpBW()
int
getMaxUploaders()
(package private) Destination
getMyDestination()
List<String>
getOpenTrackers()
List of open tracker announce URLs to use as backupsString
getOurIPString()
I2PServerSocket
getServerSocket()
I2PSocketManager
getSocketManager()
For FetchAndAddlong
getStartedTime()
When did we connect to the network? For RPCint
getStartupDelay()
String
getString(int n, String s, String p)
ngettext @since 0.7.14String
getString(String key)
lang in routerconsole.lang property, else current localeString
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)
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 alonevoid
setCollapsePanels(boolean yes)
void
setCommentsEnabled(boolean yes)
void
setCommentsName(String name)
void
setEnableAddCreate(boolean yes)
void
setEnableLightbox(boolean yes)
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 routervoid
setMaxUploaders(int limit)
void
setOpenTrackers(List<String> ot)
void
setRatingsEnabled(boolean yes)
void
setShowStatusFilter(boolean yes)
void
setStartupDelay(int minutes)
void
setUseDHT(boolean yes)
void
setUseOpenTrackers(boolean yes)
boolean
shouldUseDHT()
boolean
shouldUseOpenTrackers()
boolean
showStatusFilter()
static String
toHex(byte[] b)
Like DataHelper.toHexString but ensures no loss of leading zero bytesboolean
utCommentsEnabled()
-
Field Details
-
DEFAULT_STARTUP_DELAY
public static final int DEFAULT_STARTUP_DELAY- See Also:
- Constant Field Values
-
DEFAULT_COLLAPSE_PANELS
public static final boolean DEFAULT_COLLAPSE_PANELS- See Also:
- Constant Field Values
-
DEFAULT_SHOW_STATUSFILTER
public static final boolean DEFAULT_SHOW_STATUSFILTER- See Also:
- Constant Field Values
-
DEFAULT_ENABLE_LIGHTBOX
public static final boolean DEFAULT_ENABLE_LIGHTBOX- See Also:
- Constant Field Values
-
DEFAULT_ENABLE_ADDCREATE
public static final boolean DEFAULT_ENABLE_ADDCREATE- See Also:
- Constant Field Values
-
DEFAULT_USE_OPENTRACKERS
public static final boolean DEFAULT_USE_OPENTRACKERS- See Also:
- Constant Field Values
-
MAX_CONNECTIONS
public static final int MAX_CONNECTIONS- See Also:
- Constant Field Values
-
PROP_MAX_BW
- See Also:
- Constant Field Values
-
DEFAULT_USE_DHT
public static final boolean DEFAULT_USE_DHT- See Also:
- Constant Field Values
-
EEPGET_USER_AGENT
- See Also:
- Constant Field Values
-
-
Constructor Details
-
I2PSnarkUtil
-
I2PSnarkUtil
- Parameters:
baseName
- generally "i2psnark"- Since:
- Jetty 7
-
-
Method Details
-
getContext
- Since:
- 0.9.1
-
setI2CPConfig
- Parameters:
i2cpHost
- may be null for no changei2cpPort
- may be 0 for no changeopts
- may be null for no change
-
setMaxUploaders
public void setMaxUploaders(int limit) -
setMaxUpBW
public void setMaxUpBW(int limit)This updates ALL the session options (not just the bw) and tells the router- Parameters:
limit
- KBps
-
setMaxConnections
public void setMaxConnections(int limit) -
setStartupDelay
public void setStartupDelay(int minutes) -
getI2CPHost
-
getI2CPPort
public int getI2CPPort() -
getI2CPOptions
- Returns:
- a copy
-
getEepProxyHost
-
getEepProxyPort
public int getEepProxyPort() -
getEepProxySet
public boolean getEepProxySet() -
getMaxUploaders
public int getMaxUploaders() -
getMaxUpBW
public int getMaxUpBW()- Returns:
- KBps
-
getMaxConnections
public int getMaxConnections() -
getStartupDelay
public int getStartupDelay() -
getFilesPublic
public boolean getFilesPublic()- Since:
- 0.8.9
-
setFilesPublic
public void setFilesPublic(boolean yes)- Since:
- 0.8.9
-
getTempDir
- Since:
- 0.9.1
-
connect
public boolean connect()Connect to the router, if we aren't already -
getDHT
- Returns:
- null if disabled or not started
- Since:
- 0.8.4
-
connected
public boolean connected() -
isConnecting
public boolean isConnecting()- Since:
- 0.9.1
-
getSocketManager
For FetchAndAdd- Returns:
- null if not connected
- Since:
- 0.9.1
-
disconnect
public void disconnect()Destroy the destination itself -
getStartedTime
public long getStartedTime()When did we connect to the network? For RPC- Returns:
- 0 if not connected
- Since:
- 0.9.30
-
connect
connect to the given destination- Throws:
IOException
-
get
Fetch the given URL, returning the file it is stored in, or null on error. No retries. -
get
- Parameters:
rewrite
- if true, convert http://KEY.i2p/foo/announce to http://i2p/KEY/foo/announce
-
get
- Parameters:
retries
- if > 0, set timeout to a few seconds
-
get
- Parameters:
retries
- if > 0, set timeout to a few seconds
-
get
Fetch to memory- Parameters:
retries
- if < 0, set timeout to a few secondsinitialSize
- buffer sizemaxSize
- fails if greater- Returns:
- null on error
- Since:
- 0.9.4
-
getServerSocket
-
getOurIPString
-
getMyDestination
Destination getMyDestination()- Returns:
- dest or null
- Since:
- 0.8.4
-
getDestinationFromBase64
Base64 only - static (no naming service) -
getDestination
Base64 Hash or Hash.i2p or name.i2p using naming service -
lookup
-
rewriteAnnounce
Given http://KEY.i2p/foo/announce turn it into http://i2p/KEY/foo/announce Given http://tracker.blah.i2p/foo/announce leave it alone -
setOpenTrackers
- Parameters:
ot
- non-null list of announce URLs
-
getOpenTrackers
List of open tracker announce URLs to use as backups- Returns:
- non-null, possibly unmodifiable, empty if disabled
-
isKnownOpenTracker
Is this announce URL probably for an open tracker?- Since:
- 0.9.17
-
getBackupTrackers
List of open tracker announce URLs to use as backups even if disabled- Returns:
- non-null
- Since:
- 0.9.4
-
setUseOpenTrackers
public void setUseOpenTrackers(boolean yes) -
shouldUseOpenTrackers
public boolean shouldUseOpenTrackers() -
setUseDHT
public void setUseDHT(boolean yes)- Since:
- DHT
-
shouldUseDHT
public boolean shouldUseDHT()- Since:
- DHT
-
setRatingsEnabled
public void setRatingsEnabled(boolean yes)- Since:
- 0.9.31
-
ratingsEnabled
public boolean ratingsEnabled()- Since:
- 0.9.31
-
setCommentsEnabled
public void setCommentsEnabled(boolean yes)- Since:
- 0.9.31
-
commentsEnabled
public boolean commentsEnabled()- Since:
- 0.9.31
-
setCommentsName
- Since:
- 0.9.31
-
getCommentsName
- Returns:
- non-null, "" if none
- Since:
- 0.9.31
-
utCommentsEnabled
public boolean utCommentsEnabled()- Since:
- 0.9.31
-
collapsePanels
public boolean collapsePanels()- Since:
- 0.9.32
-
setCollapsePanels
public void setCollapsePanels(boolean yes)- Since:
- 0.9.32
-
showStatusFilter
public boolean showStatusFilter()- Since:
- 0.9.34
-
setShowStatusFilter
public void setShowStatusFilter(boolean yes)- Since:
- 0.9.34
-
enableLightbox
public boolean enableLightbox()- Since:
- 0.9.34
-
setEnableLightbox
public void setEnableLightbox(boolean yes)- Since:
- 0.9.34
-
enableAddCreate
public boolean enableAddCreate()- Since:
- 0.9.38
-
setEnableAddCreate
public void setEnableAddCreate(boolean yes)- Since:
- 0.9.38
-
toHex
Like DataHelper.toHexString but ensures no loss of leading zero bytes- Since:
- 0.8.4
-
getString
lang in routerconsole.lang property, else current locale -
getString
translate a string with a parameter This is a lot more expensive than getString(s, ctx), so use sparingly.- Parameters:
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.
-
getString
{0} and {1} -
getString
ngettext @since 0.7.14
-