Resolve CLI hostname to IPv4 to fix hyphenated host truncation - #416
Merged
AmyrAhmady merged 2 commits intoJul 1, 2026
Merged
Conversation
AmyrAhmady
requested changes
Jun 29, 2026
AmyrAhmady
approved these changes
Jul 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #415
When launching via the command line with a hyphenated hostname (e.g. -h s2.gta-mp.cz -p 7777), the game connects to s2.gta:7777 instead of s2.gta-mp.cz:7777.
The launcher's own CLI parsing is fine, gumdrop returns the full s2.gta-mp.cz. The truncation happens inside the game: SA-MP parses gta_sa.exe's command line itself and treats the -mp segment as a separate flag.
The UI launch flow resolves the hostname to a numeric IPv4 (getIpAddress then resolve_hostname) before calling inject, so the game never receives a hyphenated hostname. The CLI launch path in handle_cli_args skipped this step and passed the raw host straight to run_samp.
This change resolves the host to an IPv4 in the CLI path before reaching run_samp, mirroring the UI behaviour. resolve_hostname is refactored into a reusable resolve_hostname_to_ipv4 helper. If resolution fails (e.g. offline) it falls back to the raw value, so behaviour is never worse than before.
Verified in isolation that gumdrop keeps the full s2.gta-mp.cz and that the resolver turns it into a numeric IPv4 with no hyphen for the game to misparse.