java.lang.Object
net.i2p.router.transport.udp.EstablishmentManager.HPCallback
All Implemented Interfaces:
SSU2Payload.PayloadCallback
Enclosing class:
EstablishmentManager

private static class EstablishmentManager.HPCallbackextends Object implements SSU2Payload.PayloadCallback
Process SSU2 hole punch payload.
  • Field Details

    • _from

      private final RemoteHostId _from
      The host whose handshake failed.
    • _log

      private final Log _log
      Logger for this callback, may be null.
    • _timeReceived

      public long _timeReceived
      Time the hole punch request was received.
    • _aliceIP

      public byte[] _aliceIP
      Alice's IP from the Address block.
    • _alicePort

      public int _alicePort
      Alice's port from the Address block.
    • _respCode

      public int _respCode
      Response code from the RelayResponse block.
    • _respData

      public byte[] _respData
      Payload from the RelayResponse block.
  • Constructor Details

    • HPCallback

      public HPCallback(RemoteHostId from, Log log)
      Creates the hole punch callback.
      Parameters:
      from - the host whose handshake failed
      log - the logger to use, may be null
  • Method Details

    • gotDateTime

      public void gotDateTime(long time)
      Got a DateTime block.
      Specified by:
      gotDateTime in interface SSU2Payload.PayloadCallback
      Parameters:
      time - time in milliseconds since epoch
    • gotOptions

      public void gotOptions(byte[] options, boolean isHandshake)
      Got an Options block.
      Specified by:
      gotOptions in interface SSU2Payload.PayloadCallback
      Parameters:
      options - the option data
      isHandshake - true only for message 3 part 2
    • gotRI

      public void gotRI(RouterInfo ri, boolean isHandshake, boolean flood)
      Got an RI block.
      Specified by:
      gotRI in interface SSU2Payload.PayloadCallback
      Parameters:
      ri - will already be validated
      isHandshake - true only for message 3 part 2
      flood - true if this is a floodfill router
    • gotRIFragment

      public void gotRIFragment(byte[] data, boolean isHandshake, boolean flood, boolean isGzipped, int frag, int totalFrags)
      Got an RI fragment block.
      Specified by:
      gotRIFragment in interface SSU2Payload.PayloadCallback
      Parameters:
      data - is first gzipped and then fragmented
      isHandshake - true only for message 3 part 2
      flood - true if this is a floodfill router
      isGzipped - true if the data is gzipped
      frag - fragment number (0-based)
      totalFrags - total number of fragments
    • gotAddress

      public void gotAddress(byte[] ip, int port)
      Got an Address block.
      Specified by:
      gotAddress in interface SSU2Payload.PayloadCallback
      Parameters:
      ip - IP address bytes
      port - the port number to send
    • gotRelayTagRequest

      public void gotRelayTagRequest()
      Got a RelayTagRequest block.
      Specified by:
      gotRelayTagRequest in interface SSU2Payload.PayloadCallback
    • gotRelayTag

      public void gotRelayTag(long tag)
      Got a RelayTag block.
      Specified by:
      gotRelayTag in interface SSU2Payload.PayloadCallback
      Parameters:
      tag - the relay tag
    • gotRelayRequest

      public void gotRelayRequest(byte[] data)
      Got a RelayRequest block.
      Specified by:
      gotRelayRequest in interface SSU2Payload.PayloadCallback
      Parameters:
      data - excludes flag, includes signature
    • gotRelayResponse

      public void gotRelayResponse(int status, byte[] data)
      Got a RelayResponse block.
      Specified by:
      gotRelayResponse in interface SSU2Payload.PayloadCallback
      Parameters:
      status - 0 = accept, 1-255 = reject
      data - excludes flag, includes signature
    • gotRelayIntro

      public void gotRelayIntro(Hash aliceHash, byte[] data)
      Got a RelayIntro block.
      Specified by:
      gotRelayIntro in interface SSU2Payload.PayloadCallback
      Parameters:
      aliceHash - hash of the introducer
      data - excludes flag, includes signature
    • gotPeerTest

      public void gotPeerTest(int msg, int status, Hash h, byte[] data)
      Got a PeerTest block.
      Specified by:
      gotPeerTest in interface SSU2Payload.PayloadCallback
      Parameters:
      msg - 1-7
      status - 0 = accept, 1-255 = reject
      h - Alice or Charlie hash for msg 2 and 4, null for msg 1, 3, 5-7
      data - excludes flag, includes signature
    • gotToken

      public void gotToken(long token, long expires)
      Got a Token block.
      Specified by:
      gotToken in interface SSU2Payload.PayloadCallback
      Parameters:
      token - the session token to attach to the next peer test
      expires - token expiration time in milliseconds
    • gotI2NP

      public void gotI2NP(I2NPMessage msg)
      Got an I2NP block.
      Specified by:
      gotI2NP in interface SSU2Payload.PayloadCallback
      Parameters:
      msg - the parsed I2NP message
    • gotFragment

      public void gotFragment(byte[] data, int off, int len, long messageId, int frag, boolean isLast)
      Got a Fragment block.
      Specified by:
      gotFragment in interface SSU2Payload.PayloadCallback
      Parameters:
      data - buffer containing fragment data
      off - offset in data
      len - length of data to copy
      messageId - unique message identifier
      frag - fragment number (0-based)
      isLast - whether this is the last fragment
    • gotACK

      public void gotACK(long ackThru, int acks, byte[] ranges)
      Got an ACK block.
      Specified by:
      gotACK in interface SSU2Payload.PayloadCallback
      Parameters:
      ackThru - highest contiguous sequence number acknowledged
      acks - number of additional acknowledgments beyond ackThru
      ranges - null if none
    • gotTermination

      public void gotTermination(int reason, long count)
      Got a Termination block.
      Specified by:
      gotTermination in interface SSU2Payload.PayloadCallback
      Parameters:
      reason - termination reason code
      count - in theory could wrap around to negative, but very unlikely
    • gotPathChallenge

      public void gotPathChallenge(RemoteHostId from, byte[] data)
      Got a PathChallenge block.
      Specified by:
      gotPathChallenge in interface SSU2Payload.PayloadCallback
      Parameters:
      from - null if unknown
      data - the challenge bytes, which must be copied out
    • gotPathResponse

      public void gotPathResponse(RemoteHostId from, byte[] data)
      Got a PathResponse block.
      Specified by:
      gotPathResponse in interface SSU2Payload.PayloadCallback
      Parameters:
      from - null if unknown
      data - the response bytes, which must be copied out
    • warn

      private void warn(String msg)
      Logs a hole punch warning naming the host.
      Parameters:
      msg - the message to log