controller.transfer_min_speed is now the speed that is never closed.
A check requires that speed over 60 s less 2 MiB, which covers the
bursts the OS sends data in, so at the default of 64 KiB/s the cutoff
is about 30 KiB/s. The requirement is at least 1 byte, so a transfer
that moved nothing is still closed at low settings.
The slow receiver test sends 16 MiB so that it spans real checks, and
two upload tests with set bursts cover the allowance.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The guard measures a proxy stream on completed writes to the receiver.
The OS buffers a couple of MiB per connection and only takes more once
a large part has been sent, so a slow receiver can go a long time with
no write completing. At the old default of 30 KiB per 30 s, downloads
well above that could be closed, and the slow receiver test failed
every run on Linux.
controller.transfer_min_progress (KiB per 30 s) is replaced by
controller.transfer_min_speed (KiB/s), defaulting to 64. At that speed
the measured 1.6 MB bursts come within the 30 second check. Configs
on the old default move to the new one, other values are converted.
The slow receiver test checks every 3 s instead of 500 ms, as with a
500 ms check it fails at any minimum.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ModPack and map exchange strings need synchronous inflate and deflate.
In the browser these came from the browserify-zlib polyfill, which
brings pako, assert and util along. The browser build now imports
fflate through a #zlib_sync subpath import, Node.js keeps node:zlib.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Reading a mod zip needs zip_ops, which pulled yauzl into the web
interface bundle through the data classes. ModStore is node only, so
the zip reading now lives there.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The 1.1 test jobs failed because the test mod pack asked for
subspace_storage 2.3.11, which the stub did not build. The real mod
publishes 2.3.11 for 1.1.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CI coverage does not measure the ctl processes the integration tests start, so cover the Ctl log and debug event handlers, start-all, stop-all and pickFields with unit tests, and run mod show, user list flags, parse-exchange-string and log follow in process.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
user show, mod list, mod search and mod-pack list deleted fields off the received objects to trim the table, which made their toJSON throw in wire mode. They now pick the fields for the human table only and print the whole objects in json and wire mode.
Add integration cases for config edit on the controller, a host and an instance, user show with instance stats, log query and host pending in human mode, mod-pack show with mods and settings, and wire output of the trimmed lists.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CommandOutput.error takes a human reporter like result, so command errors log their message in human mode and print JSON in json and wire mode. table takes a map applied to each row in human mode, which note list, host plugin list, user list and save list now use. Rename streaming to streamingLog, and print startup errors with errorToJson directly.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
requiredMods entries are now Factorio dependency strings, and a mod
listed twice gives a version range. The plugin loader validates them.
The host refuses to start an instance whose mod pack is missing a
required mod of a loaded plugin, has it disabled or has it outside the
version range.
On start the controller resolves the required mods of its plugins and
their dependencies for the default mod pack's Factorio version and
downloads the ones missing from the mod store. The resolver and portal
download move from the ControlConnection handlers into Controller
methods so both paths share them.
Subspace Storage requires subspace_storage >= 1.99.0, and the
integration tests build a stub of that mod for the test mod pack.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Plugins can list the Factorio mods they need under requiredMods. When an
instance starts, the host warns in the instance log about each loaded
plugin whose required mods are missing or disabled in the mod pack.
Subspace Storage declares the subspace_storage mod.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add a wire output format that prints the toJSON format sent over the link. Commands without a result print {"success": true}, or "Command ran successfully" in human mode. The missing URL check throws a StartupError, unexpected command errors are rethrown to the startup handler, and startup errors log as fatal. user list, note list and host plugin list print the objects they received instead of their table rows.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Commands print their results through a CommandOutput on the ctl link.
In json mode lists print as arrays of objects, other results as an
object, commands without a result print {} and failures print
{ error: ClassName, message } with exit code 1. log follow and
debug dump-ws print JSON lines.
Human output now goes through the shared asTable printer in every
command, results that were logged to stderr (role create, save and mod
upload/download) print to stdout, and config edit failures are logged
instead of printed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
hasFactorioHeadless(version, platform, arch) replaces the host's
hasArm64Headless, and factorioHeadlessUrl takes the platform too and
throws when Factorio has no headless build for it, which for now is
every platform except Linux. headlessUrl is marked deprecated.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Factorio publishes a linux-arm64 headless build from 2.1.18. On ARM64
Linux the host now downloads that build, refuses versions older than
2.1.18 that are not already installed, and finds the binary in bin/arm64
or bin/x64, whichever is present.
The host builds the download URL from the version instead of using
headlessUrl from the controller, so the version list on the wire stays
the same.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The middle version adds two jobs without catching anything the top and
bottom of the range would miss. The host whitelist watcher now uses
Set.difference, which every supported Node.js has.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The reporter now handles all three modes: verbose prints everything,
normal prints output from failing tests and hooks, silent prints only
the results. The integration spawn helper and setup_logging no longer
filter output themselves.
npm install output in plugin install now goes through the logger
instead of inherited stdio, so it follows the log level and is
captured in tests like the rest.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A spec reporter subclass buffers console output, including winston's
ConsoleTransport and the integration child process lines, and prints it
above the failure line when a test or hook fails. VERBOSE_TEST streams
everything as before, and CI sets it on debug re-runs.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The controller polled system info only on the system metrics interval, so
restart required and machine details stayed empty for up to one interval
after the controller started or a host connected. Collect once right away
and then on every interval. Resumed sessions are skipped since the host
process kept running.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The check runs the same parser as scripts/pr_to_changelog.mts, so a
description that passes CI is one the release script accepts. Checks
that need the GitHub API (issue references existing, pointing at this
pull request) still only run at release time.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A new cluster gets the default mod packs but controller.default_mod_pack_id
stays null, so the first Create save or Start fails with "Default mod pack
not set on controller". When seeding the packs, also point the default at
the newest Base Game pack, unless an admin already set one. Clusters that
already have mod packs are left alone. The config is written with the
mod packs on the next autosave or shutdown.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Fix the "Permamently" typo in the delete instance confirm.
The Search Mod Portal dialog now opens on the default mod pack's
Factorio version, or the newest known version when there is no default
pack. It used to always start on 2.0. A version the user picks still
sticks while the page is open.
The mod portal cache key used request.hide_deprecated directly, and the
web interface never sends it, so the controller logged "2.0-undefined".
A missing value now counts as false, the same default
fetchAllModsFromPortal already uses, so "2.1" and "2.1-false" share a
cache entry.
Closes#1209
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
user list, user show and role list passed UserDetails and Role objects
straight to as-table, whose default String() turns the roleIds,
instances and permissions Sets into "[object Set]". Move the as-table
setup into command_ops.ts with a cell printer that joins Sets with
", ", and use it for the user and role commands.
The integration tests for role list and user list now capture the
output and check it.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
run-controller.sh and run-host.sh ran `exit $?` after the `[[ ]]` test,
so they exited with the test's status (0) even when the process exited
with 8 to ask not to be restarted. Save the status before testing it.
The .cmd scripts now pass 8 to `exit /b` explicitly instead of relying on
a bare `exit /b` to carry the errorlevel through.
Closes#1208.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Replace controller.transfer_idle_timeout with
controller.transfer_min_progress, the amount a request has to move
every 30 seconds, so a request trickled in is closed too. The check
now runs for every route.
Both ends of a proxy stream are judged on what the receiver has taken,
so a sender held back by a slow receiver is not closed.
Keep the limit on receiving headers, which turning off the request
timeout also turned off.
* Share one connect and close listener between subscribers
Every EventSubscriber added its own connect and close listener to the
connector, and Link caps the connector at 20 listeners per event. The
web Control and App use 13 close listeners, so the 8th plugin
subscriber made the browser log MaxListenersExceededWarning on every
page load. Subscribers on a connector now share one listener for each
event, which leaves the cap in place for everything else.
* Keep the connector subscribers as a static on EventSubscriber
Counts ready, resume, drop and session timeout per connection type
(host or control), plus resume attempts rejected for an unknown or
expired session. Lets a dashboard show hosts or users reconnecting.
Fixes#1192
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Guard the export, save, mod and stream routes with one middleware that
closes the connection of an upload answered before its body was read,
and of a transfer that has made no progress for the new
controller.transfer_idle_timeout.
The save and mod uploads share one handler that responds on the first
error instead of reading the rest of the upload, and uploads cut short
now fail the transfer instead of leaving it hanging.
Node's 5 minute limit on receiving a request is turned off so large
uploads over slow connections are not cut off.
* Unpatch saves started with save patching disabled
Turning factorio.enable_save_patching off did nothing to a save that
was patched before. Its control.lua still loaded every module, so the
clusterio_api interface, player_sync's join handling and the other
module event handlers kept running with no plugin on the host side.
When patching is disabled the instance now restores the original
control.lua that patching kept as scenario.lua and removes the module
files, locale files included, as listed in clusterio.json. The patch
info stays with an empty module list so the patch number keeps
counting. Otherwise patching the save again would reuse the number
stored in the game and on_server_startup would not be raised. Data
the modules put in storage is left alone.
PatchInfo.fromSave dropped the version read from the save, so the
check against newer patch versions never fired. It now keeps it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Remove scenario.lua when unpatching a save
Unpatching moves scenario.lua back to control.lua instead of copying it, so the save only keeps clusterio.json for the patch number. Patching such a save again copies control.lua back to scenario.lua.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
The mod pack page only looked up mod-setting-name.<name>, so settings
with a localised_name showed the internal name, and rich text tags in
the locale showed up as raw text.
Resolve localised_name and localised_description from the exported
settings prototypes against the exported locale, falling back to the
mod-setting-name/mod-setting-description keys and then the internal
name. The resolver handles parameters, the "" and "?" keys and
__ITEM__/__ENTITY__/__TILE__/__FLUID__ references. Rich text
formatting tags are removed and prototype icons are replaced with
their name.
Fixes#768
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Unpatching moves scenario.lua back to control.lua instead of copying it, so the save only keeps clusterio.json for the patch number. Patching such a save again copies control.lua back to scenario.lua.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Matches verifyUserToken returning the user. HostConnection._saveInfo is
renamed saveRecord to match User.saveRecord.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
controller.hosts is now a HostManager wrapping the hosts datastore, the
same way controller.users wraps the users datastore. It owns creating
hosts (moved from HostPairingManager), revoking them (moved from
ControlConnection) and signing and verifying host tokens (moved from
Controller, generateHostToken is renamed signHostToken to match
signUserToken).
UserManager gains verifyUserToken, replacing the copies of the user
token check in WsServer and routes. The WsServer copy accepted a token
without iat when the user had no tokenValidAfter; the shared check
always requires iat, which jsonwebtoken adds by default.
Follows Cooldude2606's comment on #1161.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>