Skip to content

Fix ISP fallback and add approximate IP location metadata - #887

Open
billmcilhargey wants to merge 24 commits into
librespeed:masterfrom
blackoutsecure:billmcilhargey-ip-location-fallback
Open

billmcilhargey wants to merge 24 commits into
librespeed:masterfrom
blackoutsecure:billmcilhargey-ip-location-fallback

Conversation

@billmcilhargey

@billmcilhargey billmcilhargey commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Fix unknown ISP results by attempting IPinfo without a token before falling back to offline country/ASN and city databases.
  • Retain API-key support and backward-compatible processedString/rawIspInfo fields.
  • Add a validated, additive approximate IP-derived location object and display it in classic/modern UIs.
  • Preserve privacy by not adding browser or device GPS collection.
  • Honor deployment-level provider configuration; securely trust forwarded client IPs; keep location, raw metadata, and cached responses coherent; and preserve offline fallback behavior.
  • Secure provider cache writes, require a reliable POSIX effective UID before enabling cache paths, fail closed when cache ownership is unknown, preserve telemetry diagnostics with compact/multiline/no-timing JSON-aware redaction, validate registry schemas consistently, fail closed for malformed direct or embedded telemetry payloads, clear non-array raw provider data, and keep third-party provider disclosures accurate.
  • Calculate server distance only from a cached coordinate or an approved effective IPinfo provider endpoint, using the configured provider timeout. Canonical IPinfo behavior remains compatible, while customized URL templates require an approved HTTPS server_location_url.

Verification

  • php tests/php/getIP_test.php and the posix_geteuid-disabled run pass at final head 5ec4190d1a30cc08eb89805f9fa2595068e4861e.
  • Relevant php -l checks, provider schema JSON parsing, and git diff --check pass.
  • npm run lint exits 0 (0 errors, 21 existing warnings).
  • Focused Chromium Playwright coverage passes: 3 passed (4.2s) against the rebuilt Docker compose stack.
  • npm run format:check still stops on four Prettier baseline failures reproduced identically on upstream base and PR head; no JavaScript files changed by the review-fix passes.

Context

Fixes #881.


Recovery note: this PR supersedes #882 after the original source fork was deleted and recreated. The latest review follow-up is 5ec4190; approved endpoint/test-fixture isolation is in 3ef0199; all preceding cache, registry, proxy, privacy, and redaction fixes remain on this branch. All inline review threads are resolved, and the separate Qodo review has a consolidated response.

billmcilhargey and others added 14 commits November 25, 2026 16:55
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 29, 2026 20:27
@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

PR Summary by Qodo

Fix ISP fallback and add approximate IP location

🐞 Bug fix ✨ Enhancement 🧪 Tests 📝 Documentation 🕐 40+ Minutes

Grey Divider

AI Description

• Restore ISP detection through ordered providers, caching, and offline database fallbacks.
• Add approximate IP-derived location to backend responses and classic and modern UIs.
• Strengthen proxy handling and telemetry redaction; document lookup privacy and public hosting.
Merge Risk 🔴 High

Blast radius 🔴 High 💥 3 capabilities

  • 3 affected capabilities span independent functional scopes: client identity metadata integration, telemetry privacy integration.
  • The backend response, worker fields, and both UIs form one end-to-end behavior: presenting the client's IP-derived identity during a speed test.
  • The propagation path connects these hops directly; they are not independent capabilities.
  • Telemetry receives the same client metadata produced by the get-IP flow, so this is a downstream outcome of the identity metadata integration rather than a separate technical layer.
  • This behavior independently governs whether persisted telemetry is sanitized before database insertion.
  • It has a distinct outcome from displaying metadata in the browser and is therefore a separate bounded functional scope.
Behavioral complexity 🔴 High 🧩 Multiple interactions

  • Before, redaction applied regular expressions directly to ISP and log strings.
  • After, it parses entry boundaries and JSON-like nesting, preserves timing suffixes, sanitizes structured fields, reconstructs a safe payload, and applies text redaction afterward.
  • New correctness conditions are that malformed or nested entries must not bypass sanitization, cursor advancement must preserve unrelated log content, and every identifying field removed from the payload must also be absent from the reconstructed processed string.
Potential damage 🔴 High 🩹 Confidentiality

  • If enabled redaction misses an IP, hostname, location, or ISP field, identifying data can remain in persistent telemetry.
  • Reverting stops future leaks but does not remove already stored records.
  • Existing rows require deletion, scrubbing, or database-level backfill; no automatic repair worker or invocation is shown.
Assessed commit 5ec4190
Diagram

graph TD
  A["Client request"] --> B["getIP endpoint"] --> C{"Cached metadata?"}
  C -- "miss" --> D["Offline MMDB"] --> E["Ordered providers"] --> F["Normalized metadata"] --> G["Speedtest worker"] --> H["Classic modern UI"]
  C -- "hit" --> F
  D -- "complete" --> F
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Offline databases only
  • ➕ Avoids sending client IPs to third parties.
  • ➕ Eliminates provider latency, quotas, and cooldown state.
  • ➖ Requires operators to supply and maintain suitable databases.
  • ➖ Bundled country/ASN data cannot provide the same city coverage.
2. IPinfo followed by offline fallback only
  • ➕ Smaller implementation and fewer external privacy disclosures.
  • ➕ Retains the original provider's API-key workflow.
  • ➖ Cannot recover ISP details when IPinfo and local data are incomplete or unavailable.
  • ➖ Does not meet the PR's broader fallback goal.

Recommendation: The ordered registry is reasonable for recovering unknown ISPs while retaining offline fallback and a disable switch. Review provider latency, privacy disclosures, and cache and merge behavior closely; offline-only operation is the better deployment choice where third-party IP disclosure is unacceptable.

Files changed (23) +4256 / -138

Enhancement (4) +2092 / -122
getIP.phpAdd resilient, privacy-aware IP metadata fallback +1949/-119

Add resilient, privacy-aware IP metadata fallback

• Reworks ISP lookup around an ordered provider registry, bounded attempts, positive and negative caches, provider cooldowns, and configurable ASN, country, and city MMDB fallback. Normalizes provider data into backward-compatible response fields plus an optional approximate location, validates and merges place data, and retains optional IPinfo tokens and distance calculation.

backend/getIP.php

index.jsDisplay ISP and approximate location in the modern frontend +82/-0

Display ISP and approximate location in the modern frontend

• Extracts an ISP name from supported raw metadata shapes and displays available city, region, country, and coordinates. The display labels location as approximate and IP-derived.

frontend/javascript/index.js

index-classic.htmlDisplay IP metadata in the classic frontend +49/-2

Display IP metadata in the classic frontend

• Adds ISP, approximate place, and coordinate fields beneath the client IP and populates them from worker status. Also updates the classic privacy disclosure for external lookup providers.

index-classic.html

speedtest_worker.jsCarry IP metadata through worker updates +12/-1

Carry IP metadata through worker updates

• Passes raw ISP and location fields from get-IP responses to UI status updates, resets them between runs, and includes location in telemetry submissions for server-side redaction.

speedtest_worker.js

Bug fix (3) +265 / -2
getIP_util.phpValidate public IPs and trusted proxy forwarding +166/-2

Validate public IPs and trusted proxy forwarding

• Canonicalizes IP candidates, adds exact-address and CIDR matching, and excludes non-public addresses from provider eligibility. Forwarding headers are now used only when the immediate peer belongs to a configured trusted proxy network.

backend/getIP_util.php

telemetry.phpApply structured telemetry redaction +3/-0

Apply structured telemetry redaction

• Invokes the new ISP metadata redactor when IP-address redaction is enabled and clears the stored test log in that mode.

results/telemetry.php

telemetry_redaction.phpRemove location and sensitive ISP metadata from redacted telemetry +96/-0

Remove location and sensitive ISP metadata from redacted telemetry

• Drops structured location and place fields, allowlists ISP-related raw fields, and rebuilds processedString without the client IP or country.

results/telemetry_redaction.php

Tests (3) +1156 / -0
classic-standalone-regression.spec.jsCover classic and modern IP metadata displays +110/-0

Cover classic and modern IP metadata displays

• Uses mocked worker updates to verify both UIs show the ISP, approximate place, and coordinates.

tests/e2e/classic-standalone-regression.spec.js

worker-lifecycle.spec.jsVerify worker status retains structured IP metadata +48/-0

Verify worker status retains structured IP metadata

• Checks that raw ISP information and approximate location reach the Speedtest update callback.

tests/e2e/worker-lifecycle.spec.js

getIP_test.phpExercise provider fallback, location merges, and privacy safeguards +998/-0

Exercise provider fallback, location merges, and privacy safeguards

• Adds PHP coverage for authenticated and unauthenticated IPinfo requests, provider normalization and failure handling, caches, MMDB and location precedence, proxy trust, disabled lookup, distance, and telemetry redaction.

tests/php/getIP_test.php

Documentation (6) +517 / -14
HOSTING.mdPropose public server hosting requirements +463/-0

Propose public server hosting requirements

• Documents proposed eligibility, endpoint, capacity, security, privacy, review, and ongoing-operation expectations for public test points. It distinguishes these proposals from the currently enforced submission process.

HOSTING.md

README.mdUpdate PHP requirement and link hosting policy +3/-1

Update PHP requirement and link hosting policy

• States PHP 8.0 as the server requirement and directs prospective public hosts to the new hosting document.

README.md

doc.mdDocument IP lookups, fallback, and proxy controls +22/-5

Document IP lookups, fallback, and proxy controls

• Explains unauthenticated IPinfo and ordered-provider lookup, offline MMDB options, cache and cooldown behavior, privacy opt-out, and trusted proxies. Updates the PHP requirement and backend-only registry installation guidance.

doc.md

doc_docker.mdDocument Docker IP metadata settings +8/-4

Document Docker IP metadata settings

• Clarifies unauthenticated lookup and DISABLE_IPINFO behavior, and describes environment variables for offline databases and trusted proxies.

doc_docker.md

index.htmlDisclose external IP metadata lookups +11/-2

Disclose external IP metadata lookups

• Updates the frontend privacy text to identify potential provider disclosure of the public IP and describe the DISABLE_IPINFO opt-out.

frontend/index.html

index-modern.htmlUpdate modern standalone privacy disclosure +10/-2

Update modern standalone privacy disclosure

• Describes approximate IP-derived location and possible external provider lookups in the standalone modern UI's privacy text.

index-modern.html

Other (7) +226 / -0
DockerfilePackage provider registry in the standard image +2/-0

Package provider registry in the standard image

• Copies the root provider registry and its schema into the Docker image so deployed instances can load the configured provider order.

Dockerfile

Dockerfile.alpinePackage provider registry in the Alpine image +2/-0

Package provider registry in the Alpine image

• Adds the provider registry and schema to the Alpine image alongside the existing application configuration.

Dockerfile.alpine

ip-providers.jsonBundle registry for backend-only installations +80/-0

Bundle registry for backend-only installations

• Provides the default provider order, enabled flags, timeout, attempt limit, cache lifetimes, and cooldown for deployments that copy only the backend directory.

backend/ip-providers.json

entrypoint.shInstall provider configuration in Docker modes +4/-0

Install provider configuration in Docker modes

• Copies the root provider registry and schema into the served directory in standalone, dual, and backend modes.

docker/entrypoint.sh

ip-providers.jsonDefine the default ordered IP provider registry +80/-0

Define the default ordered IP provider registry

• Lists eight enabled lookup providers and two disabled entries, with timeouts, attempt limits, cache lifetimes, and cooldown settings.

ip-providers.json

ip-providers.schema.jsonSpecify provider registry configuration format +55/-0

Specify provider registry configuration format

• Adds a JSON Schema for registry settings and provider entries, including limits and an HTTPS URL-template pattern.

ip-providers.schema.json

package.jsonExpose PHP tests and package provider files +3/-0

Expose PHP tests and package provider files

• Adds a command for the PHP get-IP suite and includes the provider registry and schema in the package file list.

package.json

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)

Grey Divider


Action required

1. Shared-host users can overwrite web files ✓ Resolved
Description
writeIpProviderJson() writes through a predictable temporary filename in the shared system temp
directory, so an existing symlink at that path is followed before the file is renamed. On a shared
host, another local user can pre-position or race a symlink when a lookup writes the cache, causing
the web process to overwrite a file it can write.

2. Proxied deployments report the proxy's IP as the client ✓ Resolved
Description
getClientIp now returns REMOTE_ADDR and skips CF-Connecting-IP, X-Real-IP and
X-Forwarded-For unless the peer matches TRUSTED_PROXIES, which is unset by default and is not
set by docker/entrypoint.sh. Every existing install behind a reverse proxy, CDN or load balancer
will now show the proxy address (often labelled "private IPv4 access") and look up the proxy's
ISP/location; results/telemetry.php stores that wrong IP too.


Remediation recommended

3. Location object has no countryName field ✓ Resolved
Description
normalizeApproximateLocation stores the country name under country and the code under
countryCode, and never emits a countryName key, so the location object does not match the
countryName field the checklist requires. When only a country code is available, the code is also
copied into country ($countryName = $countryCode), so consumers reading country as a name
receive a two-letter code. Frontends and the worker read location.country for display, so any
client expecting countryName finds it missing.

4. Complete offline records skip live lookup ✓ Resolved
Description
getIspInfoProviderFallback() returns and caches a complete offline record before entering the
ordered provider loop. When a city database supplies city, country, coordinates, and ISP, even a
configured IPinfo token is never used for that client, so live metadata cannot correct an outdated
local record.

5. Country labels change on repeat requests ✓ Resolved
Description
getPositiveProviderCache() rebuilds processedString with the country code ahead of the country
name, reversing the offline formatter’s precedence. For a complete offline record containing both
“United States” and “US,” the first response displays the name and the cached response displays the
code despite unchanged location data.

View review recommended (3)
6. Redaction now wipes the whole telemetry test log ✓ Resolved
Description
The redaction block now sets $log = '' after the IP/hostname regex scrubbing, so the three
preg_replace calls on $log are dead and the stored log is always empty. Any operator with
$redact_ip_addresses enabled loses all test logs used for diagnosing problems, a change the PR
description does not mention.

7. Privacy notices name only ipinfo.io as recipient ✓ Resolved
Description
The 'How we use the data' paragraph in frontend/index.html and index-modern.html, and the 'What
data we collect' item in index-classic.html, say the public IP is sent only to ipinfo.io.
getIspInfoProviderFallback can send it to up to eight services from ip-providers.json (ipwho.is,
FreeIPAPI, IPLocate, IP2Location, ipapi.is, DB-IP, GeoJS). Users read conflicting disclosures on the
same page, and operators deploying the default text understate which third parties receive visitor
IPs.

8. Tests cover an IPinfo path the endpoint no longer uses ✓ Resolved
Description
getIspInfo_ipinfoApi (about 100 lines, with its own API-key loading that ignores the
IPINFO_APIKEY env var) is no longer called from the request handler, which now uses only
getIspInfoProviderFallback. Yet tests/php/getIP_test.php builds its no-key, API-key, partial and
malformed-location checks on that function, so the suite passes while the real request path is not
exercised.

Grey Divider

Tip of the day
💡 Did you know, you can hide the parts of a finding you never read, like the evidence or the agent prompt

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Unresolved findings include a critical proxy-header flaw that enables spoofed lookup targets and telemetry attribution, plus inconsistent geographic and cached metadata and duplicate lookups that delay startup.

5 open issues
What changed in this PR

This PR addresses unknown ISP results by expanding PHP metadata lookup and displaying approximate IP-derived location in the classic and modern interfaces, without collecting browser or device GPS data.

Changes:

  • Adds configurable provider fallback, offline database support, caching, cooldowns, and trusted-proxy handling.
  • Passes structured ISP/location metadata through the worker and UIs, with telemetry redaction.
  • Adds regression coverage, deployment support, and operator documentation.
File Description
tests/​php/​getIP_test.php Adds backend normalization, fallback, cache, proxy, and redaction tests.
tests/​e2e/​worker-lifecycle.spec.js Tests structured metadata forwarding.
tests/​e2e/​classic-standalone-regression.spec.js Tests metadata display in both UIs.
speedtest_worker.js Includes ISP/location metadata in status and telemetry.
results/​telemetry.php Applies metadata redaction and clears logs when redacting.
results/​telemetry_redaction.php Adds structured telemetry sanitization.
README.md Updates PHP requirements and links hosting guidance.
package.json Adds a PHP test command and packages registry files.
ip-providers.schema.json Defines the provider registry schema.
ip-providers.json Configures provider order, timeouts, and cache settings.
index-modern.html Updates external-lookup privacy disclosures.
index-classic.html Displays ISP/location metadata and updates disclosures.
HOSTING.md Adds proposed public-host onboarding and operating guidance.
frontend/​javascript/​index.js Renders ISP, place, and coordinates in the modern UI.
frontend/​index.html Updates external-lookup privacy disclosures.
Dockerfile.alpine Includes provider registry files in the Alpine image.
Dockerfile Includes provider registry files in the standard image.
docker/​entrypoint.sh Installs registry files for supported backend modes.
doc.md Documents lookup behavior, databases, proxies, and installation.
doc_docker.md Documents metadata and proxy environment settings.
backend/​ip-providers.json Supplies the registry for backend-only installations.
backend/​getIP.php Implements provider selection, normalization, merging, caching, and distance handling.
backend/​getIP_util.php Adds address canonicalization, public-IP filtering, and proxy trust checks.
.gitignore Adds cache-related ignore patterns.

Review effort: Balanced

Comment thread backend/getIP_util.php Resolved
Comment thread backend/getIP.php Resolved
Comment thread backend/getIP.php Resolved
Comment thread backend/getIP.php Resolved
Comment thread backend/getIP.php Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Unresolved findings allow spoofed client IPs and telemetry attribution, merge conflicting country data, and make an offline-dependent test fail when its reader or database is unavailable.

6 open issues

Review effort: Balanced

Comment thread tests/php/getIP_test.php Resolved
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 29, 2026 21:21
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Comment thread results/telemetry.php Resolved
Comment thread doc.md Resolved
Copilot AI balanced review requested due to automatic review settings November 29, 2026 21:26
@billmcilhargey

billmcilhargey commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor Author

Addressed the full Qodo review in 8c6b602210434c7e17a9041269d99096ffbc7f9c, with proxy documentation in 0838ab0bbef73b0c7c1990864d722a6264e30f45 and structured telemetry-log redaction in d71143f6c71200de8d9477672eea7d636cf2f4a7:

  • Moved provider cache/lock data into owner-specific 0700 directories with 0600 files, symlink/permission checks, exclusive unpredictable temp files, and atomic rename.
  • Made X-Forwarded-For selection right-to-left, preserved private/loopback/link-local/CGNAT compatibility, rejected public direct-peer forwarding, and restricted alternate forwarding headers to explicit trusted peers. Documented TRUSTED_PROXY_IPS and the overwrite requirement.
  • Added countryName, compatible country name/code merge checks, and raw geographic synchronization from the selected location.
  • Kept complete offline data as fallback/merge input while always attempting enabled live providers first.
  • Unified cold/warm processedString and raw-location reconstruction with exact cache equality tests.
  • Removed telemetry log blanking, structurally redacted embedded get-IP JSON, and retained diagnostic content/timing while removing IP, hostname, and location fields.
  • Updated all three privacy notices to list the configurable provider set and ip-providers.json.
  • Removed the production-dead direct IPinfo path and moved deterministic tests onto getIspInfoProviderFallback; tests no longer depend on an installed MMDB reader.

Final verification: php tests/php/getIP_test.php passes; relevant php -l checks pass; npm run lint exits 0 with 0 errors; git diff --check passes. Focused Chromium coverage now passes 3/3 (7.1s) after installing the Playwright browser; an unrelated detached Rust service on IPv4 18185 was bypassed only in a temporary untracked config while the real Docker services ran.

All 8 inline review threads are resolved.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Server-location requests bypass provider opt-outs and configured timeouts, while metadata caches, negative entries, and cooldowns remain reusable after provider configuration changes.

2 open issues

Review effort: Balanced

Comment thread backend/getIP.php Resolved
Comment thread backend/getIP.php Resolved
Copilot AI balanced review requested due to automatic review settings November 29, 2026 22:42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Distance lookups can contact IPinfo despite an offline-only provider policy, and caches preserve metadata and failure state after provider configuration changes.

2 open issues

Review effort: Balanced

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 29, 2026 22:51
@billmcilhargey

Copy link
Copy Markdown
Contributor Author

Final review pass complete at 90b72f8224cd6baa535ef0d495cf5d8047674400 (969a548/a6bce28 cover the preceding fail-closed and no-timing redaction follow-ups).

Fixes applied:

  • Proxy/client identity: trusted-proxy-aware right-to-left XFF parsing, explicit trust for alternate forwarding headers, and operator documentation.
  • Provider policy: explicitly configured missing/invalid registries fail closed to zero external providers; live providers are attempted before complete offline fallback.
  • Distance policy: server-location lookup reuses cached coordinates or requires an enabled effective ipinfo provider and uses the configured provider timeout.
  • Cache correctness: positive, negative, and cooldown entries are invalidated by provider registry, offline DB file state, and hashed API-key policy changes; ownership is fail-closed and cache files use private 0700/0600 paths.
  • Location coherence: country/name/code compatibility checks, countryName, consistent raw geographic fields, and cold/warm processedString reconstruction.
  • Telemetry privacy: compact, multiline, and no-timing get-IP JSON entries are structurally redacted; malformed payloads fail closed while unrelated diagnostic text/timing remains.
  • Compatibility/privacy docs: deterministic provider-path tests, no MMDB dependency for unit cases, and consistent third-party disclosure/configuration text.

Verification: php tests/php/getIP_test.php passes; relevant PHP syntax and git diff --check pass; npm run lint has 0 errors; focused Chromium Playwright passes 3/3 (4.2s) against rebuilt Docker services. The four known Prettier baseline failures remain unchanged. All 10/10 inline review threads are resolved, and no tracked files or temporary test configuration remain.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Malformed provider registry entries can crash get-IP instead of returning fallback metadata, while incorrect non-POSIX UID handling can disable caches and provider cooldowns.

2 open issues
2 resolved since last review

Review effort: Balanced

Comment thread backend/getIP.php Resolved
Comment thread backend/getIP.php Resolved
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 30, 2026 08:56
@billmcilhargey

Copy link
Copy Markdown
Contributor Author

Final additional-review pass complete at d4895d21a671d93798136cec1c3c63f10bfbce05 (building on policy/cache hardening at 90b72f8, untimed JSON redaction at a6bce28, and earlier review fixes).

Fixes applied:

  • Registry safety: one shared validator now checks provider object/list shape, required string fields, unique IDs, strict booleans, HTTPS {ip} templates, optional API-key env names, and timeout/attempt/TTL bounds. Explicit invalid registries and present-invalid automatic registries fail closed to zero external providers while missing automatic files may still advance to the next fallback.
  • Cache ownership: cache identity and validation now use only a reliable numeric posix_geteuid(); without it, cache paths/read/write/cooldown use is disabled rather than trusting the script owner. Normal POSIX 0700/0600 cache behavior remains intact.
  • Provider/distance policy: effective registry/ID policy is loaded before cache reuse, all positive/negative/cooldown entries are policy-fingerprinted, and uncached distance lookup contacts IPinfo only when an enabled effective provider permits it using the registry timeout.
  • Telemetry/privacy: compact, pretty/multiline, malformed, and no-timing get-IP JSON log entries are structurally or safely redacted while unrelated diagnostics/timing remain.
  • Compatibility/coherence: proxy selection, country/name/code merging, location/raw consistency, and cold/warm response reconstruction remain covered by regressions and docs.

Verification at final head: php tests/php/getIP_test.php passes; relevant php -l and git diff --check pass; npm run lint has 0 errors; focused Chromium Playwright passes 3/3 (6.3s) against rebuilt Docker services. The four known Prettier baseline failures are unchanged. All 12/12 inline review threads are resolved; worktree/branch are clean and synchronized.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

On runtimes without posix_geteuid(), the test reads an empty cache path, causing a PHP 8 ValueError that prevents restoration of the deleted API-key file.

1 open issue
2 resolved since last review

Review effort: Balanced

Comment thread tests/php/getIP_test.php Resolved
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 30, 2026 11:23
@billmcilhargey

Copy link
Copy Markdown
Contributor Author

Resolved the latest cache-disabled test thread in e7a7bd75787d7a210f7984488cfdd70c0d801cab.

Fixes applied:

  • Guarded all cache file cleanup, reads, lstat/mode, symlink, and cache-policy assertions when the effective-UID cache path is intentionally empty.
  • Added explicit assertions that disabled-cache mode returns misses and does not persist cooldowns.
  • Registered an idempotent shutdown restoration closure before deleting the API-key fixture, so normal exits and thrown/fatal errors both restore the original API-key mode/content and any existing cache state.
  • Preserved the complete real-cache regression and mode/symlink checks on POSIX runtimes.

Verification: normal php tests/php/getIP_test.php and php -d disable_functions=posix_geteuid tests/php/getIP_test.php both pass; PHP syntax and git diff --check pass; lint has 0 errors; focused Chromium remains 3/3 (4.2s). All current inline review threads are resolved.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The distance lookup bypasses configured provider endpoints and sends tokens directly to ipinfo.io, while tests can leave provider-disabling registry files behind and expose test policy to concurrent requests.

2 open issues
1 resolved since last review

Review effort: Balanced

Comment thread tests/php/getIP_test.php Resolved
Comment thread backend/getIP.php Resolved
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 30, 2026 13:03

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Telemetry redaction still preserves arbitrary string-valued rawIspInfo and malformed ispinfo payloads, allowing city and coordinate data to persist even when IP-address redaction is enabled.

2 open issues
2 resolved since last review

Review effort: Balanced

Comment thread results/telemetry_redaction.php Resolved
Comment thread results/telemetry_redaction.php Resolved
@billmcilhargey

Copy link
Copy Markdown
Contributor Author

Additional review pass complete at 3ef019943f54d6ff424dc0e8892d00e96f87698c (building on the validated registry/cache/telemetry fixes already on this branch).

Latest fixes:

  • Distance endpoint policy: uncached server-location lookup now uses only an approved HTTPS server_location_url for customized IPinfo routes. Canonical https://ipinfo.io/{ip}/json retains the legacy https://ipinfo.io/json behavior; a custom lookup URL with no approved server endpoint omits distance and makes no request. Configured token and provider timeout are preserved.
  • Test isolation/restoration: automatic registry precedence and invalid-registry cases now use temporary candidate files rather than overwriting the real root registry. Registry and server-location fixture existence, content, and mode are captured and restored-or-unlinked through the shutdown-safe idempotent teardown.
  • Schema/coverage: server_location_url is documented and schema-validated; tests cover canonical, approved custom, and denied custom distance endpoints plus absent-file/content/mode restoration.

Verification at final head: normal and posix_geteuid-disabled PHP suites pass; provider-schema JSON and relevant PHP syntax checks pass; npm run lint has 0 errors; git diff --check passes; focused Chromium Playwright remains 3/3 (4.3s). All 15/15 inline review threads are resolved, and the worktree/remote branch are synchronized.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 30, 2026 13:14
@billmcilhargey

Copy link
Copy Markdown
Contributor Author

Latest review pass complete at 5ec4190d1a30cc08eb89805f9fa2595068e4861e.

Fixes applied:

  • Malformed/non-array ispinfo now fails closed to processedString: 0.0.0.0 with empty rawIspInfo; original bytes are never returned.
  • String-valued or otherwise non-array rawIspInfo is cleared, including serialized JSON embedded in direct or worker-log payloads; valid arrays still use the ISP allowlist.
  • Compact, pretty/multiline, malformed, and no-timing get-IP log entries are safely redacted while unrelated diagnostics/timing remain.
  • Previous reviews remain covered: strict registry validation/fail-closed policy, effective-cache fingerprints, POSIX owner identity, policy-aware distance endpoints/timeouts, proxy-chain selection, location coherence, isolated fixtures, and shutdown-safe restoration.

Verification: normal and posix_geteuid-disabled PHP suites pass; relevant PHP/schema/diff checks pass; lint has 0 errors; focused Chromium Playwright passes 3/3 (4.2s). The known four Prettier baseline failures are unchanged. All 17/17 inline review threads are resolved, and local/remote heads are synchronized.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Human assessment is needed because redaction edge cases can leave geographic data exposed and corrupt diagnostic JSON.

No open issues 🎉

4 resolved since last review

Review effort: Balanced

@sstidl

sstidl commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

Looks like someone has too many tokens.

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.

Display ISP, approximate city/region/country and coordinates from IP metadata

3 participants