Class NetherNetConstants
java.lang.Object
org.cloudburstmc.netty.channel.nethernet.NetherNetConstants
The wire constants and helpers the transport and its signalings share. Nothing here is meant
for a host, which never builds or reads a signal itself.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordA signal as the bus carries it:<type> <connection id> <payload>. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longstatic final intDSCP for data channel packets: best effort.static final StringStands in for a target this side has not learned yet, so LAN discovery picks one.static final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intA segment's countdown header is one byte, so one message spans at most this many segments.static final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final intstatic final intstatic final intstatic final intstatic final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringbuildSignalCandidateAdd(String connectionId, String candidateSdp) Builds a signaling message for a CANDIDATEADD.static StringbuildSignalConnectRequest(String connectionId, String sdp) Builds a signaling message for a CONNECTREQUEST.static StringbuildSignalConnectResponse(String connectionId, String sdp) Builds a signaling message for a CONNECTRESPONSE.static io.netty.buffer.ByteBufdecryptDiscoveryPacket(io.netty.buffer.ByteBuf input) Decrypts a discovery packet and verifies its integrity.static byte[]encryptDiscoveryPacket(io.netty.buffer.ByteBuf packet) Encrypts a discovery packet using AES encryption and HMAC-SHA256 for integrity.static NetherNetConstants.SignalparseSignal(String raw) static intsegmentCount(int length, int maxPayload) Counts the segments a message is split into.
-
Field Details
-
DISCOVERY_PORT
public static final int DISCOVERY_PORT- See Also:
-
APPLICATION_ID
public static final long APPLICATION_ID- See Also:
-
ID_DISCOVERY_REQUEST
public static final int ID_DISCOVERY_REQUEST- See Also:
-
ID_DISCOVERY_RESPONSE
public static final int ID_DISCOVERY_RESPONSE- See Also:
-
ID_DISCOVERY_MESSAGE
public static final int ID_DISCOVERY_MESSAGE- See Also:
-
RTC_NEGOTIATION_CONNECT_REQUEST
- See Also:
-
RTC_NEGOTIATION_CONNECT_RESPONSE
- See Also:
-
RTC_NEGOTIATION_CANDIDATE_ADD
- See Also:
-
RTC_NEGOTIATION_CONNECT_ERROR
- See Also:
-
DISCOVER_TARGET
Stands in for a target this side has not learned yet, so LAN discovery picks one. It is the unset value of the discovery packet's own 64-bit id field, not a NetworkID, which is an opaque string that must never be read as a number.- See Also:
-
SIGNALING_USER_AGENT
- See Also:
-
XBOX_SIGNAL_NOT_FOUND
public static final int XBOX_SIGNAL_NOT_FOUND- See Also:
-
XBOX_SIGNAL_SIGNAL
public static final int XBOX_SIGNAL_SIGNAL- See Also:
-
XBOX_SIGNAL_CREDENTIALS
public static final int XBOX_SIGNAL_CREDENTIALS- See Also:
-
XBOX_SIGNAL_ACCEPTED
public static final int XBOX_SIGNAL_ACCEPTED- See Also:
-
XBOX_SIGNAL_ACK
public static final int XBOX_SIGNAL_ACK- See Also:
-
XBOX_RPC_METHOD_TURN_AUTH
- See Also:
-
XBOX_RPC_METHOD_SEND_MESSAGE
- See Also:
-
XBOX_RPC_METHOD_RECEIVE_MESSAGE
- See Also:
-
XBOX_RPC_METHOD_PING
- See Also:
-
XBOX_RPC_METHOD_PONG
- See Also:
-
XBOX_RPC_INNER_METHOD_WEBRTC
- See Also:
-
XBOX_RPC_INNER_METHOD_DELIVERY
- See Also:
-
MAX_SCTP_MESSAGE_SIZE
public static final int MAX_SCTP_MESSAGE_SIZE- See Also:
-
MAX_ADVERTISED_MESSAGE_SIZE
public static final int MAX_ADVERTISED_MESSAGE_SIZE- See Also:
-
DATA_CHANNEL_DSCP
public static final int DATA_CHANNEL_DSCPDSCP for data channel packets: best effort. libdatachannel's default, AF11, lands in the 802.11 background queue on access points that map DSCP by its top three bits (RFC 8325 sections 2.3 and 4.2.8), which starve it whenever other traffic shares the link.- See Also:
-
MAX_SEGMENTS
public static final int MAX_SEGMENTSA segment's countdown header is one byte, so one message spans at most this many segments.- See Also:
-
RELIABLE_CHANNEL_LABEL
- See Also:
-
UNRELIABLE_CHANNEL_LABEL
- See Also:
-
-
Constructor Details
-
NetherNetConstants
public NetherNetConstants()
-
-
Method Details
-
encryptDiscoveryPacket
Encrypts a discovery packet using AES encryption and HMAC-SHA256 for integrity.- Parameters:
packet- The ByteBuf containing the discovery packet to encrypt.- Returns:
- The encrypted byte array ready for transmission.
- Throws:
Exception- if encryption fails.
-
decryptDiscoveryPacket
public static io.netty.buffer.ByteBuf decryptDiscoveryPacket(io.netty.buffer.ByteBuf input) throws Exception Decrypts a discovery packet and verifies its integrity.- Parameters:
input- The ByteBuf containing the received discovery packet.- Returns:
- A ByteBuf with the decrypted payload, or null if verification fails.
- Throws:
Exception- if decryption fails.
-
segmentCount
public static int segmentCount(int length, int maxPayload) Counts the segments a message is split into.- Parameters:
length- The message length in bytesmaxPayload- The most payload one segment carries, excluding the header byte- Returns:
- How many segments the message needs,
0for an empty one - Throws:
IllegalArgumentException- if no payload fits a segment, or the message needs more segments than the countdown header can number
-
buildSignalConnectRequest
Builds a signaling message for a CONNECTREQUEST.- Parameters:
connectionId- The connection id, the opaque token the initiator chose.sdp- The SDP payload.- Returns:
- The formatted signaling message.
-
buildSignalConnectResponse
Builds a signaling message for a CONNECTRESPONSE.- Parameters:
connectionId- The connection id, the opaque token the initiator chose.sdp- The SDP payload.- Returns:
- The formatted signaling message.
-
buildSignalCandidateAdd
Builds a signaling message for a CANDIDATEADD.- Parameters:
connectionId- The connection id, the opaque token the initiator chose.candidateSdp- The candidate SDP string.- Returns:
- The formatted signaling message.
-
parseSignal
- Parameters:
raw- The signal as received- Returns:
- The parsed signal, or null when it has no type, no connection id, or a connection id that is not printable ASCII
-