openOMSI GitHub Discord

Docs / Multiplayer / Dedicated server

Administration

13 min readEdit this pagedocs/SERVER.md

Multiplayer relocation (dedicated servers). A player authenticated with /admin <password> as administrator or moderator can relocate their own bus without reconnecting: Esc → Service → Teleport to a start point (e.g. Bauhof to Kraken), F4 map click and the navigator/city map teleport now request a host-authorized move.

The dedicated host validates the sender and returns a teleport command; the client applies the same reset logic as existing host-controlled teleports. Moderators can goto and unstick; admins can additionally bring and bringall through the new Players menu.

allow_player_teleport = 0 in server.cfg (default) restricts self teleport to authenticated moderators/admins. Set it to 1 to allow every connected player to relocate only their own bus using the same UI. This setting does not authorize moving other players, setting the world clock, or editing the map. Old game clients do not support this request protocol.

A server administers itself with passwords of server.cfg, at least 12 characters each (a shorter one lets nobody in, and the log says so - a server set up before with 8 to 11 characters needs a longer one now). The game's login goes over the session unencrypted: its challenge, salt and rounds can be overheard, and a short password could then be guessed offline, hence the length.

key role may
admin_password admin everything below, and the world: the clock and its speed, the weather, the AI traffic, the passengers; bringing players to their bus (bring, bringall)
moderator_password moderator see the server and its players, send a player away (not an admin), the chat, a word or a notice to one player or to all (tell, notify), duties, services, putting a player's bus back on its wheels (unstick), going to a player (goto, which moves the moderator's own bus)

The role comes from the password that was given and is decided by the server alone: nothing a game or a page sends names or raises it, and every operation is checked on the server, whether a menu showed it or not. A moderator_password equal to the admin_password gives the admin's role. No password: no administration.

In the game. A player says /admin <password> in the chat; the password never goes over the network (the game asks auth?, the server answers with a fresh challenge, its salt and rounds, and the game proves it knows the password: PBKDF2 and an HMAC of the challenge).

Five wrong answers in two minutes from one source (the player's address - the one behind the web gateway for a player who came by WebSocket - or their number on this machine) lock it for that source for a while; thirty from all sources together lock it for everybody.

The web panel counts its own wrong passwords apart (see below): a lock of the one is no lock of the other. The server answers admin-ok admin or admin-ok moderator (a game before the roles reads the first word), and the Esc menu's Administration sends every line to the server as admin <action>. The rights end when the player leaves or talks from another address.

A game from before the roles, given the moderator's password, shows the admin's whole old menu: the server still refuses the world's actions, but that game does not read the answer (admin-result), so nothing happens on its screen. Moderators should play a current game.

The Administration menu, from afar. A player who administers a dedicated server gets the server's own menu under Esc → Administration: who they are (admin or moderator), the clock and the weather; Players... - every player the server lists, by name and number, with what they do and drive, searchable with the menu's search line;

a player's page and, before sending them away (now, or for the rest of the run), a question naming them, their number and their connection;

the clock, its speed, the next weather, the traffic and the passengers' density with their present values - or why they cannot be changed (a moderator's role, the real time, METAR, no passengers); and what became of the last operations.

The menu asks the server over the session itself - the server may be anywhere; it never looks for it at an address of its own - every 3 seconds at most while it is open, one question at a time, and says so when no answer comes (a server older than the game: Full list of commands (older menu)... still has every line of the older menu).

The line picked stays on what it does when new answers come; a player picked who left or came back is not acted on. Stop administering ends the rights. It is a list of the game menu like the others, worked the same way (the search line needs a keyboard; the list works without it). The host of a game hosted by code keeps the menu it had.

One way of doing it. Whatever way an operation comes - a player's menu, the machine's own tool (POST /admin, see above: the admin's role), the web panel - it is checked against the role, done by the server's own loop on its tick (never by a web request's thread), and recorded with what became of it: applied (done: a player sent away is gone from the session, the clock reads the new time), pending (the server did its part, the rest is a player's game: a word or a duty sent to it), rejected with the reason (no such player, not the player picked any more, not allowed for the role, the clock follows the real time, the weather follows the METAR report, a weather that is not installed, a number out of range), or queued while the loop has not come to it.

A player's game that asked is told admin-result <record> <status> <message>. A request taken is not a request done.

Picking a player. A player is named by number and connection: kick 3#17 reason (the connection is the session's own number for that join, which the admins' list gives).

A player who left, or left and came back - the same number, a new connection - or somebody else who has the number now is not the one picked: the operation is refused and nobody else is touched. The older menus' kick 3 still works and names the number alone.

hwban 3#17 session|all [12h|3d] reason bans the player's machine and unban <id> lifts a ban (Machine bans).

The players' list for an admin (admin-list [search] → an admin-p <id> <conn> <state> <role> <aboard> <online s> <vehicle> <name> line each, then admin-end <found> <total>) needs no share_positions: it gives no position and no address.

A search finds every name that holds the text, whatever the case (pichau finds Pichau and pichau_fan, the exact name first), as text - no pattern, no command - and never picks one by itself: the admin picks.

admin-state answers admin-s with the clock, its speed, the weather, the traffic, the passengers' density and counts, the players and the locks (rt=1: real time, metar=: the METAR station).

Sending away. A player sent away (kick) reads the reason given, or "sent away by an admin", and may join again. ban keeps them out for the rest of this server run, by their game's random nonce and the address they came from.

That is not an identity: a player name is whatever the game says, an address changes (and many players can share one), and the session knows nothing that outlives a run and could not be made up. So ban is for the run only; the lasting ban is the machine ban, which holds a machine's identifier instead of a name or an address.

Bringing players, going to them. bring, bringall and goto stay in the game's menu for an admin who drives on the server: the player's game puts its bus beside the admin's (with its trailers; a player on foot is put back at the wheel first, so walking is not kept).

What becomes of other players sitting in a bus that is moved is not checked. They need the admin's bus, and are not safe for every case, so the web panel and the new panels offer none of them.

The web API. The web gateway answers the administration under /api/admin/ (and the panel under /admin/), on the server's web port; nothing else is needed. All JSON, the token of a login in Authorization: Bearer <token> - never in a cookie or in the address. A request that changes something is POST with Content-Type: application/json.

request body / query answer
POST /api/admin/login {"password": "…"} 200 {"token", "session"}; 401 wrong password; 429 {"retry_after"} too many lately; 404 no password set
POST /api/admin/logout {} 200: the session ends
GET /api/admin/session 200 {"session"}
GET /api/admin/state 200 {"session", "server", "age_ms"}
GET /api/admin/players ?q=<search> 200 {"players", "total", "age_ms"}
POST /api/admin/ops an operation, below 202 {"op"} queued; 400 not one (with the reason); 403 not for this role; 503 too many waiting
GET /api/admin/ops/<id> 200 {"op"}; 404 not kept any more (the audit log has it)
GET /api/admin/bans 200 {"bans": [{"id", "name", "reason", "by", "at", "until", "scope"}], "age_ms"} - no identifiers
GET /api/admin/events ?audit_after=<seq> 200 {"ops": the last 50 records, "audit": the audit entries after seq}

session is {"role": "admin"|"moderator", "permissions": ["view", "moderate", "world"], "actor": "web#2 (address)", "expires_in": seconds}.

server is {"name", "map", "version", "players", "max_players", "time": "HH:MM", "clock": seconds of the day, "clock_speed", "real_time", "weather", "metar": station or null, "traffic", "traffic_max", "timetable", "passengers", "passenger_density", "passenger_density_max", "waiting", "walking", "aboard", "cars", "buses"}, as the server's loop published it about a second ago (age_ms; a server that has stopped publishing shows as old).

A player is {"id", "conn", "name", "state": "joining" | "driving" | "on_foot" | "aboard", "vehicle", "line", "tour", "aboard": the driver's id or null, "online_secs", "admin": role or null} - no position, no address.

An operation's record is {"id", "actor", "op", "summary", "target": {"id", "conn"} or null, "target_name", "status": "queued" | "applied" | "pending" | "rejected", "message", "at"}.

The operations (POST /api/admin/ops), with what they need:

body role
{"op": "kick", "target": {"id": 3, "conn": 17}, "reason": "…"} (reason optional, 120 characters) moderator
{"op": "ban", "target": {…}, "reason": "…"} - for this server run moderator
{"op": "hwban", "target": {…}, "reason": "…", "scope": "session"|"all", "hours": 24} (scope default session, hours 1 .. 8784, none: for good) - the machine, see below moderator for session, admin for all
{"op": "unban", "id": "0badf00d"} admin
{"op": "say", "text": "…"} / {"op": "tell", "target": {…}, "text": "…"} (160 characters) moderator
{"op": "clock", "seconds": 30600} (0 .. 86400) / {"op": "shift", "seconds": -3600} / {"op": "speed", "factor": 2} (1 .. 30) admin
{"op": "weather", "next": true} / {"op": "weather", "file": "Weather/#CAVOK.owt"} admin
{"op": "traffic", "density": 40} (0 .. the game's top) / {"op": "traffic", "clear": true} admin
{"op": "passenger_density", "value": 1.5} (0 .. 3) admin

A request is answered queued at once; the server's loop does it on its next step and the record says what became of it (GET /api/admin/ops/<id>): the web's threads never touch the session or the world. A request the loop has not come to in 30 s is refused. The texts are values, never commands: a line break in a reason is a space, markup stays text (the panel shows it as text).

The web panel. http://127.0.0.1:<web_port>/admin/ (with the slash) on the server's machine - or through your HTTPS proxy with admin_web = remote - is a page of the server itself: no other service, nothing to install, the same API and the same checks as above.

Log in with the admin's or the moderator's password (it is sent to the server only and kept nowhere; the session's token lives in that browser tab until it is closed or you log out).

It shows the server (map, players, clock and its speed, weather, traffic, the passengers' density and how many wait, walk and ride, with "real time" and "METAR" when they hold the clock or the weather), the players with a search (by name or #number), the actions on the player picked

  • send away, for this run, a word - each confirmed with the name, number and connection; the announcement; the world's controls with their present values (disabled with the reason for a moderator, on the real time or under METAR, without passengers); and what became of each operation (queued, applied, sent, rejected and why).

    It asks the server every 3 seconds while the tab is shown (not while it is hidden), more slowly when the server does not answer, and says so; a player who left or came back while picked is not acted on. English and Portuguese, for a desktop and a phone.

    crates/omsi-lan/examples/admin_demo.rs runs a session with a few players and the panel without OMSI 2, to try it (crates/omsi-admin/panel/test/ drives it in a browser).

Who reaches the web panel and the API (server.cfg):

  • admin_web = local (what a new server's file says): from the server's own machine only, directly - a request that came through a tunnel or a reverse proxy (it carries X-Forwarded-For, CF-Connecting-IP …) is refused, the server's own Cloudflare tunnel (tunnel = 1) included. Starting the tunnel does not put the administration on the internet.
  • admin_web = remote: also through the proxies listed in admin_trusted_proxies (addresses separated by ;; this machine by default), and only for requests they say came over HTTPS (X-Forwarded-Proto: https, or Cloudflare's CF-Visitor with admin_proxy_header = cf-connecting-ip only - behind another proxy it would be the client's own).

    The address they say a request came from is believed of them alone, and only in the header they write: admin_proxy_header, the last address of X-Forwarded-For by default (Caddy, nginx, Cloudflare), or x-real-ip, or cf-connecting-ip - the other headers may be the client's own, passed on.

    That address counts its wrong passwords and names it in the records; a request the proxy names nobody for, or names this machine for, is refused. Which header to choose:

    • Caddy: the default (it adds the client to X-Forwarded-For).
    • nginx: either proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; with the default, or proxy_set_header X-Real-IP $remote_addr; with admin_proxy_header = x-real-ip - nginx passes the client's own X-Forwarded-For on unchanged otherwise.
    • Cloudflare's proxy (the orange cloud) in front of your own proxy: cf-connecting-ip - the last X-Forwarded-For address is then Cloudflare's, and every client would share a few addresses for the locks. A plain HTTP request from another machine is refused.

      Mind that with tunnel = 1 the local cloudflared is such a proxy: the panel is then on the public tunnel address, guarded by the passwords alone. A proxy of your own (Caddy, nginx with a certificate) in front of 127.0.0.1:<web_port> is the safer way; it must not pass /admin (the machine's own door) on.

  • On this machine the panel answers to its own names only (127.0.0.1, localhost, [::1]): a page of another site whose name was turned to this machine (DNS rebinding) is refused.
  • A reverse proxy on this machine must say it is one: it has to add X-Forwarded-For (or the header of admin_proxy_header) to what it passes on.

    One that adds none hands every request from the internet over as this machine's own - the server cannot tell them apart. nginx's plain proxy_pass http://127.0.0.1:<web_port>; is such a one (it sends Host: 127.0.0.1:… and no address): add proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;.

  • Mind that a tunnel working below HTTP (ssh -R, frp, playit, ngrok tcp) hands every client over as this machine, with no header to tell: with one in front of the web port, anybody who reaches it meets the login as if they were here (the passwords and their locks still hold). Point such a tunnel at the game's port only, or keep admin_web = off.
  • admin_web = off: none (the machine's own POST /admin stays as it is). A server.cfg without the key - one from before the web panel - or with a wrong word is off: an update opens no panel the operator did not ask for. Add admin_web = local to have it.
  • admin_web_origins: other https:// sites whose pages may send requests (a dispatch page elsewhere); a request whose browser names another origin is refused. No answer allows another site's page to read it (no Access-Control-Allow-Origin).

A session ends after 30 minutes unused, after 12 hours, at logout, or when the server stops; at most 16 at once (a moderator's login makes room among the moderators' sessions only, never an admin's).

Five wrong passwords in two minutes lock a source for a while, thirty from anywhere lock the door for everybody but this machine itself (a flood from afar cannot keep the operator out of their own panel). A wrong password is noted in the audit log, a lock once - not each knock on it.

The server's POST /admin for a tool on its machine stays as it was (one command a line, X-Admin-Password, the loopback only, 202 when taken): its commands go the same way as the others and are in the audit log, with what became of them.

The audit log. Every login, refused password, operation and what became of it is written to admin-audit.log beside server.cfg (a JSON object a line: when, who - player 3 'Name', local tool (POST /admin), web#2 (address) -, the role, the action, the player, the result), put aside as admin-audit.log.1 past 1 MB, keeping the previous backup as admin-audit.log.2 (about 3 MB total).

Web logins and refused passwords keep their whole source addresses in this audit file, regardless of log_addresses; that setting controls only the general game/server log. No password or token is ever written to it; names, reasons and chat lines are kept as cleaned text.

Something wrong or missing? Fix it on GitHub or open an issue.

↑↓ to move↵ to open