Skip to content

Refactor most workflows, add cross-rs for cross-compilation, and add new build targets - #584

Open
7d4d9e33 wants to merge 27 commits into
redlib-org:mainfrom
7d4d9e33:gh-actions-rebase2
Open

7d4d9e33 wants to merge 27 commits into
redlib-org:mainfrom
7d4d9e33:gh-actions-rebase2

Conversation

@7d4d9e33

@7d4d9e33 7d4d9e33 commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Overview

Cleaned up and split GitHub Actions setup, added cross-rs, and introduced a few new build targets.

Changes

  • Workflow Split & Cleanup:

    • Replaced pull-request.yml by splitting tests into code-test.yml and lints/formatting into lint-check.yml. Both run on push.
    • Use actions-rust-lang/rustfmt action instead of running rustfmt directly on lint-check.yml for its GitHub problem matcher output in the UI.
    • Moved version extraction into its own reusable workflow (parse-version.yml).
    • Added dedicated pr-*.yml workflows so PR workflow runs don't clutter up regular push runs in GitHub Actions history.
  • Artifacts & Releases:

    • build-artifacts.yaml now just uploads workflow artifacts on push/PR instead of creating GitHub releases.
    • Added optional debug profile builds alongside release in build-artifacts.yaml.
    • Added create-release.yml with workflow_dispatch to manually bundle release archives and create a draft release on GitHub when needed.
  • Cross-Compilation (cross-rs) & Target Updates:

    • Added Cross.toml and switched compilation steps to use cross. This makes cross-compiling easier in general and avoids header/LLVM conflict issues during MinGW builds on Ubuntu environments.
    • New build targets added:
      • x86_64-pc-windows-gnu (Windows 10+ 64-bit)
      • i686-unknown-linux-musl (Linux 32-bit musl)
      • i586-unknown-linux-musl (Older Linux 32-bit musl, disabled for now due to low demand)
      • i686-pc-windows-gnu (Windows 10+ 32-bit, disabled for now due to boring-sys2 build failures)
    • Existing targets (x86_64-unknown-linux-musl, aarch64-unknown-linux-musl, armv7-unknown-linux-musleabihf) were kept and now build through cross.

Notes

  • create-release.yml hasn't been tested on draft release creation yet, but I tested generating the release artifact bundle containing all files.

@7d4d9e33 7d4d9e33 changed the title Refactor workflows, add cross-rs for cross-compilation, and add new build targets Refactor most workflows, add cross-rs for cross-compilation, and add new build targets Oct 11, 2026
boringssl either require sse2 as baseline or disable assembly optimizations, otherwise compilation will fail
latest cross image seems to not include clang (headers) anymore, so we have to install them ourselves
just in case anyone needs it
follow upstream
…onfig

i am not sure this can be touched, comment for that packages kept for reference later on
Comment thread Cross.toml
]

[target.x86_64-pc-windows-gnu]
image = "ghcr.io/cross-rs/x86_64-pc-windows-gnu:main"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main reason i used main version instead of default cross-rs image is to be able to pick newer nasm, otherwise compilation will fail because curent stable cross-rs image uses very old version of Ubuntu (18.04) thus nasm also outdated.

Linux targets seems to not suffer from this issue.

Same goes for i686-pc-windows-gnu target

kashhq added a commit to kashhq/redlib that referenced this pull request Nov 19, 2026
)

## Why

From 20:35 UTC on 2026-11-19, Reddit refused every request from the instance's IP for 15–20 minutes. Freshly minted tokens were refused within a second, and the same image ran from the VPS was served. Volume wasn't the cause: about 150 API calls a day, at most 20 in a minute, and none in the hour before the block.

What sets redlib apart is that it claims to be the Android app only in its `User-Agent`. Everything else differs from the app:

- **Handshake and browser headers.** `src/transport.rs` picked Chrome 145 (Android) or Firefox 147 (Windows) at random, along with that browser's default headers. So half the processes sent `sec-ch-ua: "Chromium";v="145"…` and `sec-fetch-*` right beside `User-Agent: Reddit/…/Android`.
- **A new device every day.** Every token renewal (about daily) and every restart minted a new random device. Its version came from a stale 2026.28–30 pool, its Android version was a random 9–14, and nothing tied the two together.
- **Shuffled headers.** Headers came from a `HashMap` and were then shuffled per request (upstream redlib-org#324). No real app does either.
- **Mint details.** The mint scopes and the retry header differed from the app's, and the client echoed the server's `x-reddit-session`.

## What

The source of truth is [Averyy/wafer](https://github.com/Averyy/wafer/blob/main/docs/ref-reddit.md) (Apache-2.0, credited in `docs/fork.md`). It captured the real app 2026.44.0: ClientHellos via emulator tcpdump, and header order from the app's decompiled interceptors and Chromium's `//net`.

- **Two transports, as the app has two network stacks** (`src/transport.rs`):
  - `OKHTTP` serves the mint, REST and media. It uses OkHttp-on-Conscrypt TLS: wafer's cipher, sigalg and curve lists, BoringSSL's fixed extension order, no GREASE, OCSP and SCT (JA4 `t13d1514h2_8daaf6152771_43ade6aba3df`). Its HTTP/2 is OkHttp's: 16 MiB windows, a single SETTINGS entry, `m,p,a,s` pseudo-header order.
  - `CRONET` serves GraphQL. It is wreq-util `Chrome143` on Android with **no default headers**: the app's embedded Cronet 143 sends this hello, and Cronet adds no browser headers.
  - The browser headers and the random Chrome/Firefox choice are gone. wreq stays pinned; there is no bump.
- **One persistent install** (`src/app_install.rs`, SQLite table `app_install`):
  - It holds the device id, a real Play release (version, build, minimum Android), a phone (model, density, width, decoders), an ad id, `X-Reddit-P-Device-ID`, and the loid.
  - **Renewals and restarts keep it**, and send the stored loid back on the mint, as the app does.
  - **A blocked rotation replaces it.** In October Reddit flagged a long-lived token/device pair and a fresh pair fixed it (`docs/fork.md`), so that behaviour stays.
  - The install is saved before each mint as well as after. If a replacement's mints all fail and the process restarts, it loads the new install, not the flagged one.
  - A stored release that leaves the table moves to a current build and keeps its ids, the way an app update would.
- **Each request type's headers in the app's exact order and values** (`src/app_wire.rs`, pure builders). They go on the wire through wreq's `OrigHeaderMap`, so nothing is shuffled and nothing is added except `host` / `:authority`.
  - Mint: wafer's `token_request` order. Scopes `["*","email","pii","adsread","adsedit"]`, compact body.
  - REST: wafer's `read_headers` order. The quarantine `Cookie` is sent only when opted in, so the empty `Cookie:` header is gone. `Host` is no longer set by hand.
  - GraphQL: wafer's `gql_headers` order, including `Content-Length` first, `X-Reddit-Retry: attempt=<n>, max=3`, the `X-APOLLO-OPERATION-*` headers, `accept`, `priority: u=1, i`, and `Accept-Encoding: gzip, deflate`.
  - The `x-reddit-session` header is now the app's own HMAC-SHA512 analytics session. It is renewed after 30 idle minutes, and the server's copy is no longer echoed.
  - Media: the install's UA and `Accept: */*`, and `Accept-Encoding: gzip` except on a ranged request (OkHttp's rule). The app's image-loader headers are unverified, which the code notes.
- **Dependencies.** `boring2` is now direct, pinned to wreq's locked `5.0.0-alpha.13`, for HMAC and SHA-384, so no crate is added. `tegen` is removed, and with it `getrandom 0.2` (`cargo audit` findings drop from 16 to 6). `scripts/update_oauth_resources.sh` is gone too: it couldn't produce build numbers or minimum Android versions, so the release table is now hand-maintained.
- **Order and docs.** `db::init()` now runs before the OAuth bootstrap. Docs: `docs/fork.md` "App-coherent identity", a dated decisions entry, and AGENTS.md (architecture and startup order). Version 0.44.7 → 0.45.0.

## Verification

- **Offline:** `make ci-quick ci-unit` passes, 209 tests. The tests assert the full ordered header list for each request type. A local-listener test sends each request type through the real transports and checks the raw request: wreq adds only `host`. There are also unit tests for the session signature, the install migration and the Store, and TokenManager tests that a renewal keeps the install while a block replaces it.
- **Live, from the VPS IP** (Reddit serves it; image built on linux-box from `5a174b3`, run in a throwaway container, removed afterwards):

  | Route | Result |
  |---|---|
  | `/r/rust` | 200, 24 posts |
  | a thread | 200, post plus comments |
  | `/user/spez` | 200 |
  | `/search?q=rust` | 200, 25 posts |
  | media proxy (`/preview/…`) | 200, image |
  | token mint (×4 across two boots) | 200 |

  Every GraphQL operation returned 200: SubredditInfoByName, SubredditFeedElements, PostsByIds, PostComments, LiveCommentsByIds, UserProfileDetails, UserSubmittedPosts, SubmittedComments, SearchPosts, SearchCommunities. No 🚫, ⛔ or WARN lines.
  - **The install survives a restart:** `[📱] new install ff31e098`, then after `docker restart` `[📱] using install ff31e098`.
  - **REST gets past the gate now.** Same route (`/r/rust/random`) from the same IP: the production image got the network-policy **403** (and switched REST off for 10 minutes), while this branch reached the API, which answered **400** because Reddit retired `/r/random`.

## Not in this PR

- **IP-level blocks.** A coherent identity makes us harder to single out, but it can't lift a block on the IP itself. The 20:35 block lifted by itself.
- **Hand-maintained values:** `RELEASES` (2026.42–44) and the Cronet major (143) must follow the app as it updates (`docs/fork.md`).
- **GraphQL `variables` key order** is still alphabetical (`serde_json::Value`). Fixing it needs the crate-wide `preserve_order` feature. The top-level keys and `persistedQuery` are in the app's order.
- **Not reproduced:** the app's HTTP/3 to gql-fed (wreq has no QUIC) and its non-data companion calls.

Upstream review: no upstream commits after `.upstream-rev`. The four open PRs updated since the PR mark (redlib-org#613, redlib-org#603, redlib-org#584, redlib-org#581) don't concern blocking, tokens or security, and redlib-org#603 is already in the fork. I'll move the marks in a separate small PR.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Kind: product
Kind-By: label
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kashhq added a commit to kashhq/redlib that referenced this pull request Nov 19, 2026
## Why

The monthly upstream review was done today while diagnosing the 2026-11-19 IP block (#98). It found nothing to port, so only the review mark and the record move.

## What

- `.upstream-pr-rev` moves to the time of this review. `.upstream-rev` stays at `ba116c1`, because upstream has no commits after it.
- `docs/fork.md` "Reviews" gets the entry:
  - **Skipped:** redlib-org#613, redlib-org#603, redlib-org#584 and redlib-org#581, each with its reason.
  - **Found elsewhere and taken instead:** wafer's capture of the real app, which became #98. Nachtalb/redlib #80 found Reddit refusing anonymous REST to newer Chrome and Firefox handshakes, which explains the old transport.

## Verification

`make ci-quick` (pre-commit) and `make ci-unit` (pre-push) pass. Docs and the mark only; no code changes.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Kind: tooling
Kind-By: label
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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