fix(geoip): add icanhazip.com as first IP-echo source - #23
Open
Theyka wants to merge 1 commit into
Open
Conversation
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).
There was a problem hiding this comment.
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.comas the first entry inIPECHO_URLSfor the Python SDK. - Add
http://icanhazip.comas the first entry inIPECHO_URLSfor 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds
http://icanhazip.comas the first entry inIPECHO_URLSin both the Node and Python SDKs. The two existing sources (api.ipify.org,ip-api.com) are kept as fallbacks.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.organdip-api.comwith HTTP 502 "Host Not Found or connection failed", soresolveGeo()returnsnulland the browser keeps its host-OS timezone / language / location instead of matching the proxy's region.icanhazip.comworks 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
httpGetTextrequest logic through a backconnect proxy (92.60.79.23):http://api.ipify.orghttp://ip-api.com/line/?fields=queryhttp://icanhazip.com2a0f: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:
npm run typecheck✓,npm run build✓,vitest run test/geoip.test.ts→ 4/4 ✓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.