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

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.
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.
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.

Enums

The reason why a client is in error state
Errors from the renetcode crate.
Result from processing an packet in the server

Constants

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

Functions

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