Merge branch 'main' into wt/t_16e835ef
This commit is contained in:
commit
4623f78a69
19 changed files with 532 additions and 62 deletions
|
|
@ -43,9 +43,9 @@ env:
|
|||
CARGO_REGISTRY_VOLUME: onionwire-cargo-registry
|
||||
CARGO_TARGET_VOLUME: onionwire-target-ci
|
||||
BUILD_CONTAINER: onionwire-ci-${{ github.run_id }}
|
||||
# The SDK job gets its own target volume: it resolves the root crate with
|
||||
# `rustls` instead of `native-tls`, so sharing a target dir would thrash both
|
||||
# jobs' feature-unified artifacts.
|
||||
# The SDK job gets its own target volume: `crates/onionwire-sdk` is a
|
||||
# separate cargo workspace with its own lockfile and its own crate set, so
|
||||
# sharing a target dir with the root job would thrash both.
|
||||
SDK_CARGO_TARGET_VOLUME: onionwire-target-ci-sdk
|
||||
SDK_BUILD_CONTAINER: onionwire-ci-sdk-${{ github.run_id }}
|
||||
# The fuzz job builds on nightly with a release profile + debug=line-tables-only;
|
||||
|
|
@ -82,9 +82,7 @@ jobs:
|
|||
-v "$CARGO_TARGET_VOLUME":/target \
|
||||
-w /src \
|
||||
"$RUST_IMAGE" \
|
||||
sh -euxc 'mkdir -p /src && tar xzf - -C /src && cd /src \
|
||||
&& apt-get update \
|
||||
&& apt-get install -y --no-install-recommends pkg-config libssl-dev \
|
||||
sh -euxc 'mkdir -p /src /target/tmp && tar xzf - -C /src && cd /src \
|
||||
&& rustup component add clippy \
|
||||
&& cargo test --locked \
|
||||
&& cargo clippy --locked --all-targets -- -D warnings'
|
||||
|
|
@ -93,12 +91,19 @@ jobs:
|
|||
docker rm -f "$BUILD_CONTAINER" > /dev/null
|
||||
|
||||
# `crates/onionwire-sdk` is a SEPARATE cargo workspace: its own Cargo.lock and
|
||||
# a path dependency on the root crate, resolved with `rustls` instead of
|
||||
# `native-tls`. The `test` job above therefore never compiles it, so a
|
||||
# root-crate signature change (`Node::send` gaining the outbox result, the
|
||||
# SQLCipher passphrase entry points) breaks the Android SDK — and the tagged
|
||||
# release AAR, since android-release.yml only builds on `v*.*.*` — while both
|
||||
# the root suites and local `cargo test` stay green. Build it here.
|
||||
# a path dependency on the root crate. The `test` job above therefore never
|
||||
# compiles it, so a root-crate signature change (`Node::send` gaining the
|
||||
# outbox result, the SQLCipher passphrase entry points) breaks the Android SDK
|
||||
# — and the tagged release AAR, since android-release.yml only builds on
|
||||
# `v*.*.*` — while both the root suites and local `cargo test` stay green.
|
||||
# Build it here.
|
||||
#
|
||||
# The root `test` job no longer installs `pkg-config`/`libssl-dev` — the root
|
||||
# crate defaults to Arti's rustls backend, so TLS needs no system OpenSSL.
|
||||
# The `rusqlite` `bundled-sqlcipher-vendored-openssl` feature that both jobs
|
||||
# use compiles OpenSSL from source, which needs `perl` and `make` (present in
|
||||
# the `rust:*-bookworm` image), not the `-dev` headers. This job keeps the
|
||||
# install: the Android SDK build is unchanged by the root crate's TLS default.
|
||||
sdk:
|
||||
runs-on: docker
|
||||
timeout-minutes: 120
|
||||
|
|
@ -123,7 +128,7 @@ jobs:
|
|||
-v "$SDK_CARGO_TARGET_VOLUME":/target \
|
||||
-w /src \
|
||||
"$RUST_IMAGE" \
|
||||
sh -euxc 'mkdir -p /src && tar xzf - -C /src && cd /src/crates/onionwire-sdk \
|
||||
sh -euxc 'mkdir -p /src /target/tmp && tar xzf - -C /src && cd /src/crates/onionwire-sdk \
|
||||
&& apt-get update \
|
||||
&& apt-get install -y --no-install-recommends pkg-config libssl-dev \
|
||||
&& rustup component add clippy \
|
||||
|
|
|
|||
2
Cargo.lock
generated
2
Cargo.lock
generated
|
|
@ -2645,6 +2645,7 @@ dependencies = [
|
|||
"ratatui",
|
||||
"rpassword",
|
||||
"rusqlite",
|
||||
"rustls",
|
||||
"safelog",
|
||||
"serde_json",
|
||||
"sha2",
|
||||
|
|
@ -3500,6 +3501,7 @@ checksum = "6725596c3f2c3a0aef021139e145d4eafe314a6623e4680ca83852b2c67ab2ba"
|
|||
dependencies = [
|
||||
"log",
|
||||
"once_cell",
|
||||
"ring",
|
||||
"rustls-pki-types",
|
||||
"rustls-webpki",
|
||||
"subtle",
|
||||
|
|
|
|||
22
Cargo.toml
22
Cargo.toml
|
|
@ -8,16 +8,16 @@ license = "MIT"
|
|||
publish = false
|
||||
repository = "https://github.com/sirius0xdev/onionwire"
|
||||
|
||||
# The Linux TUI build is unchanged: `default` keeps Arti's native-tls
|
||||
# (OpenSSL) backend exactly as before, and ratatui remains a normal
|
||||
# dependency so `src/tui.rs` is untouched.
|
||||
# TLS backend: `rustls` by default, `native-tls` (OpenSSL) opt-in.
|
||||
#
|
||||
# Android has no OpenSSL in the NDK, so the SDK crate depends on this crate
|
||||
# with `default-features = false, features = ["rustls"]`. Arti marks these two
|
||||
# backends non-additive, so exactly one may be selected per build graph — hence
|
||||
# exposing them as crate features.
|
||||
# Arti marks these two backends non-additive, so exactly one may be selected per
|
||||
# build graph — hence exposing them as crate features. rustls is the default
|
||||
# because Android has no OpenSSL in the NDK and the Linux TUI/release build does
|
||||
# not need a system OpenSSL for TLS either. (OpenSSL is still *compiled* into
|
||||
# every build by rusqlite's `bundled-sqlcipher-vendored-openssl`, vendored and
|
||||
# static: that is the SQLCipher layer, not Arti's TLS.)
|
||||
[features]
|
||||
default = ["native-tls"]
|
||||
default = ["rustls"]
|
||||
native-tls = ["arti-client/native-tls"]
|
||||
rustls = ["arti-client/rustls"]
|
||||
|
||||
|
|
@ -37,6 +37,12 @@ tokio = { version = "1", features = ["rt-multi-thread", "macros", "io-util", "ti
|
|||
tor-cell = "0.46"
|
||||
tor-hsservice = "0.46"
|
||||
tor-rtcompat = { version = "0.46", features = ["tokio"] }
|
||||
# Direct dependency only to select rustls's crypto provider: Arti pulls rustls in
|
||||
# through `tor-rtcompat` with `default-features = false`, and rustls 0.23
|
||||
# resolves its provider from its OWN `ring`/`aws-lc-rs` features, so without this
|
||||
# line the rustls backend compiles with no provider at all and the first TLS
|
||||
# config fails. Same reasoning (and pin) as `crates/onionwire-sdk/Cargo.toml`.
|
||||
rustls = { version = "0.23", default-features = false, features = ["ring"] }
|
||||
ratatui = { version = "0.30.2", default-features = false, features = ["crossterm"] }
|
||||
x25519-dalek = { version = "2", features = ["static_secrets"] }
|
||||
snow = "0.10"
|
||||
|
|
|
|||
|
|
@ -88,8 +88,10 @@ cargo install --path . --locked --force
|
|||
# lands in ~/.cargo/bin/onionwire
|
||||
```
|
||||
|
||||
Build needs `pkg-config` and OpenSSL 3 headers (`libssl-dev` / `openssl-devel`) —
|
||||
the released binaries link `libssl.so.3` dynamically.
|
||||
Build needs a C toolchain plus `perl` and `make`: SQLCipher is compiled from
|
||||
vendored OpenSSL sources (`rusqlite` feature `bundled-sqlcipher-vendored-openssl`).
|
||||
No system OpenSSL headers or `pkg-config` are required — Arti's TLS backend is
|
||||
`rustls`, and the binaries carry no dynamic `libssl` dependency.
|
||||
|
||||
### Two instances on one machine
|
||||
|
||||
|
|
@ -134,6 +136,7 @@ Focus starts on the composer so typing works immediately. `Tab` cycles panes; `j
|
|||
| `F4` | Rotate **onion** (locator only) |
|
||||
| `F5` | Selected friend's profile (`/who`) |
|
||||
| `F6` | Wallet screen (receive QR, balance, transfers) |
|
||||
| `F8` | Rotate **prekey** (hard cut: every friend re-pastes the invite) |
|
||||
| Enter | Send chat to the selected friend, or run a `/command` |
|
||||
| `Esc` | Close overlay / back to Main / clear composer |
|
||||
| `Ctrl-Q` | Quit: type `CLEAR`+Enter to wipe history, `QUIT`+Enter to leave it, Esc to stay |
|
||||
|
|
@ -403,7 +406,7 @@ FORGEJO_TOKEN=<pat> scripts/build-release-local.sh v0.2.1
|
|||
|
||||
Workflows (Forgejo Actions, `.forgejo/workflows/`):
|
||||
|
||||
- [`.forgejo/workflows/ci.yml`](.forgejo/workflows/ci.yml) — two jobs on the Pi runner (`docker` label), serialized by `onionwire-ci-pi`. `test`: `cargo test --locked` + `cargo clippy --all-targets -- -D warnings` at the repo root. `sdk`: the same for `crates/onionwire-sdk` (separate cargo workspace — own `Cargo.lock`, root crate by path, `rustls` instead of `native-tls` — so a root signature change cannot silently break the Android SDK). Both run on `main` and PRs when `src/`, `crates/`, `tests/`, `Cargo.toml`, `Cargo.lock`, or this workflow change (ignored Tor-live tests are not run). `workflow_dispatch` always runs the suite.
|
||||
- [`.forgejo/workflows/ci.yml`](.forgejo/workflows/ci.yml) — two jobs on the Pi runner (`docker` label), serialized by `onionwire-ci-pi`. `test`: `cargo test --locked` + `cargo clippy --all-targets -- -D warnings` at the repo root. `sdk`: the same for `crates/onionwire-sdk` (separate cargo workspace — own `Cargo.lock`, root crate by path, so a root signature change cannot silently break the Android SDK). Both run on `main` and PRs when `src/`, `crates/`, `tests/`, `Cargo.toml`, `Cargo.lock`, or this workflow change (ignored Tor-live tests are not run). `workflow_dispatch` always runs the suite.
|
||||
- [`.forgejo/workflows/android-ci.yml`](.forgejo/workflows/android-ci.yml) — the android side of CI, on the `docker-amd64` runner: builds `:sdk:assembleRelease` + `:app:assembleRelease` with the same script the release uses (`scripts/build-android-local.sh`, Rust for `aarch64-linux-android` via cargo-ndk + UniFFI bindings) and verifies the packaged `libonionwire_sdk.so`, checksums and APK badging. Debug keystore, no publish, no tag. Runs on `main` and PRs when `android/`, `src/`, `crates/`, `Cargo.toml`, `Cargo.lock` or `scripts/build-android-local.sh` change. Same concurrency group **and** the same runner volumes as `android-release.yml`, so a PR build never fights a release build over the SDK/NDK, cargo and Gradle caches.
|
||||
- [`.forgejo/workflows/release.yml`](.forgejo/workflows/release.yml) — manual, batched release (`workflow_dispatch` only: `dry_run`, `bump`, `version`, `tag`): next tag, aarch64 (`docker`) + x86_64 (`docker-amd64`), one release, fail-closed tag delete on failure. Dispatch [`android-release.yml`](.forgejo/workflows/android-release.yml) with that tag to add the APK + AAR (no automatic trigger fires on this Forgejo; it is `workflow_dispatch` only). Concurrency group `onionwire-ci-pi` (same as `ci.yml`, `cancel-in-progress: false`) so cargo jobs do not overlap on the Pi. Amd64 dind is serialized by runner `capacity=1`.
|
||||
- [`.forgejo/workflows/android-release.yml`](.forgejo/workflows/android-release.yml) — amd64-only Android build (dispatch-only on this Forgejo; wakes from an explicit `tag=` input, not a tag push).
|
||||
|
|
|
|||
|
|
@ -130,8 +130,13 @@ fun parseDelivery(direction: String, delivery: String?): Delivery? {
|
|||
/**
|
||||
* Chat-level delivery summary derived from the rendered rows.
|
||||
*
|
||||
* Mirrors `src/tui.rs::OutboxSummary`: `Queued` + `Sending` are "still coming",
|
||||
* `Failed` is terminal and keeps a fail-closed statement on screen.
|
||||
* The *counting* rule mirrors `src/tui.rs::OutboxSummary`: `Queued` + `Sending`
|
||||
* are "still coming", `Failed` is terminal and keeps a fail-closed statement on
|
||||
* screen. The TUI's footer wording for an outstanding row also carries the
|
||||
* reachability statement and retry clock (`peer unreachable, queued (n/8, retry
|
||||
* 45s)`); on Android that per-row detail already lives in the row's own
|
||||
* `queued (try n/8, retry …)` marker (`OutboxDetail.kt`), so the summary stays
|
||||
* the short count form instead of repeating it.
|
||||
*/
|
||||
data class OutboxSummary(
|
||||
val queued: Int = 0,
|
||||
|
|
|
|||
1
crates/onionwire-sdk/Cargo.lock
generated
1
crates/onionwire-sdk/Cargo.lock
generated
|
|
@ -2776,6 +2776,7 @@ dependencies = [
|
|||
"ratatui",
|
||||
"rpassword",
|
||||
"rusqlite",
|
||||
"rustls",
|
||||
"safelog",
|
||||
"serde_json",
|
||||
"sha2",
|
||||
|
|
|
|||
|
|
@ -7,11 +7,8 @@ description = "OnionWire Android/Kotlin SDK: in-process Arti onion transport, No
|
|||
license = "MIT"
|
||||
publish = false
|
||||
|
||||
# Standalone workspace on purpose.
|
||||
# Arti's TLS backends (`native-tls` vs `rustls`) are non-additive: exactly one
|
||||
# may be enabled per feature resolution. The Linux TUI crate keeps native-tls,
|
||||
# Android has no OpenSSL in the NDK and needs rustls. Two separate workspaces
|
||||
# keep the two resolutions from colliding — this crate path-depends on the
|
||||
# Standalone workspace on purpose: the SDK carries its own lockfile and its own
|
||||
# crate set (Android: `static-sqlite`, rustls TLS), so it path-depends on the
|
||||
# root package without joining its feature graph.
|
||||
[workspace]
|
||||
resolver = "2"
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ output.
|
|||
## Why this crate has its own Cargo workspace
|
||||
|
||||
Arti's TLS backends are **non-additive**: exactly one of `native-tls` and
|
||||
`rustls` may be enabled in a given feature resolution. The Linux TUI keeps
|
||||
`native-tls` (OpenSSL, as it always has). Android has no OpenSSL in the NDK, so
|
||||
this crate selects `rustls` plus `static-sqlite` (no system `libsqlite3` on
|
||||
Android). Two separate workspaces keep the two resolutions from colliding.
|
||||
`rustls` may be enabled in a given feature resolution. The root crate defaults
|
||||
to `rustls` (Linux TUI and releases), so this crate does not differ from the
|
||||
root on TLS; it does add `static-sqlite`, because Android has no system
|
||||
`libsqlite3`. Two separate workspaces keep the two resolutions from colliding.
|
||||
|
|
|
|||
|
|
@ -23,9 +23,11 @@ part of a Tor upgrade.
|
|||
Two crate features re-expose Arti's TLS backends, which Arti marks
|
||||
**non-additive** — exactly one may be selected per build graph:
|
||||
|
||||
* `native-tls` (default) → Linux TUI build, via OpenSSL.
|
||||
* `rustls` → the Android SDK crate (`crates/onionwire-sdk`), because the NDK has
|
||||
no OpenSSL.
|
||||
* `rustls` (**default**) → every build: the Linux TUI, the released binaries and
|
||||
the Android SDK. No system OpenSSL is needed for TLS; the root `Cargo.toml`
|
||||
pins rustls's `ring` feature so the crypto provider resolves from crate
|
||||
features (without it the rustls backend compiles with no provider).
|
||||
* `native-tls` → opt-in only, via OpenSSL.
|
||||
|
||||
Published Arti releases move all four crates together in lockstep. Bump them as
|
||||
**one set**. A mixed set (e.g. `arti-client` 0.47 with `tor-hsservice` 0.46) is
|
||||
|
|
@ -118,8 +120,9 @@ issue the watcher files.
|
|||
7. Confirm the fail-closed path by hand if the publish wait changed at all:
|
||||
with the write timeout still 360s, a peer whose onion is down must fail the
|
||||
send. There is no outbox in v1 — the message must not be silently queued.
|
||||
8. Rebuild the Android target — Arti's TLS backends are non-additive, and this
|
||||
is the build that exercises the `rustls` feature:
|
||||
8. Rebuild the Android target. The root crate defaults to `rustls` now, so this
|
||||
is less about exercising a non-default feature than about proving the default
|
||||
still cross-compiles where OpenSSL does not exist:
|
||||
```
|
||||
scripts/build-android-local.sh
|
||||
```
|
||||
|
|
|
|||
|
|
@ -32,7 +32,8 @@ Each install holds:
|
|||
- **Identity** — ed25519 keypair. The 32-byte public key **is** the person.
|
||||
Roster primary key. Displayed as 64 lowercase hex chars (the fingerprint).
|
||||
- **Prekey** — x25519 keypair. This is the Noise IK *static*. It is long-lived
|
||||
in v1. Rotating the onion (`F4`) does **not** rotate it.
|
||||
in v1 — rotate it with `F8`, which hard-cuts every stored session. Rotating
|
||||
the onion (`F4`) does **not** rotate it.
|
||||
- **Onion** — Tor v3 address. Locator only. Disposable.
|
||||
|
||||
A friend is `{identity_pk, current_onion, current_prekey_pk}`. Pasting the same
|
||||
|
|
|
|||
|
|
@ -16,6 +16,10 @@ A signed `loc` frame (`onion`, `ts`, `sig`) rewrites a friend’s locator **only
|
|||
|
||||
`F4` changes the locator only. The identity key is unchanged. Anyone who already has your pubkey can still prove they are talking to you, and a later invite paste with the same `k` updates their row. To become a new person, `/wipe-all` (new identity key). There is no in-band unfriend/revoke in v1.
|
||||
|
||||
## Rotating the prekey is a hard cut, and it is wider than F4
|
||||
|
||||
`F8` rotates the long-lived signed prekey. The identity key and the onion are unchanged, but the prekey is our Noise static **and** the seed of the bootstrap ratchet epoch, so once it moves nothing is reachable any more: a friend's dial uses the prekey they pinned from your invite, and their stored epoch is derived from the old one. There is no push path for a prekey — it only travels inside a signed invite — so every friend, online or offline, has to F3-paste the new invite before chat works in either direction again. F8 therefore also drops the local ratchet state for every friend, exactly as a peer's own prekey change does. Rotating the prekey shrinks the forward-secrecy window of the long-lived static; it is not a revocation (the old invite holder still learns nothing new, but they also cannot talk to you).
|
||||
|
||||
## Your store is encrypted
|
||||
|
||||
The sqlite store is SQLCipher (`rusqlite` feature `bundled-sqlcipher-vendored-openssl`).
|
||||
|
|
@ -66,6 +70,16 @@ A chat send to an unreachable onion is written to an `outbox` row next to its `m
|
|||
|
||||
The queue is bounded in scope: chat only. File transfer and `rcp` frames are one-shot, so a failed payment claim does not sit in the store being retried forever.
|
||||
|
||||
## Reachability: there is no sealed mailbox, and no mutual-online indicator
|
||||
|
||||
**No sealed mailbox.** OnionWire does not implement a server-side message store, a sealed mailbox, or any store-and-forward drop. There is no address a peer can write a message to when you are offline, and nothing that holds a message on your behalf after your device is gone. A mailbox of that kind needs a persistent process that accepts and later replays ciphertext for an absent recipient — exactly the hosted store-and-forward server this threat model rules out (“Tor relays are not a chat server”, “Out of v1”). A sealed box whose key never leaves the user's device is still a server holding the traffic pattern and the ciphertext, and it is still a third party that can be compelled, logged, or silently serve a stale box. That is the design decision, and it is not planned as a follow-up.
|
||||
|
||||
**The chat outbox is local-device retry only.** A message to an unreachable peer is written to the local `outbox` row and re-dialed from this device. It dies with the device: no relay, no friend, no other install ever holds it. Nothing in the outbox is a delivery guarantee.
|
||||
|
||||
**No mutual-online indicator.** OnionWire has no presence, no "peer is online" dot, and no shared online state. Every send is a one-shot Noise IK session to the peer's onion and is closed after one application frame; the peer's availability is only learned from whether *this* dial succeeded. A roster row we have not reached is marked `stale` (from the last connect attempt, `last_connect_ok`) and the footer states the consequence instead of implying presence: `peer unreachable, queued (n/8, retry …)` while an outbox row is outstanding. "They are offline right now" and "they have never been online since my last attempt" are indistinguishable to OnionWire, and the UI does not pretend otherwise.
|
||||
|
||||
**What this costs, stated plainly.** Two devices that are never online at the same time cannot talk, and there is no queue that changes that — the sender's own device is the only queue. Anyone who needs offline delivery must run their own always-on OnionWire install (their own identity, their own onion) to hold the messages, which is a hosted server *they* own and operate, not a service OnionWire provides.
|
||||
|
||||
## Chat is ratcheted on top of the one-shot Noise session
|
||||
|
||||
The Noise IK session is still the transport: handshake, **one** application
|
||||
|
|
@ -118,7 +132,9 @@ device.
|
|||
- *No one-time prekeys.* The bootstrap epoch uses the long-lived signed prekey
|
||||
only, so there is no per-session prekey consumption. A peer prekey change
|
||||
drops the state locally and the next chat frame re-bootstraps; there is no
|
||||
in-band reset and no key confirmation.
|
||||
in-band reset and no key confirmation. The same is true of your **own**
|
||||
prekey: `F8` rotates it, drops every stored state, and each friend has to
|
||||
re-paste your invite, because a new prekey is never pushed.
|
||||
- *A compromised endpoint is out of scope.* The ratchet state lives in the same
|
||||
SQLCipher file as the chat log, under the same passphrase. Anyone who opens
|
||||
the store holds the roots, both chain keys, the skipped keys and the plaintext
|
||||
|
|
@ -234,7 +250,8 @@ the peer already knows the plaintext they sent.
|
|||
|
||||
## Out of v1
|
||||
|
||||
Prosody, XMPP, s2s, MAM, carbons, a **server-side** outbox / store-and-forward
|
||||
relay, multi-device, DHT / name server, A/V. The local retry queue of the
|
||||
previous section is not an outbox in the XMPP sense: it never leaves the device.
|
||||
Prosody, XMPP, s2s, MAM, carbons, a **sealed mailbox**, a **server-side**
|
||||
outbox / store-and-forward relay, multi-device, DHT / name server, A/V. The
|
||||
local retry queue of the previous section is not an outbox in the XMPP sense: it
|
||||
never leaves the device, and it is not a mailbox either — see “Reachability”.
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,8 @@ chmod +x onionwire-x86_64-unknown-linux-gnu
|
|||
./onionwire-<target> --version
|
||||
```
|
||||
|
||||
Keep the asset filenames so `sha256sum -c` matches. Both binaries link OpenSSL 3
|
||||
dynamically (`libssl.so.3`), which is standard on Debian 12+/Ubuntu 24.04+.
|
||||
Keep the asset filenames so `sha256sum -c` matches. The TLS stack is rustls and
|
||||
OpenSSL (for SQLCipher) is compiled in from vendored sources, so the binaries
|
||||
have no dynamic `libssl` dependency.
|
||||
|
||||
Building from source is covered in the README install guide.
|
||||
|
|
|
|||
171
src/node.rs
171
src/node.rs
|
|
@ -8,6 +8,7 @@ use std::time::{Duration, Instant, SystemTime, UNIX_EPOCH};
|
|||
use futures::StreamExt;
|
||||
use futures::io::{AsyncRead, AsyncWrite};
|
||||
use hkdf::Hkdf;
|
||||
use rand::rngs::OsRng;
|
||||
use sha2::Sha256;
|
||||
use tor_cell::relaycell::msg::Connected;
|
||||
use tor_hsservice::{RunningOnionService, handle_rend_requests};
|
||||
|
|
@ -623,7 +624,7 @@ impl Node {
|
|||
}
|
||||
|
||||
/// Pay selected friend via wallet RPC, then signed receipt.
|
||||
pub async fn tip(&self, friend_pk: &[u8], atomic: &str, _memo: &str) -> Result<(), String> {
|
||||
pub async fn tip(&self, friend_pk: &[u8], atomic: &str, memo: &str) -> Result<(), String> {
|
||||
if !self.wallet.configured() {
|
||||
return Err("wallet not connected — set ONIONWIRE_WALLET_RPC".into());
|
||||
}
|
||||
|
|
@ -645,20 +646,23 @@ impl Node {
|
|||
.map_err(|e| e.to_string())?;
|
||||
let rcp = self.sign_receipt(&txid, atomic, &address)?;
|
||||
let rcp_pt = pay::encode_receipt(&rcp);
|
||||
let tip = self.sign_tip(&txid, atomic, &address, _memo)?;
|
||||
let tip = self.sign_tip(&txid, atomic, &address, memo)?;
|
||||
let tip_pt = pay::encode_tip(&tip);
|
||||
self.send_once(friend_pk, &rcp_pt).await?;
|
||||
self.send_once(friend_pk, &tip_pt).await?;
|
||||
let store = self.store.lock().map_err(|e| e.to_string())?;
|
||||
// The user just *spent* this money: the row is a tip, matching the
|
||||
// inbound `ingest_tip` direction. The receipt frame above is the
|
||||
// recipient's copy of the payment, not the local one.
|
||||
store
|
||||
.insert_payment(
|
||||
friend_pk,
|
||||
PaymentWrite {
|
||||
dir: "out",
|
||||
kind: "receipt",
|
||||
kind: "tip",
|
||||
amount_atomic: atomic,
|
||||
address: &address,
|
||||
memo: "",
|
||||
memo,
|
||||
txid: Some(&txid),
|
||||
verified: true,
|
||||
},
|
||||
|
|
@ -678,7 +682,7 @@ impl Node {
|
|||
.append_message(
|
||||
friend_pk,
|
||||
"out",
|
||||
pay::tip_chat_line(atomic, _memo, false).as_bytes(),
|
||||
pay::tip_chat_line(atomic, memo, false).as_bytes(),
|
||||
)
|
||||
.map_err(|e| e.to_string())?;
|
||||
Ok(())
|
||||
|
|
@ -877,6 +881,34 @@ impl Node {
|
|||
})
|
||||
}
|
||||
|
||||
/// Rotate the long-lived signed prekey (F8). Hard cut, like the locator
|
||||
/// rotate: the prekey is our Noise static and the bootstrap ratchet epoch is
|
||||
/// derived from the prekey DH, so every stored session is dead the moment
|
||||
/// this returns and every friend has to F3-paste the new invite. Nothing is
|
||||
/// pushed to peers — a new prekey only travels inside a signed invite. The
|
||||
/// identity key (and therefore the fingerprint) does not move; the caller
|
||||
/// re-encodes the F2 invite around the returned pubkey.
|
||||
pub fn rotate_prekey(&self) -> Result<[u8; 32], String> {
|
||||
let mut k = self.keys()?;
|
||||
let sk = StaticSecret::random_from_rng(OsRng);
|
||||
let pk = X25519Public::from(&sk).to_bytes();
|
||||
{
|
||||
let store = self.store.lock().map_err(|e| e.to_string())?;
|
||||
// `replace_identity_keys` rewrites the prekey columns too; the
|
||||
// identity values passed back are the ones already stored.
|
||||
store
|
||||
.replace_identity_keys(&k.identity_sk, &k.identity_pk, &sk.to_bytes(), &pk)
|
||||
.map_err(|e| e.to_string())?;
|
||||
for f in store.list_friends().map_err(|e| e.to_string())? {
|
||||
store.clear_ratchet(&f.pubkey).map_err(|e| e.to_string())?;
|
||||
}
|
||||
}
|
||||
k.prekey_sk = sk.to_bytes();
|
||||
k.prekey_pk = pk;
|
||||
*self.keys.lock().map_err(|e| e.to_string())? = k;
|
||||
Ok(pk)
|
||||
}
|
||||
|
||||
/// One-shot file to a friend. Fail closed; no outbox, no resume.
|
||||
/// Chunks are paced (`file::CHUNK_PACE`) with bounded per-chunk retry so
|
||||
/// a 1 MiB transfer fits the receiver's rendezvous token bucket.
|
||||
|
|
@ -1823,5 +1855,134 @@ mod tests {
|
|||
"the sender's chat must show the tip they just paid"
|
||||
);
|
||||
}
|
||||
|
||||
/// F8: rotate the long-lived signed prekey. The identity must not move, the
|
||||
/// stored/dialed prekey must, every prekey-bound ratchet epoch must be
|
||||
/// dropped, and the F2 invite must be re-encodable around the new prekey.
|
||||
#[tokio::test]
|
||||
async fn rotating_the_prekey_keeps_identity_and_drops_stale_ratchet_state() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let node = offline_node(&dir.path().join("bob"), Arc::new(NoDial));
|
||||
let peer = Keys::generate();
|
||||
let old_identity = node.identity_pk();
|
||||
let old_prekey = node_prekey(&node);
|
||||
*node.onion.lock().unwrap() = format!("{}.onion", "a".repeat(56));
|
||||
{
|
||||
let store = node.store.lock().unwrap();
|
||||
befriend(&store, &peer.identity_pk, &peer.prekey_pk, "peer.onion");
|
||||
store
|
||||
.save_ratchet(&peer.identity_pk, b"epoch-bound-to-the-old-prekey")
|
||||
.expect("seed ratchet state");
|
||||
}
|
||||
|
||||
let new_prekey = node.rotate_prekey().expect("rotate prekey");
|
||||
|
||||
assert_ne!(new_prekey, old_prekey, "the prekey must actually change");
|
||||
assert_eq!(node_prekey(&node), new_prekey, "the live keys follow");
|
||||
assert_eq!(
|
||||
node.identity_pk(),
|
||||
old_identity,
|
||||
"identity = pubkey, it stays"
|
||||
);
|
||||
{
|
||||
let store = node.store.lock().unwrap();
|
||||
assert_eq!(
|
||||
store.self_identity().unwrap().prekey_pk,
|
||||
new_prekey.to_vec(),
|
||||
"the self row carries the new prekey"
|
||||
);
|
||||
assert!(
|
||||
store.load_ratchet(&peer.identity_pk).unwrap().is_none(),
|
||||
"the bootstrap epoch is prekey-bound, so the stored state is stale"
|
||||
);
|
||||
}
|
||||
let payload = qr::decode(&node.qr_payload().expect("re-encode the invite"))
|
||||
.expect("the re-encoded invite decodes");
|
||||
assert_eq!(payload.signed_prekey, new_prekey.to_vec());
|
||||
assert_eq!(
|
||||
payload.pubkey,
|
||||
old_identity.to_vec(),
|
||||
"the new invite still names the same identity"
|
||||
);
|
||||
}
|
||||
|
||||
/// An outbound tip must be recorded as a *tip*. The receipt row is the
|
||||
/// recipient's view of a receipt frame; for money the user just spent the
|
||||
/// wallet history wants the tip they paid. `ingest_tip` already stores
|
||||
/// `kind = "tip"` for the inbound direction.
|
||||
#[tokio::test]
|
||||
async fn outbound_tip_records_a_tip_payment_row() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let node = offline_node_with_wallet(
|
||||
&dir.path().join("bob"),
|
||||
Arc::new(DialOk),
|
||||
mock_wallet().await,
|
||||
);
|
||||
let peer = Keys::generate();
|
||||
let addr = xmr_addr();
|
||||
{
|
||||
let store = node.store.lock().unwrap();
|
||||
befriend(&store, &peer.identity_pk, &peer.prekey_pk, "peer.onion");
|
||||
let prf = crate::profile::sign(&peer.identity_sk, "peer", "", &addr, 1)
|
||||
.expect("sign peer profile");
|
||||
assert!(store.apply_profile(&peer.identity_pk, &prf).unwrap());
|
||||
}
|
||||
|
||||
node.tip(&peer.identity_pk, "500000000000", "lunch")
|
||||
.await
|
||||
.expect("tip");
|
||||
|
||||
let store = node.store.lock().unwrap();
|
||||
let rows = store.list_payments(&peer.identity_pk).expect("payments");
|
||||
assert_eq!(rows.len(), 1, "one row for one outbound tip");
|
||||
assert_eq!(rows[0].dir, "out");
|
||||
assert_eq!(rows[0].kind, "tip", "an outbound tip is stored as a tip");
|
||||
assert_eq!(rows[0].amount_atomic, "500000000000");
|
||||
assert_eq!(rows[0].txid.as_deref(), Some("abc123"));
|
||||
assert_eq!(rows[0].memo, "lunch");
|
||||
}
|
||||
|
||||
/// Same storage for the other direction: a tip signed by the peer lands as
|
||||
/// a `kind = "tip"` row plus the `[tip]` line. This is the path the
|
||||
/// payments CHECK constraint had been rejecting.
|
||||
#[tokio::test]
|
||||
async fn an_inbound_tip_is_recorded_and_shown() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let node = offline_node(&dir.path().join("bob"), Arc::new(NoDial));
|
||||
let peer = Keys::generate();
|
||||
befriend(
|
||||
&node.store.lock().unwrap(),
|
||||
&peer.identity_pk,
|
||||
&peer.prekey_pk,
|
||||
"peer.onion",
|
||||
);
|
||||
let tip = pay::sign_tip(
|
||||
&peer.identity_sk,
|
||||
"abc123",
|
||||
"500000000000",
|
||||
&xmr_addr(),
|
||||
"lunch",
|
||||
1,
|
||||
)
|
||||
.expect("sign peer tip");
|
||||
|
||||
node.ingest_tip(&peer.identity_pk, &pay::encode_tip(&tip))
|
||||
.await
|
||||
.expect("inbound tip must be stored");
|
||||
|
||||
assert_eq!(
|
||||
chat_lines(&node, &peer),
|
||||
vec![(
|
||||
"in".to_string(),
|
||||
"[tip] 0.5 XMR — lunch (pending)".to_string()
|
||||
)],
|
||||
"the receiver's chat shows the tip that arrived"
|
||||
);
|
||||
let rows = node.store.lock().unwrap().list_payments(&peer.identity_pk);
|
||||
let rows = rows.expect("payments");
|
||||
assert_eq!(rows.len(), 1, "one row for one inbound tip");
|
||||
assert_eq!(rows[0].dir, "in");
|
||||
assert_eq!(rows[0].kind, "tip");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
97
src/store.rs
97
src/store.rs
|
|
@ -261,7 +261,7 @@ impl Store {
|
|||
id INTEGER PRIMARY KEY,
|
||||
friend_id INTEGER NOT NULL REFERENCES friends(id),
|
||||
dir TEXT NOT NULL CHECK(dir IN ('in','out')),
|
||||
kind TEXT NOT NULL CHECK(kind IN ('invoice','receipt')),
|
||||
kind TEXT NOT NULL CHECK(kind IN ('invoice','receipt','tip')),
|
||||
amount_atomic TEXT NOT NULL,
|
||||
address TEXT NOT NULL,
|
||||
memo TEXT NOT NULL DEFAULT '',
|
||||
|
|
@ -365,6 +365,51 @@ impl Store {
|
|||
"payload",
|
||||
"ALTER TABLE outbox ADD COLUMN payload BLOB",
|
||||
)?;
|
||||
// `insert_payment` has accepted `kind = "tip"` since the tip path
|
||||
// landed, but the table's CHECK only allowed invoice/receipt, so every
|
||||
// tip insert (inbound *and* outbound) failed the constraint and the
|
||||
// frame was dropped. SQLite cannot alter a CHECK, so rebuild.
|
||||
self.widen_payment_kinds()?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Widen `payments.kind` to accept `'tip'` on stores created before the
|
||||
/// tip path. The table is rebuilt in place because SQLite has no
|
||||
/// `ALTER TABLE ... DROP CONSTRAINT`; ids and rows are preserved verbatim.
|
||||
fn widen_payment_kinds(&self) -> Result<()> {
|
||||
let schema: Option<String> = self
|
||||
.conn
|
||||
.query_row(
|
||||
"SELECT sql FROM sqlite_master WHERE type = 'table' AND name = 'payments'",
|
||||
[],
|
||||
|row| row.get(0),
|
||||
)
|
||||
.optional()?;
|
||||
let Some(schema) = schema else {
|
||||
return Ok(());
|
||||
};
|
||||
if schema.contains("'tip'") {
|
||||
return Ok(());
|
||||
}
|
||||
self.conn.execute_batch(
|
||||
"ALTER TABLE payments RENAME TO payments_pre_tip;
|
||||
CREATE TABLE payments (
|
||||
id INTEGER PRIMARY KEY,
|
||||
friend_id INTEGER NOT NULL REFERENCES friends(id),
|
||||
dir TEXT NOT NULL CHECK(dir IN ('in','out')),
|
||||
kind TEXT NOT NULL CHECK(kind IN ('invoice','receipt','tip')),
|
||||
amount_atomic TEXT NOT NULL,
|
||||
address TEXT NOT NULL,
|
||||
memo TEXT NOT NULL DEFAULT '',
|
||||
txid TEXT,
|
||||
verified INTEGER NOT NULL DEFAULT 0,
|
||||
created_at INTEGER NOT NULL
|
||||
);
|
||||
INSERT INTO payments (id, friend_id, dir, kind, amount_atomic, address, memo, txid, verified, created_at)
|
||||
SELECT id, friend_id, dir, kind, amount_atomic, address, memo, txid, verified, created_at
|
||||
FROM payments_pre_tip;
|
||||
DROP TABLE payments_pre_tip;",
|
||||
)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
@ -1940,6 +1985,56 @@ mod at_rest {
|
|||
}
|
||||
}
|
||||
|
||||
/// The old `payments.kind` CHECK allowed only invoice/receipt, so every
|
||||
/// `kind = "tip"` insert (inbound and outbound) failed the constraint.
|
||||
/// Opening an existing store must widen it without losing the rows in it.
|
||||
#[test]
|
||||
fn a_store_predating_tip_payments_is_widened_on_open() {
|
||||
const ADDR: &str = "4AdUndXHHZ6cfufTMvppY6JwXNouMBzSkbLYfpAV5Usx3skxNgYeYTRj5UzqtReoS44qo9mtmXCqY45DJ852K5Jv2684Rge";
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let db_path = dir.path().join("onionwire.db");
|
||||
write_legacy_plaintext_store(&db_path, "tip-pass");
|
||||
{
|
||||
let conn = Connection::open(&db_path).unwrap();
|
||||
let schema: String = conn
|
||||
.query_row(
|
||||
"SELECT sql FROM sqlite_master WHERE name = 'payments'",
|
||||
[],
|
||||
|r| r.get(0),
|
||||
)
|
||||
.unwrap();
|
||||
assert!(!schema.contains("'tip'"), "fixture is the pre-tip table");
|
||||
conn.execute(
|
||||
"INSERT INTO payments (friend_id, dir, kind, amount_atomic, address, memo, txid, verified, created_at)
|
||||
VALUES (1, 'out', 'invoice', '1000000000000', ?1, 'm', NULL, 0, 7)",
|
||||
params![ADDR],
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
let store = Store::open_at_with_passphrase(dir.path(), "tip-pass").expect("open+upgrade");
|
||||
let rows = store.list_payments(&LEGACY_FRIEND_PK).unwrap();
|
||||
assert_eq!(rows.len(), 1, "the pre-tip row survives the rebuild");
|
||||
assert_eq!(rows[0].kind, "invoice");
|
||||
assert_eq!(rows[0].amount_atomic, "1000000000000");
|
||||
assert_eq!(rows[0].created_at, 7, "rows are copied verbatim");
|
||||
|
||||
store
|
||||
.insert_payment(
|
||||
&LEGACY_FRIEND_PK,
|
||||
PaymentWrite {
|
||||
dir: "in",
|
||||
kind: "tip",
|
||||
amount_atomic: "500000000000",
|
||||
address: ADDR,
|
||||
memo: "lunch",
|
||||
txid: Some("abc123"),
|
||||
verified: false,
|
||||
},
|
||||
)
|
||||
.expect("a migrated store accepts the tip kind");
|
||||
}
|
||||
|
||||
/// `ratchet_sessions` keys on `friend_id`, and nothing in the crate deletes
|
||||
/// friends yet, so the cascade is exercised with the raw statement a future
|
||||
/// friend-removal path would run.
|
||||
|
|
|
|||
97
src/tui.rs
97
src/tui.rs
|
|
@ -204,11 +204,22 @@ pub struct OutboxSummary {
|
|||
pub failed: usize,
|
||||
/// First terminal failure, for the fail-closed footer copy.
|
||||
pub first_error: Option<String>,
|
||||
/// Highest attempt count across outstanding rows (0 when nothing is
|
||||
/// outstanding). With `DEFAULT_MAX_ATTEMPTS` this is the `n` in `(n/8)`.
|
||||
pub attempts: u32,
|
||||
/// Seconds until the earliest scheduled retry, relative to the render
|
||||
/// `now`. `None` while nothing is outstanding.
|
||||
pub next_in_secs: Option<i64>,
|
||||
}
|
||||
|
||||
impl OutboxSummary {
|
||||
/// Footer note, or `None` when nothing is outstanding. Any terminal failure
|
||||
/// keeps a `send failed` statement so the fail-closed copy stays visible.
|
||||
///
|
||||
/// An outstanding row is a reachability statement, not just a count: the
|
||||
/// peer's onion did not answer *this* dial, so the note names that and the
|
||||
/// retry it is waiting on (`peer unreachable, queued (n/8, retry 45s)`).
|
||||
/// There is no mutual-online indicator to fall back on.
|
||||
pub fn note(&self) -> Option<String> {
|
||||
let reason = || {
|
||||
short_send_reason(
|
||||
|
|
@ -216,12 +227,19 @@ impl OutboxSummary {
|
|||
FAIL_REASON_BUDGET,
|
||||
)
|
||||
};
|
||||
let queued = || {
|
||||
format!(
|
||||
"peer unreachable, queued ({}/{DEFAULT_MAX_ATTEMPTS}, {})",
|
||||
self.attempts,
|
||||
retry_in_text(self.next_in_secs.unwrap_or(0))
|
||||
)
|
||||
};
|
||||
match (self.queued, self.failed) {
|
||||
(0, 0) => None,
|
||||
(queued, 0) => Some(format!("{queued} queued")),
|
||||
(0, 1) => Some(format!("send failed: {}", reason())),
|
||||
(0, failed) => Some(format!("send failed: {} ({failed} failed)", reason())),
|
||||
(queued, _) => Some(format!("{queued} queued, send failed: {}", reason())),
|
||||
(_, 0) => Some(queued()),
|
||||
(_, _) => Some(format!("{}, send failed: {}", queued(), reason())),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -244,7 +262,17 @@ pub fn chat_with_delivery(
|
|||
summary.failed += 1;
|
||||
summary.first_error.get_or_insert_with(|| why.clone());
|
||||
}
|
||||
_ => summary.queued += 1,
|
||||
_ => {
|
||||
summary.queued += 1;
|
||||
// The note is the reachability statement for the selected
|
||||
// friend: highest attempt count, soonest scheduled retry.
|
||||
summary.attempts = summary.attempts.max(entry.attempts);
|
||||
let secs = entry.next_attempt_at - now;
|
||||
summary.next_in_secs = Some(match summary.next_in_secs {
|
||||
Some(prev) => prev.min(secs),
|
||||
None => secs,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
if msgs.is_empty() {
|
||||
|
|
@ -463,6 +491,17 @@ Offline friends CANNOT find you until they F3-paste your new invite.\n\
|
|||
Type ROTATE to confirm Esc to cancel"
|
||||
}
|
||||
|
||||
/// F8. Hard cut like the locator rotate: the prekey is our Noise static and the
|
||||
/// ratchet bootstrap is derived from the prekey DH, so nothing short of a fresh
|
||||
/// invite re-syncs a friend.
|
||||
pub fn prekey_screen_text() -> &'static str {
|
||||
"Rotate prekey?\n\
|
||||
Your identity and onion stay the same.\n\
|
||||
Every friend must F3-paste your new invite to pick up the new prekey,\n\
|
||||
or you cannot reach them and they cannot reach you.\n\
|
||||
Type ROTATE to confirm Esc to cancel"
|
||||
}
|
||||
|
||||
pub fn quit_screen_text() -> &'static str {
|
||||
"Quit OnionWire?\n\
|
||||
Message history can be cleared; identity and friends stay.\n\
|
||||
|
|
@ -507,6 +546,7 @@ OnionWire keys\n\
|
|||
F4 rotate onion locator\n\
|
||||
F5 selected friend's profile (/who)\n\
|
||||
F6 wallet (receive QR, create/import)\n\
|
||||
F8 rotate prekey\n\
|
||||
/profile edit name, bio, Monero address\n\
|
||||
/pay <xmr> [memo] invoice to receive\n\
|
||||
/tip <xmr> [memo] pay selected friend\n\
|
||||
|
|
@ -1157,6 +1197,9 @@ enum Screen {
|
|||
Rotate {
|
||||
prompt: RotatePrompt,
|
||||
},
|
||||
RotatePrekey {
|
||||
prompt: RotatePrompt,
|
||||
},
|
||||
Wipe {
|
||||
kind: WipeKind,
|
||||
prompt: WipePrompt,
|
||||
|
|
@ -1296,6 +1339,11 @@ impl App {
|
|||
}
|
||||
KeyCode::F(5) => self.who_open = true,
|
||||
KeyCode::F(6) => self.open_wallet()?,
|
||||
KeyCode::F(8) => {
|
||||
self.screen = Screen::RotatePrekey {
|
||||
prompt: RotatePrompt::new(),
|
||||
};
|
||||
}
|
||||
KeyCode::Esc => self.composer.clear(),
|
||||
KeyCode::Backspace => {
|
||||
if self.focus == Pane::Composer {
|
||||
|
|
@ -1415,6 +1463,18 @@ impl App {
|
|||
}
|
||||
_ => {}
|
||||
},
|
||||
Screen::RotatePrekey { prompt } => match key.code {
|
||||
KeyCode::Esc => self.screen = Screen::Main,
|
||||
KeyCode::Char(c) if !key.modifiers.contains(KeyModifiers::CONTROL) => {
|
||||
if prompt.on_char(c) == RotateDecision::Confirm {
|
||||
self.confirm_rotate_prekey()?;
|
||||
}
|
||||
}
|
||||
KeyCode::Backspace => {
|
||||
prompt.on_char('\u{8}');
|
||||
}
|
||||
_ => {}
|
||||
},
|
||||
Screen::Wipe { kind, prompt } => {
|
||||
let kind = *kind;
|
||||
match key.code {
|
||||
|
|
@ -1687,6 +1747,24 @@ impl App {
|
|||
}
|
||||
}
|
||||
|
||||
/// F8. Local and synchronous: nothing is pushed to peers — the new prekey
|
||||
/// only travels inside a fresh signed invite — so the screen goes straight
|
||||
/// to that invite (the F2 share path) for the user to hand out.
|
||||
fn confirm_rotate_prekey(&mut self) -> Result<(), String> {
|
||||
match self.node.rotate_prekey() {
|
||||
Ok(_) => {
|
||||
self.status_note =
|
||||
Some("prekey rotated · friends must F3-paste your new invite".into());
|
||||
self.open_share()
|
||||
}
|
||||
Err(e) => {
|
||||
self.alert = Some(e);
|
||||
self.screen = Screen::Main;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn open_share(&mut self) -> Result<(), String> {
|
||||
let payload = self.node.qr_payload()?;
|
||||
self.screen = Screen::Share { payload };
|
||||
|
|
@ -2064,6 +2142,7 @@ impl App {
|
|||
Screen::Paste { buf, err } => draw_paste(f, buf, err.as_deref()),
|
||||
Screen::Approve { payload } => draw_approve(f, payload),
|
||||
Screen::Rotate { prompt } => draw_rotate(f, prompt.typed()),
|
||||
Screen::RotatePrekey { prompt } => draw_rotate_prekey(f, prompt.typed()),
|
||||
Screen::Wipe { kind, prompt } => draw_wipe(f, *kind, prompt.typed()),
|
||||
Screen::Profile { editor } => draw_profile(f, editor),
|
||||
Screen::ConfirmKeys { kind, prompt, .. } => draw_confirm_keys(f, *kind, prompt.typed()),
|
||||
|
|
@ -2382,6 +2461,7 @@ match screen {
|
|||
Screen::Paste { .. } => "Enter submit Esc back ? help",
|
||||
Screen::Approve { .. } => "y accept n reject ? help",
|
||||
Screen::Rotate { .. } => "type ROTATE Esc cancel ? help",
|
||||
Screen::RotatePrekey { .. } => "type ROTATE Esc cancel ? help",
|
||||
Screen::Wipe { kind, .. } => match kind {
|
||||
WipeKind::Messages => "type WIPE Esc cancel ? help",
|
||||
WipeKind::All => "type WIPEALL Esc cancel ? help",
|
||||
|
|
@ -2482,6 +2562,17 @@ fn draw_rotate(f: &mut Frame, typed: &str) {
|
|||
);
|
||||
}
|
||||
|
||||
fn draw_rotate_prekey(f: &mut Frame, typed: &str) {
|
||||
let body = format!("{}\n\n{typed}", prekey_screen_text());
|
||||
f.render_widget(
|
||||
Paragraph::new(body)
|
||||
.style(style_text())
|
||||
.wrap(Wrap { trim: false })
|
||||
.block(themed_block("(o) rotate prekey")),
|
||||
f.area(),
|
||||
);
|
||||
}
|
||||
|
||||
fn draw_wipe(f: &mut Frame, kind: WipeKind, typed: &str) {
|
||||
let title = match kind {
|
||||
WipeKind::Messages => "(o) wipe",
|
||||
|
|
|
|||
|
|
@ -130,3 +130,27 @@ fn rotate_prompt_text_matches_spec() {
|
|||
assert!(t.contains("Type ROTATE to confirm"));
|
||||
assert!(t.contains("Esc to cancel"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn f8_prekey_rotation_screen_text_matches_spec() {
|
||||
let t = onionwire::tui::prekey_screen_text();
|
||||
assert!(t.contains("Rotate prekey?"));
|
||||
assert!(t.contains("Your identity and onion stay the same."));
|
||||
assert!(
|
||||
t.contains("F3-paste"),
|
||||
"the re-paste requirement is the whole point of the screen"
|
||||
);
|
||||
assert!(t.contains("Type ROTATE to confirm"));
|
||||
assert!(t.contains("Esc to cancel"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn f8_reuses_the_type_rotate_confirm_prompt() {
|
||||
let mut p = RotatePrompt::new();
|
||||
assert_eq!(p.on_esc(), RotateDecision::Cancel);
|
||||
for c in "ROTA".chars() {
|
||||
assert_eq!(p.on_char(c), RotateDecision::Pending);
|
||||
}
|
||||
assert_eq!(p.on_char('T'), RotateDecision::Pending);
|
||||
assert_eq!(p.on_char('E'), RotateDecision::Confirm);
|
||||
}
|
||||
|
|
|
|||
36
tests/tls_backend.rs
Normal file
36
tests/tls_backend.rs
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
//! Pin the crate's default TLS backend to Arti's `rustls` feature.
|
||||
//!
|
||||
//! The TUI/release build and the Android SDK are the same crate compiled with
|
||||
//! different feature sets, and Arti's two TLS backends are non-additive. The
|
||||
//! default must be `rustls` so no build pulls OpenSSL in for TLS (Android has
|
||||
//! no OpenSSL in the NDK, and the released binaries should not need a system
|
||||
//! OpenSSL).
|
||||
|
||||
// The default feature set must select `rustls`, not `native-tls`.
|
||||
//
|
||||
// Pinned at compile time: this test target is built with the crate's default
|
||||
// features, so it stops compiling if `default` ever moves back off Arti's
|
||||
// rustls backend.
|
||||
const _: () = assert!(cfg!(feature = "rustls"));
|
||||
const _: () = assert!(!cfg!(feature = "native-tls"));
|
||||
|
||||
/// Building a `rustls` config the way Arti does works with no manual provider
|
||||
/// install, straight from the process default.
|
||||
///
|
||||
/// This is the load-bearing half: `tor-rtcompat` depends on rustls with
|
||||
/// `default-features = false`, so unless *this* crate turns on rustls's `ring`
|
||||
/// feature the TLS backend compiles with no `CryptoProvider` and Arti dies the
|
||||
/// first time it builds a TLS config.
|
||||
#[test]
|
||||
fn rustls_resolves_a_crypto_provider_from_crate_features() {
|
||||
assert!(
|
||||
rustls::crypto::CryptoProvider::get_default().is_none(),
|
||||
"another test in this binary installed a CryptoProvider first"
|
||||
);
|
||||
let _ = rustls::ClientConfig::builder();
|
||||
assert!(
|
||||
rustls::crypto::CryptoProvider::get_default().is_some(),
|
||||
"rustls resolved no CryptoProvider — the crate feature that selects one \
|
||||
(`ring`) is missing from the dependency graph"
|
||||
);
|
||||
}
|
||||
|
|
@ -46,6 +46,7 @@ fn help_overlay_lists_core_bindings() {
|
|||
"F4",
|
||||
"F5",
|
||||
"F6",
|
||||
"F8",
|
||||
"send chat",
|
||||
"/profile",
|
||||
"/pay",
|
||||
|
|
|
|||
|
|
@ -531,7 +531,10 @@ fn identical_bodies_join_by_message_id_not_body() {
|
|||
"delivered row (id 8) must keep its mark: {:?}",
|
||||
lines[1]
|
||||
);
|
||||
assert_eq!(summary.note().as_deref(), Some("1 queued"));
|
||||
assert_eq!(
|
||||
summary.note().as_deref(),
|
||||
Some("peer unreachable, queued (1/8, retry 30s)")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
@ -621,13 +624,19 @@ fn footer_summary_counts_queued_and_keeps_fail_closed() {
|
|||
queued: 2,
|
||||
failed: 0,
|
||||
first_error: None,
|
||||
attempts: 3,
|
||||
next_in_secs: Some(45),
|
||||
};
|
||||
assert_eq!(queued.note().as_deref(), Some("2 queued"));
|
||||
assert_eq!(
|
||||
queued.note().as_deref(),
|
||||
Some("peer unreachable, queued (3/8, retry 45s)")
|
||||
);
|
||||
|
||||
let failed = OutboxSummary {
|
||||
queued: 0,
|
||||
failed: 1,
|
||||
first_error: Some("connect peer.onion:80: connection timed out".into()),
|
||||
..OutboxSummary::default()
|
||||
};
|
||||
let note = failed.note().expect("failed rows must produce a note");
|
||||
assert!(note.starts_with("send failed:"), "{note:?}");
|
||||
|
|
@ -637,9 +646,15 @@ fn footer_summary_counts_queued_and_keeps_fail_closed() {
|
|||
queued: 3,
|
||||
failed: 1,
|
||||
first_error: Some("connect peer.onion:80: connection timed out".into()),
|
||||
attempts: 2,
|
||||
next_in_secs: Some(60),
|
||||
};
|
||||
let mixed_note = mixed.note().expect("mixed rows must produce a note");
|
||||
assert!(mixed_note.contains("3 queued"), "{mixed_note:?}");
|
||||
assert!(
|
||||
mixed_note.contains("queued (2/8, retry 1m)"),
|
||||
"{mixed_note:?}"
|
||||
);
|
||||
assert!(mixed_note.starts_with("peer unreachable"), "{mixed_note:?}");
|
||||
assert!(mixed_note.contains("send failed"), "{mixed_note:?}");
|
||||
|
||||
// Fail-closed copy stays visible in the real footer at the 80-col floor.
|
||||
|
|
@ -653,7 +668,10 @@ fn footer_summary_counts_queued_and_keeps_fail_closed() {
|
|||
assert!(line.contains("TOR") && line.contains("? help"), "{line:?}");
|
||||
|
||||
let queued_line = status_footer(80, FP, ONION, queued.note().as_deref(), main_footer_hints());
|
||||
assert!(queued_line.contains("2 queued"), "{queued_line:?}");
|
||||
assert!(
|
||||
queued_line.contains("queued (3/8, retry 45s)"),
|
||||
"{queued_line:?}"
|
||||
);
|
||||
assert!(queued_line.chars().count() <= 80);
|
||||
|
||||
// `! ` ornament (colour off) still lands on the derived failing note.
|
||||
|
|
@ -731,7 +749,7 @@ fn chat_and_footer_rows_fit_80x24_and_wrap_instead_of_clipping() {
|
|||
"long row was clipped, not wrapped:\n{screen}"
|
||||
);
|
||||
assert!(
|
||||
screen.contains("1 queued"),
|
||||
screen.contains("peer unreachable, queued (3/8, retry 45s)"),
|
||||
"footer summary missing:\n{screen}"
|
||||
);
|
||||
println!("===== AFTER outbox 80x24 (real draw_chat + status_footer) =====\n{screen}");
|
||||
|
|
@ -789,7 +807,10 @@ async fn renders_a_queued_row_from_a_real_outbox_send() {
|
|||
"real outbox row did not render: {:?}",
|
||||
lines[0]
|
||||
);
|
||||
assert_eq!(summary.note().as_deref(), Some("1 queued"));
|
||||
assert_eq!(
|
||||
summary.note().as_deref(),
|
||||
Some("peer unreachable, queued (1/8, retry 45s)")
|
||||
);
|
||||
|
||||
// And once a send crosses the circuit the row is gone, so the same message
|
||||
// renders as delivered.
|
||||
|
|
|
|||
Loading…
Reference in a new issue