net.i2p.router.tunnel

## Class HopProcessor

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

- Direct Known Subclasses:
    InboundGatewayProcessor

      public class HopProcessor
      extends Object

  Take a received tunnel message, verify that it isn't a duplicate, and translate it into what the next hop will want. The hop processor works the same on all peers - inbound and outbound participants, outbound endpoints, and inbound gateways (with a small modification per InbuondGatewayProcessor).

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected HopConfig` | `_config`
    `protected I2PAppContext` | `_context`
    `(package private) static int` | `IV_LENGTH`
    `(package private) static boolean` | `USE_DOUBLE_IV_ENCRYPTION` as of i2p 0.6, the tunnel crypto will change by encrypting the IV both before and after using it at each hop so as to prevent a certain type of replay/confirmation attack.
    `(package private) static boolean` | `USE_ENCRYPTION` helpful flag for debugging

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `HopProcessor(I2PAppContext ctx, HopConfig config)` Deprecated. unused
    `HopProcessor(I2PAppContext ctx, HopConfig config, IVValidator validator)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected static IVValidator` | `createValidator()` Deprecated. unused
    `boolean` | `process(byte[] orig, int offset, int length, Hash prev)` Process the data for the current hop, overwriting the original data with what should be sent to the next peer.

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

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

- - ### Field Detail

    - #### _context

          protected I2PAppContext _context

    - #### _config

          protected HopConfig _config

    - #### USE_ENCRYPTION

          static final boolean USE_ENCRYPTION

      helpful flag for debugging
      See Also:
        Constant Field Values

    - #### USE_DOUBLE_IV_ENCRYPTION

          static final boolean USE_DOUBLE_IV_ENCRYPTION

      as of i2p 0.6, the tunnel crypto will change by encrypting the IV both before and after using it at each hop so as to prevent a certain type of replay/confirmation attack.
      See Also:
        Constant Field Values

    - #### IV_LENGTH

          static final int IV_LENGTH

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### HopProcessor

          public HopProcessor(I2PAppContext ctx,
                      HopConfig config)

      Deprecated. unused

    - #### HopProcessor

          public HopProcessor(I2PAppContext ctx,
                      HopConfig config,
                      IVValidator validator)

  - ### Method Detail

    - #### createValidator

          protected static IVValidator createValidator()

      Deprecated. unused

    - #### process

          public boolean process(byte[] orig,
                        int offset,
                        int length,
                        Hash prev)

      Process the data for the current hop, overwriting the original data with what should be sent to the next peer. This also validates the previous peer and the IV, making sure its not a repeat and not a loop.
      Parameters:
        `orig` - IV+data of the message
        `offset` - index into orig where the IV begins
        `length` - how long after the offset does the message go for?
        `prev` - previous hop in the tunnel, or null if we are the gateway
      Returns:
        true if the message was updated and valid, false if it was not.