Skip to content

Server configuration

The server reads config.json from its working directory and merges it with Dart environment declarations and command-line arguments. Later values override earlier ones. Restart the server after editing the file, except for role definitions updated through console commands, which are applied and saved at runtime.

FieldModel defaultPurpose
host"127.0.0.1"Bind address
port28006WebSocket/status port
publicAddress""Canonical address used for authentication
trustedProxies[]Proxy IP addresses or CIDR networks allowed to supply X-Forwarded-For
description"A server for Setonix."Text shown in server lists
thumbnail""Image path, absolute or relative to the server directory
autosavetrueSave changes automatically
multiWorldfalseReserved for multi-world connections; routing is incomplete
maxPlayers-1Player limit; negative means unlimited
gameMode""Mode for a new default world; empty means sandbox
guestPrefix"Guest "Prefix for guest names
accountRequiredtrueRequire account authentication
whitelistEnabledfalseRestrict access to whitelisted registered users
apiEndpoint""Optional remote user-service base URL
endpointSecret""Bearer secret for that service
serverRolesBuilt-in rolesRole definition map
worldFile"world.stnx"Legacy model field; current world loading uses worlds/*.stnx

The executable currently supplies autosave: false, maxPlayers: 10, and multiWorld: false to the configuration merge when their options are absent. These override the model/file values. In embedded servers, the model defaults apply unless the caller supplies overrides.

OptionShortMeaning
--help-hShow usage
--version-VShow executable version
--verbose-vAdditional output
--host <address>-HBind address
--port <number>-pListen port
--description <text>-dServer-list description
--thumbnail <path>-tServer-list image
--max-players <number>-mPlayer limit
--multi-world-wSet the multi-world option; routing is incomplete
--public-address <url>Canonical public URL
--trusted-proxy <ip-or-cidr>Trust a reverse proxy; repeat or separate entries with commas
--game-mode <namespace:id>-gInitial mode
--autosave <value>-aCurrent parser requires a value and enables autosave when the option is present

The current --autosave implementation checks whether the option was supplied, not its value; --autosave false also enables it. Use --autosave true to enable automatic saving. Without it, use save and an orderly stop to persist your session. The help text for this option does not match that behavior.

Terminal window
./server --host 127.0.0.1 --port 28006 --autosave true --max-players 8 --game-mode core:blackjack

For public access, configure TLS and the public origin as described in server setup.

The SETONIX_* names are read using Dart’s String.fromEnvironment, bool.fromEnvironment, and int.fromEnvironment. These are compilation/environment declarations, not ordinary process environment variables read through Platform.environment.

Available names are SETONIX_HOST, SETONIX_PORT, SETONIX_WORLD_FILE, SETONIX_AUTOSAVE, SETONIX_MULTI_WORLD, SETONIX_MAX_PLAYERS, SETONIX_DESCRIPTION, SETONIX_THUMBNAIL, SETONIX_GUEST_PREFIX, SETONIX_WHITELIST_ENABLED, SETONIX_ACCOUNT_REQUIRED, SETONIX_PUBLIC_ADDRESS, SETONIX_TRUSTED_PROXIES, SETONIX_API_ENDPOINT, SETONIX_ENDPOINT_SECRET, and SETONIX_GAME_MODE. SETONIX_TRUSTED_PROXIES is a comma-separated list of IP addresses or CIDR networks; an empty value disables proxy trust. Use config.json or CLI options to configure a downloaded executable.

No proxies are trusted by default. Set trustedProxies to the source IP addresses or CIDR networks of your proxies, for example ["127.0.0.1", "::1"] for nginx on the same machine. IPv4 and IPv6 are supported; hostnames and wildcards are rejected. Invalid entries prevent startup. Lists supplied by environment declarations or CLI replace earlier lists.

For WebSocket connections from a trusted peer, the server reads X-Forwarded-For from right to left, skips trusted proxy hops, and uses the first untrusted address as the client IP. This address is used for logs, player listings, plugins, and authentication rate limits. Headers from untrusted peers are ignored. Missing or malformed forwarding headers fall back to the socket peer address.

Trust only proxies you control, and configure them to overwrite forwarding headers or append the actual connecting client’s address. Keep the backend listener on loopback or restrict access to it. trustedProxies controls forwarded IP handling; it does not restrict connections to the listener or enable TLS. Authentication continues to use the configured publicAddress, so set it to the public wss:// URL when TLS terminates at the proxy. See the nginx example.

Each serverRoles entry has a name, integer priority, and permissions array. See roles and permissions for a complete example.

By default users are stored in setonix.db. A non-empty apiEndpoint selects a remote user service instead. It must use HTTPS, except for localhost HTTP. Requests include Authorization: Bearer <endpointSecret> when a secret is set. The service handles user lookup and updates for names, roles, whitelisting, bans, and login times. The implementation is documented by RemoteUserService.