Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
leojonathanoh committed Dec 6, 2023
1 parent be7284c commit d45be2a
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 39 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ docker-compose restart daemon

# 3. Finally, add a Counter-Strike 1.6 server. click Games > and unhide 'cstrike' game.
# Then, click Game Settings > Counter-Strike (cstrike) > Add Server.
# IP: 192.168.1.100
# IP: 10.5.0.100
# Port: 27015
# Name: My Counter-Strike 1.6 server
# Rcon Password: password
Expand Down
9 changes: 9 additions & 0 deletions docker-compose.servers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#
# Note: This is a docker-compose.yml override file to start more servers in development, e.g. CS2
# To run this:
# docker-compose -f docker-compose.yml -f docker-compose.servers.yml up
#
version: '2.2'
services:
networks:
default:
81 changes: 44 additions & 37 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,72 +9,73 @@ services:
ports:
- 27015:27015/udp
networks:
- default
default:
ipv4_address: 10.5.0.100 # Static IP
stdin_open: true
tty: true
stop_signal: SIGKILL
depends_on:
- source-udp-forwarder
entrypoint:
- /bin/bash
command:
- -c
- |
set -eu
exec hlds_linux -console -noipx -secure -game cstrike +map de_dust2 +maxplayers 32 +sv_lan 0 +ip 0.0.0.0 +port 27015 +rcon_password password +log on +logaddress_add "$$( cat /dns/source-udp-forwarder )" 26999
exec hlds_linux -console -noipx -secure -game cstrike +map de_dust2 +maxplayers 32 +sv_lan 0 +ip 0.0.0.0 +port 27015 +rcon_password password +log on +logaddress_add 10.5.0.50 27500
# 1. Counter-Strike 2 gameserver sends UDP logs to source-udp-forwarder
# Uncomment to test CS2
# 1. Counter-Strike 2 gameserver sends HTTP logs to source-udp-forwarder
# See: https://github.com/startersclan/docker-sourceservers
# cs2:
# image: sourceservers/cs2:latest
# volumes:
# - dns-volume:/dns:ro
# ports:
# - 27015:27015/udp
# - 27016:27016/tcp
# - 27016:27016/udp
# networks:
# - default
# default:
# ipv4_address: 10.5.0.101 # Static IP
# stdin_open: true
# tty: true
# stop_signal: SIGKILL
# depends_on:
# - source-udp-forwarder
# - source-udp-forwarder-cs2
# entrypoint:
# - /bin/bash
# command:
# - -c
# - |
# set -eu
# 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://$$( cat /dns/source-udp-forwarder ):26999"
# exec game/bin/linuxsteamrt64/cs2 -dedicated -port 27016 +game_type 0 +game_mode 1 +mapgroup mg_active +map de_dust2 +rcon_password password +log on +logaddress_add_http "http://source-udp-forwarder-cs2:26999"

# Uncomment to test CS2
# 2. source-udp-forwarder proxy forwards gameserver logs to the daemon
# See: https://github.com/startersclan/source-udp-forwarder
source-udp-forwarder:
image: startersclan/source-udp-forwarder:latest
environment:
- LISTEN_ADDR=:26999
- UDP_FORWARD_ADDR=daemon:27500
- FORWARD_PROXY_KEY=somedaemonsecret # The daemon's proxy_key secret
- FORWARD_GAMESERVER_IP=192.168.1.100 # The gameserver's IP as registered in the HLStatsX:CE database
- FORWARD_GAMESERVER_PORT=27015 # The gameserver's IP as registered in the HLStatsX:CE database
- LOG_LEVEL=INFO
- LOG_FORMAT=txt
volumes:
- dns-volume:/dns
networks:
- 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
# source-udp-forwarder-cs2:
# image: startersclan/source-udp-forwarder:latest
# environment:
# - LISTEN_ADDR=:26999
# - UDP_FORWARD_ADDR=daemon:27500
# - FORWARD_PROXY_KEY=somedaemonsecret # The daemon's proxy_key secret
# - FORWARD_GAMESERVER_IP=10.5.0.101 # The gameserver's IP as registered in the HLStatsX:CE database
# - FORWARD_GAMESERVER_PORT=27016 # The gameserver's IP as registered in the HLStatsX:CE database
# - LOG_LEVEL=INFO
# - LOG_FORMAT=txt
# volumes:
# - dns-volume:/dns
# networks:
# - 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-cs2
# 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 Settings under 'Proxy Settings' section
Expand All @@ -86,7 +87,8 @@ services:
ports:
- 27500:27500/udp # For external servers to send logs to the daemon
networks:
- default
default:
ipv4_address: 10.5.0.50 # Static IP
depends_on:
- db
command:
Expand Down Expand Up @@ -265,6 +267,11 @@ services:
networks:
default:
driver: bridge
ipam:
config:
- subnet: 10.5.0.0/16
gateway: 10.5.0.1

volumes:
dns-volume:
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/HLstats_Server.pm
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ sub track_server_load
my $map;
my $uptime;
my $fps;
if ($self->{play_game|} == CS2()) {
if ($self->{play_game} == CS2()) {
$status_json = $self->dorcon("status_json");
my @lines = split(/[\r\n]+/, $status_json);
foreach my $line (@lines) {
Expand Down
3 changes: 3 additions & 0 deletions src/scripts/hlstats.pl
Original file line number Diff line number Diff line change
Expand Up @@ -1167,11 +1167,14 @@ sub getPlayerInfo
# Note that GOTV's $player->{userid} > 0 by default. This means in the HLStats_Player constructor's it will call $self->insertPlayerLivestats() and GOTV will be added to the LiveStats table.
# For cs2 - Give the bot userid < 0, so it registers as a HLstats_Player
# E.g. L 11/15/2023 - 03:22:54.003 - "SourceTV<0><BOT><>" connected, address "none"
# E.g. L 12/06/2023 - 07:34:16.564 - "Romanov<0><BOT><>" entered the game
if ($uniqueid eq "BOT" && index($name, "GOTV") != -1) {
$team = 'TV';
}elsif ($uniqueid eq "BOT" && index($name, "SourceTV") != -1) {
$userid = -1;
$team = 'TV';
}elsif ($uniqueid eq "BOT" && $userid eq '0') {
$userid = -1;
}
}
}
Expand Down

0 comments on commit d45be2a

Please sign in to comment.