Skip to content

Commit 1ec4e1e

Browse files
authored
fix: update hostname argument handling in run_sbox function (#17)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved hostname resolution logic during application startup for more reliable system initialization. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
2 parents 1c400bc + 01d654e commit 1ec4e1e

1 file changed

Lines changed: 16 additions & 19 deletions

File tree

Yolk/entrypoint.sh

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -423,16 +423,6 @@ run_sbox() {
423423
exit 1
424424
fi
425425

426-
# Backward compatibility: use HOSTNAME only when SERVER_NAME is empty and
427-
# HOSTNAME does not look like a container ID.
428-
if [ -z "${resolved_server_name}" ] && [ -n "${HOSTNAME_FALLBACK}" ] && [[ ! "${HOSTNAME_FALLBACK}" =~ ^[0-9a-f]{12,64}$ ]]; then
429-
resolved_server_name="${HOSTNAME_FALLBACK}"
430-
fi
431-
432-
if [ -n "${resolved_server_name}" ]; then
433-
args+=( +hostname "${resolved_server_name}" )
434-
fi
435-
436426
if [ -n "${TOKEN}" ]; then
437427
args+=( +net_game_server_token "${TOKEN}" )
438428
fi
@@ -460,6 +450,10 @@ run_sbox() {
460450
args+=( "${cli_args[@]}" )
461451
fi
462452

453+
if [ -n "${resolved_server_name}" ]; then
454+
args+=( +hostname "\"${resolved_server_name}\"" )
455+
fi
456+
463457
unset DOTNET_ROOT DOTNET_ROOT_X86 DOTNET_ROOT_X64
464458

465459
launch_env=(
@@ -470,19 +464,22 @@ run_sbox() {
470464
DOTNET_ZapDisable=1
471465
)
472466

473-
for arg in "${args[@]}"; do
474-
if [[ "${arg}" == "+net_game_server_token" ]]; then
467+
i=0
468+
while [ $i -lt ${#args[@]} ]; do
469+
arg="${args[$i]}"
470+
if [[ "$arg" == "+net_game_server_token" ]]; then
475471
redacted_args+=( "+net_game_server_token" "[REDACTED]" )
476-
# Skip the next iteration to avoid logging the actual token
472+
i=$((i+2))
477473
continue
478474
fi
479-
480-
# Only add to redacted if we didn't just skip a token flag
481-
if [ -z "${skip_next:-}" ]; then
482-
redacted_args+=( "${arg}" )
483-
else
484-
unset skip_next
475+
if [[ "$arg" == "+hostname" && $((i+1)) -lt ${#args[@]} ]]; then
476+
# Always log +hostname and its value as a single quoted argument
477+
redacted_args+=( "+hostname \"${args[$((i+1))]}\"" )
478+
i=$((i+2))
479+
continue
485480
fi
481+
redacted_args+=( "$arg" )
482+
i=$((i+1))
486483
done
487484

488485
if [ "${ENABLE_DIRECT_CONNECT}" = "1" ]; then

0 commit comments

Comments
 (0)