public abstract class TunnelCreatorConfig extends Object implements TunnelInfo
| Modifier and Type | Field and Description |
|---|---|
protected RouterContext | _contextThe router context. |
static int | MAX_CONSECUTIVE_TEST_FAILURESMaximum consecutive test failures before the tunnel is retired. |
static int | REPLY_IV_LENGTHIV length for getAESReplyIV(int) |
| Constructor and Description |
|---|
TunnelCreatorConfig(RouterContext ctx,
int length,
boolean isInbound)For exploratory only (null destination) |
TunnelCreatorConfig(RouterContext ctx,
int length,
boolean isInbound,
Hash destination)Allocates the hop configs and peer arrays for the given length. |
| Modifier and Type | Method and Description |
|---|---|
void | addLatencySample(int ms)Add a latency sample from a test result. |
void | clearExpeditedTest()Clear the expedited test flag after running the expedited test. |
void | clearTestFailures()Reset the consecutive failure counter and mark the tunnel as GOOD. |
byte[] | getAESReplyIV(int hop)IV used to encrypt the reply sent for the tunnel creation crypto. |
SessionKey | getAESReplyKey(int hop)Key to encrypt the reply sent for the tunnel creation crypto. |
int | getAverageLatency()The average latency of the last 3 tests. |
Hash | getBlankHash()Checksum for blank record |
byte[] | getChaChaReplyAD(int hop)The ECIES reply associated data for the given hop, or null. |
SessionKey | getChaChaReplyKey(int hop)The ECIES reply key for the given hop, or null. |
HopConfig | getConfig(int hop)Retrieve the config for the given hop. |
int | getConsecutiveFailures()The number of consecutive test failures. |
Hash | getDestination()If this is a client tunnel, what destination is it for? |
String | getDestinationNickname()Pool nickname for this tunnel, or null if not set. |
Hash | getEndpoint()For convenience |
long | getExpiration()The tunnel expiration, in ms since the epoch. |
Hash | getFarEnd()For convenience |
MessageWrapper.OneTimeSession | getGarlicReplyKeys()ECIES short OBEP record only. |
Hash | getGateway()For convenience |
int | getLastLatency()The last recorded test latency. |
long | getLastRealTraffic()When the tunnel last carried real traffic. |
long | getLastTransferred()When we last sent or received data on this tunnel |
int | getLength()How many hops are there in the tunnel?
INCLUDING US. |
Properties | getOptions()The tunnel pool options. |
Hash | getPeer(int hop)Retrieve the peer at the given hop (the gateway is hop 0). |
int | getPriority()Outbound message priority - for outbound tunnels only |
int | getProcessedMessagesCount()The number of messages pumped through this tunnel. |
TunnelId | getReceiveTunnelId(int hop)Retrieve the tunnelId that the given hop receives messages on. |
int | getRecentTestExemptions()The number of recent-traffic test exemptions used. |
long | getReplyMessageId()The message ID for the new style reply. |
List<Integer> | getReplyOrder()Component ordering in the new style request. |
TunnelId | getSendTunnelId(int hop)Retrieve the tunnelId that the given hop sends messages on. |
TunnelTestStatus | getTestStatus()The current test status of this tunnel for UI display. |
boolean | getTunnelFailed()Has the tunnel failed completely? |
int | getTunnelFailures()The consecutive failure count. |
long | getVerifiedBytesTransferred()The total verified bytes transferred on this tunnel. |
boolean | hasEnoughLatencyTests()Whether at least 3 latency samples have been collected. |
void | incrementProcessedMessages()Take note of a message being pumped through this tunnel. |
void | incrementRecentTestExemptions()Increment the recent-traffic test exemption counter. |
void | incrementTestFailures()Increment the failure count without triggering pool removal or reuse flag. |
void | incrementVerifiedBytesTransferred(int bytes)This calls profile manager tunnelDataPushed1m() for each peer |
boolean | isEC(int hop)Is it an ECIES hop? |
boolean | isInbound()Is this an inbound tunnel? |
boolean | needsExpeditedTest()Whether the tunnel needs an expedited test due to slow detection. |
void | recordRealTraffic()Record that the tunnel carried real traffic. |
void | requestExpeditedTest()The tunnel appeared slow, so flag it for an expedited test. |
void | setAESReplyKeys(int hop,
SessionKey key,
byte[] iv)Key and IV to encrypt the reply sent for the tunnel creation crypto. |
void | setBlankHash(Hash h)Checksum for blank record |
void | setChaChaReplyKeys(int hop,
SessionKey key,
byte[] ad)The ECIES reply key and associated data for the given hop. |
void | setDestinationNickname(String name)Optional display nickname for this tunnel (e.g. |
void | setExpiration(long when)The tunnel expiration, in ms since the epoch. |
void | setGarlicReplyKeys(MessageWrapper.OneTimeSession keys)ECIES short OBEP record only. |
void | setLastLatency(int ms)The latency of the last completed test. |
void | setPeer(int hop,
Hash peer)The peer at the given hop. |
void | setPriority(int priority)Outbound message priority - for outbound tunnels only |
void | setReplyMessageId(long id)The message ID for the new style reply. |
void | setReplyOrder(List<Integer> order)The component ordering for the new style request. |
void | setReused()Note that we reused this tunnel |
void | setTestFailed()Called when a test fails. |
void | setTestOverBudget()Mark tunnel as scheduled for early expiry due to pool being over budget. |
void | setTestStarted()Called when a test is started. |
void | setTestTooSlow()Mark tunnel as scheduled for early expiry (pruned from pool). |
void | testSuccessful(int ms)Mark the tunnel as GOOD, recording the latency of the successful test. |
String | toString()Human-readable description of the tunnel, its peers, and its state. |
String | toStringFull() |
boolean | tunnelFailed()The tunnel failed a test, so (maybe) stop using it |
void | tunnelFailedCompletely()The tunnel failed completely, so definitely stop using it |
void | tunnelFailedFirstHop()We failed to contact the first hop for an outbound tunnel,
so immediately stop using it. |
boolean | wasReused()Did we reuse this tunnel? |
protected final RouterContext _context
public static final int MAX_CONSECUTIVE_TEST_FAILURES
public static final int REPLY_IV_LENGTH
getAESReplyIV(int)public TunnelCreatorConfig(RouterContext ctx, int length, boolean isInbound)
length - 1 minimum (0 hop is length 1)public TunnelCreatorConfig(RouterContext ctx, int length, boolean isInbound, Hash destination)
length - 1 minimum (0 hop is length 1)destination - null for exploratorypublic void addLatencySample(int ms)
ms - latency in millisecondspublic void clearExpeditedTest()
public void clearTestFailures()
public byte[] getAESReplyIV(int hop)
public SessionKey getAESReplyKey(int hop)
IllegalArgumentException - if iv not 16 bytespublic int getAverageLatency()
public Hash getBlankHash()
public byte[] getChaChaReplyAD(int hop)
public SessionKey getChaChaReplyKey(int hop)
public HopConfig getConfig(int hop)
public int getConsecutiveFailures()
getConsecutiveFailures in interface TunnelInfopublic Hash getDestination()
getDestination in interface TunnelInfopublic String getDestinationNickname()
public Hash getEndpoint()
getEndpoint in interface TunnelInfopublic long getExpiration()
getExpiration in interface TunnelInfopublic Hash getFarEnd()
getFarEnd in interface TunnelInfopublic MessageWrapper.OneTimeSession getGarlicReplyKeys()
public Hash getGateway()
getGateway in interface TunnelInfopublic int getLastLatency()
getLastLatency in interface TunnelInfopublic long getLastRealTraffic()
getLastRealTraffic in interface TunnelInfopublic long getLastTransferred()
public int getLength()
getLength in interface TunnelInfopublic Properties getOptions()
public Hash getPeer(int hop)
getPeer in interface TunnelInfopublic int getPriority()
public int getProcessedMessagesCount()
getProcessedMessagesCount in interface TunnelInfopublic TunnelId getReceiveTunnelId(int hop)
getReceiveTunnelId in interface TunnelInfopublic int getRecentTestExemptions()
public long getReplyMessageId()
public TunnelId getSendTunnelId(int hop)
getSendTunnelId in interface TunnelInfopublic TunnelTestStatus getTestStatus()
getTestStatus in interface TunnelInfopublic boolean getTunnelFailed()
getTunnelFailed in interface TunnelInfopublic int getTunnelFailures()
public long getVerifiedBytesTransferred()
getVerifiedBytesTransferred in interface TunnelInfopublic boolean hasEnoughLatencyTests()
public void incrementProcessedMessages()
public void incrementRecentTestExemptions()
public void incrementTestFailures()
public void incrementVerifiedBytesTransferred(int bytes)
incrementVerifiedBytesTransferred in interface TunnelInfobytes - the number of bytes to add to the verified totalpublic boolean isEC(int hop)
public boolean isInbound()
isInbound in interface TunnelInfopublic boolean needsExpeditedTest()
public void recordRealTraffic()
recordRealTraffic in interface TunnelInfopublic void requestExpeditedTest()
public void setAESReplyKeys(int hop,
SessionKey key,
byte[] iv)IllegalArgumentException - if iv not 16 bytespublic void setBlankHash(Hash h)
public void setChaChaReplyKeys(int hop,
SessionKey key,
byte[] ad)public void setDestinationNickname(String name)
public void setExpiration(long when)
setExpiration in interface TunnelInfowhen - expiration time in milliseconds since epochpublic void setGarlicReplyKeys(MessageWrapper.OneTimeSession keys)
public void setLastLatency(int ms)
ms - latency in millisecondspublic void setPeer(int hop,
Hash peer)public void setPriority(int priority)
priority - -25 to +25, default 0public void setReplyMessageId(long id)
public void setReplyOrder(List<Integer> order)
public void setReused()
setReused in interface TunnelInfopublic void setTestFailed()
setTestFailed in interface TunnelInfopublic void setTestOverBudget()
public void setTestStarted()
setTestStarted in interface TunnelInfopublic void setTestTooSlow()
public void testSuccessful(int ms)
testSuccessful in interface TunnelInfoms - the response time in millisecondspublic String toString()
public String toStringFull()
public boolean tunnelFailed()
public void tunnelFailedCompletely()
public void tunnelFailedFirstHop()
Base hook: marks the tunnel as failed. Subclasses with a pool (PooledTunnelCreatorConfig) also notify the pool of the failure.
public boolean wasReused()
wasReused in interface TunnelInfo