GameServerManagers / LinuxGSM

The command-line tool for quick, simple deployment and management of Linux dedicated game servers.
https://linuxgsm.com
MIT License
4.25k stars 813 forks source link

fix(info_game): add ip query timeout and backup api service #4524

Closed MicLieg closed 7 months ago

MicLieg commented 7 months ago

Description

This PR fixes an issue where some users experienced very slow LinuxGSM script execution because ip-api.com was not reachable. This caused the info_game.sh script to wait for minutes until curl's default timeout stopped the request: info_game.sh#L2466

To resolve this issue and enhance the user experience, the following changes have been implemented in this PR:

  1. Timeout Specification: A timeout of 3 seconds (curl -s --max-time 3 URL) has now been explicitly set for connections to ip-api.com. This ensures that if the script cannot establish (and complete) a connection within this period, it will promptly move on to the next steps rather than waiting for curl's default timeout. This change significantly reduces the script's total execution time in scenarios where ip-api.com cannot be reached.
  2. Backup API Service: In addition to the timeout, this PR introduces a fallback mechanism by integrating the IP API service, myip.wtf as a backup. This service is utilized in instances where connecting to ip-api.com fails or when ip-api.com is inaccessible due to being blocked. This redundancy ensures that the script can still perform its necessary IP address resolution function without significant delays, thereby maintaining smooth and efficient script execution.

What's myip.wtf?

myip.wtf (also known as wtfismyip.com) is a IP address lookup service known for respecting user privacy and being free of ads, trackers or analytics. The project is also open source.

Fixes #4462

Type of change

Checklist

PR will not be merged until all steps are complete.

Documentation

If documentation does need updating either update it by creating a PR (preferred) or request a documentation update.

Thank you for your Pull Request!