All checks were successful
PR Checks / rust-gates (pull_request) Successful in 7m52s
Phase 0.2 of the installer plan (docs/installer/PLAN.md §5). The installer has to drive this binary non-interactively, and today it cannot: the auth token is only readable by scraping the startup log, the config path can only be named through an environment variable, and a relative db path follows the process working directory — which a service manager, not the operator, chooses. - Add a four-flag CLI (cli.rs): --print-config, --config <PATH>, --version, --help. Hand-rolled; an argument-parsing dependency would be larger than the code it replaced. An unrecognized flag exits 2 rather than starting a sidecar that is not the one that was asked for. - --print-config resolves the configuration exactly as a normal start does — including writing a missing config file and generating a blank auth token — and prints it as JSON on stdout: versions, protocol, both bind addresses, ws path, resolved db path, and the token. config_created / token_generated let a re-run tell "read an existing install" from "provisioned a new one". The log subscriber is deliberately not started in this mode, so the document is the whole output. - Anchor a relative [store].path to the config file's directory instead of the CWD, and report resolved absolute paths. A unit pinning UOLINK_CONFIG now keeps its database beside its config rather than in %SystemRoot%\System32 or a VirtualStore redirect. Development is unaffected: under cargo run the two directories are the same. :memory: and file: URIs are left alone. - Hand the db path to sqlx as a filesystem path instead of formatting it into a sqlite:// URL, which percent-decodes it and splits it on '?'. An installed path containing %20 previously opened a different file; verified it now does not. - Create the config's and the database's parent directories when missing, so a service can name /var/lib/runicgateway on a host where nothing made it yet. - 22 unit tests covering argument parsing, path anchoring, token persistence, the generated config template, and the --print-config document. No protocol change: PROTOCOL_VERSION stays 3. Co-Authored-By: Claude <noreply@anthropic.com>
39 lines
1.8 KiB
Plaintext
39 lines
1.8 KiB
Plaintext
# uo-link sidecar configuration — example.
|
|
#
|
|
# The sidecar reads `sidecar.toml` (override the path with --config or $UOLINK_CONFIG).
|
|
# If that file is absent on first run, one is generated automatically with a random
|
|
# auth_token, so you normally do not create this by hand — just start the sidecar and edit
|
|
# the file it writes. Nothing here is compiled into the binary.
|
|
#
|
|
# Environment variables override the file:
|
|
# UOLINK_SHARD_BIND, UOLINK_WEB_BIND, UOLINK_WEB_TOKEN, UOLINK_DB_PATH
|
|
#
|
|
# Read the resolved settings back without starting the sidecar (JSON, includes the token):
|
|
# uo-link-sidecar --print-config --config /etc/runicgateway/sidecar.toml
|
|
|
|
[shard]
|
|
# Loopback address the shard dials out to. Keep this on localhost — the game must not
|
|
# be reachable from anywhere else.
|
|
bind = "127.0.0.1:7788"
|
|
|
|
[web]
|
|
# Address the website connects to (WebSocket + REST).
|
|
# 127.0.0.1:8080 -> same host only
|
|
# 0.0.0.0:8080 -> accept remote clients (then auth_token is mandatory)
|
|
bind = "127.0.0.1:8080"
|
|
|
|
# Shared secret the website must present on every request:
|
|
# REST: Authorization: Bearer <token> (or X-Api-Key: <token>)
|
|
# WebSocket: add ?token=<token> to the connect URL
|
|
# Authentication is ALWAYS on. If this is left blank, the sidecar generates a token
|
|
# here on startup and logs it. Rotate by changing this value and restarting.
|
|
auth_token = "replace-with-a-long-random-secret"
|
|
|
|
[store]
|
|
# A RELATIVE path resolves against the directory holding this file, not the working
|
|
# directory of the process — so a service pinned to /etc/runicgateway/sidecar.toml keeps
|
|
# its database beside its config no matter what CWD the service manager picked. Give an
|
|
# absolute path (or set UOLINK_DB_PATH) to put the data somewhere else, e.g.
|
|
# /var/lib/runicgateway/uo-link.db or C:\ProgramData\RunicGateway\uo-link.db.
|
|
path = "uo-link.db"
|