Introductions and sharing
Introductions and STUN
Every master's UDP side helps players reach servers whose routers don't forward the game port. Nothing goes through a master but these few small packets: the game itself, voice and mod downloads go straight between the player and the server.
- Registration: a server proves its address and its key, then repeats that every 20 seconds. A registration lasts a minute.
- Introduction: a player's game asks the master to introduce it to a server, again every second until the server answers. The master tells each side where the other is, and both send packets at once, which opens both routers. This is hole punching.
- STUN: anyone can ask a master where their router shows them, with a standard Binding request (RFC 8489). Servers, joining players and the Server Browser compare the answers of two or more masters to learn what their router does, and so which ports to try.
A master can't be used to aim packets at someone: an introduction needs a cookie for the asker's own address, and a server only obeys orders signed with the key its registration proved. A master's UDP side allows 20 requests in a burst and then 10 a second per address, and 256 introductions in a burst and then 64 a second, since everyone behind a provider's shared address shares that allowance.
Which routers connect, and what still can't, is on the hosting page: hosts behind routers.
How masters share
There's no central list that everything depends on. The masters form a network, and each part of it learns about the rest:
- Masters name other masters. Every master's answer carries its listings and the other masters it reached lately, up to 64. When the browser has to fall back on other masters, it asks those too, in the same refresh, and remembers the ones that answer. That's how it finds servers while its own masters can't help.
- The browser checks masters ahead of time. A refresh whose masters list servers also checks two other masters: first the ones those masters name or the browser remembers that it has never checked, then the ones it checked longest ago. Their listings aren't used. The list still shows only what its own masters list, and the browser has masters that answer ready for an outage.
- Masters swap every 60 seconds. Each master sends its listings to the masters it was told to keep (
--peer, or[master] peers), reads up to 12 others, in two waves of six, from those, the masters it remembers and the ones that wrote to it, then sends its listings on to the ones it read. - New masters introduce themselves. A master that sends its listings to another names its own address (
--origin, or[master] origin). The other checks that address at its next swap and, once it answers, passes it on to everyone who asks. A master with no origin, or no peer to tell, stays unknown. See get it known. - The default masters keep to themselves. They swap with each other only: they take no listings pushed by other masters and name no other masters. Every server reports to them directly, so they miss nothing, and a community master can still read them and list their servers. A master of your own can run the same way, with
--closed. - Everyone remembers. Browsers and masters each keep up to 64 masters that answered, in
peers.json, for 30 days, one per IP address, and forget one that fails two checks in a row.
Listings stay intact on the way. They're signed, so a master that passes one on can't change its address or make it last longer, and when several masters hand out the same listing, the browser keeps the newest signed copy.
Masters only hand out what the asker can use. A master takes a listing only if it could work from where it came, and gives a listing to a player only if that player can reach it: a server at 127.0.0.1 goes only to players on that machine, and one at 192.168.x.x only to players on that network.
