mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-20 07:43:12 +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
+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