Class UniteMessage

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

@UnstableApi 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).
  • Endpoints: UDP-port-IP-address-combinations were the peer can be reached. IPv4 addresses will be mapped to IPv6 addresses (2 + 16 bytes per endpoint)

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> endpoints)
      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
      endpoints - the UDP-port-IP-address-combinations were the peer can be reached
      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> endpoints)
      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
      endpoints - the UDP-port-IP-address-combinations were the peer can be reached.
      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.
    • getEndpoints

      public abstract Set<InetSocketAddress> getEndpoints()
      Returns the UDP-port-IP-address-combinations were the peer can be reached.
      Returns:
      the UDP-port-IP-address-combinations were the peer can be reached.
    • 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)
    • getLength

      public int getLength()
    • arm

      public ArmedProtocolMessage arm(io.netty.buffer.ByteBufAllocator alloc, 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<?>>
      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)