mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-18 23:33:12 +09:00
Make showing the connect address a config option
This commit is contained in:
4 files changed
+19
-7
No files matched your search
@@ -66,10 +66,11 @@ export class ControllerPlugin extends BaseControllerPlugin {
|
|||||||
: host.publicAddress;
|
: host.publicAddress;
|
||||||
|
|
||||||
const settings = instance.config.get("factorio.settings");
|
const settings = instance.config.get("factorio.settings");
|
||||||
|
const includeAddress = this.controller.config.get("player_auth.show_connect_address");
|
||||||
servers.push({
|
servers.push({
|
||||||
name: settings["name"] as string || "unnamed server",
|
name: settings["name"] as string || "unnamed server",
|
||||||
factorioVersion: instance.factorioVersion,
|
factorioVersion: instance.factorioVersion,
|
||||||
address,
|
address: includeAddress ? address : undefined,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ declare module "@clusterio/lib" {
|
|||||||
export interface ControllerConfigFields {
|
export interface ControllerConfigFields {
|
||||||
"player_auth.code_length": number;
|
"player_auth.code_length": number;
|
||||||
"player_auth.code_timeout": number;
|
"player_auth.code_timeout": number;
|
||||||
|
"player_auth.show_connect_address": boolean;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,6 +32,12 @@ export const plugin: lib.PluginDeclaration = {
|
|||||||
type: "number",
|
type: "number",
|
||||||
initialValue: 120,
|
initialValue: 120,
|
||||||
},
|
},
|
||||||
|
"player_auth.show_connect_address": {
|
||||||
|
title: "Show Connect Address",
|
||||||
|
description: "Show server connect addresses to unauthenticated users.",
|
||||||
|
type: "boolean",
|
||||||
|
initialValue: false,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
features: [
|
features: [
|
||||||
|
|||||||
@@ -5,21 +5,25 @@ export class PlayerAuthServer {
|
|||||||
|
|
||||||
static jsonSchema = Type.Object({
|
static jsonSchema = Type.Object({
|
||||||
name: Type.String(),
|
name: Type.String(),
|
||||||
address: Type.String(),
|
address: Type.Optional(Type.String()),
|
||||||
factorioVersion: Type.Optional(Type.String()),
|
factorioVersion: Type.Optional(Type.String()),
|
||||||
});
|
});
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
public name: string,
|
public name: string,
|
||||||
public address: string,
|
public address?: string,
|
||||||
public factorioVersion?: string,
|
public factorioVersion?: string,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
toJSON(): Static<typeof PlayerAuthServer.jsonSchema> {
|
toJSON(): Static<typeof PlayerAuthServer.jsonSchema> {
|
||||||
if (this.factorioVersion === undefined) {
|
const json = { name: this.name } as Static<typeof PlayerAuthServer.jsonSchema>;
|
||||||
return { name: this.name, address: this.address };
|
if (this.address !== undefined) {
|
||||||
|
json.address = this.address;
|
||||||
}
|
}
|
||||||
return { name: this.name, address: this.address, factorioVersion: this.factorioVersion };
|
if (this.factorioVersion !== undefined) {
|
||||||
|
json.factorioVersion = this.address;
|
||||||
|
}
|
||||||
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
static fromJSON(json: Static<typeof PlayerAuthServer.jsonSchema>) {
|
static fromJSON(json: Static<typeof PlayerAuthServer.jsonSchema>) {
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ describe("player_auth", function() {
|
|||||||
it("should be round trip json serialisable", function() {
|
it("should be round trip json serialisable", function() {
|
||||||
testRoundTripJsonSerialisable(PlayerAuthServer, testMatrix(
|
testRoundTripJsonSerialisable(PlayerAuthServer, testMatrix(
|
||||||
["server1", "server2"], // name
|
["server1", "server2"], // name
|
||||||
["127.0.0.1", "10.0.0.1:1234"], // address
|
[undefined, "127.0.0.1", "10.0.0.1:1234"], // address
|
||||||
[undefined, "1.1.0", "2.0.0"], // version
|
[undefined, "1.1.0", "2.0.0"], // version
|
||||||
));
|
));
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in new issue
Block a user