Skip to content

feat: show country flags of connection endpoints - #571

Merged
linroid merged 3 commits into
mainfrom
feat/connection-country-flags
Oct 17, 2026
Merged

linroid merged 3 commits into
mainfrom
feat/connection-country-flags

Conversation

@linroid

@linroid linroid commented Oct 17, 2026

Copy link
Copy Markdown
Owner

Summary

The Connections page shows each endpoint's country flag. Countries come from the engine that owns the connection, so a remote device downloads and uses its own database.

  • API: ActiveConnection.country (ISO code) and a CountryDatabase controller (status(), download()), listed as KetchFeatures.COUNTRIES (net.countries).
  • Core: Ketch(countries = ...) takes a CountryLookup; ConnectionRegistry fills country as it samples. DbIpCountryDatabase (JVM/Android) downloads DB-IP's monthly IP to Country Lite (CC BY 4.0, ~5 MB) only on request, reads it at start (~160 ms, ~10 MB), and resolves host names through the system, then Cloudflare DNS over HTTPS when the system only answers with addresses without a country (a proxy's fake-IP 198.18.0.0/15).
  • Server / remote: GET /api/countries and POST /api/countries/download; RemoteKetch.controller(CountryDatabase) uses them and fails closed against older servers.
  • Engines: the desktop app, the Android app and ketch server get a database (dbip-country-lite.csv.gz in the config directory; Android noBackupFilesDir). iOS has none. The CLI native image is built with --enable-url-protocols=https.
  • App: a Show countries button under the list asks every shown device without a database to download it, polling until done; afterwards the footer shows the DB-IP attribution.

Snapshots

Before After

Sample connections carry countries in these snapshots; the sample devices have no database, so the button is not shown.

Testing

  • CountryTableTest (IPv4/IPv6 ranges, IPv4-mapped IPv6, reserved ranges), ConnectionRegistryTest.samples_nameEachHostsCountry
  • RemoteCountriesTest: a real KetchServer + RemoteKetch download the server's database and see country on its connections; a server without one fails closed
  • Manual run of DbIpCountryDatabase against db-ip.com: 8.8.8.8 → US, a Facebook IPv6 → IE, webtorrent.io (fake-IP DNS) → US via DoH, www.baidu.com → CN
  • Compiles for desktop, Android, CLI, iOS and web; design token, hardcoded text and localization tests pass

The Connections page offers to download DB-IP's free IP to Country Lite database (CC BY 4.0) on desktop and Android, then shows each endpoint's flag. Host names resolve through system DNS, falling back to DNS over HTTPS when the system answers with reserved addresses, as a proxy's fake-IP mode does.
Ketch takes a CountryLookup (DbIpCountryDatabase on desktop, Android and ketch server) that fills ActiveConnection.country, offered as the CountryDatabase controller and over GET /api/countries and POST /api/countries/download (net.countries). A remote device therefore downloads its own database, and the Connections page asks each shown device to download one.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-17T09:19:38.092542Z e81ef2e PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@claude

claude Bot commented Oct 17, 2026

Copy link
Copy Markdown

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e81ef2effc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@github-actions

Copy link
Copy Markdown
Contributor

Test Results

 1 962 files  + 5   1 990 suites  +5   22m 35s ⏱️ - 1m 21s
13 190 tests +22  12 929 ✅ +22  261 💤 ±0  0 ❌ ±0 
15 893 runs  +22  15 632 ✅ +22  261 💤 ±0  0 ❌ ±0 

Results for commit 793fcf2. ± Comparison against base commit 9693f43.

@linroid
linroid merged commit f168285 into main Oct 17, 2026
14 checks passed
@linroid
linroid deleted the feat/connection-country-flags branch October 17, 2026 10:49
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.

1 participant