Skip to content

Avoid WMIC in CivilizationBot’s independent HTTP clients - #128

Merged
valzargaming merged 2 commits into
mainfrom
fix/remaining-reactphp-windows-dns
Nov 24, 2026
Merged

valzargaming merged 2 commits into
mainfrom
fix/remaining-reactphp-windows-dns

Conversation

@valzargaming

@valzargaming valzargaming commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

The normal bootstrap already supplies DNS explicitly, but the dedicated hosted verifier and fallback HTTP clients could still instantiate a connector without DNS policy and reach react/dns’s Windows WMIC lookup. Reuse the existing system DNS helper and preserve ReactPHP’s 8.8.8.8 fallback when discovery has no result. The hosted verification trust, timeout and redirect policy are unchanged. Existing DiscordPHP lock work (#100) is separate and is not duplicated here.

Verification: six touched PHP files linted and eleven local DNS assertions passed. All eight observed pull-request workflows passed on head 3376e03, including the portable fixture on Windows and Linux PHP 8.3, 8.4 and 8.5, and exact locked dependencies. The Windows test intercepted both the PowerShell and unconfigured upstream WMIC paths and verified that an explicit DNS option does not discover system DNS. No runtime started or services contacted.

Summary by CodeRabbit

  • Bug Fixes
    • HTTP connections now use the system’s DNS settings when available, preserving the configured nameserver order.
    • When no nameservers are configured, connections fall back to a public DNS resolver.
    • DNS discovery is handled more safely on Windows and where shell commands are unavailable, helping prevent connection setup issues.

@coderabbitai

coderabbitai Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

Walkthrough

SystemDns now creates HTTP browsers with explicit DNS configuration and falls back to 8.8.8.8 when discovery returns no nameservers. Civ13 and Civ14 browser creation paths use this factory. The portable workflow runs tests that check DNS configuration and discovery behavior.

Changes: System DNS browser setup

Layer / File(s) Summary
SystemDns browser and DNS configuration
src/Civ13/ServerDirectory/SystemDns.php
SystemDns adds a browser factory and connector configuration method. DNS discovery handles an unavailable shell_exec function and redirects PowerShell stderr.
Browser creation integration
src/Civ13/Civ13.php, src/Civ13/HostedVerificationSource.php, src/Civ13/MessageCommand/Civ13MessageCommand.php, src/Civ14/GameServer.php
Civ13 and Civ14 browser fallback paths and the authenticated verification browser now use SystemDns::browser(). Existing configured or shared browser paths remain preferred where described.
DNS behavior checks
tests/system-dns.php, .github/workflows/portable.yml
The system DNS test checks fallback and discovered nameserver ordering, browser construction, and Windows DNS discovery behavior. The portable workflow runs the test.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant Civ13 as Civ13::resolveOptions
  participant SystemDns as SystemDns::browser()
  participant ConnectorConfig as SystemDns::connectorConfig()
  participant DNSDiscovery as SystemDns::load()
  Civ13->>SystemDns: loop and browser options
  alt dns option is absent
    SystemDns->>ConnectorConfig: obtain DNS configuration
    ConnectorConfig->>DNSDiscovery: load system DNS settings
    DNSDiscovery-->>ConnectorConfig: discovered nameservers or empty configuration
    ConnectorConfig-->>SystemDns: configuration with fallback if empty
  else dns option is supplied
    SystemDns->>SystemDns: use supplied DNS option
  end
  SystemDns-->>Civ13: Browser with Connector and loop
Loading
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@valzargaming
valzargaming marked this pull request as ready for review November 24, 2026 17:33
Copilot AI balanced review requested due to automatic review settings November 24, 2026 17:33

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@valzargaming
valzargaming merged commit a81cd77 into main Nov 24, 2026
65 of 66 checks 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.

2 participants