mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-20 15:43:13 +09:00
Address review of host pairing
Revoking a host now unassigns its instances instead of being refused while it has any, and removes its system metrics. Approving and revoking no longer force a save. Hosts are saved by autosave and on exit like everything else, which also removes the approving state from pairing requests. The approval code and link are logged as warnings so they show up in the systemd service, which only prints warnings and above. The pairing limits are now the controller.host_pairing_timeout and controller.host_pairing_max_pending config values, 0 removes the limit. Subscribers take an optional permitted function, used for the pairing requests instead of overrides in a subclass.
This commit is contained in:
29 files changed
+356
-418
No files matched your search
@@ -20,7 +20,6 @@ The installer runs without prompts when all the questions for the mode are answe
|
||||
## Modes
|
||||
|
||||
- `standalone`: controller and host on this computer. The host is approved like any other host the first time it starts.
|
||||
The host is added to the controller directly and does not need to be approved.
|
||||
- `controller`: controller only.
|
||||
- `host`: host only, joins the cluster of an existing controller, see [Setting up a host](#setting-up-a-host).
|
||||
- `ctl`: the clusterioctl command line interface only.
|
||||
@@ -33,21 +32,24 @@ The installer runs without prompts when all the questions for the mode are answe
|
||||
| Option | Modes | Description |
|
||||
| --- | --- | --- |
|
||||
| `--mode <mode>` | all | Operating mode to install. |
|
||||
| `--admin <name>` | standalone, controller | Name of the admin account to create. |
|
||||
| `--http-port <port>` | standalone, controller | Port the controller web interface listens on, defaults to 8080. |
|
||||
| `--admin <name>` | controller | Name of the admin account to create. |
|
||||
| `--http-port <port>` | controller | Port the controller web interface listens on, defaults to 8080. |
|
||||
| `--host-name <name>` | host | Name to request for the host, defaults to the name of the computer. |
|
||||
| `--controller-url <url>` | host, ctl | URL of the controller, the same as for its web interface. |
|
||||
| `--controller-token <token>` | ctl | Authentication token saved for clusterioctl. |
|
||||
| `--public-address <address>` | standalone, host | DNS name or IP address players connect to this computer with. |
|
||||
| `--factorio-dir <path>` | standalone, host | Path to the Factorio installation. |
|
||||
| `--self-signed-cert <path>` | standalone, host | Certificate to trust for a controller using a self-signed certificate. It is added to the run scripts. |
|
||||
| `--remote-npm`, `--no-remote-npm` | standalone, controller, host | Allow or deny remote updates, plugin updates and plugin installs from the web interface. |
|
||||
| `--public-address <address>` | host | DNS name or IP address players connect to this computer with. |
|
||||
| `--factorio-dir <path>` | host | Path to the Factorio installation. |
|
||||
| `--self-signed-cert <path>` | host | Certificate to trust for a controller using a self-signed certificate. It is added to the run scripts. |
|
||||
| `--remote-npm`, `--no-remote-npm` | controller, host | Allow or deny remote updates, plugin updates and plugin installs from the web interface. |
|
||||
| `--plugins <package...>` | all | Plugins to install, pass `--plugins` without packages to install none. |
|
||||
| `--plugin-template <template...>`, `--plugin-name <name>` | plugin-template | Templates to use and name of the new plugin. |
|
||||
| `--log-level <level>` | all | Log level to print, defaults to info. |
|
||||
| `--allow-install-as-root` | all | Linux only, allow installing as root (not recommended). |
|
||||
| `--migrate-rename` | | Migrate an installation from before the slave/master rename. |
|
||||
|
||||
Options for the `controller` and `host` modes also work in the `standalone` mode, except for `--controller-url` as the host connects to the controller on the same computer.
|
||||
`--host-name` defaults to `local` in the `standalone` mode.
|
||||
|
||||
|
||||
## Setting up a host
|
||||
|
||||
@@ -84,8 +86,8 @@ The installer adds it to the run scripts.
|
||||
When a host is revoked in the web interface or with `npx clusterioctl host revoke <host>` its token stops working and a running host shuts down.
|
||||
Starting it again requests to join the cluster again, and the host gets a new id once approved.
|
||||
|
||||
To move a host to another controller, change `host.controller_url` with `npx clusteriohost config set host.controller_url <url>` and set `host.controller_token` back to `enter token here`.
|
||||
The host then requests to join that controller the next time it starts.
|
||||
To move a host to another controller, change `host.controller_url` with `npx clusteriohost config set host.controller_url <url>`.
|
||||
The new controller does not accept the token of the host, so the host requests to join it the next time it starts.
|
||||
|
||||
|
||||
## Docker
|
||||
|
||||
+12
-11
@@ -161,6 +161,9 @@ async function execCtl(args) {
|
||||
return await execFile(path.join("node_modules", ".bin", `clusterioctl${scriptExt}`), args);
|
||||
}
|
||||
|
||||
// Same characters as the controller refuses in host names.
|
||||
const hostNameControlCharacters = /[\p{Cc}\u202a-\u202e\u2066-\u2069]/u;
|
||||
|
||||
function validateHostName(input) {
|
||||
if (!input || !input.trim()) {
|
||||
return "Host name may not be empty";
|
||||
@@ -174,9 +177,6 @@ function validateHostName(input) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Same characters as the controller refuses in host names.
|
||||
const hostNameControlCharacters = /[\p{Cc}\u202a-\u202e\u2066-\u2069]/u;
|
||||
|
||||
function validateControllerUrl(input) {
|
||||
let url;
|
||||
try {
|
||||
@@ -594,6 +594,14 @@ async function inquirerMissingArgs(args) {
|
||||
], answers);
|
||||
}
|
||||
|
||||
if (answers.mode === "standalone") {
|
||||
answers.hostName = args.hostName ?? "local";
|
||||
const result = validateHostName(answers.hostName);
|
||||
if (result !== true) {
|
||||
throw new InstallError(result);
|
||||
}
|
||||
}
|
||||
|
||||
if (answers.mode === "host") {
|
||||
if (args.hostName) { answers.hostName = args.hostName; }
|
||||
if (args.controllerUrl) { answers.controllerUrl = args.controllerUrl; }
|
||||
@@ -783,7 +791,7 @@ async function main() {
|
||||
nargs: 1, describe: "HTTP port to listen on [standalone/controller]", type: "number",
|
||||
})
|
||||
.option("host-name", {
|
||||
nargs: 1, describe: "Host name [host]", type: "string",
|
||||
nargs: 1, describe: "Host name [standalone/host]", type: "string",
|
||||
})
|
||||
.option("controller-url", {
|
||||
nargs: 1, describe: "Controller URL [host/ctl]", type: "string",
|
||||
@@ -869,7 +877,6 @@ async function main() {
|
||||
|
||||
if (answers.mode === "standalone") {
|
||||
// Default to localhost on correct port for host in standalone mode
|
||||
answers.hostName = "local";
|
||||
answers.controllerUrl = `http://localhost:${answers.httpPort}/`;
|
||||
}
|
||||
|
||||
@@ -895,12 +902,6 @@ async function main() {
|
||||
|
||||
/* eslint-disable no-console */
|
||||
console.log(`Successfully installed ${answers.mode}`);
|
||||
if (["standalone", "host"].includes(answers.mode)) {
|
||||
console.log(
|
||||
`Start the host with run-host${process.platform === "win32" ? ".cmd" : ".sh"}, then approve it on the ` +
|
||||
`Hosts page of ${answers.controllerUrl}`
|
||||
);
|
||||
}
|
||||
if (adminToken) {
|
||||
console.log(`Admin authentication token: ${adminToken}`);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user