## org.klomp.snark
Class I2PSnarkUtil

    java.lang.Object
      org.klomp.snark.I2PSnarkUtil

    public class I2PSnarkUtil

extends java.lang.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
`static int` `DEFAULT_MAX_UP_BW`
`static java.lang.String` `DEFAULT_OPENTRACKERS`
`static boolean` `DEFAULT_USE_OPENTRACKERS`
`static int` `MAX_CONNECTIONS`
`static java.lang.String` `PROP_OPENTRACKERS`
`static java.lang.String` `PROP_USE_OPENTRACKERS`

Constructor Summary
`I2PSnarkUtil(I2PAppContext ctx)`

Method Summary
`boolean` `configured()` public void setProxy(String host, int port) { if ( (host != null) && (port > 0) ) { _shouldProxy = true; _proxyHost = host; _proxyPort = port; } else { _shouldProxy = false; _proxyHost = null; _proxyPort = -1; } _configured = true; }
`boolean` `connect()` Connect to the router, if we aren't already
`(package private) I2PSocket` `connect(PeerID peer)` connect to the given destination
`boolean` `connected()`
`(package private) void` `debug(java.lang.String msg, int snarkDebugLevel)` hook between snark's logger and an i2p log
`(package private) void` `debug(java.lang.String msg, int snarkDebugLevel, java.lang.Throwable t)`
`void` `disconnect()` Destroy the destination itself
`java.io.File` `get(java.lang.String url)` fetch the given URL, returning the file it is stored in, or null on error
`java.io.File` `get(java.lang.String url, boolean rewrite)`
`java.io.File` `get(java.lang.String url, boolean rewrite, int retries)`
`java.io.File` `get(java.lang.String url, int retries)`
`(package private) Destination` `getDestination(java.lang.String ip)` Base64 Hash or Hash.i2p or name.i2p using naming service
`(package private) static Destination` `getDestinationFromBase64(java.lang.String ip)` Base64 only - static (no naming service)
`java.lang.String` `getEepProxyHost()`
`int` `getEepProxyPort()`
`boolean` `getEepProxySet()`
`java.lang.String` `getI2CPHost()`
`java.util.Map<java.lang.String,java.lang.String>` `getI2CPOptions()`
`int` `getI2CPPort()`
`int` `getMaxConnections()`
`int` `getMaxUpBW()`
`int` `getMaxUploaders()`
`java.util.List` `getOpenTrackers()` sorted map of name to announceURL=baseURL
`java.lang.String` `getOpenTrackerString()`
`(package private) java.lang.String` `getOurIPString()`
`I2PServerSocket` `getServerSocket()`
`java.lang.String` `getString(int n, java.lang.String s, java.lang.String p)` ngettext @since 0.7.14
`java.lang.String` `getString(java.lang.String key)` lang in routerconsole.lang property, else current locale
`java.lang.String` `getString(java.lang.String s, java.lang.Object o)` translate a string with a parameter This is a lot more expensive than getString(s, ctx), so use sparingly.
`java.lang.String` `getString(java.lang.String s, java.lang.Object o, java.lang.Object o2)` {0} and {1}
`java.lang.String` `lookup(java.lang.String name)`
`(package private) java.lang.String` `rewriteAnnounce(java.lang.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` `setI2CPConfig(java.lang.String i2cpHost, int i2cpPort, java.util.Map opts)`
`void` `setMaxConnections(int limit)`
`void` `setMaxUpBW(int limit)`
`void` `setMaxUploaders(int limit)`
`void` `setOpenTrackerString(java.lang.String ot)`
`boolean` `shouldUseOpenTrackers()`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### PROP_USE_OPENTRACKERS

    public static final java.lang.String PROP_USE_OPENTRACKERS

See Also:
  Constant Field Values

### DEFAULT_USE_OPENTRACKERS

    public static final boolean DEFAULT_USE_OPENTRACKERS

See Also:
  Constant Field Values

### PROP_OPENTRACKERS

    public static final java.lang.String PROP_OPENTRACKERS

See Also:
  Constant Field Values

### DEFAULT_OPENTRACKERS

    public static final java.lang.String DEFAULT_OPENTRACKERS

See Also:
  Constant Field Values

### DEFAULT_MAX_UP_BW

    public static final int DEFAULT_MAX_UP_BW

See Also:
  Constant Field Values

### MAX_CONNECTIONS

    public static final int MAX_CONNECTIONS

See Also:
  Constant Field Values

Constructor Detail

### I2PSnarkUtil

    public I2PSnarkUtil(I2PAppContext ctx)

Method Detail

### configured

    public boolean configured()

  public void setProxy(String host, int port) { if ( (host != null) && (port > 0) ) { _shouldProxy = true; _proxyHost = host; _proxyPort = port; } else { _shouldProxy = false; _proxyHost = null; _proxyPort = -1; } _configured = true; }

### setI2CPConfig

    public void setI2CPConfig(java.lang.String i2cpHost,
                              int i2cpPort,
                              java.util.Map opts)

### setMaxUploaders

    public void setMaxUploaders(int limit)

### setMaxUpBW

    public void setMaxUpBW(int limit)

### setMaxConnections

    public void setMaxConnections(int limit)

### getI2CPHost

    public java.lang.String getI2CPHost()

### getI2CPPort

    public int getI2CPPort()

### getI2CPOptions

    public java.util.Map<java.lang.String,java.lang.String> getI2CPOptions()

### getEepProxyHost

    public java.lang.String getEepProxyHost()

### getEepProxyPort

    public int getEepProxyPort()

### getEepProxySet

    public boolean getEepProxySet()

### getMaxUploaders

    public int getMaxUploaders()

### getMaxUpBW

    public int getMaxUpBW()

### getMaxConnections

    public int getMaxConnections()

### connect

    public boolean connect()

  Connect to the router, if we aren't already

### connected

    public boolean connected()

### disconnect

    public void disconnect()

  Destroy the destination itself

### connect

    I2PSocket connect(PeerID peer)
                throws java.io.IOException

  connect to the given destination

  Throws:
    `java.io.IOException`

### get

    public java.io.File get(java.lang.String url)

  fetch the given URL, returning the file it is stored in, or null on error

### get

    public java.io.File get(java.lang.String url,
                            boolean rewrite)

### get

    public java.io.File get(java.lang.String url,
                            int retries)

### get

    public java.io.File get(java.lang.String url,
                            boolean rewrite,
                            int retries)

### getServerSocket

    public I2PServerSocket getServerSocket()

### getOurIPString

    java.lang.String getOurIPString()

### getDestinationFromBase64

    static Destination getDestinationFromBase64(java.lang.String ip)

  Base64 only - static (no naming service)

### getDestination

    Destination getDestination(java.lang.String ip)

  Base64 Hash or Hash.i2p or name.i2p using naming service

### lookup

    public java.lang.String lookup(java.lang.String name)

### rewriteAnnounce

    java.lang.String rewriteAnnounce(java.lang.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

### setOpenTrackerString

    public void setOpenTrackerString(java.lang.String ot)

  Parameters:
    `ot` - non-null

### getOpenTrackerString

    public java.lang.String getOpenTrackerString()

### getOpenTrackers

    public java.util.List getOpenTrackers()

  sorted map of name to announceURL=baseURL

### shouldUseOpenTrackers

    public boolean shouldUseOpenTrackers()

### debug

    void debug(java.lang.String msg,
               int snarkDebugLevel)

  hook between snark's logger and an i2p log

### debug

    void debug(java.lang.String msg,
               int snarkDebugLevel,
               java.lang.Throwable t)

### getString

    public java.lang.String getString(java.lang.String key)

  lang in routerconsole.lang property, else current locale

### getString

    public java.lang.String getString(java.lang.String s,
                                      java.lang.Object o)

  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 tranlslate parameter also, use _("foo {0} bar", _("baz")) Do not double the single quotes in the parameter. Use autoboxing to call with ints, longs, floats, etc.

### getString

    public java.lang.String getString(java.lang.String s,
                                      java.lang.Object o,
                                      java.lang.Object o2)

  {0} and {1}

### getString

    public java.lang.String getString(int n,
                                      java.lang.String s,
                                      java.lang.String p)

  ngettext @since 0.7.14