Skip to content

[Player Counter] Allow use of hostnames as aliases when resolving query address#135

Open
BrentOates wants to merge 1 commit into
pelican-dev:mainfrom
BrentOates:main
Open

[Player Counter] Allow use of hostnames as aliases when resolving query address#135
BrentOates wants to merge 1 commit into
pelican-dev:mainfrom
BrentOates:main

Conversation

@BrentOates
Copy link
Copy Markdown

@BrentOates BrentOates commented May 29, 2026

I'd found that when trying to use this plugin, that the player counts weren't showing up on any of the servers I was hosting.

My allocation was on 0.0.0.0, and alias set as the hostname so the plugin wasn't activating for them.

If there's a reason for that, happy to close this, but this is what I've been using locally to get this working and figured its worth adding upstream.

Summary by CodeRabbit

  • Bug Fixes
    • Improved IPv6 address handling in game server queries to ensure proper formatting.
    • Enhanced host validation to prevent invalid query attempts against reserved addresses.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 29, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 8300f32f-bca2-479a-9a7a-adf03ff84052

📥 Commits

Reviewing files that changed from the base of the PR and between 30fd519 and 30bd634.

📒 Files selected for processing (1)
  • player-counter/src/Models/GameQuery.php
📜 Recent review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: PHPStan (8.5)
  • GitHub Check: PHPStan (8.4)
  • GitHub Check: PHPStan (8.3)
🔇 Additional comments (4)
player-counter/src/Models/GameQuery.php (4)

76-85: LGTM!


71-74: LGTM!


62-62: LGTM!


46-47: ⚡ Quick win

is_ipv6() won’t bracket-wrap hostnames in this codepath.

Laravel’s is_ipv6() checks IPv6 address literals (via filter_var(..., FILTER_VALIDATE_IP | FILTER_FLAG_IPV6)), so a hostname like example.com won’t be treated as IPv6 and won’t be wrapped as [...] in player-counter/src/Models/GameQuery.php (lines 46-47).


📝 Walkthrough

Walkthrough

This PR extracts a new getQueryHost() helper method to centralize host selection logic based on alias configuration. GameQuery::runQuery() now derives its target host from this helper and formats it for IPv6 compatibility. GameQuery::canRunQuery() uses the helper to validate that the selected host is neither blank nor a wildcard address.

Changes

Host Query Extraction and Validation

Layer / File(s) Summary
Host selection helper and validation
player-counter/src/Models/GameQuery.php
New getQueryHost(Allocation $allocation): string helper centralizes alias-or-IP selection logic with fallback to allocation IP. canRunQuery() validates via this helper, checking for blank values and explicitly filtering wildcard addresses 0.0.0.0 and ::.
Query execution with extracted host
player-counter/src/Models/GameQuery.php
runQuery() computes $host from getQueryHost(), wraps IPv6 addresses in brackets, and passes the formatted host to QueryTypeService::process().

🎯 2 (Simple) | ⏱️ ~10 minutes

A helper hops onto the stage so clean,
Making host selection lean and lean,
IPv6 wrapped in brackets bright,
Query checks are now just right! 🐰✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: introducing hostname alias support for query address resolution in the Player Counter module.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

1 participant