Skip to content

Fix Cloudlog/Wavelog Test Connection over cleartext LAN + report the reason (#756) - #773

Merged
patrickrb merged 2 commits into
devfrom
fix/cloudlog-cleartext-756
Aug 25, 2026
Merged

Fix Cloudlog/Wavelog Test Connection over cleartext LAN + report the reason (#756)#773
patrickrb merged 2 commits into
devfrom
fix/cloudlog-cleartext-756

Conversation

@patrickrb

Copy link
Copy Markdown
Owner

Fixes #756.

What was wrong

The app disabled cleartext HTTP app-wide (network_security_config.xml with cleartextTrafficPermitted="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 plain http://. So HttpURLConnection threw Cleartext HTTP traffic … not permitted before a single packet left the phone — matching both reporters exactly: Test Connection fails, the server access log is empty, and tcpdump on the server sees no TCP attempt at all.

Two secondary problems compounded it:

  • Every failure (cleartext block, 404, wrong key, dead host) collapsed to a bare "Fail" with nothing in debug.log.
  • Installs without URL rewriting only answer at /index.php/api/...; the app only ever tried /api/....
  • A scheme-less address (192.168.15.20/cloudlog) threw MalformedURLException, and the Test path didn't .trim() a pasted newline.

The fix

  • network_security_config: permit cleartext by default (only affects the address the user typed), 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 or downgrade can't move those to http://.
  • New CloudlogEndpoint (pure/tested): normalizes the address (adds http:// 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; a ConnectionCheck carrying a human reason (HTTP status, host unreachable, key read-only/rejected); every attempt written to debug.log with the API key redacted.
  • LoggingSettings: shows the failure reason under "Fail"; trims the address/key before testing.

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

…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

codecov Bot commented Aug 25, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 16 lines in your changes missing coverage. Please review.
✅ Project coverage is 42.34%. Comparing base (551b0a2) to head (2f9db3b).

Files with missing lines Patch % Lines
.../radio/ks3ckc/ft8af/ui/settings/LoggingSettings.kt 0.00% 16 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@             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     
Flag Coverage Δ
android 16.90% <0.00%> (+0.24%) ⬆️
native 9.93% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
.../radio/ks3ckc/ft8af/ui/settings/LoggingSettings.kt 0.00% <0.00%> (ø)

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

🟡 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.php fallback.
  • 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.

Comment thread ft8af/app/src/main/res/xml/network_security_config.xml
Comment thread ft8af/app/src/main/java/com/k1af/ft8af/log/CloudlogEndpoint.java Outdated
Comment thread ft8af/app/src/main/java/com/k1af/ft8af/log/ThirdPartyService.java Outdated
Comment thread ft8af/app/src/main/java/com/k1af/ft8af/log/ThirdPartyService.java Outdated
- 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>
@patrickrb
patrickrb merged commit 6f8ab14 into dev Aug 25, 2026
17 checks passed
@patrickrb
patrickrb deleted the fix/cloudlog-cleartext-756 branch August 25, 2026 20:26
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