Explorar o código

fix(details): detect and display Source Steam ports (#5046)

Daniel Gibbs hai 4 días
pai
achega
5d625d995a
Modificáronse 2 ficheiros con 5 adicións e 5 borrados
  1. 4 4
      lgsm/modules/info_game.sh
  2. 1 1
      lgsm/modules/info_messages.sh

+ 4 - 4
lgsm/modules/info_game.sh

@@ -2149,10 +2149,10 @@ fn_info_game_source() {
 		fn_info_game_valve_keyvalues "servername" "hostname"
 		fn_info_game_valve_keyvalues "serverpassword" "sv_password"
 	fi
-	# Steamport can be between 26901-26910 and is normally automatically set.
-	# Some servers might support -steamport parameter to set
-	if [ "${steamport}" == "0" ] || [ -v "${steamport}" ]; then
-		steamport="$(echo "${ssinfo}" | grep "${srcdslinuxpid}" | awk '{print $5}' | grep ":269" | cut -d ":" -f2)"
+	# Detect the optional Steam port from this server's UDP sockets in the 269xx range.
+	# Keep an explicitly configured port, including ports outside the default range.
+	if { [ -z "${steamport}" ] || [ "${steamport}" == "0" ]; } && [ -n "${srcdslinuxpid}" ]; then
+		steamport="$(echo "${ssinfo}" | awk -v pid="${srcdslinuxpid}" '$1 == "udp" && $0 ~ ("pid=" pid ",") { port = $5; sub(/^.*:/, "", port); if (port ~ /^269[0-9][0-9]$/) { print port; exit } }')"
 	fi
 	clientport="${clientport:-"0"}"
 	defaultmap="${defaultmap:-"NOT SET"}"

+ 1 - 1
lgsm/modules/info_messages.sh

@@ -1603,7 +1603,7 @@ fn_info_messages_source() {
 		fn_port "RCON" rconport tcp
 		fn_port "SourceTV" sourcetvport udp
 		# Will not show if unavailable
-		if [ "${steamport}" == "0" ] || [ -v "${steamport}" ]; then
+		if [ -n "${steamport}" ] && [ "${steamport}" != "0" ]; then
 			fn_port "Steam" steamport udp
 		fi
 		fn_port "Client" clientport udp