Protocol
Limits
ankor.sh bounds what each node sends, because a node may be run by someone else. Your controller can apply the same limits or its own. It enforces either with the answers in Limiting a node.
ankor.sh’s limits
The numbers are constants in the contract, most of them in limits.ts. An agent within them is never limited. Ankor’s agent stays within them even with 64 busy slots.
- A node has at most 64 slots. Its
hellolists at most the 50 newest demos. Each demo’s file name has at most 160 characters. - A socket message is at most 960 KiB. A socket carries one
hello, which is due within 10 seconds of the upgrade. - Each kind of message draws on a budget per connection. The budget allows a burst and refills at
a steady rate. Where the table says “a slot”, add that amount for every slot the node has. The
slot count comes from the node’s last
helloor appliedset_configreply. Before the first of these, count one slot.
| Messages | Burst | Refill | Over budget |
|---|---|---|---|
| Every message, in bytes | 32 MiB + 1 MiB a slot | 512 KiB/s + 16 KiB/s a slot | close |
hello, slot_status, node_status, server_exited, demo, demo_removed, event_backlog, shutdown, unreadable |
64 + 32 a slot | 2/s + 1/s a slot | close |
log_batch, log_index |
128, and 16 MiB | 32/s, and 256 KiB/s | dropped |
resource_batch |
10 | 1/s | dropped |
cs2_update_progress |
50 | 10/s | dropped |
demo_progress |
10 | 2/s | dropped |
phase_change, score, backup |
0 + 16 a slot | 1 every Infinity s + 1/s a slot | dropped |
reply to no open request |
32 | 1/s | close |
| WebSocket pings | 5 | 1/s | close |
- A log replay that would exceed the byte budget arrives without its oldest lines, so frequent replays do not close the socket.
- ankor.sh closes a socket that breaks these rules with the code and reason that
Closing the socket lists. After a close for a larger message or a
budget, ankor.sh answers the node’s upgrades with
429for a minute. - More than 10 upgrades of one node within
a minute are answered
429until that window ends. - More than 20 missing or unknown tokens from one address within
a minute are answered
429until that window ends. An IPv6 address counts as its whole /64. - Event uploads may carry 32 MiB +
4 MiB a slot in a minute. Each
request counts 1 KiB more than its body. Past that
budget, ankor.sh answers
429. - The agent handles at most one
check_cs2_buildin a minute and drops any that comes sooner. The agent’s scheduled read of the public CS2 build, every 30 minutes, is not limited. - ankor.sh’s demo receiver accepts one upload per node at a time.
It answers
429to a second upload. It answers403to an upload that would push the node’s stored demos past the service’s quota.
Limiting a node
Enforce limits with the answers below. The agent needs nothing else from you. It backs off,
retries and sends a fresh hello by itself. It keeps every event it stored.
- Socket over a budget: close it with code
1008andrate_limited. Refuse the node’s upgrades with429for as long as you want to keep the node out. The agent redials with its usual backoff. Its nexthellocarries its state. - A message you would rather drop: ignore it and keep the socket open. Only the messages that
the table marks
droppedare safe to ignore. The others carry state that the agent sends again only after it reconnects. - Event upload: answer
429. The agent keeps the batch and retries with backoff. - Demo upload: answer
429. The agent keeps the file and retries. Answers has the details. - The agent ignores
Retry-Afterand the response body of a429.