net.i2p.router

## Class TunnelPoolSettings

- java.lang.Object
- - net.i2p.router.TunnelPoolSettings

-     public class TunnelPoolSettings
      extends Object

  Wrap up the settings for a pool of tunnels.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static boolean` | `DEFAULT_ALLOW_ZERO_HOP`
    `static int` | `DEFAULT_BACKUP_QUANTITY`
    `static int` | `DEFAULT_DURATION`
    `static int` | `DEFAULT_IP_RESTRICTION`
    `static int` | `DEFAULT_QUANTITY`
    `static String` | `PREFIX_INBOUND_EXPLORATORY` prefix used to configure the inbound exploratory pool
    `static String` | `PREFIX_OUTBOUND_EXPLORATORY` prefix used to configure the outbound exploratory pool
    `static String` | `PROP_ALLOW_ZERO_HOP` don't trust this, always true
    `static String` | `PROP_BACKUP_QUANTITY`
    `static String` | `PROP_DURATION`
    `static String` | `PROP_IP_RESTRICTION`
    `static String` | `PROP_LENGTH`
    `static String` | `PROP_LENGTH_VARIANCE`
    `static String` | `PROP_NICKNAME`
    `static String` | `PROP_PRIORITY`
    `static String` | `PROP_QUANTITY`
    `static String` | `PROP_RANDOM_KEY`
    `static String` | `PROP_SHOULD_TEST`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `TunnelPoolSettings(boolean isInbound)` Exploratory tunnel
    `TunnelPoolSettings(Hash dest, boolean isInbound)` Client tunnel unless dest == null

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `Set<Hash>` | `getAliases()` Other destinations that use the same tunnel (or null if exploratory) Modifiable, concurrent, not a copy
    `Hash` | `getAliasOf()` Other destination that this is an alias of (or null).
    `boolean` | `getAllowZeroHop()` If there are no tunnels to build with, will this pool allow 0 hop tunnels? As of 0.9.44, same goes for exploratory: Prior to 0.9.35, generally true for client.
    `int` | `getBackupQuantity()` how many backup tunnels should be kept waiting in the wings
    `Hash` | `getDestination()` what destination is this a client tunnel for (or null if exploratory)
    `String` | `getDestinationNickname()` what user supplied name was given to the client connected (can be null)
    `Set<Hash>` | `getFirstPeerExclusions()` Get the set of first peer exclusions for diversity.
    `int` | `getIPRestriction()` How many bytes to match to determine if a router's IP is too close to another's to be in the same tunnel (1-4, 0 to disable) Support removed in the ClientPeerSelector in 0.8.6; restored in 0.9.53
    `Set<Hash>` | `getLastPeerExclusions()` Get the set of last peer exclusions for diversity.
    `int` | `getLength()` How many remote hops should be in the tunnel NOT including us
    `int` | `getLengthOverride()` A temporary length to be used due to network conditions.
    `int` | `getLengthVariance()` how should the length be varied.
    `long` | `getMsgIdBloomXor()`
    `int` | `getPriority()` Outbound message priority - for outbound tunnels only
    `int` | `getQuantity()` how many tunnels should be available at all times
    `SessionKey` | `getRandomKey()` random key used for peer ordering
    `int` | `getTotalQuantity()` Convenience
    `Properties` | `getUnknownOptions()`
    `boolean` | `isExploratory()` is this an exploratory tunnel (or a client tunnel)
    `boolean` | `isInbound()` is this an inbound tunnel?
    `void` | `readFromProperties(String prefix, Properties props)` Defaults in props are NOT honored.
    `void` | `setAliasOf(Hash h)` Set other destination that this is an alias of (or null).
    `void` | `setBackupQuantity(int quantity)`
    `void` | `setDestinationNickname(String name)`
    `void` | `setFirstPeerExclusions(Set<Hash> exclusions)` Set the first peer exclusions for diversity.
    `void` | `setLastPeerExclusions(Set<Hash> exclusions)` Set the last peer exclusions for diversity.
    `void` | `setLength(int length)` How many remote hops should be in the tunnel NOT including us
    `void` | `setLengthOverride(int length)` A temporary length to be used due to network conditions.
    `void` | `setLengthVariance(int variance)`
    `void` | `setQuantity(int quantity)`
    `boolean` | `shouldTest()` Whether this tunnel should be tested.
    `String` | `toString()`
    `void` | `writeToProperties(String prefix, Properties props)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### DEFAULT_ALLOW_ZERO_HOP

          public static final boolean DEFAULT_ALLOW_ZERO_HOP

      See Also:
        Constant Field Values

    - #### DEFAULT_BACKUP_QUANTITY

          public static final int DEFAULT_BACKUP_QUANTITY

      See Also:
        Constant Field Values

    - #### DEFAULT_DURATION

          public static final int DEFAULT_DURATION

      See Also:
        Constant Field Values

    - #### DEFAULT_IP_RESTRICTION

          public static final int DEFAULT_IP_RESTRICTION

      See Also:
        Constant Field Values

    - #### DEFAULT_QUANTITY

          public static final int DEFAULT_QUANTITY

      See Also:
        Constant Field Values

    - #### PREFIX_INBOUND_EXPLORATORY

          public static final String PREFIX_INBOUND_EXPLORATORY

      prefix used to configure the inbound exploratory pool
      See Also:
        Constant Field Values

    - #### PREFIX_OUTBOUND_EXPLORATORY

          public static final String PREFIX_OUTBOUND_EXPLORATORY

      prefix used to configure the outbound exploratory pool
      See Also:
        Constant Field Values

    - #### PROP_ALLOW_ZERO_HOP

          public static final String PROP_ALLOW_ZERO_HOP

      don't trust this, always true
      See Also:
        Constant Field Values

    - #### PROP_BACKUP_QUANTITY

          public static final String PROP_BACKUP_QUANTITY

      See Also:
        Constant Field Values

    - #### PROP_DURATION

          public static final String PROP_DURATION

      See Also:
        Constant Field Values

    - #### PROP_IP_RESTRICTION

          public static final String PROP_IP_RESTRICTION

      See Also:
        Constant Field Values

    - #### PROP_LENGTH

          public static final String PROP_LENGTH

      See Also:
        Constant Field Values

    - #### PROP_LENGTH_VARIANCE

          public static final String PROP_LENGTH_VARIANCE

      See Also:
        Constant Field Values

    - #### PROP_NICKNAME

          public static final String PROP_NICKNAME

      See Also:
        Constant Field Values

    - #### PROP_PRIORITY

          public static final String PROP_PRIORITY

      See Also:
        Constant Field Values

    - #### PROP_QUANTITY

          public static final String PROP_QUANTITY

      See Also:
        Constant Field Values

    - #### PROP_RANDOM_KEY

          public static final String PROP_RANDOM_KEY

      See Also:
        Constant Field Values

    - #### PROP_SHOULD_TEST

          public static final String PROP_SHOULD_TEST

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### TunnelPoolSettings

          public TunnelPoolSettings(boolean isInbound)

      Exploratory tunnel

    - #### TunnelPoolSettings

          public TunnelPoolSettings(Hash dest,
                                    boolean isInbound)

      Client tunnel unless dest == null

  - ### Method Detail

    - #### getAliases

          public Set<Hash> getAliases()

      Other destinations that use the same tunnel (or null if exploratory) Modifiable, concurrent, not a copy

    - #### getAliasOf

          public Hash getAliasOf()

      Other destination that this is an alias of (or null). If non-null, don't build tunnels.

    - #### getAllowZeroHop

          public boolean getAllowZeroHop()

      If there are no tunnels to build with, will this pool allow 0 hop tunnels? As of 0.9.44, same goes for exploratory: Prior to 0.9.35, generally true for client. As of 0.9.35, generally false for client, but true if getLength() + Math.min(getLengthVariance(), 0) <= 0, OR if getLengthOverride() == 0 OR if setAllowZeroHop(true) was called or set in properties.

    - #### getBackupQuantity

          public int getBackupQuantity()

      how many backup tunnels should be kept waiting in the wings

    - #### getDestination

          public Hash getDestination()

      what destination is this a client tunnel for (or null if exploratory)

    - #### getDestinationNickname

          public String getDestinationNickname()

      what user supplied name was given to the client connected (can be null)

    - #### getFirstPeerExclusions

          public Set<Hash> getFirstPeerExclusions()

      Get the set of first peer exclusions for diversity. These are peers that should not be used as the first hop in new tunnels because they are already used as the first hop in existing tunnels.
      Returns:
        Set of peer hashes to exclude, or null if none set

    - #### getIPRestriction

          public int getIPRestriction()

      How many bytes to match to determine if a router's IP is too close to another's to be in the same tunnel (1-4, 0 to disable) Support removed in the ClientPeerSelector in 0.8.6; restored in 0.9.53
      Returns:
        0-4 Number of bytes to match to determine if peers in the same IP range should not be in the same tunnel. 0 = disable check; 1 = /8; 2 = /16; 3 = /24; 4 = exact IP match

    - #### getLastPeerExclusions

          public Set<Hash> getLastPeerExclusions()

      Get the set of last peer exclusions for diversity. These are peers that should not be used as the last hop in new tunnels because they are already used as the last hop in existing tunnels.
      Returns:
        Set of peer hashes to exclude, or null if none set

    - #### getLength

          public int getLength()

      How many remote hops should be in the tunnel NOT including us
      Returns:
        0 to 7

    - #### getLengthOverride

          public int getLengthOverride()

      A temporary length to be used due to network conditions. If less than zero, the standard length should be used. Unused until 0.8.11

    - #### getLengthVariance

          public int getLengthVariance()

      how should the length be varied. if negative, this randomly skews from (length - variance) to (length + variance), or if positive, from length to (length + variance), inclusive.

    - #### getMsgIdBloomXor

          public long getMsgIdBloomXor()

    - #### getPriority

          public int getPriority()

      Outbound message priority - for outbound tunnels only
      Returns:
        -25 to +30, default 30 for outbound exploratory and 0 for others

    - #### getQuantity

          public int getQuantity()

      how many tunnels should be available at all times

    - #### getRandomKey

          public SessionKey getRandomKey()

      random key used for peer ordering
      Returns:
        non-null

    - #### getTotalQuantity

          public int getTotalQuantity()

      Convenience
      Returns:
        getQuantity() + getBackupQuantity()

    - #### getUnknownOptions

          public Properties getUnknownOptions()

      Returns:
        non-null

    - #### isExploratory

          public boolean isExploratory()

      is this an exploratory tunnel (or a client tunnel)

    - #### isInbound

          public boolean isInbound()

      is this an inbound tunnel?

    - #### readFromProperties

          public void readFromProperties(String prefix,
                                         Properties props)

      Defaults in props are NOT honored. In-JVM client side must promote defaults to the primary map.
      Parameters:
        `prefix` - non-null

    - #### setAliasOf

          public void setAliasOf(Hash h)

      Set other destination that this is an alias of (or null). If non-null, don't build tunnels.

    - #### setBackupQuantity

          public void setBackupQuantity(int quantity)

    - #### setDestinationNickname

          public void setDestinationNickname(String name)

    - #### setFirstPeerExclusions

          public void setFirstPeerExclusions(Set<Hash> exclusions)

      Set the first peer exclusions for diversity. These are peers that should not be used as the first hop in new tunnels because they are already used as the first hop in existing tunnels. This is a transient setting used during tunnel building.
      Parameters:
        `exclusions` - Set of peer hashes to exclude, or null to clear

    - #### setLastPeerExclusions

          public void setLastPeerExclusions(Set<Hash> exclusions)

      Set the last peer exclusions for diversity. These are peers that should not be used as the last hop in new tunnels because they are already used as the last hop in existing tunnels. This is a transient setting used during tunnel building.
      Parameters:
        `exclusions` - Set of peer hashes to exclude, or null to clear

    - #### setLength

          public void setLength(int length)

      How many remote hops should be in the tunnel NOT including us
      Parameters:
        `length` - 0 to 7 (not enforced here)

    - #### setLengthOverride

          public void setLengthOverride(int length)

      A temporary length to be used due to network conditions. If less than zero, the standard length will be used. Unused until 0.8.11

    - #### setLengthVariance

          public void setLengthVariance(int variance)

    - #### setQuantity

          public void setQuantity(int quantity)

    - #### shouldTest

          public boolean shouldTest()

      Whether this tunnel should be tested.
      Returns:
        true (default) for most tunnels, false for ping tunnels and other short-lived tunnels

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### writeToProperties

          public void writeToProperties(String prefix,
                                        Properties props)

      Parameters:
        `prefix` - non-null