Skip to content

refactor: move steammaster check to info_game #3821

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

Merged
merged 1 commit into from
Apr 26, 2022
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
55 changes: 0 additions & 55 deletions lgsm/functions/info_distro.sh
Original file line number Diff line number Diff line change
Expand Up @@ -267,61 +267,6 @@ fi
netint=$(${ipcommand} -o addr | grep "${ip}" | awk '{print $2}')
netlink=$(${ethtoolcommand} "${netint}" 2>/dev/null| grep Speed | awk '{print $2}')

# External IP address
if [ -z "${extip}" ]; then
extip="$(curl --connect-timeout 10 -s https://api.ipify.org 2>/dev/null)"
exitcode=$?
# Should ifconfig.co return an error will use last known IP.
if [ ${exitcode} -eq 0 ]; then
if [[ "${extip}" != *"DOCTYPE"* ]]; then
echo -e "${extip}" > "${tmpdir}/extip.txt"
else
if [ -f "${tmpdir}/extip.txt" ]; then
extip="$(cat "${tmpdir}/extip.txt")"
else
fn_print_error_nl "Unable to get external IP"
fi
fi
else
if [ -f "${tmpdir}/extip.txt" ]; then
extip="$(cat "${tmpdir}/extip.txt")"
else
fn_print_error_nl "Unable to get external IP"
fi
fi
fi

# Alert IP address
if [ "${displayip}" ]; then
alertip="${displayip}"
elif [ "${extip}" ]; then
alertip="${extip}"
else
alertip="${ip}"
fi

# Steam Master Server - checks if detected by master server.
if [ -z "${displaymasterserver}" ]; then
if [ "$(command -v jq 2>/dev/null)" ]; then
if [ "${ip}" ]&&[ "${port}" ]; then
if [ "${steammaster}" == "true" ]||[ "${commandname}" == "DEV-QUERY-RAW" ]; then
# Will query server IP addresses first.
for queryip in "${queryips[@]}"; do
masterserver="$(curl --connect-timeout 10 -m 3 -s "https://api.steampowered.com/ISteamApps/GetServersAtAddress/v0001?addr=${queryip}&format=json" | jq --arg port "${port}" --arg queryport "${queryport}" '.response.servers[] | select((.gameport == ($port|tonumber) or (.gameport == ($queryport|tonumber)))) | .addr' | wc -l 2>/dev/null)"
done
# Should that not work it will try the external IP.
if [ "${masterserver}" == "0" ]; then
masterserver="$(curl --connect-timeout 10 -m 3 -s "https://api.steampowered.com/ISteamApps/GetServersAtAddress/v0001?addr=${extip}&format=json" | jq --arg port "${port}" --arg queryport "${queryport}" '.response.servers[] | select((.gameport == ($port|tonumber) or (.gameport == ($queryport|tonumber)))) | .addr' | wc -l 2>/dev/null)"
fi
if [ "${masterserver}" == "0" ]; then
displaymasterserver="false"
else
displaymasterserver="true"
fi
fi
fi
fi
fi
# Sets the SteamCMD glibc requirement if the game server requirement is less or not required.
if [ "${appid}" ]; then
if [ "${glibc}" = "null" ]||[ -z "${glibc}" ]||[ "$(printf '%s\n'${glibc}'\n' "2.14" | sort -V | head -n 1)" != "2.14" ]; then
Expand Down
57 changes: 57 additions & 0 deletions lgsm/functions/info_game.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2412,3 +2412,60 @@ elif [ "${engine}" == "source" ]||[ "${engine}" == "goldsrc" ]; then
elif [ "${engine}" == "unreal2" ]; then
fn_info_game_unreal2
fi

# External IP address
if [ -z "${extip}" ]; then
extip="$(curl --connect-timeout 10 -s https://api.ipify.org 2>/dev/null)"
exitcode=$?
# Should ifconfig.co return an error will use last known IP.
if [ ${exitcode} -eq 0 ]; then
if [[ "${extip}" != *"DOCTYPE"* ]]; then
echo -e "${extip}" > "${tmpdir}/extip.txt"
else
if [ -f "${tmpdir}/extip.txt" ]; then
extip="$(cat "${tmpdir}/extip.txt")"
else
fn_print_error_nl "Unable to get external IP"
fi
fi
else
if [ -f "${tmpdir}/extip.txt" ]; then
extip="$(cat "${tmpdir}/extip.txt")"
else
fn_print_error_nl "Unable to get external IP"
fi
fi
fi

# Alert IP address
if [ "${displayip}" ]; then
alertip="${displayip}"
elif [ "${extip}" ]; then
alertip="${extip}"
else
alertip="${ip}"
fi

# Steam Master Server - checks if detected by master server.
# Checked after config init, as the queryport is needed
if [ -z "${displaymasterserver}" ]; then
if [ "$(command -v jq 2>/dev/null)" ]; then
if [ "${ip}" ]&&[ "${port}" ]; then
if [ "${steammaster}" == "true" ]||[ "${commandname}" == "DEV-QUERY-RAW" ]; then
# Will query server IP addresses first.
for queryip in "${queryips[@]}"; do
masterserver="$(curl --connect-timeout 10 -m 3 -s "https://api.steampowered.com/ISteamApps/GetServersAtAddress/v0001?addr=${queryip}&format=json" | jq --arg port "${port}" --arg queryport "${queryport}" '.response.servers[] | select((.gameport == ($port|tonumber) or (.gameport == ($queryport|tonumber)))) | .addr' | wc -l 2>/dev/null)"
done
# Should that not work it will try the external IP.
if [ "${masterserver}" == "0" ]; then
masterserver="$(curl --connect-timeout 10 -m 3 -s "https://api.steampowered.com/ISteamApps/GetServersAtAddress/v0001?addr=${extip}&format=json" | jq --arg port "${port}" --arg queryport "${queryport}" '.response.servers[] | select((.gameport == ($port|tonumber) or (.gameport == ($queryport|tonumber)))) | .addr' | wc -l 2>/dev/null)"
fi
if [ "${masterserver}" == "0" ]; then
displaymasterserver="false"
else
displaymasterserver="true"
fi
fi
fi
fi
fi