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). - 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 Summary
Fields inherited from interface org.drasyl.handler.remote.protocol.RemoteMessage
MAGIC_NUMBER
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionarm
(io.netty.buffer.ByteBuf byteBuf, Crypto cryptoInstance, SessionPair sessionPair) Returns an armed version (ArmedProtocolMessage
) of this message for sending it through untrustworthy channels.abstract DrasylAddress
Returns the public key of the peer.abstract Set<InetSocketAddress>
Returns the ip address of the peer.Returns this message with incremented hop count.static UniteMessage
of
(int networkId, DrasylAddress recipient, IdentityPublicKey sender, ProofOfWork proofOfWork, DrasylAddress address, Set<InetSocketAddress> inetAddresses) 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.protected void
writeBodyTo
(io.netty.buffer.ByteBuf out) protected void
writePrivateHeaderTo
(io.netty.buffer.ByteBuf out) protected void
writePublicHeaderTo
(io.netty.buffer.ByteBuf out) void
writeTo
(io.netty.buffer.ByteBuf out) Writes this message to the bufferout
.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> inetAddresses) 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 peerinetAddresses
- the internet addresses of the peer- 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> inetAddresses) - 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 peerinetAddresses
- the ip inetAddress and port of the peer- 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.
-
getInetAddresses
Returns the ip address of the peer.- Returns:
- the ip address of the peer.
-
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 interfaceFullReadMessage<T extends FullReadMessage<?>>
- Parameters:
byteBuf
- theByteBuf
to write throughcryptoInstance
- 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
-
writeTo
public void writeTo(io.netty.buffer.ByteBuf out) Description copied from interface:RemoteMessage
Writes this message to the bufferout
.- Specified by:
writeTo
in interfaceRemoteMessage
- Parameters:
out
- writes this envelope to this buffer
-
writePublicHeaderTo
protected void writePublicHeaderTo(io.netty.buffer.ByteBuf out)
-