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
DrasylAddressto 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
FieldsFields inherited from interface org.drasyl.handler.remote.protocol.RemoteMessage
MAGIC_NUMBER, MAGIC_NUMBER_LEN -
Constructor Summary
Constructors -
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.abstract DrasylAddressReturns the public key of the peer.abstract Set<InetSocketAddress>Returns the ip address of the peer.intReturns this message with incremented hop count.static UniteMessageof(int networkId, DrasylAddress recipient, IdentityPublicKey sender, ProofOfWork proofOfWork, DrasylAddress address, Set<InetSocketAddress> inetAddresses) static UniteMessageof(HopCount hopCount, boolean isArmed, int networkId, Nonce nonce, DrasylAddress recipient, DrasylAddress sender, ProofOfWork proofOfWork, DrasylAddress address, Set<InetSocketAddress> inetAddresses) Creates new unit message.protected voidwriteBodyTo(io.netty.buffer.ByteBuf out) protected voidwritePrivateHeaderTo(io.netty.buffer.ByteBuf out) protected voidwritePublicHeaderTo(io.netty.buffer.ByteBuf out) voidwriteTo(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, waitMethods inherited from interface org.drasyl.handler.remote.protocol.FullReadMessage
getRecipientMethods 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 ofsenderaddress- the public key of the peerinetAddresses- the internet addresses of the peer- Throws:
NullPointerException- ifnonce,sender,proofOfWork,recipient,hopCount,address, orinetAddressisnullIllegalArgumentException- ifportis 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 ofsenderaddress- the public key of the peerinetAddresses- the ip inetAddress and port of the peer- Throws:
NullPointerException- ifsender,proofOfWork,recipient,address, orinetAddress.getAddress()isnullIllegalArgumentException- 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:FullReadMessageReturns 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:FullReadMessageReturns an armed version (ArmedProtocolMessage) of this message for sending it through untrustworthy channels.- Specified by:
armin 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
-
writeTo
public void writeTo(io.netty.buffer.ByteBuf out) Description copied from interface:RemoteMessageWrites this message to the bufferout.- Specified by:
writeToin interfaceRemoteMessage- Parameters:
out- writes this envelope to this buffer
-
writePublicHeaderTo
protected void writePublicHeaderTo(io.netty.buffer.ByteBuf out)
-