Wrapper around Source Dedicated Server UDP log streams for JavaScript. Supports most major runtimes.
Your server must have logs enabled. To do so, run log on in your server console or through RCON. In order to receive messages, you must also add a log address using logaddress_add command to add the URL or IP of your server's receiver. To delete a destination, use logaddress_del.
You can always list existing addresses using logaddress_list.
Install using JSR:
npx jsr add @c4321/srcds-log-receiverSee https://jsr.io/@c43721/srcds-log-receiver for more details.
You can define a receiver and listen to messages published to the UDP stream.
import { LogReceiver } from "@c43721/srcds-log-receiver";
using receiver = new LogReceiver({
address: "0.0.0.0",
port: 9871,
});
await receiver.start();
console.log("Receiver started on port 9871");
await for (const message of reciever) {
console.log(message);
}In order to make this as extendable as possible, there is no built in security. However, you can mitigate this by using sv_logsecret and checking for the password in the packet. Otherwise, you can use the Socket information to determine what IPs sent the message.
For more examples, see documentation or the examples folder.
If there's a feature or bug, please raise a Github issue first alongside your PR (if you're kind enough to make a PR.)
Distributed under the MIT License. See LICENSE for more information.