Skip to content

fix(domain_fronter): large download resilience, stream timeout decoupling, and compact log timestamps#1346

Open
CaptainMirage wants to merge 3 commits into
therealaleph:mainfrom
CaptainMirage:fix/download-res-reli
Open

fix(domain_fronter): large download resilience, stream timeout decoupling, and compact log timestamps#1346
CaptainMirage wants to merge 3 commits into
therealaleph:mainfrom
CaptainMirage:fix/download-res-reli

Conversation

@CaptainMirage
Copy link
Copy Markdown
Contributor

@CaptainMirage CaptainMirage commented May 22, 2026

Summary

  • Large download resilience — range requests (Range: bytes=N-) are
    now routed through a parallel resume streaming path. Idempotent
    exit-node timeouts fall back to direct Apps Script instead of aborting.
    TLS close_notify is sent on shutdown so wget/curl can resume from
    the correct offset.

  • Stream timeout decoupling — splits request_timeout_secs
    (header/connect phase, 30 s) from a new stream_timeout_secs
    (per-chunk body idle, default 300 s) so large transfers through Apps
    Script are no longer killed mid-body by the batch timeout firing
    during the drain phase.

  • Compact log timestamps — replaces the noisy ISO 8601 default
    (2026-05-22T12:56:28.992990Z) with [2026-05-22]-[12:56:28.9].
    Terminal output gets ANSI colouring (orange date, light blue time,
    gray structure); UI log panel and Android Logcat stay plain text.

Here are the log timestamp colours; they may vary slightly depending on the terminal, since they use ANSI colouring :
image


i also looked into fixing WebSocket support in Apps Script proxy mode, but in practice i dropped it

the main issue is that Apps Script web app requests don’t stay alive long enough for a stable long-lived WebSocket path, in my testing, they die around the ~6 minute mark, which matches the general Apps Script execution/runtime limits. I even built and tested a local ws tunnel layer for this, but the connection still could not survive past that limit reliably

that would already make the Apps Script WebSocket path fragile, but the bigger problem is what happens after the upstream socket dies. Some services (Discord especially) can behave badly here depending on how the client/library handles the close, so just letting the tunnel die and hoping reconnect works is not good enough. To make it usable, it would need a more dynamic reconnect/rebind system on top

at that point it becomes a lot of extra complexity for something that still has a built-in timeout ceiling every few minutes, while the Google Cloud path already solves the problem properly, so i dropped it

for lighter WebSocket use cases, like short-lived notifications or some live-feed scenarios, this limitation may be less painful. But for something like Discord, where long-lived stable gateway connections matter, it is too annoying to justify

Inside the MITM TLS session, detect Connection: Upgrade + Upgrade:
websocket before hitting the Apps Script relay. Establish a direct TLS
connection to the real server (via upstream_socks5 if configured),
relay the upgrade handshake, then splice both directions with
copy_bidirectional. Apps Script cannot hold persistent connections so
the bypass is the only viable path for wss://.

Split request_timeout_secs (header/connect, 30s) from a new
stream_timeout_secs (per-chunk body idle, default 300s) so large range
downloads through Apps Script are not killed mid-transfer by the
batch_timeout firing during the body drain phase.
Handle idempotent exit-node timeouts by falling back to direct Apps Script, route Range: bytes=N- requests through parallel resume streaming, and send TLS close_notify on shutdown so wget/curl can resume from the correct offset.
Adds src/logging.rs with CompactUtcTime (FormatTime impl, time crate).
Replaces the default ISO 8601 timestamp with [2026-05-22]-[12:56:28.9].
ANSI-gated colouring on terminals: orange date digits, light blue time
digits, darker shades on internal punctuation, gray brackets/separator,
green separator dash. Plain text fallback for the UI log panel and
Android Logcat. Wired into all three subscriber setups (main, UI, JNI).

Also fixes a compile error in the UI binary: stream_timeout_secs was
added to Config in b3c51e0 but never plumbed through FormState. Added
to the struct, both init paths (load-from-config and fresh-default),
to_config() output, and ConfigWire so Save doesn't drop a non-default
value.
@github-actions github-actions Bot added the type: fix fix: PR — auto-applied by release-drafter label May 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: fix fix: PR — auto-applied by release-drafter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant