net.i2p.router.transport.udp

## Class IntroductionManager

- java.lang.Object
- - net.i2p.router.transport.udp.IntroductionManager

-     class IntroductionManager
      extends Object

  Keep track of inbound and outbound introductions. See http://i2p-projekt.i2p/spec/ssu2 for documentation.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `MAX_OUTBOUND` This is enforced in EstablishmentManager

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `IntroductionManager(RouterContext ctx, UDPTransport transport)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `add(PeerState peer)`
    `void` | `cleanup()` Loop and cleanup _nonceToAlice Called from EstablishmentManager doFailSafe() so we don't need a cleaner timer here.
    `(package private) int` | `introducedCount()` Combined IPv4 and IPv6
    `(package private) int` | `introducerCount(boolean ipv6)` Not as elaborate as pickInbound() above.
    `boolean` | `isInboundTagValid(long tag)` Is this inbound tag currently valid, i.e.
    `int` | `pickInbound(RouterAddress current, boolean ipv6, Properties ssuOptions, int howMany)` Grab a bunch of peers who are willing to be introducers for us that are locally known (duh) and have published their own SSU address (duh^2).
    `void` | `pingIntroducers()` Was part of pickInbound(), moved out so we can call it more often
    `(package private) void` | `receiveHolePunch(RemoteHostId charlie, byte[] data)` We are Alice and we got this from Charlie.
    `(package private) void` | `receiveRelayIntro(PeerState2 bob, Hash alice, byte[] data)` Processes a relay introduction message received from another peer.
    `(package private) void` | `receiveRelayRequest(PeerState2 alice, byte[] data)` We are Bob and we got this from Alice.
    `(package private) void` | `receiveRelayResponse(PeerState2 peer, int status, byte[] data)` We are Bob and we got this from Charlie, OR we are Alice and we got this from Bob.
    `void` | `remove(PeerState peer)`
    `void` | `reset()`

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

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

- - ### Field Detail

    - #### MAX_OUTBOUND

          public static final int MAX_OUTBOUND

      This is enforced in EstablishmentManager
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### IntroductionManager

          public IntroductionManager(RouterContext ctx,
                                     UDPTransport transport)

  - ### Method Detail

    - #### add

          public void add(PeerState peer)

    - #### cleanup

          public void cleanup()

      Loop and cleanup _nonceToAlice Called from EstablishmentManager doFailSafe() so we don't need a cleaner timer here.

    - #### introducedCount

          int introducedCount()

      Combined IPv4 and IPv6
      Returns:
        number of peers we have volunteered to introduce

    - #### introducerCount

          int introducerCount(boolean ipv6)

      Not as elaborate as pickInbound() above. Just a quick check to see how many volunteers we know, which the Transport uses to see if we need more.
      Parameters:
        `ipv6` - what type of address are they introducing us for
      Returns:
        number of peers that have volunteered to introduce us

    - #### isInboundTagValid

          public boolean isInboundTagValid(long tag)

      Is this inbound tag currently valid, i.e. is the peer still connected?

    - #### pickInbound

          public int pickInbound(RouterAddress current,
                                 boolean ipv6,
                                 Properties ssuOptions,
                                 int howMany)

      Grab a bunch of peers who are willing to be introducers for us that are locally known (duh) and have published their own SSU address (duh^2). The picked peers have their info tacked on to the ssuOptions parameter for use in the SSU RouterAddress. Try to use "good" peers (i.e. reachable, active) Also, ping all idle peers that were introducers in the last 2 hours, to keep the connection up, since the netDb can have quite stale information, and we want to keep our introducers valid.
      Parameters:
        `current` - current router address, may be null
        `ipv6` - what type is the current address we need introducers for?
        `ssuOptions` - out parameter, options are added
      Returns:
        number of introducers added

    - #### pingIntroducers

          public void pingIntroducers()

      Was part of pickInbound(), moved out so we can call it more often

    - #### receiveHolePunch

          void receiveHolePunch(RemoteHostId charlie,
                                byte[] data)

      We are Alice and we got this from Charlie. Send a SessionRequest to Charlie, whether or not we got the Relay Response already. SSU 2 only, out-of-session.

    - #### receiveRelayIntro

          void receiveRelayIntro(PeerState2 bob,
                                 Hash alice,
                                 byte[] data)

      Processes a relay introduction message received from another peer. This method is responsible for initiating a HolePunch to the specified destination peer ('Alice') and preparing a RelayResponse to be sent back to the originating peer ('Bob'). It is designed for use with the SSU 2 protocol.
      Parameters:
        `bob` - the PeerState2 instance representing the peer that sent the relay introduction message
        `alice` - the Hash object identifying the destination peer ('Alice') to which a HolePunch will be initiated
        `data` - the byte array containing the data payload of the relay introduction message

    - #### receiveRelayRequest

          void receiveRelayRequest(PeerState2 alice,
                                   byte[] data)

      We are Bob and we got this from Alice. Send Alice's RI and a RelayIntro to Charlie, or reject with a RelayResponse to Alice. We should already have a session with Charlie and definitely with Alice. SSU 2 only.

    - #### receiveRelayResponse

          void receiveRelayResponse(PeerState2 peer,
                                    int status,
                                    byte[] data)

      We are Bob and we got this from Charlie, OR we are Alice and we got this from Bob. If we are Bob, send to Alice. If we are Alice, send a SessionRequest to Charlie. We should already have a session with Charlie, but not necessarily with Alice. SSU 2 only.

    - #### remove

          public void remove(PeerState peer)

    - #### reset

          public void reset()