Merge pull request #678 from Cooldude2606/fix/host-user-sync

Fix host being unable to sync user state to instances after controller connection
This commit is contained in:
Cooldude2606 authored and GitHub committed 2024-10-29 16:28:37 +00:00
commit 9e03c743e9
3 files changed
+15 -4

No files matched your search

+1
View File
@@ -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
+3 -3
View File
@@ -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(
+11 -1
View File
@@ -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) {