java.lang.Object
net.i2p.router.TunnelPoolSettings
Wrap up the settings for a pool of tunnels.
Field Summary
Modifier and TypeFieldDescriptionDestination hashes aliasing this pool.private HashDestination this pool is an alias of, null if none.private booleanTrue to allow zero-hop tunnels.private intBackup tunnels wanted.private final HashThe tunnel's destination hash.private StringNickname for the destination, may be null.Peers excluded as the first hop of a new tunnel, for diversity.private intIP restriction level of the pool.private final booleanTrue for the exploratory pools.private final booleanTrue for an inbound tunnel pool.Peers excluded as the last hop of a new tunnel, for diversity.private intHop count of the tunnels.private intHop count override for the next tunnels, -1 if none.private intAllowed random variation of the hop count.private final longXOR value randomizing the message id bloom filter.private intPriority of the pool for bandwidth and builds.private intActive tunnels wanted.private SessionKeyRandom key used for strict peer ordering.private booleanTrue to test the tunnels.private final PropertiesSession options this version does not know.static final booleanDefault for PROP_ALLOW_ZERO_HOP: zero-hop tunnels are off.static final intDefault spare tunnels to keep on hand in a pool.static final intDefault tunnel lifetime in milliseconds.private static final intDefault inbound tunnel length for exploratory pools.private static final intDefault inbound exploratory hop variance.private static final intDefault inbound tunnel length for client pools.static final intDefault for PROP_IP_RESTRICTION, restricting peers to a class B (/16) address range.private static final intDefault hop count variance.private static final intDefault outbound exploratory hop count.private static final intDefault outbound exploratory hop variance.private static final intDefault hop count of outbound tunnels.static final intDefault tunnels to keep available in a pool.private static final intPriority of the exploratory pools.private static final booleanTrue on devices where defaults are reduced.private static final intHighest tunnel priority allowed.private static final intLowest tunnel priority allowed.static final StringPrefix used to configure the inbound exploratory pool.static final StringPrefix used to configure the outbound exploratory pool.static final StringConfig property allowing zero-hop tunnels; unreliable, zero hops are always possible.static final StringPool property for how many spare tunnels to keep on hand.static final StringPool property for how long a tunnel is kept before being expired, in minutes.static final StringPool property for the IP address class the peers are drawn from, 0 to 4.static final StringPool property for the number of hops in each tunnel.static final StringPool property for how much the hop count may vary around PROP_LENGTH.static final StringPool property naming the client a client pool serves.static final StringPool property for the outbound selection priority, -25 to 25.static final StringPool property for how many tunnels to keep available.static final StringPool property holding the base64 random key used to order peer selection.static final StringPool property for whether the pool's tunnels are tested.Constructor Summary
ConstructorsConstructorDescriptionTunnelPoolSettings(boolean isInbound) An exploratory pool, with no destination and every default.TunnelPoolSettings(Hash dest, boolean isInbound) A pool with the defaults, exploratory if dest is null and a client pool otherwise.Method Summary
Modifier and TypeMethodDescriptionprivate static SessionKeyGenerates the random key for peer ordering.Other destinations that use the same tunnel (or null if exploratory).Other destination that this is an alias of (or null).booleanIf there are no tunnels to build with, will this pool allow 0 hop tunnels?intHow many backup tunnels should be kept waiting in the wings.private static final booleangetBoolean(String str, boolean defaultValue) Parses a boolean option with a fallback.What destination is this a client tunnel for (or null if exploratory)?What user supplied name was given to the client connected (can be null).First peer exclusions for diversity.private static final intParses an integer option with a fallback.intHow 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)Last peer exclusions for diversity.intHow many remote hops should be in the tunnel NOT including us.intA temporary length to be used due to network conditions.intHow the length should be varied.private static final longParses a long option with a fallback.longThe msg ID bloom xor value used to randomize message IDs.intOutbound message priority - for outbound tunnels only.intHow many tunnels should be available at all times.Random key used for peer ordering.intAdds the primary and backup quantities into one target total.Options not recognized when reading from properties.booleanIs this an exploratory tunnel (or a client tunnel)?booleanIs this an inbound tunnel?booleanWhether the pool is expressly configured for zero-hop tunnels, by length 0 or lengthOverride 0.voidreadFromProperties(String prefix, Properties props) Defaults in props are NOT honored.voidsetAliasOf(Hash h) Other destination that this is an alias of (or null).voidsetBackupQuantity(int quantity) How many backup tunnels should be kept waiting in the wings.voidsetDestinationNickname(String name) User supplied name given to the connected client.voidsetFirstPeerExclusions(Set<Hash> exclusions) First peer exclusions for diversity.voidsetLastPeerExclusions(Set<Hash> exclusions) Last peer exclusions for diversity.voidsetLength(int length) How many remote hops should be in the tunnel NOT including us.voidsetLengthOverride(int length) A temporary length to be used due to network conditions.voidsetLengthVariance(int variance) How the length should be varied.voidsetQuantity(int quantity) How many tunnels should be available at all times.booleanShould tunnels in this pool be tested?toString()String representation of these settings for debugging.voidwriteToProperties(String prefix, Properties props) Write the settings into the given properties map.
Field Details
_destination
The tunnel's destination hash._destinationNickname
Nickname for the destination, may be null._quantity
private int _quantityActive tunnels wanted._backupQuantity
private int _backupQuantityBackup tunnels wanted._length
private int _lengthHop count of the tunnels._lengthVariance
private int _lengthVarianceAllowed random variation of the hop count._lengthOverride
private int _lengthOverrideHop count override for the next tunnels, -1 if none._isInbound
private final boolean _isInboundTrue for an inbound tunnel pool._isExploratory
private final boolean _isExploratoryTrue for the exploratory pools._allowZeroHop
private boolean _allowZeroHopTrue to allow zero-hop tunnels._shouldTest
private boolean _shouldTestTrue to test the tunnels._IPRestriction
private int _IPRestrictionIP restriction level of the pool._unknownOptions
Session options this version does not know._randomKey
Random key used for strict peer ordering._priority
private int _priorityPriority of the pool for bandwidth and builds._aliases
_aliasOf
Destination this pool is an alias of, null if none._firstPeerExclusions
_lastPeerExclusions
PREFIX_INBOUND_EXPLORATORY
Prefix used to configure the inbound exploratory pool.- See Also:
PREFIX_OUTBOUND_EXPLORATORY
Prefix used to configure the outbound exploratory pool.- See Also:
PROP_NICKNAME
Pool property naming the client a client pool serves.- See Also:
PROP_QUANTITY
Pool property for how many tunnels to keep available.- See Also:
PROP_BACKUP_QUANTITY
Pool property for how many spare tunnels to keep on hand.- See Also:
PROP_DURATION
Pool property for how long a tunnel is kept before being expired, in minutes.- See Also:
PROP_LENGTH
Pool property for the number of hops in each tunnel.- See Also:
PROP_LENGTH_VARIANCE
Pool property for how much the hop count may vary around PROP_LENGTH.- See Also:
PROP_ALLOW_ZERO_HOP
Config property allowing zero-hop tunnels; unreliable, zero hops are always possible.- See Also:
PROP_SHOULD_TEST
Pool property for whether the pool's tunnels are tested.- See Also:
PROP_IP_RESTRICTION
Pool property for the IP address class the peers are drawn from, 0 to 4.- See Also:
PROP_PRIORITY
Pool property for the outbound selection priority, -25 to 25.- See Also:
PROP_RANDOM_KEY
Pool property holding the base64 random key used to order peer selection.- See Also:
DEFAULT_QUANTITY
public static final int DEFAULT_QUANTITYDefault tunnels to keep available in a pool.- See Also:
DEFAULT_BACKUP_QUANTITY
public static final int DEFAULT_BACKUP_QUANTITYDefault spare tunnels to keep on hand in a pool.- See Also:
DEFAULT_DURATION
public static final int DEFAULT_DURATIONDefault tunnel lifetime in milliseconds.- See Also:
IS_SLOW
private static final boolean IS_SLOWTrue on devices where defaults are reduced.DEFAULT_IB_LENGTH
private static final int DEFAULT_IB_LENGTHDefault inbound tunnel length for client pools.- See Also:
DEFAULT_OB_LENGTH
private static final int DEFAULT_OB_LENGTHDefault hop count of outbound tunnels.- See Also:
DEFAULT_LENGTH_VARIANCE
private static final int DEFAULT_LENGTH_VARIANCEDefault hop count variance.- See Also:
DEFAULT_IB_EXPL_LENGTH
private static final int DEFAULT_IB_EXPL_LENGTHDefault inbound tunnel length for exploratory pools.DEFAULT_OB_EXPL_LENGTH
private static final int DEFAULT_OB_EXPL_LENGTHDefault outbound exploratory hop count.DEFAULT_IB_EXPL_LENGTH_VARIANCE
private static final int DEFAULT_IB_EXPL_LENGTH_VARIANCEDefault inbound exploratory hop variance.DEFAULT_OB_EXPL_LENGTH_VARIANCE
private static final int DEFAULT_OB_EXPL_LENGTH_VARIANCEDefault outbound exploratory hop variance.DEFAULT_ALLOW_ZERO_HOP
public static final boolean DEFAULT_ALLOW_ZERO_HOPDefault for PROP_ALLOW_ZERO_HOP: zero-hop tunnels are off.- See Also:
DEFAULT_IP_RESTRICTION
public static final int DEFAULT_IP_RESTRICTIONDefault for PROP_IP_RESTRICTION, restricting peers to a class B (/16) address range.- See Also:
MIN_PRIORITY
MAX_PRIORITY
EXPLORATORY_PRIORITY
private static final int EXPLORATORY_PRIORITYPriority of the exploratory pools.- See Also:
_msgIDBloomXor
private final long _msgIDBloomXorXOR value randomizing the message id bloom filter.
Constructor Details
TunnelPoolSettings
public TunnelPoolSettings(boolean isInbound) An exploratory pool, with no destination and every default.- Parameters:
isInbound- true for the inbound pool, false for the outbound one
TunnelPoolSettings
A pool with the defaults, exploratory if dest is null and a client pool otherwise.- Parameters:
dest- the client destination, or null for an exploratory poolisInbound- true for the inbound pool, false for the outbound one
Method Details
getQuantity
public int getQuantity()How many tunnels should be available at all times.- Returns:
- the desired quantity
setQuantity
public void setQuantity(int quantity) How many tunnels should be available at all times.- Parameters:
quantity- the desired quantity
getBackupQuantity
public int getBackupQuantity()How many backup tunnels should be kept waiting in the wings.- Returns:
- the desired backup quantity
setBackupQuantity
public void setBackupQuantity(int quantity) How many backup tunnels should be kept waiting in the wings.- Parameters:
quantity- the desired backup quantity
getTotalQuantity
public int getTotalQuantity()Adds the primary and backup quantities into one target total.- Returns:
getQuantity()+ getBackupQuantity()
getLength
public int getLength()How many remote hops should be in the tunnel NOT including us.- Returns:
- 0 to 7
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)
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() + min(getLengthVariance(), 0)<= 0, OR ifgetLengthOverride()== 0.- Returns:
- the allow zero hop
isZeroHop
public boolean isZeroHop()Whether the pool is expressly configured for zero-hop tunnels, by length 0 or lengthOverride 0. Excludes the allowZeroHop fallback flag, which permits zero hops only as a last resort.- Returns:
- true if zero hops are the configured tunnel length
shouldTest
public boolean shouldTest()Should tunnels in this pool be tested?- Returns:
- true for normal pools, false for hostchecker/ping tunnels
getLengthVariance
public int getLengthVariance()How the length should be varied. If negative, this randomly skews from (length - variance) to (length + variance), or if positive, from length to (length + variance), inclusive.- Returns:
- the length variance
setLengthVariance
public void setLengthVariance(int variance) How the length should be varied.- Parameters:
variance- the length variance
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.- Returns:
- the length override
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.- Parameters:
length- the override in hops, or negative for the standard length
isInbound
public boolean isInbound()Is this an inbound tunnel?- Returns:
- true if the pool builds inbound tunnels
isExploratory
public boolean isExploratory()Is this an exploratory tunnel (or a client tunnel)?- Returns:
- true if the pool has no destination
getDestination
What destination is this a client tunnel for (or null if exploratory)?- Returns:
- the client destination, or null for an exploratory pool
getAliases
getAliasOf
Other destination that this is an alias of (or null). If non-null, don't build tunnels.- Returns:
- the alias of
setAliasOf
Other destination that this is an alias of (or null). If non-null, don't build tunnels.- Parameters:
h- the destination this pool is an alias of, or null
getFirstPeerExclusions
setFirstPeerExclusions
getLastPeerExclusions
setLastPeerExclusions
getRandomKey
getDestinationNickname
What user supplied name was given to the client connected (can be null).- Returns:
- the nickname, or null if none was supplied
setDestinationNickname
User supplied name given to the connected client.- Parameters:
name- the nickname, or null
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
getPriority
public int getPriority()Outbound message priority - for outbound tunnels only.- Returns:
- -25 to +30, default 30 for outbound exploratory and 0 for others
getUnknownOptions
Options not recognized when reading from properties.- Returns:
- non-null
getMsgIdBloomXor
public long getMsgIdBloomXor()The msg ID bloom xor value used to randomize message IDs.- Returns:
- the msg id bloom xor
readFromProperties
Defaults in props are NOT honored. In-JVM client side must promote defaults to the primary map.- Parameters:
prefix- the pool prefix to match, non-nullprops- the properties to read, every entry starting with prefix is considered
writeToProperties
Write the settings into the given properties map. Does nothing if props is null.- Parameters:
prefix- the pool prefix to write each property under, non-nullprops- the map to write into, or null to skip
toString
generateRandomKey
Generates the random key for peer ordering.- Returns:
- the new key
getBoolean
Parses a boolean option with a fallback.- Parameters:
str- the option text, may be nulldefaultValue- the value to return if unparseable- Returns:
- the parsed value
getInt
Parses an integer option with a fallback.- Parameters:
str- the option text, may be nulldefaultValue- the value to return if unparseable- Returns:
- the parsed value
getLong
Parses a long option with a fallback.- Parameters:
str- the option text, may be nulldefaultValue- the value to return if unparseable- Returns:
- the parsed value