Send raw payloads over UDP and emit them as udp events

Review feedback from Cooldude2606: UDP is most useful for arbitrary
blobs, so send_udp now takes any string and the packet is just
"channel?payload".  Plugins get it as a udp-<channel> event with the
payload as a Buffer, or through handleUdp which logs handler errors
like handle does for ipc events.

The host socket is now opened when the RCON client is started and
closed where the RCON client is ended, matching how the RCON client is
handled, instead of being bound in start() and closed by _resetState.

The integration round trip moved to the FactorioServer tests, where it
sends a packet each way through a real server without the module.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
bbassieandClaude Fable 5.1 committed 2026-10-15 16:38:34 +00:00
1 parent 4b0238b64b
commit 7a64706c82
8 files changed
+222 -134

No files matched your search

-18
View File
@@ -158,24 +158,6 @@ describe("Clusterio Instance", function() {
const userLeave = await getUser("JoiningPlayer");
assert(!userLeave.instances.has(instId), "Player is not shown as offline");
});
it("should respond to a player join and leave event sent over UDP", async function() {
// The host port is passed to the module by updateInstanceData on startup
if (!hasLuaUdp() || !scriptCommandsEnabled) {
this.skip();
}
await sendRcon(instId,
`/sc ${requireApi} api.send_udp("player_event",` +
"{ type='join', name='UdpPlayer' })"
);
const userJoin = await getUser("UdpPlayer");
assert(userJoin.instances.has(instId), "Player is not shown as online");
await sendRcon(instId,
`/sc ${requireApi} api.send_udp("player_event",` +
"{ type='leave', name='UdpPlayer', reason='quit' })"
);
const userLeave = await getUser("UdpPlayer");
assert(!userLeave.instances.has(instId), "Player is not shown as offline");
});
}
it("should respond to a player ban and unban event", async function() {
await execCtl(`${instSetConfig} factorio.sync_banlist bidirectional`);