Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs: Update docker-compose.yml examples #49

Merged
merged 1 commit into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/.go
/.*
/!.github
/!.vscode
Dockerfile.*
!Dockerfile.tmpl
coverage.txt
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ A simple HTTP and UDP log forwarder to the [HLStatsX:CE daemon](https://github.c

## Agenda

The [HLStatsX:CE perl daemon](https://github.com/startersclan/hlstatsx-community-edition/blob/v1.9.0/scripts) infers a gameserver's IP:PORT from the client socket from which it receives (reads) the gameserver's `logaddress_add_http` or `logaddress_add` logs. This means both the daemon and the gameservers have to run on the same network.
The [HLStatsX:CE perl daemon](https://github.com/startersclan/hlstatsx-community-edition/blob/v1.11.0/src/scripts) infers a gameserver's IP:PORT from the client socket from which it receives (reads) the gameserver's `logaddress_add_http` or `logaddress_add` logs. This means both the daemon and the gameservers have to run on the same network.

This log forwarder eliminates this need by leveraging on an already built-in proxy protocol in the daemon - It simply runs as a sidecar to the gameserver, receives logs from the gameserver, prepends each log line with a spoofed `IP:PORT` as well as a [`proxy_key`](https://github.com/startersclan/hlstatsx-community-edition/blob/v1.9.0/scripts/hlstats.pl#L1621) secret only known by the daemon, and finally sends that log line to the daemon. The daemon reads the gameserver's `IP:PORT` from each log line, rather than the usual inferring it from the client socket.
This log forwarder eliminates this need by leveraging on an already built-in proxy protocol in the daemon - It simply runs as a sidecar to the gameserver, receives logs from the gameserver, prepends each log line with a spoofed `IP:PORT` as well as a [`proxy_key`](https://github.com/startersclan/hlstatsx-community-edition/blob/v1.11.0/src/scripts/hlstats.pl#L1826) secret only known by the daemon, and finally sends that log line to the daemon. The daemon reads the gameserver's `IP:PORT` from each log line, rather than the usual inferring it from the client socket.

`source-udp-forwarder` uses less than `3MB` of memory.

Expand Down
1 change: 1 addition & 0 deletions docs/hlds-cstrike-example/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
COMPOSE_PROJECT_NAME=example
3 changes: 1 addition & 2 deletions docs/hlds-cstrike-example/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ services:
# The daemon's proxy_key secret can only be setup in the HLStatsX:CE Web Admin Panel and not via env vars
# See: https://github.com/startersclan/docker-hlstatsxce-daemon
daemon:
image: startersclan/hlstatsx-community-edition:1.9.0-daemon
image: startersclan/hlstatsx-community-edition:1.11.0-daemon
ports:
- 27500:27500/udp # For external servers to send logs to the daemon
networks:
Expand All @@ -81,5 +81,4 @@ networks:

volumes:
dns-volume:
db-volume:

1 change: 1 addition & 0 deletions docs/srcds-cs2-example/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
COMPOSE_PROJECT_NAME=example
20 changes: 5 additions & 15 deletions docs/srcds-cs2-example/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# In this example, you will see that Counter-Strike 2 server sends its HTTP logs to `source-udp-forwarder` which then proxies (forwards) logs to the HLStatsX:CE perl daemon.
version: '2.2'
services:
# 1. Counter-Strike 2 gameserver sends UDP logs to source-udp-forwarder
# 1. Counter-Strike 2 gameserver sends HTTP logs to source-udp-forwarder
# See: https://github.com/startersclan/docker-sourceservers
cs2:
image: sourceservers/cs2:latest
Expand All @@ -15,13 +15,15 @@ services:
stdin_open: true
tty: true
stop_signal: SIGKILL
depends_on:
- source-udp-forwarder
entrypoint:
- /bin/bash
command:
- -c
- |
set -eu
exec game/bin/linuxsteamrt64/cs2 -dedicated -game cs2 -port 27015 +game_type 0 +game_mode 1 +mapgroup mg_active +map de_dust2 +log on +logaddress_add_http "http://$$( cat /dns/source-udp-forwarder ):26999"
exec game/bin/linuxsteamrt64/cs2 -dedicated -port 27015 +game_type 0 +game_mode 1 +mapgroup mg_active +map de_dust2 +rcon_password password +log on +logaddress_add_http "http://source-udp-forwarder:26999"

# 2. source-udp-forwarder proxy forwards gameserver logs to the daemon
# See: https://github.com/startersclan/source-udp-forwarder
Expand All @@ -41,23 +43,12 @@ services:
- default
depends_on:
- daemon
entrypoint:
- /bin/sh
command:
- -c
- |
set -eu

echo "Outputting my IP address"
ip addr show eth0 | grep 'inet ' | awk '{print $$2}' | cut -d '/' -f1 | tee /dns/source-udp-forwarder

exec /source-udp-forwarder

# 3. HLStatsX:CE perl daemon accepts the gameserver logs. Gameserver Logs are parsed and stats are recorded
# The daemon's proxy_key secret can only be setup in the HLStatsX:CE Web Admin Panel and not via env vars
# See: https://github.com/startersclan/docker-hlstatsxce-daemon
daemon:
image: startersclan/hlstatsx-community-edition:1.9.0-daemon
image: startersclan/hlstatsx-community-edition:1.11.0-daemon
ports:
- 27500:27500/udp # For external servers to send logs to the daemon
networks:
Expand All @@ -79,4 +70,3 @@ networks:

volumes:
dns-volume:
db-volume:
1 change: 1 addition & 0 deletions docs/srcds-hl2mp-example/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
COMPOSE_PROJECT_NAME=example
3 changes: 1 addition & 2 deletions docs/srcds-hl2mp-example/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ services:
# The daemon's proxy_key secret can only be setup in the HLStatsX:CE Web Admin Panel and not via env vars
# See: https://github.com/startersclan/docker-hlstatsxce-daemon
daemon:
image: startersclan/hlstatsx-community-edition:1.9.0-daemon
image: startersclan/hlstatsx-community-edition:1.11.0-daemon
ports:
- 27500:27500/udp # For external servers to send logs to the daemon
networks:
Expand All @@ -81,4 +81,3 @@ networks:

volumes:
dns-volume:
db-volume: