diff --git a/.gitignore b/.gitignore index 872ec9e..8a1da0a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ -/.go +/.* +/!.github +/!.vscode Dockerfile.* !Dockerfile.tmpl coverage.txt diff --git a/README.md b/README.md index 30f62a3..e282d5b 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/docs/hlds-cstrike-example/.env b/docs/hlds-cstrike-example/.env new file mode 100644 index 0000000..f38f00e --- /dev/null +++ b/docs/hlds-cstrike-example/.env @@ -0,0 +1 @@ +COMPOSE_PROJECT_NAME=example diff --git a/docs/hlds-cstrike-example/docker-compose.yml b/docs/hlds-cstrike-example/docker-compose.yml index 594b521..33baf90 100644 --- a/docs/hlds-cstrike-example/docker-compose.yml +++ b/docs/hlds-cstrike-example/docker-compose.yml @@ -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: @@ -81,5 +81,4 @@ networks: volumes: dns-volume: - db-volume: diff --git a/docs/srcds-cs2-example/.env b/docs/srcds-cs2-example/.env new file mode 100644 index 0000000..f38f00e --- /dev/null +++ b/docs/srcds-cs2-example/.env @@ -0,0 +1 @@ +COMPOSE_PROJECT_NAME=example diff --git a/docs/srcds-cs2-example/docker-compose.yml b/docs/srcds-cs2-example/docker-compose.yml index e30537a..936fdd5 100644 --- a/docs/srcds-cs2-example/docker-compose.yml +++ b/docs/srcds-cs2-example/docker-compose.yml @@ -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 @@ -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 @@ -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: @@ -79,4 +70,3 @@ networks: volumes: dns-volume: - db-volume: diff --git a/docs/srcds-hl2mp-example/.env b/docs/srcds-hl2mp-example/.env new file mode 100644 index 0000000..f38f00e --- /dev/null +++ b/docs/srcds-hl2mp-example/.env @@ -0,0 +1 @@ +COMPOSE_PROJECT_NAME=example diff --git a/docs/srcds-hl2mp-example/docker-compose.yml b/docs/srcds-hl2mp-example/docker-compose.yml index 4def8e2..c70d49e 100644 --- a/docs/srcds-hl2mp-example/docker-compose.yml +++ b/docs/srcds-hl2mp-example/docker-compose.yml @@ -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: @@ -81,4 +81,3 @@ networks: volumes: dns-volume: - db-volume: