Class UniteMessage

java.lang.Object
org.drasyl.handler.remote.protocol.UniteMessage
All Implemented Interfaces:
FullReadMessage<UniteMessage>, RemoteMessage

public abstract class UniteMessage extends Object
This message is sent by a super node for NAT traversal. The message provides routing information for a peer we want to directly communicate. The message's body is structured as follows:
  • Address: The DrasylAddress to which this message contains routing information (32 bytes).
  • Port: The UDP port through which the node can be reached (2 bytes).
  • InetAddress: The IP address which the node can be reached. IPv4 addresses will be mapped to IPv6 addresses (16 bytes).

This is an immutable object.

  • Field Details

  • Constructor Details

    • UniteMessage

      public UniteMessage()
  • Method Details

    • of

      public static UniteMessage of(HopCount hopCount, boolean isArmed, int networkId, Nonce nonce, DrasylAddress recipient, DrasylAddress sender, ProofOfWork proofOfWork, DrasylAddress address, Set<InetSocketAddress> inetAddresses)
      Creates new unit message.
      Parameters:
      hopCount - the hop count
      isArmed - if the message is armed or not
      networkId - the network id
      nonce - the nonce
      recipient - the public key of the recipient
      sender - the public key of the sender
      proofOfWork - the proof of work of sender
      address - the public key of the peer
      inetAddresses - the internet addresses of the peer
      Throws:
      NullPointerException - if nonce, sender, proofOfWork, recipient, hopCount, address, or inetAddress is null
      IllegalArgumentException - if port is invalid
    • of

      public static UniteMessage of(int networkId, DrasylAddress recipient, IdentityPublicKey sender, ProofOfWork proofOfWork, DrasylAddress address, Set<InetSocketAddress> inetAddresses)
      Creates new unit message with random Nonce, and minimal HopCount value.
      Parameters:
      networkId - the network id
      recipient - the public key of the recipient
      sender - the public key of the sender
      proofOfWork - the proof of work of sender
      address - the public key of the peer
      inetAddresses - the ip inetAddress and port of the peer
      Throws:
      NullPointerException - if sender, proofOfWork, recipient, address, or inetAddress.getAddress() is null
      IllegalArgumentException - if inetAddress.getPort() is invalid
    • getAddress

      public abstract DrasylAddress getAddress()
      Returns the public key of the peer.
      Returns:
      the public key of the peer.
    • getInetAddresses

      public abstract Set<InetSocketAddress> getInetAddresses()
      Returns the ip address of the peer.
      Returns:
      the ip address of the peer.
    • incrementHopCount

      public UniteMessage incrementHopCount()
      Description copied from interface: FullReadMessage
      Returns this message with incremented hop count.
      Returns:
      this message with incremented hop count.
    • writePrivateHeaderTo

      protected void writePrivateHeaderTo(io.netty.buffer.ByteBuf out)
    • writeBodyTo

      protected void writeBodyTo(io.netty.buffer.ByteBuf out)
    • arm

      public ArmedProtocolMessage arm(io.netty.buffer.ByteBuf byteBuf, Crypto cryptoInstance, SessionPair sessionPair) throws InvalidMessageFormatException
      Description copied from interface: FullReadMessage
      Returns an armed version (ArmedProtocolMessage) of this message for sending it through untrustworthy channels.
      Specified by:
      arm in interface FullReadMessage<T extends FullReadMessage<?>>
      Parameters:
      byteBuf - the ByteBuf to write through
      cryptoInstance - the crypto instance that should be used
      sessionPair - will be used for encryption
      Returns:
      the armed version of this message
      Throws:
      InvalidMessageFormatException - if arming was not possible
    • writeTo

      public void writeTo(io.netty.buffer.ByteBuf out)
      Description copied from interface: RemoteMessage
      Writes this message to the buffer out.
      Specified by:
      writeTo in interface RemoteMessage
      Parameters:
      out - writes this envelope to this buffer
    • writePublicHeaderTo

      protected void writePublicHeaderTo(io.netty.buffer.ByteBuf out)