net.i2p.router.tunnel

## Class TunnelCreatorConfig

- java.lang.Object
- - net.i2p.router.tunnel.TunnelCreatorConfig

- All Implemented Interfaces:
    TunnelInfo
  Direct Known Subclasses:
    PooledTunnelCreatorConfig

      public abstract class TunnelCreatorConfig
      extends Object
      implements TunnelInfo

  Coordinate the info that the tunnel creator keeps track of, including what peers are in the tunnel and what their configuration is See PooledTunnelCreatorConfig for the non-abstract class

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected RouterContext` | `_context`
    `static int` | `REPLY_IV_LENGTH` IV length for `getAESReplyIV(int)`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `TunnelCreatorConfig(RouterContext ctx, int length, boolean isInbound)` For exploratory only (null destination)
    `TunnelCreatorConfig(RouterContext ctx, int length, boolean isInbound, Hash destination)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `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.
    `Hash` | `getBlankHash()` Checksum for blank record
    `byte[]` | `getChaChaReplyAD(int hop)` Get ECIES reply AD
    `SessionKey` | `getChaChaReplyKey(int hop)` Get ECIES reply key
    `HopConfig` | `getConfig(int hop)` retrieve the config for the given hop.
    `Hash` | `getDestination()` If this is a client tunnel, what destination is it for?
    `Hash` | `getEndpoint()` For convenience
    `long` | `getExpiration()` Get the tunnel's expiration time.
    `Hash` | `getFarEnd()` For convenience
    `MessageWrapper.OneTimeSession` | `getGarlicReplyKeys()` ECIES short OBEP record only.
    `Hash` | `getGateway()` For convenience
    `int` | `getLength()` How many hops are there in the tunnel? INCLUDING US.
    `Properties` | `getOptions()`
    `Hash` | `getPeer(int hop)` retrieve the peer at the given hop.
    `int` | `getPriority()` Outbound message priority - for outbound tunnels only
    `int` | `getProcessedMessagesCount()` Get the count of messages that have been processed through this tunnel.
    `TunnelId` | `getReceiveTunnelId(int hop)` retrieve the tunnelId that the given hop receives messages on.
    `long` | `getReplyMessageId()` new style reply message id
    `List<Integer>` | `getReplyOrder()` component ordering in the new style request
    `TunnelId` | `getSendTunnelId(int hop)` retrieve the tunnelId that the given hop sends messages on.
    `boolean` | `getTunnelFailed()` Has the tunnel failed completely?
    `int` | `getTunnelFailures()`
    `long` | `getVerifiedBytesTransferred()` we know for sure that this many bytes travelled through the tunnel in its lifetime
    `void` | `incrementProcessedMessages()` take note of a message being pumped through this tunnel
    `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?
    `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)` Set ECIES reply key and IV
    `void` | `setExpiration(long when)`
    `void` | `setGarlicReplyKeys(MessageWrapper.OneTimeSession keys)` ECIES short OBEP record only.
    `void` | `setPeer(int hop, Hash peer)`
    `void` | `setPriority(int priority)` Outbound message priority - for outbound tunnels only
    `void` | `setReplyMessageId(long id)`
    `void` | `setReplyOrder(List<Integer> order)`
    `void` | `setReused()` Note that we reused this tunnel
    `void` | `testSuccessful(int ms)` Record that the tunnel successfully processed a test with the given response time.
    `String` | `toString()`
    `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
    `boolean` | `wasReused()` Did we reuse this tunnel?

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

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

- - ### Field Detail

    - #### _context

          protected final RouterContext _context

    - #### REPLY_IV_LENGTH

          public static final int REPLY_IV_LENGTH

      IV length for `getAESReplyIV(int)`
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### TunnelCreatorConfig

          public TunnelCreatorConfig(RouterContext ctx,
                                     int length,
                                     boolean isInbound)

      For exploratory only (null destination)
      Parameters:
        `length` - 1 minimum (0 hop is length 1)

    - #### TunnelCreatorConfig

          public TunnelCreatorConfig(RouterContext ctx,
                                     int length,
                                     boolean isInbound,
                                     Hash destination)

      Parameters:
        `length` - 1 minimum (0 hop is length 1)
        `destination` - null for exploratory

  - ### Method Detail

    - #### getAESReplyIV

          public byte[] getAESReplyIV(int hop)

      IV used to encrypt the reply sent for the tunnel creation crypto. Null for short build record.
      Returns:
        16 bytes or null

    - #### getAESReplyKey

          public SessionKey getAESReplyKey(int hop)

      Key to encrypt the reply sent for the tunnel creation crypto. Null for short build record.
      Returns:
        key or null
      Throws:
        `IllegalArgumentException` - if iv not 16 bytes

    - #### getBlankHash

          public Hash getBlankHash()

      Checksum for blank record

    - #### getChaChaReplyAD

          public byte[] getChaChaReplyAD(int hop)

      Get ECIES reply AD

    - #### getChaChaReplyKey

          public SessionKey getChaChaReplyKey(int hop)

      Get ECIES reply key

    - #### getConfig

          public HopConfig getConfig(int hop)

      retrieve the config for the given hop. the gateway is hop 0.

    - #### getDestination

          public Hash getDestination()

      If this is a client tunnel, what destination is it for?
      Specified by:
        `getDestination` in interface `TunnelInfo`
      Returns:
        null for exploratory

    - #### getEndpoint

          public Hash getEndpoint()

      For convenience
      Specified by:
        `getEndpoint` in interface `TunnelInfo`
      Returns:
        getPeer(getLength() - 1)

    - #### getExpiration

          public long getExpiration()

      Description copied from interface: `TunnelInfo`
      Get the tunnel's expiration time.
      Specified by:
        `getExpiration` in interface `TunnelInfo`
      Returns:
        expiration time in milliseconds since epoch

    - #### getFarEnd

          public Hash getFarEnd()

      For convenience
      Specified by:
        `getFarEnd` in interface `TunnelInfo`
      Returns:
        isInbound() ? getGateway() : getEndpoint()

    - #### getGarlicReplyKeys

          public MessageWrapper.OneTimeSession getGarlicReplyKeys()

      ECIES short OBEP record only.
      Returns:
        null for ElGamal or ECIES long record or non-OBEP

    - #### getGateway

          public Hash getGateway()

      For convenience
      Specified by:
        `getGateway` in interface `TunnelInfo`
      Returns:
        getPeer(0)

    - #### getLength

          public int getLength()

      How many hops are there in the tunnel? INCLUDING US. i.e. one more than the TunnelCreatorConfig length.
      Specified by:
        `getLength` in interface `TunnelInfo`

    - #### getOptions

          public Properties getOptions()

    - #### getPeer

          public Hash getPeer(int hop)

      retrieve the peer at the given hop. the gateway is hop 0
      Specified by:
        `getPeer` in interface `TunnelInfo`

    - #### getPriority

          public int getPriority()

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

    - #### getProcessedMessagesCount

          public int getProcessedMessagesCount()

      Description copied from interface: `TunnelInfo`
      Get the count of messages that have been processed through this tunnel.
      Specified by:
        `getProcessedMessagesCount` in interface `TunnelInfo`
      Returns:
        the number of processed messages

    - #### getReceiveTunnelId

          public TunnelId getReceiveTunnelId(int hop)

      retrieve the tunnelId that the given hop receives messages on. the gateway is hop 0.
      Specified by:
        `getReceiveTunnelId` in interface `TunnelInfo`

    - #### getReplyMessageId

          public long getReplyMessageId()

      new style reply message id

    - #### getReplyOrder

          public List<Integer> getReplyOrder()

      component ordering in the new style request

    - #### getSendTunnelId

          public TunnelId getSendTunnelId(int hop)

      retrieve the tunnelId that the given hop sends messages on. the gateway is hop 0.
      Specified by:
        `getSendTunnelId` in interface `TunnelInfo`

    - #### getTunnelFailed

          public boolean getTunnelFailed()

      Has the tunnel failed completely?
      Specified by:
        `getTunnelFailed` in interface `TunnelInfo`

    - #### getTunnelFailures

          public int getTunnelFailures()

    - #### getVerifiedBytesTransferred

          public long getVerifiedBytesTransferred()

      Description copied from interface: `TunnelInfo`
      we know for sure that this many bytes travelled through the tunnel in its lifetime
      Specified by:
        `getVerifiedBytesTransferred` in interface `TunnelInfo`

    - #### incrementProcessedMessages

          public void incrementProcessedMessages()

      take note of a message being pumped through this tunnel

    - #### incrementVerifiedBytesTransferred

          public void incrementVerifiedBytesTransferred(int bytes)

      This calls profile manager tunnelDataPushed1m() for each peer
      Specified by:
        `incrementVerifiedBytesTransferred` in interface `TunnelInfo`
      Parameters:
        `bytes` - the number of bytes to add to the verified total

    - #### isEC

          public boolean isEC(int hop)

      Is it an ECIES hop?

    - #### isInbound

          public boolean isInbound()

      is this an inbound tunnel?
      Specified by:
        `isInbound` in interface `TunnelInfo`

    - #### setAESReplyKeys

          public void setAESReplyKeys(int hop,
                                      SessionKey key,
                                      byte[] iv)

      Key and IV to encrypt the reply sent for the tunnel creation crypto.
      Throws:
        `IllegalArgumentException` - if iv not 16 bytes

    - #### setBlankHash

          public void setBlankHash(Hash h)

      Checksum for blank record

    - #### setChaChaReplyKeys

          public void setChaChaReplyKeys(int hop,
                                         SessionKey key,
                                         byte[] ad)

      Set ECIES reply key and IV

    - #### setExpiration

          public void setExpiration(long when)

    - #### setGarlicReplyKeys

          public void setGarlicReplyKeys(MessageWrapper.OneTimeSession keys)

      ECIES short OBEP record only.

    - #### setPeer

          public void setPeer(int hop,
                              Hash peer)

    - #### setPriority

          public void setPriority(int priority)

      Outbound message priority - for outbound tunnels only
      Parameters:
        `priority` - -25 to +25, default 0

    - #### setReplyMessageId

          public void setReplyMessageId(long id)

    - #### setReplyOrder

          public void setReplyOrder(List<Integer> order)

    - #### setReused

          public void setReused()

      Note that we reused this tunnel
      Specified by:
        `setReused` in interface `TunnelInfo`

    - #### testSuccessful

          public void testSuccessful(int ms)

      Description copied from interface: `TunnelInfo`
      Record that the tunnel successfully processed a test with the given response time.
      Specified by:
        `testSuccessful` in interface `TunnelInfo`
      Parameters:
        `ms` - the response time in milliseconds

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### toStringFull

          public String toStringFull()

    - #### tunnelFailed

          public boolean tunnelFailed()

      The tunnel failed a test, so (maybe) stop using it
      Returns:
        false if we stopped using it, true if still ok

    - #### tunnelFailedCompletely

          public void tunnelFailedCompletely()

      The tunnel failed completely, so definitely stop using it

    - #### wasReused

          public boolean wasReused()

      Did we reuse this tunnel?
      Specified by:
        `wasReused` in interface `TunnelInfo`