mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-21 16:13:12 +09:00
Make the player proxy follow the Factorio handshake and route by version
The proxy now parses the full message header, so confirms and fragmented ConnectionRequestReplyConfirm messages (which carry the mod list) are forwarded intact, with the server request id patched into the first fragment. It resends the connection request until the instance answers, starts over when a client reconnects from the same socket (as Factorio does after LuaPlayer::connect_to_server), answers pings from the server browser and tells clients the same 508 byte max packet size Factorio servers use. Routing is decided by the new playerProxyRoute controller hook, which is given the name and version of the player, then a dedicated port set with instance.player_proxy_port, the instance the player was last on (taken from the user's instance stats instead of a separate routing store), and controller.player_proxy_default_instance_id. The proxy is now off by default, as port 34197 is in the default host.factorio_port_range. Leftovers of the per-instance proxy on hosts are removed.
This commit is contained in:
13 files changed
+1334
-602
No files matched your search
@@ -247,15 +247,19 @@ export class ControllerConfig extends classes.Config<ControllerConfigFields> {
|
||||
},
|
||||
"controller.player_proxy_port": {
|
||||
title: "Player Proxy Port",
|
||||
description: "UDP port to accept player connections for the controller proxy, set to null to disable.",
|
||||
description:
|
||||
"UDP port the controller accepts Factorio player connections on and forwards them to an " +
|
||||
"instance, starting it if needed. Disabled when null.",
|
||||
restartRequired: true,
|
||||
type: "number",
|
||||
optional: true,
|
||||
initialValue: 34197,
|
||||
validator: validators.optional(validators.greaterThanZero),
|
||||
},
|
||||
"controller.player_proxy_default_instance_id": {
|
||||
title: "Player Proxy Default Instance",
|
||||
description: "Instance ID to route players to when no routing history is available.",
|
||||
description:
|
||||
"Instance ID to send players connecting through the player proxy to when no plugin picks one " +
|
||||
"and they have not been on any instance before.",
|
||||
type: "number",
|
||||
optional: true,
|
||||
},
|
||||
@@ -487,6 +491,7 @@ export interface InstanceConfigFields {
|
||||
"instance.id": number;
|
||||
"instance.assigned_host": number | null;
|
||||
"instance.auto_start": boolean;
|
||||
"instance.player_proxy_port": number | null;
|
||||
"instance.exclude_from_start_all": boolean;
|
||||
[key: `${string}.load_plugin`]: boolean;
|
||||
[key: `${string}.version`]: string;
|
||||
@@ -561,6 +566,14 @@ export class InstanceConfig extends classes.Config<InstanceConfigFields> {
|
||||
type: "boolean",
|
||||
initialValue: false,
|
||||
},
|
||||
"instance.player_proxy_port": {
|
||||
description:
|
||||
"Extra UDP port on the controller's player proxy that sends players straight to this instance, " +
|
||||
"starting it if needed. Requires controller.player_proxy_port to be set.",
|
||||
type: "number",
|
||||
optional: true,
|
||||
validator: validators.optional(validators.greaterThanZero),
|
||||
},
|
||||
"instance.exclude_from_start_all": {
|
||||
description: "Exclude this instance from the 'Start all' button operation",
|
||||
type: "boolean",
|
||||
|
||||
@@ -935,30 +935,3 @@ export class InstancePlayerUpdateEvent {
|
||||
return new this(json.type, json.name, PlayerStats.fromJSON(json.stats), json.reason);
|
||||
}
|
||||
}
|
||||
|
||||
export class InstancePlayerRouteUpdateEvent {
|
||||
declare ["constructor"]: typeof InstancePlayerRouteUpdateEvent;
|
||||
static type = "event" as const;
|
||||
static src = "instance" as const;
|
||||
static dst = "controller" as const;
|
||||
|
||||
constructor(
|
||||
public name: string,
|
||||
public instanceId: number,
|
||||
public hostId: number,
|
||||
public gamePort: number,
|
||||
public timestampMs: number,
|
||||
) { }
|
||||
|
||||
static jsonSchema = Type.Object({
|
||||
"name": Type.String(),
|
||||
"instanceId": Type.Integer(),
|
||||
"hostId": Type.Integer(),
|
||||
"gamePort": Type.Integer(),
|
||||
"timestampMs": Type.Number(),
|
||||
});
|
||||
|
||||
static fromJSON(json: Static<typeof this.jsonSchema>) {
|
||||
return new this(json.name, json.instanceId, json.hostId, json.gamePort, json.timestampMs);
|
||||
}
|
||||
}
|
||||
@@ -102,7 +102,6 @@ export const dataClasses: (RequestClass<unknown, unknown> | EventClass<unknown>)
|
||||
instance.InstanceAdminlistUpdateEvent,
|
||||
instance.InstanceWhitelistUpdateEvent,
|
||||
instance.InstancePlayerUpdateEvent,
|
||||
instance.InstancePlayerRouteUpdateEvent,
|
||||
|
||||
mod.ModPackGetRequest,
|
||||
mod.ModPackGetDefaultRequest,
|
||||
|
||||
Reference in new issue
Block a user