npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

srcds-log-receiver

v1.0.2

Published

A simple too to receive srcds logs

Downloads

19

Readme

Srcds Log Receiver

A library to receive logs directly from a Source dedicated server (srcds) via its UDP log transport (logaddress_add). As these logs are sent live during the game, this allows you to build interactive real time systems that react to in-game events.

Also included is a simple app that saves all received logs to disk. This means that no matter what happens to your game server, the logs will always be saved. See further below for usage information.

Library usage

npm install --save srcds-log-receiver

Javascript example, but Typecript is also supported:

var logReceiver = require("srcds-log-receiver");
var options = {
	port: 9871  // this is the default
};

var receiver = new logReceiver.LogReceiver();
receiver.on("data", function(data) {
	if (data.isValid) {
		console.log("Received at " + data.receivedAt.format() + " a log of type " + data.packetType);
		console.log("The message is: " + data.message);
	}
});
receiver.on("invalid", function(invalidMessage) {
	console.log("Got some completely unparseable gargbase: " + invalidMessage);
})

The options object has the following structure:

interface ILogListenerOptions {
	port?: number; // Port number for deamon to listen on - default 9871
	address?: string; // IP address for deamon to listen on - default 0.0.0.0
	requirePassword?: boolean; // Reject messages from servers with no log password - default false
	defaultPassword?: string; // Catch-all password that any unspecified server may have
	definedSources?: ILogSourceDetails[]; // List of know servers/passwords - default empty
}

// Defines a server that you know will send log messages 
interface ILogSourceDetails {
	port?: number; // IP address of srcds server
	address?: string; // port of srcds server (same as game port)
	password?: string; // If blank/empty, no password. If set, require this password. 
}

Log secrets

When the log payloads are sent, they include a type field in their header. This will always be either Log with password or Log without password.

If the type is without password, then the log will be accepted if either the server exists as a defined source with no password, or, the requirePassword option is false.

If the type is with password, then the log will only be accepted if the server exists as a defined source with a matching password, or the provided password matches the default password, irrespective of what requirePassword is set to.

The secret is defined in your srcds instance by setting the cvar sv_logsecret. If it does not work, try a numeric password.

Save to disk app usage:

For the log saver app, build with:

npm install 
npm install -g typings
typings install
tsc

And run with:

node saveToDisk.js

On your SRCDS server:

mp_logdetail 3
sv_logsecret 12345
logaddress_add ipaddress-or-hostname:9871
log on

And hey presto, you're receiving logs in the ./logs directory!

If you are running Warmod, you can send warmod logs here as well -

wm_stats_method 2 // To make sure logs are sent to both this app via UDP and stored locally 
wm_stats_trace 1 // If you want to record player locations in the logs too, set this

For example:

$ tail -n 5 logs/2016-06-05-10.0.0.100-27015.log
06/05/2016 - 06:39:06: "Norm<20><BOT><TERRORIST>" [619 -1349 -280] attacked "Keith<17><BOT><CT>" [420 -1444 -280] with "nova" (damage "16") (damage_armor "0") (health "6") (armor "58") (hitgroup "left leg")
06/05/2016 - 06:39:06: "Norm<20><BOT><TERRORIST>" [619 -1349 -280] attacked "Keith<17><BOT><CT>" [420 -1444 -280] with "nova" (damage "13") (damage_armor "6") (health "0") (armor "51") (hitgroup "stomach")
06/05/2016 - 06:39:06: "Norm<20><BOT><TERRORIST>" [619 -1349 -280] killed "Keith<17><BOT><CT>" [420 -1444 -216] with "nova"
06/05/2016 - 06:39:06: "Norm<20><BOT><TERRORIST>" [619 -1349 -280] attacked "Dean<14><BOT><CT>" [400 -1464 -280] with "nova" (damage "16") (damage_armor "0") (health "84") (armor "100") (hitgroup "left leg")
06/05/2016 - 06:39:07: "Norm<20><BOT><TERRORIST>" [619 -1349 -280] attacked "Dean<14><BOT><CT>" [399 -1445 -280] with "nova" (damage "13") (damage_armor "6") (health "71") (armor "93") (hitgroup "stomach")

TODO

  • Add tests
  • Tidy up project
  • Add way to add/remove defined sources after instantiation