Skip to content

[WIP] Update IP handling and OpenAPI configuration - #18

Merged
jjesse merged 1 commit into
feature/openapi-ipv6-private-ipfrom
copilot/featureopenapi-ipv6-private-ip
Aug 1, 2026
Merged

jjesse merged 1 commit into
feature/openapi-ipv6-private-ipfrom
copilot/featureopenapi-ipv6-private-ip

Conversation

Copilot AI commented Aug 1, 2026

Copy link
Copy Markdown
Contributor
  • Explore codebase and understand all files to modify
  • A) server.js: Fix lookupIp() IPv6 CIDR matching, add IPv6 private-IP checks in getIpGeolocation(), update JSDoc
  • B) openapi.yaml: Replace with v1.4.0 schema (nested datacenter, results[], IPv4/IPv6 params, ZDX shape)
  • C) public/app.js: Dual-stack validateIp, fix showSuccess() for nested datacenter, normalize results→hops, soften IP sanitizer
  • D) tests/unit/ip.test.js: Add IPv6 tests, update imports
  • E) Documentation: TODO.md, CHANGELOG.md, README.md, README_PYTHON.md updates
Original prompt

Continue work on branch feature/openapi-ipv6-private-ip. The following is already committed on this branch:

  1. utils/ip.js – full dual-stack IPv4/IPv6 CIDR parsing and matching (BigInt for v6)
  2. requirements.txt – Python deps
  3. zdx_oneapi_geopath.py – fixed RFC 1918 172.16.0.0/12 range check and bare except→except Exception, plus IPv6 ULA/link-local handling

Please implement the remaining changes on this same branch:

A) server.js

  • In lookupIp(), REMOVE the line if (cidr.includes(':')) continue; and instead skip only when the range family does not match the query IP family:
    const range = parseCidr(cidr);
    const queryIsV6 = ip.includes(':');
    if ((range.family === 'ipv6') !== queryIsV6) continue;
  • Update getIpGeolocation() to treat ::1, IPv6 ULA (fc/fd prefix) and fe80: link-local as private (return null), same as IPv4 RFC1918 handling.
  • Update JSDoc comments that say IPv4-only to say IPv4 or IPv6.

B) openapi.yaml – replace entirely with a corrected OpenAPI 3.0.3 schema version 1.4.0 that:

  • Documents nested datacenter object on LookupFound: { name, city, country, latitude, longitude, ipRanges[] }
  • LookupNotFound has datacenter: null and matchedRange: null
  • TraceResult uses results[] (not hops), totalResults, foundResults, totalDistance, totalDistanceMiles
  • Trace hop items match server shape (hop number, nested datacenter, matchedRange, distanceFromPrevious)
  • IP parameters described as IPv4 or IPv6 (no format: ipv4 restriction)
  • ZDX userpath response matches { success, data: { user, device, application, probe, timestamp, hops[] } }

C) public/app.js

  • Replace validateIp with dual-stack validation (IPv4 octet check + basic IPv6 structural check allowing hex/colons).
  • Update error messages from 'IPv4' to 'IPv4 or IPv6'.
  • Fix showSuccess() to read nested data.datacenter.name/city/country/latitude/longitude and data.matchedRange (backend returns nested object, not flat strings).
  • In handleTraceSubmit success path: if data.results exists but not data.hops, normalize results into hops shape expected by showTraceSuccess (map datacenter.name etc.), and set totalHops/foundHops from totalResults/foundResults.
  • Soften ipInput sanitizer to allow hex letters and colons for IPv6 (not only digits and dots).

D) tests/unit/ip.test.js – expand tests for IPv6 parseCidr, isIpInRange on Zscaler-style /40 ranges (2605:4300:e800::/40, 2a03:eec0:1300::/40), isValidIpv6, isValidIp accepting both families, getIpFamily. Keep existing IPv4 tests. Import new exports (ipv6ToBigInt, isValidIpv4, isValidIpv6, getIpFamily).

E) Documentation updates

  • TODO.md: mark as done the OpenAPI LookupFound schema fix, private-IP prefix list fix, bare except fix, IPv6 support, requirements.txt, OneAPI docs, TRUST_PROXY docs.
  • CHANGELOG.md [Unreleased]: document IPv6 support, OpenAPI 1.4.0 nested schema, private-IP fix, frontend nested-datacenter fix.
  • README.md: mention IPv6 in features; update lookup response example to nested datacenter shape; document TRUST_PROXY; troubleshooting note for IPv4 or IPv6.
  • README_PYTHON.md: add a short section documenting zdx_oneapi_geopath.py (OneAPI env vars and usage).

Do not change unrelated files. Keep code style consistent with the existing project.

@jjesse
jjesse requested a review from Copilot August 1, 2026 03:43
@jjesse
jjesse marked this pull request as ready for review August 1, 2026 03:43

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 wasn't able to review any files in this pull request.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@jjesse
jjesse merged commit 0763ef1 into feature/openapi-ipv6-private-ip Aug 1, 2026
1 check failed
Copilot AI requested a review from jjesse August 1, 2026 03:43
Copilot stopped work on behalf of jjesse due to an error August 1, 2026 03:43
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.

3 participants