Configuration
2. Configuration, without a new file
int ngnet_set(const char* key, const char* value); /* 0 ok, -1 unknown key */| key | default | |
|---|---|---|
off | 1: the library does nothing | |
webrtc | shim: off; native API: 1 | the shim’s opt-in: without webrtc=1 a program built with -include ngnet/enet.h is plain ENet (no thread, no socket, no announce, no intercept). 0: no browsers (no WebRTC port, no offers); the server still announces and answers HELLOINFO |
ipv6 | 0 | 1: browsers that reach the master over IPv6 are taken and the announce goes over IPv6 too. Default IPv4 only: an IPv6 browser’s offer is refused with “this server takes IPv4 players only”. With a classic (IPv4) ENet an IPv6 browser’s peer->address is 0.0.0.0, so leave it off there |
webrtc_port | game port + 1 | UDP port of every browser |
master | https://master.shootanddestroy.obex.pw | a master URL; repeatable (several masters at once); the first call replaces the default; - or empty: none |
stun | stun:stun.l.google.com:19302 | comma separated |
turn, turn_username, turn_credential | TURN relays for players behind symmetric NATs | |
name, map, mode | from the classic announce, else ngnet server | clipped to 64, 32, 16 bytes on a UTF-8 boundary (the master refuses longer) |
protocol | 0.75 after a classic announce, else the master’s default | any [0-9A-Za-z._-]{1,16} |
max_players | from the classic announce, else 32 | |
country | the master finds it from the address when absent | |
key_file | empty: in memory | the Ed25519 identity on the master. Empty: a new key at every start (a new row id; the old row drops off within 90 s). A path: read from it, or made once and written there (kept in memory if it cannot be written) |
cert_file | empty: in memory | the DTLS certificate WebRTC needs. Empty: made at every start. A path: read from it, or made once and written there |
join_code, unlisted | play with friends, no forwarded port | |
bind | any | local address for ICE (multi-homed hosts, tests) |
The environment variable NGNET_<KEY> (upper case) overrides ngnet_set; NGNET_MASTER is a list separated by spaces or commas. ngnet_set_info() updates name, map, mode, protocol, player counts and the HELLOINFO JSON at runtime.
Lua (5.1 to 5.4, LuaJIT), header only, compiled against the program’s own Lua headers:
#include <ngnet/lua.h>
ngnet_lua_open(L); /* registers ngnet_set(key, value) and ngnet_get(key) */ngnet_set("master", "https://master.example.org")
ngnet_set("name", "My server")