Add web_root option to the master server and use it create URLs for
resources hosted by it. This permits hosting the master server web
interface behind reverse proxy under a dedicated path.
Replace socket.io with plain WebSocket using the ws library as it
doesn't really provide any useful tools over plain WebSocket when it
comes to implementing reliable communication that works across
reconnects. The widespread browser support for WebSocket also means
it has little value to add for the web interface over WebSocket.
Catch errors thrown when constructing or initializing master pluigns and
wrap them in PluginError to ensure that they are properly reported as
plugin errors.
Replace current configuration mess with a trimmed down version of the
original vision of #200. Configs are collection of config groups that
have fields that can be set. These groups allow organizing the fields
as well as opertunity for plugins to add their own groups. By default
plugins have an auto generated group with the enabled field.
Close active connections and http servers during master shutdown and let
node exit on its own. If this fails with an error set output streams to
blocking and report it then shutdown with process.exit.
Also add double SIGINT handling to immediately shutdown.
Change Instance class to be a subclass of Link and refactor the
communication to and establisment of instances to use a virtual
connection between the slave and the instance. This is simplifies the
implementation of plugin communication for instances.
Replace InstanceRequest with a forwardTo option to Request which does
the task of forwarding in a much cleaner way.
Remove connection and client subclasses of Link and put the connection
logic into a "connector" class. The connector deals with sending
and receiving messages, handling the connection and reconnection of lost
connections and giving sequence numbers to messages.
This move the logic of the actual connection away from the link
sub-classes, which in turn means the connection should be a lot easier
to mock in tests.
Merge the events and requests categories in lib/link into messages and
use the class name of the message to determine which handler to call.
Also swaps the order of the arguments for forwardInstanceRequest to be
consistent with the rest of the lib/link code and fixes up the docs for
requests and events.
Add instance output event that is forwarded by the master server to
control connections that are subscribing to them. Add code subscribing
to the relevant instance output when dealing with instances in
clusterctl.
Rework client.js to support running multiple instances at once and be
managed remotely and implement the neccessary communication
infrastructure for this.
Due to circular dependencies on the implementation of this the master
branch is significantly broken after this.
The default limit of 100kb to JSON payloads of bodyParser can be
exceeded when running modded games with researchSync. Increase the
limit to 10mb as a bandaid to fix this issue.
This is a port of 25eb5e5.
Move item database, tests, endpoint definitions for /api/place,
/api/remove, /api/inventory, /api/inventoryAsObject, and the web
interface view for the storage page into the clusterioMod plugin.
Remove the .js suffix from help texts of node invocations as well as
actual invocations as this is not necessary. Removing it opens up the
possibility of restructuring the code into a directory with the same
name.
Move getFactorioLocale to the new lib/factorio namespace and refactor it
to use async functions instead of callbacks. Split tests into
integration with factorio and testing of the function itself.
Also removes the cacheing from the function itself as this breaks the
isolated testing of it.
Move the ejs templates to the default Express.js views/ folder and
change their extension to .ejs. Reconfigure Express.js to look for
templates in the views folders as well as the plugins folder. This
enables plugins to render templates using paths of following format
"pluginName/path/to/page-or-view".
After 651b09b the instance ID would be treated differently depending on
wheteher it was a string or a number in the master server. This caused
researchSync to break as it would send the ID as a number while the
master server would have it stored as a string.
Fix by coercing instanceID to a string in the master HTTP API.
Authenticate connections made to the socket.io server via a token query
parameter that's validated in a similar manner to the x-access-token for
HTTP requests.
This is a port of 0c45e57.
Change the ugly global slaves object to be a member of the db object and
implement the items database as a separate integrety verifying class in
lib/database.
Add missing attach calls to the master socket.io object that was
accidentally removed by the refactoring in a3fc1dd. Unfortunately I've
been unable to determine if socket.io actually supports listening on
multiple servers at the same time, this needs further investigation.
Add StartupError that differentiates unhandled errors from errors with
known causes and use it to only print the "please report" banner when an
unhandled error occurs.
Also makes the error reporting more visible in the console.
Remove remoteMap specific code left behind after the removal of the
remoteMap plugin in 6415784. The plugin interface should be versatile
enough to allow all of this code to reside inside the plugin itself.
Remove code pushing metrics to a hardcoded Prometheus pushgateway that
is no longer in operation. There's no point supporting the use of a
pushgateway as there's already a full client implemented and since the
master server is not ephemeral or batch job it shouldn't be using a
pushgateway in the first place.