feat: connect through the OpenChamber private relay
A server can now be added by pasting an openchamber://connect pairing link. The one-time secret is redeemed over the first reachable candidate (direct addresses first, then the relay), and the device token is stored with the connection, so later launches reconnect without the link. The relay candidate carries the relay WebSocket URL, the host's routing id and its P-256 public key. The new transport opens one encrypted tunnel to the relay: P-256 ECDH + HKDF-SHA256 derive one AES-256-GCM key per direction; frames carry a version, a 12-byte IV and the GCM tag; a small mux carries HTTP, SSE and WebSocket sub-streams with fragmentation and ping/pong. Every request and the terminal socket ride it; WebSocket upgrades first mint the short-lived oc_url_token over the tunnel, since upgrades cannot send headers. Only the host's legacy path is negotiated (no batching, downstream flow control or body gzip). Pairing while connected switches servers like picking one in the list, which exposed and fixes a ChatScreen crash when app.chat is cleared during the switch. 0.4.4 (404).
This commit is contained in:
1 parent
a7bc380ac0
commit
902f1e18bb
20 files changed
+1918
-75
No files matched your search
@@ -3,7 +3,6 @@
|
||||
// tag, then JSON). A socket can attach to several terminals; we attach to one.
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'transport.dart';
|
||||
|
||||
@@ -112,7 +111,7 @@ class TerminalSocket {
|
||||
final void Function(TerminalEvent event) onEvent;
|
||||
final void Function(TerminalLinkState state, {String? detail}) onState;
|
||||
|
||||
WebSocket? _socket;
|
||||
TransportSocket? _socket;
|
||||
Timer? _keepAlive;
|
||||
Timer? _reconnect;
|
||||
final StringBuffer _pending = StringBuffer();
|
||||
@@ -144,7 +143,7 @@ class TerminalSocket {
|
||||
}
|
||||
_socket = socket;
|
||||
_failures = 0;
|
||||
socket.listen(
|
||||
socket.messages.listen(
|
||||
_handle,
|
||||
onError: (_) => _drop(generation),
|
||||
onDone: () => _drop(generation),
|
||||
|
||||
Reference in new issue
Block a user