Fix Cloudlog/Wavelog Test Connection over cleartext LAN + report the reason (#756) - #773
Conversation
…756) The app forbade cleartext HTTP app-wide (network_security_config cleartextTrafficPermitted="false"), so HttpURLConnection threw before a single packet left the phone whenever a self-hosted Cloudlog/Wavelog/Nextlog server was addressed over plain http:// on a LAN — exactly the reporters' symptom: "Test Connection" fails, and tcpdump on the server sees no TCP attempt at all. Every failure also collapsed to a bare "Fail" with nothing in debug.log, so the cause was invisible. Changes: - network_security_config: permit cleartext by default (only affects the user-typed logbook address), and pin every hard-coded public API the app itself calls (qrz.com, pota.app, pskreporter.info, cognito/amazonaws, github.com, ft8af.app) to TLS via domain-config so a typo/downgrade can't move those to http://. - New CloudlogEndpoint: normalizes a hand-typed address (adds http:// for IPv4/LAN names, https:// for public hostnames; trims; single trailing slash) and yields ordered candidate URLs so installs without URL rewriting — which only answer at /index.php/api/... — are tried too, then pins the variant that worked. - ThirdPartyService: connect/read timeouts on all logbook HTTP; status-aware GET/POST; a ConnectionCheck that carries a human reason (HTTP status, host unreachable, key read-only/rejected); every attempt logged to debug.log with the API key redacted. - LoggingSettings: show the failure reason under "Fail", and trim the address/key before the test (a pasted newline used to break it). Tests: CloudlogEndpointTest (normalize/candidate/remember/describe), ThirdPartyServiceCloudlogAuthTest (auth-response interpretation). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev #773 +/- ##
============================================
+ Coverage 42.29% 42.34% +0.05%
Complexity 226 226
============================================
Files 267 267
Lines 31730 31830 +100
Branches 3634 3651 +17
============================================
+ Hits 13419 13479 +60
- Misses 18054 18093 +39
- Partials 257 258 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🟡 Changes recommended
The global cleartext policy and URL logging introduce security risks, while fallback detection and request-layer tests need correction.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Improves Cloudlog-compatible connectivity for LAN and non-rewritten installations while exposing actionable failure details.
Changes:
- Normalizes Cloudlog endpoints and adds
index.phpfallback. - Enables LAN cleartext traffic while restricting known public APIs.
- Adds connection diagnostics, timeouts, UI feedback, and unit tests.
File summaries
| File | Description |
|---|---|
ThirdPartyServiceCloudlogAuthTest.java |
Tests authentication response handling. |
CloudlogEndpointTest.java |
Tests endpoint normalization and candidates. |
network_security_config.xml |
Revises cleartext policy. |
LoggingSettings.kt |
Displays connection failure details. |
ThirdPartyService.java |
Adds status-aware Cloudlog request handling. |
CloudlogEndpoint.java |
Implements endpoint normalization and fallback. |
Review details
- Files reviewed: 6/6 changed files
- Comments generated: 4
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
- network_security_config: a domain-config can't express "cleartext only
for the host the user typed", so the base-config stays permissive, but the
exposure is now contained: support.qq.com joins the pinned-TLS list, and
the embedded WebViews (QRZ lookup, FAQ) refuse non-https navigations via
a new, tested WebNavigationPolicy so link-following inside them stays
HTTPS-only as before.
- CloudlogEndpoint.candidates: detect the no-rewrite form by a terminal
/index.php/ *path* segment instead of contains("index.php"), so a host
like index.php.example still gets the fallback.
- ThirdPartyService.redactUrlApiKey also masks authority user-info
(http://user:pw@host/...) so debug.log never carries a basic-auth
password.
- Extract the GET/POST candidate walk into cloudlogRequest() behind a
package-private CloudlogTransport so the 404-only fallback, stop-on-other
status/exception and remembered-variant reordering are unit-tested.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Fixes #756.
What was wrong
The app disabled cleartext HTTP app-wide (
network_security_config.xmlwithcleartextTrafficPermitted="false"). The only user-supplied host in the app is the Cloudlog/Wavelog/Nextlog logbook server, which is very often self-hosted on a LAN over plainhttp://. SoHttpURLConnectionthrewCleartext HTTP traffic … not permittedbefore a single packet left the phone — matching both reporters exactly: Test Connection fails, the server access log is empty, andtcpdumpon the server sees no TCP attempt at all.Two secondary problems compounded it:
debug.log./index.php/api/...; the app only ever tried/api/....192.168.15.20/cloudlog) threwMalformedURLException, and the Test path didn't.trim()a pasted newline.The fix
domain-config, so a typo or downgrade can't move those tohttp://.CloudlogEndpoint(pure/tested): normalizes the address (addshttp://for IPv4/LAN names,https://for public hostnames; trims; one trailing slash) and returns ordered candidate URLs so a no-rewrite install (/index.php/api/...) is tried too, pinning whichever variant answered.ThirdPartyService: connect/read timeouts on all logbook HTTP; status-aware GET/POST; aConnectionCheckcarrying a human reason (HTTP status, host unreachable, key read-only/rejected); every attempt written todebug.logwith the API key redacted.Tests
CloudlogEndpointTest— normalize / candidate ordering / index.php fallback / remember-working / failure description.ThirdPartyServiceCloudlogAuthTest— auth-response interpretation (valid rw / read-only / rejected / not-an-API).Unit tests pass; debug APK builds.
🤖 Generated with Claude Code