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 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( 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) {