From ef6861a566406d3569b4f0f631800d86464f84a6 Mon Sep 17 00:00:00 2001 From: Cooldude2606 <25043174+Cooldude2606@users.noreply.github.com> Date: Tue, 29 Oct 2024 00:59:17 +0000 Subject: [PATCH 1/3] Fixed host tests not checking the message was valid --- test/host.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/test/host.js b/test/host.js index 75244b9e..f5189d0d 100644 --- a/test/host.js +++ b/test/host.js @@ -4,6 +4,7 @@ const path = require("path"); const lib = require("@clusterio/lib"); const Host = require("@clusterio/host/dist/node/src/Host").default; +const Instance = require("@clusterio/host/dist/node/src/Instance").default; const { _discoverInstances } = require("@clusterio/host/dist/node/src/Host"); describe("Host testing", function() { @@ -28,7 +29,15 @@ describe("Host testing", function() { describe("class Host", function() { describe(".handleSyncUserListsEvent()", function() { - let mockHost; + const hostAddress = lib.Address.fromShorthand({ hostId: 1 }); + const instanceAddress = lib.Address.fromShorthand({ instanceId: 1 }); + let mockHost, hostConnector, instanceConnector; + before(function() { + [hostConnector, instanceConnector] = lib.VirtualConnector.makePair(hostAddress, instanceAddress); + instanceConnector.on("message", function(message) { + Instance.prototype._validateMessage(message); + }); + }); beforeEach(function() { mockHost = { adminlist: new Set(), @@ -37,6 +46,7 @@ describe("Host testing", function() { broadcasts: [], broadcastEventToInstance(event) { this.broadcasts.push(event); + hostConnector.sendEvent(event, instanceAddress); }, handleSyncUserListsEvent: Host.prototype.handleSyncUserListsEvent, syncLists(adminlist, banlist, whitelist) { From 198e58c76275a907bd09c4355e9841619d86cac6 Mon Sep 17 00:00:00 2001 From: Cooldude2606 <25043174+Cooldude2606@users.noreply.github.com> Date: Tue, 29 Oct 2024 01:03:08 +0000 Subject: [PATCH 2/3] Allow host as src for user sync events --- packages/lib/src/data/messages_instance.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/lib/src/data/messages_instance.ts b/packages/lib/src/data/messages_instance.ts index 13d80966..26ec89a5 100644 --- a/packages/lib/src/data/messages_instance.ts +++ b/packages/lib/src/data/messages_instance.ts @@ -864,7 +864,7 @@ export class InstanceDetailsChangedEvent { export class InstanceBanlistUpdateEvent { declare ["constructor"]: typeof InstanceBanlistUpdateEvent; static type = "event" as const; - static src = "controller" as const; + static src = ["controller", "host"] as const; static dst = "instance" as const; constructor( @@ -887,7 +887,7 @@ export class InstanceBanlistUpdateEvent { export class InstanceAdminlistUpdateEvent { declare ["constructor"]: typeof InstanceAdminlistUpdateEvent; static type = "event" as const; - static src = "controller" as const; + static src = ["controller", "host"] as const; static dst = "instance" as const; constructor( @@ -908,7 +908,7 @@ export class InstanceAdminlistUpdateEvent { export class InstanceWhitelistUpdateEvent { declare ["constructor"]: typeof InstanceWhitelistUpdateEvent; static type = "event" as const; - static src = "controller" as const; + static src = ["controller", "host"] as const; static dst = "instance" as const; constructor( From dba2dd246eef2078913266c985ffae14fa0b05d9 Mon Sep 17 00:00:00 2001 From: Cooldude2606 <25043174+Cooldude2606@users.noreply.github.com> Date: Tue, 29 Oct 2024 01:15:58 +0000 Subject: [PATCH 3/3] Update change log --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a37fc6b..9bad60a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -64,6 +64,7 @@ Many thanks to the following for contributing to this release: - Added `host.factorio_username` and `host.factorio_token` config to set Factorio credentials used on a given host. - Fixed 2.0 version extraction from linux headless downloaded during installation of clusterio. [#671](https://github.com/clusterio/clusterio/pull/671) - Updated display name and description of `controller.external_address` to avoid confusion. [#674](https://github.com/clusterio/clusterio/pull/674) +- Fixed host user sync to instances after reconnecting to the controller. [#678](https://github.com/clusterio/clusterio/pull/678) ### Breaking Changes