6 Commits
Author SHA1 Message Date
lotherk ea31073ce0 dtchat: exchange media keys and wire live calls into the UI (T6.5)
The local protocol gets media-key: each side sends its ephemeral X25519 public key (base64) and UDP port over the ready text connection; both derive the direction keys with HKDF-SHA256, the caller is the initiator. localui sends the key on Conversation > Call, answers an offer with its own key, creates the call with dc_call_new_bound on the listener port (TLS and media share the number), rings, and opens the call window; an incoming ring enables Answer. The Xt loop pumps the call: drain, Opus decode to the playback stream, capture and encode only while our own PTT is held, video frames to the window, ring timeout. dc_local_conn_remote_addr gives the numeric peer address; dc_call_new_bound binds the announced port. dc_call_talking() is now only our own key, dc_call_peer_talking() the peer's (a received PTT used to start our microphone too). The call window has an Answer button and lays the buttons above the video so they stay visible. --call-first and DTCHAT_TEST_TRUST/DTCHAT_TEST_AUTOANSWER/DTCHAT_TEST_PTT drive the test: two UI instances auto-paired, exchanged media-key, rang, answered, reached IN_CALL and carried 200 Opus frames caller->callee with the callee silent (audio out 200 on the receiver, audio in 200 on the sender); screenshot build/mcde-shots/dtchat-t65-live.png. The smoke still passes; test_media_call uses peer_talking; test_media_packet covers the base64 key exchange. The test switch is documented in the security review.
2026-11-17 08:49:25 +00:00
lotherk 134cacc93d dtchat: bind local identities to their keys and gate files on pairing (T10.2)
Security review findings: (1) the local peer identity was only a claimed pin; the listener now requests the client certificate and compares the certificate hash that completed the handshake with the pin in hello, refusing a mismatch or a missing certificate, and the client presents its identity certificate (test_local uses real identities: matching, other identity, any). (2) unpaired peers could send file offers; the UI manager carries a paired flag, answers offers from unpaired peers with file-reject 'pairing required' and refuses to send. The review document lists both fixes and the accepted limits (no passphrase, public pins, media nonces later, adapter spawn, file names, QR, parser limits). Standalone: test_local, test_filexfer, tests/p2p.sh and the UI pairing/message run pass with the changes. The in-tree build is pending because another release chain holds the lock (pid 4040149).
2026-11-17 06:49:35 +00:00
lotherk dc44fc25a3 dtchat: add the headless peer mode (T5.7)
dtchat-headless starts the TLS listener (--listen [HOST:]PORT, port 0 prints the real port) and one reconnecting link per --peer, loads/creates the identity in --config, prints JSON events (ready, peer-online, peer-offline, message, typing, file-offer, error) and takes JSON commands on stdin (send by host:port or peer id, quit). dc_local_peer_conn() and the ack id let a link know its peer. tests/p2p.sh runs two instances over loopback: A listens, B connects, B sends, A answers by id, both quit; standalone run prints 'tests/p2p.sh: all ok'. Wired into noinst_PROGRAMS and mcde-tests.sh (expect 29 ok). make mcde-host still blocked by pid 2126511 (release/sourcesets/usb).
2026-11-16 20:43:06 +00:00
lotherk 7c8642298c dtchat: add local file transfer (T5.6)
filexfer.c offers name/size/sha256, sends 64 KiB chunks as base64 file-data lines and a file-end; the receiver writes NAME.part, enforces the 512 MiB limit, checks size and SHA-256 and renames to a sanitized name without overwriting. Cancel removes the part. Names take the basename, drop dot-dot and control characters. The local connection buffers grow to 128 KiB for one chunk per line; dc_local_conn_busy() lets the sender pace itself. test_filexfer: safe names, 1 MiB+12345 transfer with 64 KiB chunks and matching hash, oversized offer refused, cancel leaves no part file; standalone and ASan/UBSan clean; test_local still green. make mcde-host still blocked by the foreign release/sourcesets/usb chain (pid 2126511).
2026-11-16 20:39:37 +00:00
lotherk ce0b684613 dtchat: add the local text protocol and reconnect (T5.5)
local.c now has the client side of the peer protocol: dc_local_connect verifies that the server's hello-ack pin is the pin of the certificate it actually saw (and against the expected pin), sends our hello after the handshake, and has a 5 s hello-ack timeout. Ready connections exchange presence, msg, msg-ack and typing as JSON lines; the server and client dispatch input line by line from a shifted buffer. dc_local_peer_* wraps a client with 2, 4, 8 ... 60 s reconnect and online/offline callbacks. configure now requires libtls (the ADR does). test_local covers the three T5.4 pin cases, a full protocol round trip (msg -> ack, typing, presence) and a reconnect after the server restarts; standalone and ASan/UBSan clean. make mcde-host is still blocked by the foreign release chain (pid 2126511).
2026-11-16 20:35:47 +00:00
lotherk 3aab4e35c8 dtchat: add the local TLS listener and TOFU hello (T5.4)
local.c binds a nonblocking TLS listener (identity certificate, 127.0.0.1 or all interfaces, port 0 = ephemeral) and drives the handshake from DcLoop. A peer sends one JSON line {type:hello,id,pin}; the listener checks id and pin against what it expects, answers {type:hello-ack,ok:true|false,pin:...} and closes on a wrong pin, a lying or malformed hello. The accepted hello goes to the callback once; connections stay open for the protocol of T5.5. identity.c now also exposes the private key as PEM for libtls. test_local starts a listener per case and connects with a blocking libtls client: matching pin accepted (callback sees id/pin), wrong pin rejected (no callback, ok:false), any-pin accepted. Standalone test all ok; make mcde-host could not run because another agent's release+sourcesets+usb chain holds build/.build.lock (pid 2126511); the next build verifies the wiring.
2026-11-16 20:23:14 +00:00