mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-11 23:04:52 +09:00
Split up the action of registring an event or request data class to be decoded by the Link class and the action of registring a handler for those requests and events. This moves the validation work from Link instantiation time to startup initialisation which makes logic errors fail on startup instead of failing instantiation of the link when a connection attempt is made. Additionally implement a partial validation logic for messages received using the newly refactored message registration. This unfortunately ended up merged with the registration refactor.
39 lines
1.0 KiB
JavaScript
39 lines
1.0 KiB
JavaScript
"use strict";
|
|
let { libConfig } = require("@clusterio/lib");
|
|
let messages = require("./messages");
|
|
|
|
|
|
class ControllerConfigGroup extends libConfig.PluginConfigGroup {}
|
|
ControllerConfigGroup.defaultAccess = ["controller", "host", "control"];
|
|
ControllerConfigGroup.groupName = "player_auth";
|
|
ControllerConfigGroup.define({
|
|
name: "code_length",
|
|
title: "Code Length",
|
|
description: "Length in characters of the generated codes.",
|
|
type: "number",
|
|
initial_value: 6,
|
|
});
|
|
ControllerConfigGroup.define({
|
|
name: "code_timeout",
|
|
title: "Code Timeout",
|
|
description: "Time in seconds for the generated codes to stay valid.",
|
|
type: "number",
|
|
initial_value: 120,
|
|
});
|
|
ControllerConfigGroup.finalize();
|
|
|
|
module.exports = {
|
|
name: "player_auth",
|
|
title: "Player Auth",
|
|
description: "Provides authentication to the cluster via logging into a Factorio server.",
|
|
controllerEntrypoint: "controller",
|
|
instanceEntrypoint: "instance",
|
|
webEntrypoint: "./web",
|
|
ControllerConfigGroup,
|
|
|
|
messages: [
|
|
messages.FetchPlayerCodeRequest,
|
|
messages.SetVerifyCodeRequest,
|
|
],
|
|
};
|