v0.9.5: bubble for Android 0.7.8 — the relay is just a relay server: its address is a setting, and deploy-relay.sh reads scripts/relay.env

This commit is contained in:
2026-11-16 11:19:54 -08:00
parent 8b3cfdca24
commit 6f365df087
24 changed files with 103 additions and 93 deletions
+1
View File
@@ -11,3 +11,4 @@ android/build/
CLAUDE.md CLAUDE.md
android/*.keystore android/*.keystore
__pycache__/ __pycache__/
scripts/relay.env
+1 -1
View File
@@ -6,7 +6,7 @@ A Signal-style desktop SMS/MMS client for [voip.ms](https://voip.ms) and Google
- Keeps your whole message history locally (SQLite), with full-text search - Keeps your whole message history locally (SQLite), with full-text search
- Group chats, MMS, reactions, emoji shortcodes, GNOME contacts - Group chats, MMS, reactions, emoji shortcodes, GNOME contacts
- Optional end-to-end-sealed relay to sync with the Rabbit R1 (`server/`) - Optional relay server to sync with the Rabbit R1: it only ever holds sealed messages (`server/`, deployed with `scripts/deploy-relay.sh`)
## Run ## Run
+3 -3
View File
@@ -87,7 +87,7 @@ Install/Sync buttons then target the dev app with the sandbox's made-up data.
side, through `MmsFiles`. Long texts go as multipart SMS; photos, voice notes side, through `MmsFiles`. Long texts go as multipart SMS; photos, voice notes
and group chats as MMS (needs mobile data on). The dev app's sandbox never and group chats as MMS (needs mobile data on). The dev app's sandbox never
uses the SIM. uses the SIM.
- Relay (`Relay`, `RelayJob`): the desktop's link through jai (its - Relay (`Relay`, `RelayJob`): the desktop's link through the relay server (its
`src/main/relay.ts`, server `server/bubble_relay.py`). config.json's `relay` `src/main/relay.ts`, server `server/bubble_relay.py`). config.json's `relay`
(address, token, AES-256-GCM key) comes from Sync to Rabbit. The SIM's (address, token, AES-256-GCM key) comes from Sync to Rabbit. The SIM's
messages go to the desktop, sends typed there go out here (each one at most messages go to the desktop, sends typed there go out here (each one at most
@@ -96,7 +96,7 @@ Install/Sync buttons then target the dev app with the sandbox's made-up data.
of its own: it rides along with `PollJob`'s checks, plus one network job a few of its own: it rides along with `PollJob`'s checks, plus one network job a few
seconds after something happens here (a text in, a send done, a swipe or seconds after something happens here (a text in, a send done, a swipe or
rename), and a catch-up when the app is opened (at most once a minute). Plain rename), and a catch-up when the app is opened (at most once a minute). Plain
http is allowed only to jai's tailscale address and localhost http is allowed only to a tailscale (100.64/10) address and localhost
(`res/xml/network_security_config.xml`). (`Config`; `res/xml/network_security_config.xml` lets cleartext through).
- The scroll wheel is left alone: it stays the volume control (and volume - The scroll wheel is left alone: it stays the volume control (and volume
down + the side button still takes a screenshot). down + the side button still takes a screenshot).
@@ -53,7 +53,7 @@ final class Config {
final List<Did> dids = new CopyOnWriteArrayList<>(); final List<Did> dids = new CopyOnWriteArrayList<>();
private boolean hasSim; private boolean hasSim;
String defaultDid; String defaultDid;
/** The relay through jai (Relay.java): address, bearer token, and the 32-byte key that seals everything. */ /** The relay server (Relay.java): address, bearer token, and the 32-byte key that seals everything. */
String relayUrl, relayToken; String relayUrl, relayToken;
byte[] relayKey; byte[] relayKey;
/** Made-up data for testing (android/tools/push_sandbox.py): never goes online. */ /** Made-up data for testing (android/tools/push_sandbox.py): never goes online. */
@@ -127,8 +127,8 @@ final class Config {
if (r != null) { if (r != null) {
String url = r.optString("url", ""), token = r.optString("token", ""); String url = r.optString("url", ""), token = r.optString("token", "");
byte[] key = android.util.Base64.decode(r.optString("key", ""), android.util.Base64.DEFAULT); byte[] key = android.util.Base64.decode(r.optString("key", ""), android.util.Base64.DEFAULT);
// Only the addresses network_security_config lets through, and a real key. // Plain http only to a tailscale (100.64/10) address or localhost, as the desktop allows, and a real key.
if (url.matches("http://(100\\.\\d+\\.\\d+\\.\\d+|127\\.0\\.0\\.1)(:\\d+)?|https://[^/]+") && !token.isEmpty() && key.length == 32) { if (url.matches("http://(100\\.(6[4-9]|[7-9]\\d|1[01]\\d|12[0-7])\\.\\d+\\.\\d+|127\\.0\\.0\\.1)(:\\d+)?|https://[^/]+") && !token.isEmpty() && key.length == 32) {
cfg.relayUrl = url; cfg.relayUrl = url;
cfg.relayToken = token; cfg.relayToken = token;
cfg.relayKey = key; cfg.relayKey = key;
@@ -28,13 +28,13 @@ import javax.crypto.spec.GCMParameterSpec;
import javax.crypto.spec.SecretKeySpec; import javax.crypto.spec.SecretKeySpec;
/** /**
* The relay through jai (the desktop's src/main/relay.ts; server in * The relay server (the desktop's src/main/relay.ts; server in
* server/bubble_relay.py): the SIM's texts go to the desktop, texts typed * server/bubble_relay.py): the SIM's texts go to the desktop, texts typed
* there go out over the SIM here, and chat names and read/unread/archived * there go out over the SIM here, and chat names and read/unread/archived
* stay in step without a cable. * stay in step without a cable.
* *
* Everything is AES-256-GCM sealed with the key the desktop handed over USB * Everything is AES-256-GCM sealed with the key the desktop handed over USB
* (config.json "relay"); jai only passes blobs on. It runs with the checks * (config.json "relay"); the relay server only passes blobs on. It runs with the checks
* the Rabbit already makes (PollJob) plus one network job after something * the Rabbit already makes (PollJob) plus one network job after something
* happens here (a text, a send, a swipe), never on a timer of its own: the * happens here (a text, a send, a swipe), never on a timer of its own: the
* battery pays for nothing new while nothing's going on. * battery pays for nothing new while nothing's going on.
@@ -141,7 +141,7 @@ final class Relay {
// ---- one sync ---- // ---- one sync ----
/** One round with jai (more while there's more). Off the main thread; quiet when jai's unreachable. */ /** One round with the relay server (more while there's more). Off the main thread; quiet when it's unreachable. */
static void sync(Context c) { static void sync(Context c) {
Config cfg = Config.get(c); Config cfg = Config.get(c);
if (!configured(cfg)) return; if (!configured(cfg)) return;
@@ -241,11 +241,11 @@ final class Relay {
h.put("Authorization", "Bearer " + cfg.relayToken); h.put("Authorization", "Bearer " + cfg.relayToken);
h.put("Content-Type", "application/json"); h.put("Content-Type", "application/json");
Http.Response r = Http.request("POST", cfg.relayUrl + "/sync", h, body, 120_000); Http.Response r = Http.request("POST", cfg.relayUrl + "/sync", h, body, 120_000);
if (r.status == 401) throw new Exception("jai turned down the token (Sync to Rabbit from the desktop again)"); if (r.status == 401) throw new Exception("The relay server turned down the token (Sync to Rabbit from the desktop again)");
if (r.status != 200) throw new Exception("jai answered " + r.status); if (r.status != 200) throw new Exception("The relay server answered " + r.status);
JSONObject res = new JSONObject(new String(r.body, StandardCharsets.UTF_8)); JSONObject res = new JSONObject(new String(r.body, StandardCharsets.UTF_8));
// jai has them now. // The relay server has them now.
if (resultsPushed > 0) takeList(c, "results", resultsPushed); if (resultsPushed > 0) takeList(c, "results", resultsPushed);
if (wantsDone > 0) takeList(c, "wants", wantsDone); if (wantsDone > 0) takeList(c, "wants", wantsDone);
SharedPreferences.Editor ed = p.edit().putLong("smsLast", newSms[0]).putLong("mmsLast", newMms[0]); SharedPreferences.Editor ed = p.edit().putLong("smsLast", newSms[0]).putLong("mmsLast", newMms[0]);
@@ -144,7 +144,7 @@ public final class SettingsActivity extends BaseActivity {
} }
if (Relay.configured(cfg)) { if (Relay.configured(cfg)) {
section("Relay (jai)"); section("Relay server");
kv("Desktop link", Relay.status(c)); kv("Desktop link", Relay.status(c));
note("Texts typed on the desktop for \"via SIM\" go out at this Rabbit's background check, and chat names and read status" note("Texts typed on the desktop for \"via SIM\" go out at this Rabbit's background check, and chat names and read status"
+ " go both ways. Sealed with a key only the desktop and this Rabbit have."); + " go both ways. Sealed with a key only the desktop and this Rabbit have.");
@@ -1,11 +1,9 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!-- Everything is https, except the relay on jai over tailscale (WireGuard <!-- Everything is https, except the relay server over tailscale (WireGuard
already encrypts that hop, and what it carries is sealed: Relay.java) and already encrypts that hop, and what it carries is sealed: Relay.java) and
localhost for testing it with adb reverse. --> localhost for testing it with adb reverse. Its address is a setting, so
cleartext can't be pinned to it here: Config only accepts http:// for a
tailscale (100.64/10) address or 127.0.0.1, and nothing else uses http. -->
<network-security-config> <network-security-config>
<base-config cleartextTrafficPermitted="false" /> <base-config cleartextTrafficPermitted="true" />
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="false">100.69.139.40</domain>
<domain includeSubdomains="false">127.0.0.1</domain>
</domain-config>
</network-security-config> </network-security-config>
+2 -2
View File
@@ -26,8 +26,8 @@ import sys
import zipfile import zipfile
from pathlib import Path from pathlib import Path
VERSION_NAME = "0.7.7" VERSION_NAME = "0.7.8"
VERSION_CODE = 15 VERSION_CODE = 16
PACKAGE = "me.teafry.voipmessages" PACKAGE = "me.teafry.voipmessages"
DEV_PACKAGE = PACKAGE + ".dev" DEV_PACKAGE = PACKAGE + ".dev"
+2 -2
View File
@@ -1,12 +1,12 @@
{ {
"name": "voipms-desktop", "name": "voipms-desktop",
"version": "0.7.1", "version": "0.9.5",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "voipms-desktop", "name": "voipms-desktop",
"version": "0.7.1", "version": "0.9.5",
"hasInstallScript": true, "hasInstallScript": true,
"dependencies": { "dependencies": {
"better-sqlite3": "^13.0.3" "better-sqlite3": "^13.0.3"
+1 -1
View File
@@ -1,7 +1,7 @@
{ {
"name": "voipms-desktop", "name": "voipms-desktop",
"productName": "bubble", "productName": "bubble",
"version": "0.9.4", "version": "0.9.5",
"description": "Signal-style desktop SMS client for voip.ms", "description": "Signal-style desktop SMS client for voip.ms",
"author": "trav <trav@teafry.me>", "author": "trav <trav@teafry.me>",
"private": true, "private": true,
Binary file not shown.
+1 -1
View File
@@ -1 +1 @@
{"version_name": "0.7.7", "version_code": 15, "package": "me.teafry.voipmessages"} {"version_name": "0.7.8", "version_code": 16, "package": "me.teafry.voipmessages"}
-33
View File
@@ -1,33 +0,0 @@
#!/bin/bash
# Deploy bubble-relay to jai (see ~/Documents/shared-resources/jai.html#run).
# jai is production: this only ever touches ~/Documents/bubble-server and its
# own screen session, and installs nothing.
#
# scripts/deploy-jai.sh copy the code and (re)start the service
# scripts/deploy-jai.sh --stop stop it
# scripts/deploy-jai.sh --token print the bearer token, for Settings → Rabbit relay on the desktop
#
# What runs is server/run.sh, also started by jai's ~/startup.sh (re-run by its
# watchdog every 5 minutes), so it comes back after a crash or a reboot.
set -euo pipefail
HOST=${JAI_HOST:-jai-ext}
DIR=/home/jai/Documents/bubble-server
NAME=bubble-relay
cd "$(dirname "$0")/.."
case "${1:-}" in
--token) ssh "$HOST" "cat $DIR/data/token"; echo; exit 0 ;;
--stop) ssh "$HOST" "screen -S $NAME -X quit || true"; echo "stopped"; exit 0 ;;
esac
ssh "$HOST" "mkdir -p $DIR/app $DIR/data ~/service-logs && chmod 700 $DIR $DIR/data"
rsync -a server/bubble_relay.py server/run.sh "$HOST:$DIR/app/"
ssh "$HOST" bash -s <<REMOTE
set -e
screen -S $NAME -X quit 2>/dev/null || true
sleep 1
screen -dmS $NAME bash -c 'bash $DIR/app/run.sh 2>&1 | tee ~/service-logs/$NAME.log'
sleep 2
for pid in \$(pgrep -f bubble_relay.py); do echo 1000 > /proc/\$pid/oom_score_adj; done
curl -s -m 5 http://100.69.139.40:8080/health; echo
REMOTE
+36
View File
@@ -0,0 +1,36 @@
#!/bin/bash
# Deploy the relay server (server/bubble_relay.py) over ssh. Where it goes
# comes from scripts/relay.env (not in git; see scripts/relay.env.example).
# This only touches $RELAY_DIR and its own screen session, and installs nothing.
#
# scripts/deploy-relay.sh copy the code and (re)start it
# scripts/deploy-relay.sh --stop stop it
# scripts/deploy-relay.sh --token print the bearer token, for Settings → Relay server on the desktop
#
# What runs is server/run.sh; have the server start that at boot too, e.g.
# screen -dmS bubble-relay bash -c 'bash $RELAY_DIR/app/run.sh'
set -euo pipefail
cd "$(dirname "$0")/.."
[ -f scripts/relay.env ] || { echo "No scripts/relay.env: copy scripts/relay.env.example and fill it in." >&2; exit 1; }
. scripts/relay.env
: "${RELAY_SSH:?}" "${RELAY_DIR:?}" "${RELAY_BIND:?}"
PORT=${RELAY_PORT:-8080}
NAME=bubble-relay
case "${1:-}" in
--token) ssh "$RELAY_SSH" "cat $RELAY_DIR/data/token"; echo; exit 0 ;;
--stop) ssh "$RELAY_SSH" "screen -S $NAME -X quit || true"; echo "stopped"; exit 0 ;;
esac
ssh "$RELAY_SSH" "mkdir -p $RELAY_DIR/app $RELAY_DIR/data ~/service-logs && chmod 700 $RELAY_DIR $RELAY_DIR/data"
rsync -a server/bubble_relay.py server/run.sh "$RELAY_SSH:$RELAY_DIR/app/"
printf 'RELAY_BIND=%q\nRELAY_PORT=%q\n' "$RELAY_BIND" "$PORT" | ssh "$RELAY_SSH" "cat > $RELAY_DIR/app/relay.env"
ssh "$RELAY_SSH" bash -s <<REMOTE
set -e
screen -S $NAME -X quit 2>/dev/null || true
sleep 1
screen -dmS $NAME bash -c 'bash $RELAY_DIR/app/run.sh 2>&1 | tee ~/service-logs/$NAME.log'
sleep 2
for pid in \$(pgrep -f bubble_relay.py); do echo 1000 > /proc/\$pid/oom_score_adj; done
curl -s -m 5 http://$RELAY_BIND:$PORT/health; echo
REMOTE
+5
View File
@@ -0,0 +1,5 @@
# Copy to scripts/relay.env (git ignores it) for scripts/deploy-relay.sh.
RELAY_SSH=myserver # ssh host (an alias from ~/.ssh/config is fine)
RELAY_DIR=/home/me/bubble-server # on the server: app/ and data/ (token, mailbox) go here
RELAY_BIND=100.101.102.103 # the server's tailscale address; the desktop's Settings → Relay server uses http://<this>:<port>
RELAY_PORT=8080
+4 -3
View File
@@ -1,8 +1,9 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
"""bubble-relay: a mailbox between the desktop app and the Rabbit R1. Runs on jai. """bubble-relay: a mailbox between the desktop app and the Rabbit R1. Runs on a
server of yours that both can reach (a tailscale address is the easy way).
It never sees a message: every blob is AES-256-GCM sealed by the apps with a It never sees a message: every blob is AES-256-GCM sealed by the apps with a
key jai doesn't have (the desktop makes it and hands it to the Rabbit over key the server doesn't have (the desktop makes it and hands it to the Rabbit over
USB). This only stores opaque base64 strings, hands each device what the USB). This only stores opaque base64 strings, hands each device what the
other one posted, and forgets them once picked up (or after KEEP_DAYS). other one posted, and forgets them once picked up (or after KEEP_DAYS).
@@ -19,7 +20,7 @@ to it, which the other side posted, so those are deleted. `more` = there's
more than fits in one answer: call again with the new cursor. A cursor past more than fits in one answer: call again with the new cursor. A cursor past
anything this server ever issued (a wiped server) means "from the start". anything this server ever issued (a wiped server) means "from the start".
python3 bubble_relay.py --host 100.69.139.40 --port 8080 --data DIR python3 bubble_relay.py --host <tailscale address> --port 8080 --data DIR
""" """
import argparse import argparse
+6 -3
View File
@@ -1,4 +1,7 @@
#!/bin/bash #!/bin/bash
# The one real command line for bubble-relay on jai (~/startup.sh and scripts/deploy-jai.sh both run this). # The one real command line for the relay server (scripts/deploy-relay.sh runs
cd /home/jai/Documents/bubble-server/app || exit 1 # it; run it at boot too). relay.env next to it, written by the deploy, says
exec python3 bubble_relay.py --host 100.69.139.40 --port 8080 --data /home/jai/Documents/bubble-server/data # which address and port to listen on.
cd "$(dirname "$(readlink -f "$0")")" || exit 1
. ./relay.env
exec python3 bubble_relay.py --host "$RELAY_BIND" --port "${RELAY_PORT:-8080}" --data ../data
+5 -5
View File
@@ -49,7 +49,7 @@ let dids: Did[] = []
let gv: GVoice | undefined let gv: GVoice | undefined
let gvSync: GvSyncEngine | undefined let gvSync: GvSyncEngine | undefined
let waa: WaaSigner | undefined let waa: WaaSigner | undefined
// The relay through jai: the Rabbit's SIM, names and read state (relay.ts). // The relay server: the Rabbit's SIM, names and read state (relay.ts).
let relay: RelayEngine | undefined let relay: RelayEngine | undefined
const send = (channel: string, ...args: unknown[]): void => { const send = (channel: string, ...args: unknown[]): void => {
@@ -112,7 +112,7 @@ function openFromNotification(key: { did: string; contact: string }): void {
const gvNumber = (): string | undefined => db.get('gv_number') || undefined const gvNumber = (): string | undefined => db.get('gv_number') || undefined
// Every number we can text from: voip.ms's DIDs, then Google Voice's, then // Every number we can text from: voip.ms's DIDs, then Google Voice's, then
// the Rabbit's SIM (through jai). // the Rabbit's SIM (through the relay server).
function allDids(): Did[] { function allDids(): Did[] {
const n = gvNumber() const n = gvNumber()
const out: Did[] = n ? [...dids, { did: n, description: 'Google Voice', smsEnabled: true, provider: 'gvoice' }] : [...dids] const out: Did[] = n ? [...dids, { did: n, description: 'Google Voice', smsEnabled: true, provider: 'gvoice' }] : [...dids]
@@ -137,7 +137,7 @@ function startRelay(): void {
// A text over the Rabbit's SIM: pending here until the Rabbit's next check // A text over the Rabbit's SIM: pending here until the Rabbit's next check
// sends it and says how it went (relay.ts). // sends it and says how it went (relay.ts).
function relaySend(contact: string, text: string, refs: MediaRef[]): void { function relaySend(contact: string, text: string, refs: MediaRef[]): void {
if (!relay) throw new Error('The Rabbit relay is off: connect it in Settings → jai.') if (!relay) throw new Error('The Rabbit relay is off: connect it in Settings → Relay server.')
const kind = refs.length || isGroup(contact) ? 'mms' : 'sms' const kind = refs.length || isGroup(contact) ? 'mms' : 'sms'
const tempId = db.insertPending({ did: SIM_DID, contact, direction: 'out', body: text, ts: Date.now(), kind, ...(refs.length ? { media: refs } : {}) }) const tempId = db.insertPending({ did: SIM_DID, contact, direction: 'out', body: text, ts: Date.now(), kind, ...(refs.length ? { media: refs } : {}) })
relay.send(tempId, contact, text, refs) relay.send(tempId, contact, text, refs)
@@ -682,8 +682,8 @@ function registerIpc(): void {
signal: AbortSignal.timeout(15_000) signal: AbortSignal.timeout(15_000)
}).catch(() => undefined) }).catch(() => undefined)
if (!res) throw new Error(`Couldn't reach ${origin}. Is tailscale up?`) if (!res) throw new Error(`Couldn't reach ${origin}. Is tailscale up?`)
if (res.status === 401) throw new Error('jai turned down that token.') if (res.status === 401) throw new Error('The relay server turned down that token.')
if (!res.ok) throw new Error(`jai answered ${res.status}.`) if (!res.ok) throw new Error(`The relay server answered ${res.status}.`)
// Keep the key across reconnects so the Rabbit's copy stays good. // Keep the key across reconnects so the Rabbit's copy stays good.
saveRelayConfig({ url: origin, token: tok, key: loadRelayConfig()?.key ?? newKey() }) saveRelayConfig({ url: origin, token: tok, key: loadRelayConfig()?.key ?? newKey() })
startRelay() startRelay()
+1 -1
View File
@@ -22,7 +22,7 @@ export interface RabbitConfig {
gvoice: { number: string; cookies: Record<string, string> } | null gvoice: { number: string; cookies: Record<string, string> } | null
dids: Array<{ did: string; description: string }> dids: Array<{ did: string; description: string }>
defaultDid?: string defaultDid?: string
// The relay through jai (relay.ts): address, token, and the key that seals everything. // The relay server (relay.ts): address, token, and the key that seals everything.
relay?: { url: string; token: string; key: string } | null relay?: { url: string; token: string; key: string } | null
} }
+8 -9
View File
@@ -1,11 +1,11 @@
// The relay through jai: the Rabbit's SIM texts reach this computer, texts // The relay server: the Rabbit's SIM texts reach this computer, texts
// typed here go out over the Rabbit's SIM, and chat names and read/unread/ // typed here go out over the Rabbit's SIM, and chat names and read/unread/
// archived stay in step between the two, all without a USB cable. // archived stay in step between the two, all without a USB cable.
// //
// jai only ever holds sealed blobs: AES-256-GCM with a key made here and handed // The relay server only ever holds sealed blobs: AES-256-GCM with a key made here and handed
// to the Rabbit over USB (Install/Sync to Rabbit puts it in the app's private // to the Rabbit over USB (Install/Sync to Rabbit puts it in the app's private
// config.json). The bearer token only lets a device talk to the mailbox; the // config.json). The bearer token only lets a device talk to the mailbox; the
// key is what keeps jai (and anyone else on it) from reading or forging // key is what keeps the relay server (and anyone else on it) from reading or forging
// anything. Server: server/bubble_relay.py. Android side: Relay.java. // anything. Server: server/bubble_relay.py. Android side: Relay.java.
// //
// What travels (inside the seal; `t` is the kind): // What travels (inside the seal; `t` is the kind):
@@ -27,7 +27,6 @@ import type { MessageDb, NameChange, NewMessage, ReadState } from './db'
import type { MediaStore } from './media' import type { MediaStore } from './media'
export { SIM_DID } from '@shared/phone' export { SIM_DID } from '@shared/phone'
export const DEFAULT_URL = 'http://100.69.139.40:8080'
export interface RelayConfig { export interface RelayConfig {
url: string url: string
@@ -228,10 +227,10 @@ export class RelayEngine extends EventEmitter {
body: JSON.stringify({ device: 'desktop', since, push: push.map((r) => r.blob) }), body: JSON.stringify({ device: 'desktop', since, push: push.map((r) => r.blob) }),
signal: AbortSignal.timeout(120_000) signal: AbortSignal.timeout(120_000)
}) })
if (res.status === 401) throw new Error('jai turned down the token. Check it in Settings → jai.') if (res.status === 401) throw new Error('The relay server turned down the token. Check it in Settings → Relay server.')
if (!res.ok) throw new Error(`jai answered ${res.status}`) if (!res.ok) throw new Error(`The relay server answered ${res.status}`)
const body = (await res.json()) as { cursor: number; events: string[]; more: boolean } const body = (await res.json()) as { cursor: number; events: string[]; more: boolean }
// Only now that jai has them: out of the outbox. // Only now that the relay server has them: out of the outbox.
if (push.length) this.db.db.prepare('DELETE FROM relay_outbox WHERE seq <= ?').run(push.at(-1)!.seq) if (push.length) this.db.db.prepare('DELETE FROM relay_outbox WHERE seq <= ?').run(push.at(-1)!.seq)
for (const blob of body.events) this.handle(unseal(this.key, 'rabbit', blob) as Incoming | undefined) for (const blob of body.events) this.handle(unseal(this.key, 'rabbit', blob) as Incoming | undefined)
this.db.set('relay_cursor', String(body.cursor)) this.db.set('relay_cursor', String(body.cursor))
@@ -240,8 +239,8 @@ export class RelayEngine extends EventEmitter {
this.lastSync = Date.now() this.lastSync = Date.now()
this.error = undefined this.error = undefined
} catch (e) { } catch (e) {
// Can't reach jai: an ordinary, quiet outcome; try again next round. // Can't reach the relay server: an ordinary, quiet outcome; try again next round.
this.error = (e as Error).name === 'TimeoutError' ? "jai didn't answer" : (e as Error).message this.error = (e as Error).name === 'TimeoutError' ? "The relay server didn't answer" : (e as Error).message
} }
this.emit('status', this.status()) this.emit('status', this.status())
} }
@@ -225,7 +225,7 @@ export function SettingsDialog({ state, sync, onClose, onChanged }: Props) {
), ),
Contacts: <ContactsSection value={s.contactBook} onChange={(contactBook) => change({ ...s, contactBook })} />, Contacts: <ContactsSection value={s.contactBook} onChange={(contactBook) => change({ ...s, contactBook })} />,
Rabbit: <RabbitSection onChanged={onChanged} />, Rabbit: <RabbitSection onChanged={onChanged} />,
jai: <RelaySection onChanged={onChanged} />, 'Relay server': <RelaySection onChanged={onChanged} />,
Storage: ( Storage: (
<section className="group"> <section className="group">
<h3>Storage &amp; backups</h3> <h3>Storage &amp; backups</h3>
@@ -499,10 +499,10 @@ function RabbitSection({ onChanged }: { onChanged: () => void }) {
) )
} }
// The Rabbit's SIM (and names + read status) through jai, no cable needed. // The Rabbit's SIM (and names + read status) through the relay server, no cable needed.
function RelaySection({ onChanged }: { onChanged: () => void }) { function RelaySection({ onChanged }: { onChanged: () => void }) {
const [st, setSt] = useState<RelayStatus>() const [st, setSt] = useState<RelayStatus>()
const [url, setUrl] = useState('http://100.69.139.40:8080') const [url, setUrl] = useState('')
const [token, setToken] = useState('') const [token, setToken] = useState('')
const [busy, setBusy] = useState(false) const [busy, setBusy] = useState(false)
const [error, setError] = useState<string>() const [error, setError] = useState<string>()
@@ -550,10 +550,10 @@ function RelaySection({ onChanged }: { onChanged: () => void }) {
: undefined : undefined
return ( return (
<section className="group"> <section className="group">
<h3>Rabbit relay</h3> <h3>Relay server</h3>
<p className="muted small"> <p className="muted small">
Texts the Rabbit's SIM card sends and gets show up here, you can text from it here (as "Rabbit SIM"), and chat names and Texts the Rabbit's SIM card sends and gets show up here, you can text from it here (as "Rabbit SIM"), and chat names and
read/unread/archived stay in step with the Rabbit without plugging it in. It goes through jai, which only passes on sealed messages read/unread/archived stay in step with the Rabbit without plugging it in. It goes through your relay server (server/bubble_relay.py), which only passes on sealed messages
it can't read: the key stays on this computer and the Rabbit. A text sent from here goes out at the Rabbit's next background check it can't read: the key stays on this computer and the Rabbit. A text sent from here goes out at the Rabbit's next background check
(Settings there: how often), so it can take a while. (Settings there: how often), so it can take a while.
</p> </p>
@@ -583,7 +583,7 @@ function RelaySection({ onChanged }: { onChanged: () => void }) {
<> <>
<label className="field"> <label className="field">
Address Address
<input value={url} onChange={(e) => setUrl(e.target.value)} spellCheck={false} /> <input value={url} onChange={(e) => setUrl(e.target.value)} placeholder="http://100.x.y.z:8080" spellCheck={false} />
</label> </label>
<label className="field"> <label className="field">
Token Token
@@ -591,12 +591,12 @@ function RelaySection({ onChanged }: { onChanged: () => void }) {
type="password" type="password"
value={token} value={token}
onChange={(e) => setToken(e.target.value)} onChange={(e) => setToken(e.target.value)}
placeholder="from scripts/deploy-jai.sh --token" placeholder="from scripts/deploy-relay.sh --token"
autoComplete="off" autoComplete="off"
/> />
</label> </label>
<div className="btn-row"> <div className="btn-row">
<button className="primary" disabled={busy || !token.trim()} onClick={connect}> <button className="primary" disabled={busy || !url.trim() || !token.trim()} onClick={connect}>
Connect Connect
</button> </button>
</div> </div>
+1 -1
View File
@@ -8,7 +8,7 @@ export function normalizeNumber(raw: string): string {
return digits return digits
} }
// The Rabbit's SIM, reached through jai (main/relay.ts): a number we text // The Rabbit's SIM, reached through the relay server (main/relay.ts): a number we text
// from that isn't a phone number here. // from that isn't a phone number here.
export const SIM_DID = 'sim' export const SIM_DID = 'sim'
+1 -1
View File
@@ -1,7 +1,7 @@
// The relay against the dev app on a plugged-in Rabbit (DEVICE=1 npm test -- // The relay against the dev app on a plugged-in Rabbit (DEVICE=1 npm test --
// test/relay.device.test.ts). A throwaway local relay, reached from the Rabbit // test/relay.device.test.ts). A throwaway local relay, reached from the Rabbit
// through adb reverse; the dev app's made-up data (tools/push_sandbox.py). // through adb reverse; the dev app's made-up data (tools/push_sandbox.py).
// Never the real app, never jai. // Never the real app, never the real relay server.
import { execFileSync, spawn, type ChildProcess } from 'node:child_process' import { execFileSync, spawn, type ChildProcess } from 'node:child_process'
import fs from 'node:fs' import fs from 'node:fs'
import net from 'node:net' import net from 'node:net'
+2 -2
View File
@@ -73,7 +73,7 @@ describe('relay', () => {
}) })
it('only sends the token to tailscale or https', () => { it('only sends the token to tailscale or https', () => {
expect(checkUrl('http://100.69.139.40:8080/')).toBe('http://100.69.139.40:8080') expect(checkUrl('http://100.101.102.103:8080/')).toBe('http://100.101.102.103:8080')
expect(() => checkUrl('http://example.com')).toThrow() expect(() => checkUrl('http://example.com')).toThrow()
expect(checkUrl('https://example.com')).toBe('https://example.com') expect(checkUrl('https://example.com')).toBe('https://example.com')
}) })
@@ -143,7 +143,7 @@ describe('relay', () => {
const ref = await media.resolve(oldMms, 0) const ref = await media.resolve(oldMms, 0)
expect(fs.readFileSync(media.filePath(ref!.file!)).toString()).toBe('fake png') expect(fs.readFileSync(media.filePath(ref!.file!)).toString()).toBe('fake png')
// Picked up = gone from jai. // Picked up = gone from the relay server.
expect(await rabbit(key)).toEqual([]) expect(await rabbit(key)).toEqual([])
engine.stop() engine.stop()
db.close() db.close()