Skip to content

Resolve CLI hostname to IPv4 to fix hyphenated host truncation - #416

Merged
AmyrAhmady merged 2 commits into
openmultiplayer:masterfrom
ricardoofnl:fix/cli-hyphenated-hostname
Jul 1, 2026
Merged

Resolve CLI hostname to IPv4 to fix hyphenated host truncation#416
AmyrAhmady merged 2 commits into
openmultiplayer:masterfrom
ricardoofnl:fix/cli-hyphenated-hostname

Conversation

@ricardoofnl

Copy link
Copy Markdown
Contributor

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.

Comment thread src-tauri/src/commands.rs Outdated
@ricardoofnl
ricardoofnl requested a review from AmyrAhmady June 29, 2026 16:25
@AmyrAhmady
AmyrAhmady merged commit 3bde3bc into openmultiplayer:master Jul 1, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Hyphenated hostnames passed via CLI are truncated because hyphen parts are treated as arguments

2 participants