Building and linking
Build
make # build/libngnet.a (+ libdatachannel, fetched the first time)
make install PREFIX=/usr/local
make test # ctestor CMake directly:
cmake -S . -B build && cmake --build build && ctest --test-dir buildOptions: NGNET_WEBRTC (libdatachannel), NGNET_MASTER (libcurl, OpenSSL), NGNET_SHIM, NGNET_CLIENT, NGNET_TESTS, NGNET_ENET_HEADER (enet/enet.h or enet6/enet.h; with NGNET_ENET_INCLUDE_DIR and NGNET_ENET_LIBRARY when ENet is not found by pkg-config), NGNET_FETCH_LIBDATACHANNEL.
libdatachannel is found with find_package(LibDataChannel), otherwise fetched (v0.24.6, as the game server does); offline builds set FETCHCONTENT_SOURCE_DIR_LIBDATACHANNEL to a checkout with its submodules. Needs OpenSSL (Ed25519, DTLS certificate), libcurl, a C11 and a C++17 compiler (libdatachannel’s face is C++), POSIX threads and sockets (Linux, macOS; not Windows yet).
A project that compiles sources itself includes ngnet.cmake and uses NGNET_SOURCES, NGNET_INCLUDE_DIR, NGNET_DEFINITIONS, NGNET_LIBRARIES. A POSIX make project links -lngnet -ldatachannel -ljuice -lusrsctp -lstdc++ -lcurl -lcrypto -lpthread (pkg-config --libs ngnet gives it).
The master server’s allow list
If the master runs with -keys (an allow list of server keys), the key must be listed, so set a key_file (a key in memory changes at every start). The key is printed in the log at start (Announcing to ... (key <base64>)); ngnet_public_key() returns it. Keep ngnet.key between restarts: it is the server’s identity on the list. Locally, the master refuses private addresses unless it runs with MASTER_ALLOW_PRIVATE_IPS=1.