Class UniteMessage
java.lang.Object
org.drasyl.handler.remote.protocol.UniteMessage
- All Implemented Interfaces:
FullReadMessage<UniteMessage>
,RemoteMessage
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 Summary
Fields inherited from interface org.drasyl.handler.remote.protocol.RemoteMessage
MAGIC_NUMBER, MAGIC_NUMBER_LEN
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionarm
(io.netty.buffer.ByteBufAllocator alloc, Crypto cryptoInstance, SessionPair sessionPair) Returns an armed version (ArmedProtocolMessage
) of this message for sending it through untrustworthy channels.io.netty.buffer.ByteBuf
encodeMessage
(io.netty.buffer.ByteBufAllocator alloc) Writes this message to a buffer created byalloc
.abstract DrasylAddress
Returns the public key of the peer.abstract Set<InetSocketAddress>
Returns the UDP-port-IP-address-combinations were the peer can be reached.int
Returns this message with incremented hop count.static UniteMessage
of
(int networkId, DrasylAddress recipient, IdentityPublicKey sender, ProofOfWork proofOfWork, DrasylAddress address, Set<InetSocketAddress> endpoints) 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.protected void
writeBodyTo
(io.netty.buffer.ByteBuf out) protected void
writePrivateHeaderTo
(io.netty.buffer.ByteBuf out) protected void
writePublicHeaderTo
(io.netty.buffer.ByteBuf out) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.drasyl.handler.remote.protocol.FullReadMessage
getRecipient
Methods inherited from interface org.drasyl.handler.remote.protocol.RemoteMessage
getArmed, getHopCount, getNetworkId, getNonce, getProofOfWork, getSender
-
Field Details
-
MIN_LENGTH
public static final int MIN_LENGTH- See Also:
-
-
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 countisArmed
- if the message is armed or notnetworkId
- the network idnonce
- the noncerecipient
- the public key of the recipientsender
- the public key of the senderproofOfWork
- the proof of work ofsender
address
- the public key of the peerendpoints
- the UDP-port-IP-address-combinations were the peer can be reached- Throws:
NullPointerException
- ifnonce
,sender
,proofOfWork
,recipient
,hopCount
,address
, orinetAddress
isnull
IllegalArgumentException
- ifport
is invalid
-
of
public static UniteMessage of(int networkId, DrasylAddress recipient, IdentityPublicKey sender, ProofOfWork proofOfWork, DrasylAddress address, Set<InetSocketAddress> endpoints) - Parameters:
networkId
- the network idrecipient
- the public key of the recipientsender
- the public key of the senderproofOfWork
- the proof of work ofsender
address
- the public key of the peerendpoints
- the UDP-port-IP-address-combinations were the peer can be reached.- Throws:
NullPointerException
- ifsender
,proofOfWork
,recipient
,address
, orinetAddress.getAddress()
isnull
IllegalArgumentException
- ifinetAddress.getPort()
is invalid
-
getAddress
Returns the public key of the peer.- Returns:
- the public key of the peer.
-
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
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 interfaceFullReadMessage<T extends FullReadMessage<?>>
cryptoInstance
- the crypto instance that should be usedsessionPair
- will be used for encryption- Returns:
- the armed version of this message
- Throws:
InvalidMessageFormatException
- if arming was not possible
-
encodeMessage
public io.netty.buffer.ByteBuf encodeMessage(io.netty.buffer.ByteBufAllocator alloc) Description copied from interface:RemoteMessage
Writes this message to a buffer created byalloc
.- Specified by:
encodeMessage
in interfaceRemoteMessage
- Returns:
- the buffer written to
-
writePublicHeaderTo
protected void writePublicHeaderTo(io.netty.buffer.ByteBuf out)
-