Crate renetcode

Source
Expand description

Renetcode is a simple connection based client/server protocol agnostic to the transport layer, was developed be used in games with UDP in mind. Implements the Netcode 1.02 standard, available here and the original implementation in C++ is available in the netcode repository.

Has the following feature:

  • Encrypted and signed packets
  • Secure client connection with connect tokens
  • Connection based protocol

and protects the game server from the following attacks:

  • Zombie clients
  • Man in the middle
  • DDoS amplification
  • Packet replay attacks

Structs§

ConnectToken
A public connect token that the client receives to start connecting to the server. How the client receives ConnectToken is up to you, could be from a matchmaking system or from a call to a REST API as an example.
NetcodeClient
A client that can generate encrypted packets that be sent to the connected server, or consume encrypted packets from the server. The client is agnostic from the transport layer, only consuming and generating bytes that can be transported in any way desired.
NetcodeServer
A server that can generate packets from connect clients, that are encrypted, or process incoming encrypted packets from clients. The server is agnostic from the transport layer, only consuming and generating bytes that can be transported in any way desired.
ServerConfig

Enums§

ClientAuthentication
Configuration to establish a secure or unsecure connection with the server.
DisconnectReason
The reason why a client is in error state
NetcodeError
Errors from the renetcode crate.
ServerAuthentication
Configuration to establish a secure or unsecure connection with the server.
ServerResult
Result from processing an packet in the server
TokenGenerationError

Constants§

NETCODE_KEY_BYTES
The number of bytes in a private key;
NETCODE_MAX_PACKET_BYTES
The maximum number of bytes that a netcode packet can contain.
NETCODE_MAX_PAYLOAD_BYTES
The maximum number of bytes that a payload can have when generating a payload packet.
NETCODE_USER_DATA_BYTES
The number of bytes that an user data can contain in the ConnectToken.

Functions§

generate_random_bytes
Generate a buffer with random bytes using randomness from the operating system.