Skip to content

fix(geoip): add icanhazip.com as first IP-echo source - #23

Open
Theyka wants to merge 1 commit into
clearcotelabs:mainfrom
Theyka:fix/geoip-icanhazip
Open

fix(geoip): add icanhazip.com as first IP-echo source#23
Theyka wants to merge 1 commit into
clearcotelabs:mainfrom
Theyka:fix/geoip-icanhazip

Conversation

@Theyka

@Theyka Theyka commented Aug 25, 2026

Copy link
Copy Markdown

What

Adds http://icanhazip.com as the first entry in IPECHO_URLS in both the Node and Python SDKs. The two existing sources (api.ipify.org, ip-api.com) are kept as fallbacks.

- const IPECHO_URLS = ["http://api.ipify.org", "http://ip-api.com/line/?fields=query"];
+ const IPECHO_URLS = ["http://icanhazip.com", "http://api.ipify.org", "http://ip-api.com/line/?fields=query"];

No other code changes — both looksLikeIp() (Node) and _looks_like_ip() (Python) already accept IPv6, and the cached MaxMind DB handles IPv6 lookups.

Why

Backconnect / residential proxy providers commonly block api.ipify.org and ip-api.com with HTTP 502 "Host Not Found or connection failed", so resolveGeo() returns null and the browser keeps its host-OS timezone / language / location instead of matching the proxy's region.

icanhazip.com works through such proxies and auto-adapts: it returns IPv4 when the egress is IPv4, IPv6 when the egress is IPv6 — no subdomain needed.

Verified

Reproduced clearcote's exact httpGetText request logic through a backconnect proxy (92.60.79.23):

URL Result
http://api.ipify.org 502 "Host Not Found or connection failed"
http://ip-api.com/line/?fields=query 502 "Host Not Found or connection failed"
http://icanhazip.com 2002a0f:ca81:b00b:1d:6141:7cbd:33e7:b0b0 (IPv6 egress)

MaxMind DB lookup of the IPv6 returned by icanhazip.com:

{ "country": "DE", "timezone": "Europe/Berlin", "lat": 51.2993, "lon": 9.491 }

Existing tests pass unchanged:

  • Node: npm run typecheck ✓, npm run build ✓, vitest run test/geoip.test.ts → 4/4 ✓
  • Python: pytest tests/test_geoip.py → 4/4 ✓

The Node test suite asserts only on acceptLanguageForCountry() and the SOCKS-null path, neither of which is touched by this change.

Backconnect/residential proxy providers block api.ipify.org and
ip-api.com with HTTP 502 'Host Not Found or connection failed', so
geoip detection fails (timezone/acceptLanguage/location stay unset).

icanhazip.com works through such proxies and auto-adapts: returns
IPv4 when the egress is IPv4, IPv6 when the egress is IPv6. Both
looksLikeIp() (Node) and _looks_like_ip() (Python) already accept
IPv6, so no other changes are needed.

Verified against a backconnect proxy (92.60.79.23):
  - api.ipify.org        -> 502 'Host Not Found'
  - ip-api.com/line      -> 502 'Host Not Found'
  - icanhazip.com        -> 200, returns IPv6 egress
  - MaxMind DB resolves  -> DE / Europe/Berlin

Existing tests pass: Node (4/4 vitest), Python (4/4 pytest).
Copilot AI lite review requested due to automatic review settings August 25, 2026 17:04

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.

Pull request overview

This PR improves the reliability of GeoIP resolution in Clearcote’s Node and Python SDKs when running behind backconnect/residential proxies by adding an additional IP-echo endpoint (http://icanhazip.com) as the first source used to discover the egress IP before performing MaxMind DB lookup.

Changes:

  • Add http://icanhazip.com as the first entry in IPECHO_URLS for the Python SDK.
  • Add http://icanhazip.com as the first entry in IPECHO_URLS for the Node SDK.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
sdk/python/clearcote/geoip.py Prepends icanhazip.com to the IP-echo fallback list used to discover the proxy egress IP.
sdk/node/src/geoip.ts Prepends icanhazip.com to the IP-echo fallback list used to discover the proxy egress IP.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

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