Class NetherNetConstants

java.lang.Object
org.cloudburstmc.netty.channel.nethernet.NetherNetConstants

public class NetherNetConstants extends Object
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.
  • 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

      public static final String RTC_NEGOTIATION_CONNECT_REQUEST
      See Also:
    • RTC_NEGOTIATION_CONNECT_RESPONSE

      public static final String RTC_NEGOTIATION_CONNECT_RESPONSE
      See Also:
    • RTC_NEGOTIATION_CANDIDATE_ADD

      public static final String RTC_NEGOTIATION_CANDIDATE_ADD
      See Also:
    • RTC_NEGOTIATION_CONNECT_ERROR

      public static final String RTC_NEGOTIATION_CONNECT_ERROR
      See Also:
    • DISCOVER_TARGET

      public static final String 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

      public static final String 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

      public static final String XBOX_RPC_METHOD_TURN_AUTH
      See Also:
    • XBOX_RPC_METHOD_SEND_MESSAGE

      public static final String XBOX_RPC_METHOD_SEND_MESSAGE
      See Also:
    • XBOX_RPC_METHOD_RECEIVE_MESSAGE

      public static final String XBOX_RPC_METHOD_RECEIVE_MESSAGE
      See Also:
    • XBOX_RPC_METHOD_PING

      public static final String XBOX_RPC_METHOD_PING
      See Also:
    • XBOX_RPC_METHOD_PONG

      public static final String XBOX_RPC_METHOD_PONG
      See Also:
    • XBOX_RPC_INNER_METHOD_WEBRTC

      public static final String XBOX_RPC_INNER_METHOD_WEBRTC
      See Also:
    • XBOX_RPC_INNER_METHOD_DELIVERY

      public static final String 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_DSCP
      DSCP 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_SEGMENTS
      A segment's countdown header is one byte, so one message spans at most this many segments.
      See Also:
    • RELIABLE_CHANNEL_LABEL

      public static final String RELIABLE_CHANNEL_LABEL
      See Also:
    • UNRELIABLE_CHANNEL_LABEL

      public static final String UNRELIABLE_CHANNEL_LABEL
      See Also:
  • Constructor Details

    • NetherNetConstants

      public NetherNetConstants()
  • Method Details

    • encryptDiscoveryPacket

      public static byte[] encryptDiscoveryPacket(io.netty.buffer.ByteBuf packet) throws Exception
      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 bytes
      maxPayload - The most payload one segment carries, excluding the header byte
      Returns:
      How many segments the message needs, 0 for an empty one
      Throws:
      IllegalArgumentException - if no payload fits a segment, or the message needs more segments than the countdown header can number
    • buildSignalConnectRequest

      public static String buildSignalConnectRequest(String connectionId, String sdp)
      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

      public static String buildSignalConnectResponse(String connectionId, String sdp)
      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

      public static String buildSignalCandidateAdd(String connectionId, String candidateSdp)
      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

      public static NetherNetConstants.Signal parseSignal(String raw)
      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