feat: change extip to public ip (#4301)

also change ark parms for epic to use publicip
This commit is contained in:
Daniel Gibbs 2023-09-01 22:08:26 +01:00 committed by GitHub
parent 6b9393f949
commit 7b374249ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 22 additions and 22 deletions

View File

@ -19,7 +19,7 @@ altsavedirectoryname="${defaultmap}"
maxplayers="70"
## Server Parameters | https://docs.linuxgsm.com/configuration/start-parameters#additional-parameters
startparameters="${defaultmap}?AltSaveDirectoryName=${altsavedirectoryname}?listen?MultiHome=${ip}?MaxPlayers=${maxplayers}?QueryPort=${queryport}?RCONPort=${rconport}?Port=${port} -automanagedmods -crossplay -PublicIPForEpic=${ip}"
startparameters="${defaultmap}?AltSaveDirectoryName=${altsavedirectoryname}?listen?MultiHome=${ip}?MaxPlayers=${maxplayers}?QueryPort=${queryport}?RCONPort=${rconport}?Port=${port} -automanagedmods -crossplay -PublicIPForEpic=${publicip}"
#### LinuxGSM Settings ####

View File

@ -14,7 +14,7 @@ port="7777"
queryport="7780"
## Server Parameters | https://docs.linuxgsm.com/configuration/start-parameters#additional-parameters
startparameters="/Game/Maps/Final_Maps/Derailed?Game=/Script/ShooterGame.WartideGameMode?listen -log -broadcastip=\"${extip}\" -PORT=${port} -QueryPort=${queryport} -defgameini=\"${servercfgfullpath}\""
startparameters="/Game/Maps/Final_Maps/Derailed?Game=/Script/ShooterGame.WartideGameMode?listen -log -broadcastip=\"${publicip}\" -PORT=${port} -QueryPort=${queryport} -defgameini=\"${servercfgfullpath}\""
#### LinuxGSM Settings ####

View File

@ -58,9 +58,9 @@ fi
echo -e "${lightblue}Game Server IP:\t${default}${ip}:${port}"
# External server IP.
if [ "${extip}" ]; then
if [ "${ip}" != "${extip}" ]; then
echo -e "${lightblue}Internet IP:\t${default}${extip}:${port}"
if [ "${publicip}" ]; then
if [ "${ip}" != "${publicip}" ]; then
echo -e "${lightblue}Internet IP:\t${default}${publicip}:${port}"
fi
fi

View File

@ -44,7 +44,7 @@ declare -A server_details=(
['HTTP Password']="${httppassword}"
['HTTP Port']="${httpport}"
['HTTP User']="${httpuser}"
['Internet IP']="${extip}"
['Internet IP']="${publicip}"
['LAN Port']="${lanport}"
['Master Port']="${masterport}"
['Master']="${master}"

View File

@ -2378,30 +2378,30 @@ fi
# External IP address
# Cache external IP address for 24 hours
if [ -f "${tmpdir}/extip.txt" ]; then
if [ "$(find "${tmpdir}/extip.txt" -mmin +1440)" ]; then
rm -f "${tmpdir:?}/extip.txt"
if [ -f "${tmpdir}/publicip.txt" ]; then
if [ "$(find "${tmpdir}/publicip.txt" -mmin +1440)" ]; then
rm -f "${tmpdir:?}/publicip.txt"
fi
fi
if [ ! -f "${tmpdir}/extip.txt" ]; then
extip="$(curl --connect-timeout 10 -s https://api.ipify.org 2> /dev/null)"
if [ ! -f "${tmpdir}/publicip.txt" ]; then
publicip="$(curl --connect-timeout 10 -s https://api.ipify.org 2> /dev/null)"
exitcode=$?
# if curl passes add extip to externalip.txt
# if curl passes add publicip to externalip.txt
if [ "${exitcode}" == "0" ]; then
echo "${extip}" > "${tmpdir}/extip.txt"
echo "${publicip}" > "${tmpdir}/publicip.txt"
else
echo "Unable to get external IP address"
fi
else
extip="$(cat "${tmpdir}/extip.txt")"
publicip="$(cat "${tmpdir}/publicip.txt")"
fi
# Alert IP address
if [ "${displayip}" ]; then
alertip="${displayip}"
elif [ "${extip}" ]; then
alertip="${extip}"
elif [ "${publicip}" ]; then
alertip="${publicip}"
else
alertip="${ip}"
fi
@ -2421,7 +2421,7 @@ if [ -z "${displaymasterserver}" ]; then
if [ -n "${ip}" ] && [ -n "${port}" ]; then
if [ "${steammaster}" == "true" ] || [ "${commandname}" == "DEV-QUERY-RAW" ]; then
# Query external IP first as most liky to succeed.
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}" --arg port3 "${port3}" 'if .response.servers != null then .response.servers[] | select((.gameport == ($port|tonumber) or .gameport == ($queryport|tonumber) or .gameport == ($port3|tonumber))) | .addr else empty end' | wc -l 2> /dev/null)"
masterserver="$(curl --connect-timeout 10 -m 3 -s "https://api.steampowered.com/ISteamApps/GetServersAtAddress/v0001?addr=${publicip}&format=json" | jq --arg port "${port}" --arg queryport "${queryport}" --arg port3 "${port3}" 'if .response.servers != null then .response.servers[] | select((.gameport == ($port|tonumber) or .gameport == ($queryport|tonumber) or .gameport == ($port3|tonumber))) | .addr else empty end' | wc -l 2> /dev/null)"
if [ "${masterserver}" == "0" ]; then
# Loop though server IP addresses if external IP fails.
for queryip in "${queryips[@]}"; do

View File

@ -166,8 +166,8 @@ fn_info_message_server_resource() {
echo -e "${lightblue}Link Speed:\t${default}${netlink}"
fi
echo -e "${lightblue}IP:\t${default}${ip}"
if [ "${ip}" != "${extip}" ]; then
echo -e "${lightblue}Internet IP:\t${default}${extip}"
if [ "${ip}" != "${publicip}" ]; then
echo -e "${lightblue}Internet IP:\t${default}${publicip}"
fi
} | column -s $'\t' -t
}
@ -274,9 +274,9 @@ fn_info_message_gameserver() {
echo -e "${lightblue}Server IP:\t${default}${ip}:${port}"
# Internet ip
if [ -n "${extip}" ]; then
if [ "${ip}" != "${extip}" ]; then
echo -e "${lightblue}Internet IP:\t${default}${extip}:${port}"
if [ -n "${publicip}" ]; then
if [ "${ip}" != "${publicip}" ]; then
echo -e "${lightblue}Internet IP:\t${default}${publicip}:${port}"
fi
fi