Gateway gate - NexusTomorrow/server GitHub Wiki

reference, committed verified 2026-10-18 bootstrap c3409ba run 2026-10-18

The checks every client message passes before it reaches a handler, and the rate limit after them. The opcode table the gate reads is generated on Gateway opcode table, and how the gate fits the gateway is on Gateway.

The checks

In order

Check If it fails
The frame is a client envelope, its length is its own, and anything nested in it is one already-encoded message The connection ends
The opcode has a row in the opcode table Dropped and counted; the session carries on
The opcode isn't switched off in DisabledOpcodes Dropped and counted
The message is declared and verified to Fields or beyond Dropped and counted, never read
The body reads cleanly, with less than a byte left over The connection ends

A dropped message is counted by opcode and reason, and logged at debug level.

The opcode table

One row per client message the first stage admits. Each row names the owner the message goes to, its priority and its rate, and whether a message past that rate is dropped or ends the connection. Gateway opcode table lists every row.

The rate limit

Each session keeps a token bucket per opcode. A row's bucket refills at the row's rate per second, up to one second's worth, and a message takes one token. A message that finds the bucket empty gets the row's action past the limit:

Action Does
drop The message is dropped and counted; the session carries on
disconnect The connection ends

Known edges

  • The opcode table holds pregame rows only; a message the client sends tagged has no row yet, so it's dropped until in-world routing (Gateway design).
  • DisabledOpcodes is read when the server starts, so switching an opcode off takes a restart.
  • Sending and handling still need Fields; the per-member rules come with step 3's second stage (Message audit design).

Where the code lives

Piece Path
The catalog, the opcode table, the decoder and the rate gate Source/NexusTomorrow.Gateway/Catalog/
The kill switch Source/NexusTomorrow.Gateway/GatewayOptions.cs
Tests Tests/NexusTomorrow.Gateway.Tests/