Simplify Remote setup and prepare experimental 0.1.1 release
This commit is contained in:
1 parent
346ec77c75
commit
6d043ee01f
14 files changed
+684
-640
No files matched your search
+43
-18
@@ -1,17 +1,19 @@
|
||||
# Remote 0.1.0 — experimental test release
|
||||
# Remote 0.1.1 — experimental test release
|
||||
|
||||
Remote connects Cthulhu to an NVDA Remote protocol-v2 relay, as either a
|
||||
controller or a controlled computer, with relay/role selection, reader-owned
|
||||
consent, connection controls, speech, keyboard, clipboard text and Braille.
|
||||
Version 0.1.0 is the first packaged release for live testing. Physical keyboard
|
||||
recovery, audible speech/masking, physical Braille and NVDA/Orca interoperability
|
||||
Version 0.1.1 simplifies the connection UI and remains a release for live
|
||||
testing. Physical keyboard recovery, audible speech/masking, physical Braille and NVDA/Orca interoperability
|
||||
have not yet passed live acceptance. ARM64 is cross-built and has not been run
|
||||
on ARM64 hardware.
|
||||
|
||||
## Install and test 0.1.0
|
||||
## Install and test 0.1.1
|
||||
|
||||
Use the matching experimental Cthulhu reader from `testing` revision
|
||||
`952d3c82049a5521c506d7e30e6118361f2c7f4d` or a compatible later revision.
|
||||
`bf4a23645eafa3efbd4321e6f95fe13a011ced7a` or a compatible later revision.
|
||||
It must support optional Remote grants and polling form transitions; see the
|
||||
reader's `docs/testing/remote-ui.md`. Older readers cannot run this workflow.
|
||||
Keyboard control requires its `cthulhu-input-helper`; Braille requires
|
||||
`cthulhu-braille`. Keyboard capture/injection requires Xorg. Installing this
|
||||
Tentacle does not update the reader or its helpers.
|
||||
@@ -20,15 +22,38 @@ In global Cthulhu Preferences → Tentacles, add or refresh
|
||||
`https://git.stormux.org/storm/cthulhu-tentacles`, select **Remote**, review its
|
||||
version and requested access, and choose **Install and enable**. Packages for
|
||||
Linux amd64 and arm64 and their SHA-256 checksums are on the
|
||||
[0.1.0 release page](https://git.stormux.org/storm/cthulhu-tentacles/releases/tag/remote-v0.1.0).
|
||||
[0.1.1 release page](https://git.stormux.org/storm/cthulhu-tentacles/releases/tag/remote-v0.1.1).
|
||||
|
||||
Press Cthulhu+Ctrl+Shift+R, select the role and relay, and choose the services
|
||||
to test. Each connection also needs physical local approval in the reader's
|
||||
dialog. Use a private test relay and harmless text on disposable test desktops.
|
||||
Choose **Return to desktop and keep this connection** after connecting; the
|
||||
same shortcut reopens status and Disconnect. Keyboard focus uses
|
||||
Cthulhu+Ctrl+Shift+F; F11 returns to local control. Clipboard send/receive use
|
||||
Cthulhu+Ctrl+Shift+C/V and never automatically overwrite the clipboard.
|
||||
Press **Cthulhu+Ctrl+Shift+R**. Choose Mode, enter Host and Key, then
|
||||
choose Connect. Host accepts `relay.example:7000`; the default port is 6837.
|
||||
The key is masked and is never saved automatically. More options contains
|
||||
explicit saved-key actions, certificate inspection and keyboard mapping.
|
||||
|
||||
The certificate is verified before the reader asks you to select access.
|
||||
Only installed permissions are offered; all start unchecked. Select speech,
|
||||
keyboard, clipboard or Braille as needed and choose **Allow selected access and
|
||||
connect**. The form closes automatically after joining the relay. Reopen Remote
|
||||
for status and Disconnect; Close or Escape keeps a live connection.
|
||||
|
||||
If certificate verification fails, use **Inspect relay certificate** in the
|
||||
options form. Check its fingerprint with the relay operator and choose Trust
|
||||
once or remember it for this host and port. Inspection sends no key; trust
|
||||
alone never connects. Choose Connect again to review access and join.
|
||||
|
||||
| Keys | Action |
|
||||
| --- | --- |
|
||||
| Cthulhu+Ctrl+Shift+R | Connect, or open connection status |
|
||||
| Cthulhu+Alt+Tab | Switch keyboard control; F11 also returns here |
|
||||
| Cthulhu+Alt+Page Down | Disconnect |
|
||||
| Cthulhu+Ctrl+Shift+Page Up | Report status |
|
||||
| Cthulhu+Alt+M | Mute or unmute remote speech |
|
||||
| Cthulhu+Ctrl+Shift+C | Send clipboard text |
|
||||
| Cthulhu+Ctrl+Shift+V | Accept received clipboard text |
|
||||
|
||||
While the keyboard controls the other computer, any Remote shortcut first
|
||||
returns it here. Press the shortcut again to run its action; the keyboard toggle
|
||||
therefore returns in one press. Mute affects only remote speech. Clipboard text
|
||||
never overwrites this computer's clipboard until explicitly accepted.
|
||||
|
||||
Follow [the physical keyboard, speech, clipboard and Braille checks](command.md)
|
||||
on both desktops. Check disconnect/lock/handoff with modifiers held, local
|
||||
@@ -50,7 +75,7 @@ Implemented:
|
||||
ancestry, including every joined zone and outer menu ancestors. Incoming
|
||||
software speech now has delivery-time lease/output policy, local priority and
|
||||
separate cancellation ownership. Other reading producers and audible
|
||||
acceptance remain pending. Explicit Return to desktop now releases the status
|
||||
acceptance remain pending. Automatic desktop return releases the connection
|
||||
form while retaining the original approved lease; the shortcut reopens status
|
||||
and Disconnect. Physical capture/release acceptance remains pending.
|
||||
See [speech.md](speech.md).
|
||||
@@ -80,7 +105,7 @@ Implemented:
|
||||
Cthulhu+Ctrl+Shift+C; received text waits until Cthulhu+Ctrl+Shift+V copies
|
||||
it. Up to 8 KiB of text; no files, no automatic overwrite.
|
||||
- Controller keyboard control: with keyboard control approved, the
|
||||
`remote-focus` command (Cthulhu+Ctrl+Shift+F) sends this keyboard through the
|
||||
`remote-focus` command (Cthulhu+Alt+Tab) switches this keyboard through the
|
||||
reader's exclusive capture; F11 or any Remote shortcut returns it. Live
|
||||
acceptance is pending. See [command.md](command.md).
|
||||
- Controlled-role keyboard control: an explicit session-only option requests
|
||||
@@ -130,8 +155,8 @@ Implemented:
|
||||
- Explicit certificate inspection with no application data, fingerprint review
|
||||
with Copy/Trust once/Cancel, and masked Remember/Forget key form handlers.
|
||||
A single library connection workflow now combines them with explicit saved-key
|
||||
loading, Connect and status/Disconnect. Setup cancellation follows pending
|
||||
approval lifetime; stale forms cannot disconnect a newer epoch. These have
|
||||
loading, Connect and status/Disconnect. Credentials and certificate checks precede approval. Setup cancellation follows the
|
||||
local interaction lifetime; stale forms cannot disconnect a newer epoch. These have
|
||||
private SDK-process coverage and source-command registration.
|
||||
The reader authorization prerequisite is described below. See [security-ui.md](security-ui.md) and
|
||||
[connection-ui.md](connection-ui.md).
|
||||
@@ -167,7 +192,7 @@ adds core consent, lock/handoff cancellation and local-only sensitive forms.
|
||||
Injected approval is rejected in private XI2 tests; physical-keyboard approval
|
||||
remains unverified. The source command now requests core consent through typed
|
||||
interaction requests. Core revokes the original epoch on ordinary interaction completion;
|
||||
an explicit desktop return retains only the verified already-open lease.
|
||||
automatic desktop return retains only the verified already-open lease.
|
||||
Bounded cancellation also stops pre-lease inspection on lock/handoff.
|
||||
Keyboard, clipboard text and Braille desktop services use these approved leases.
|
||||
|
||||
|
||||
+61
-309
@@ -1,320 +1,72 @@
|
||||
# Remote source command and reader consent
|
||||
# Remote connection workflow, 0.1.1
|
||||
|
||||
The source-built Remote executable now registers a production command through
|
||||
the public Go SDK. This increment joins relay/role selection, reader-owned
|
||||
consent and the existing connection workflow. It provides **experimental speech**
|
||||
with the matching reader. Subsequent increments added keyboard control,
|
||||
clipboard text and Braille; version 0.1.0 packages these for live testing.
|
||||
See [installation and current requirements](README.md#install-and-test-010).
|
||||
Remote uses Cthulhu+Ctrl+Shift+R to open a compact Mode, Host and masked Key
|
||||
form. Host accepts an optional port. Cancel starts focused and works with empty
|
||||
entries. More options opens explicit saved-key, certificate and keyboard-map
|
||||
controls. Only relay address, mode and explicitly remembered trust are ordinary
|
||||
saved settings; the channel key is saved or loaded only by explicit action.
|
||||
|
||||
The subsequent [speech coordinator increment](speech.md) now connects typed
|
||||
relay speech to presentation IPC and reader output events to relay writes.
|
||||
The matching reader now has limited observation of explicitly local ordinary
|
||||
accessibility/document speech after worker policy. Production software sessions
|
||||
now attach an incoming owner with original-lease checks, local output priority
|
||||
and isolated cancellation. Status now offers **Return to desktop and keep this connection** once
|
||||
the reader lease opens. The shortcut reopens status and Disconnect; forms capture
|
||||
local keys only while open. The UI retains experimental-speech wording until live acceptance is complete.
|
||||
Receiving speech with no reader owner closes the connection and lease. Hardware
|
||||
backends fail isolated acquisition and retire the lease; no hardware device is
|
||||
opened for incoming Remote speech.
|
||||
Connect performs a normal verified TLS handshake without application data before
|
||||
requesting reader consent. An untrusted relay returns to options for explicit
|
||||
certificate inspection and fingerprint review. Trust is bound to the immutable
|
||||
host/port and certificate and does not connect. The actual join uses a new TLS
|
||||
connection and verifies trust again before sending the key.
|
||||
|
||||
Base revisions checked against maintained upstreams on 2026-11-04: reader
|
||||
`testing` at `4cf3335`, Tentacles `master` at `0c74038`. No installed reader or
|
||||
active desktop session is changed by building or running the private tests.
|
||||
Explicit Return to desktop requires reader commit `b4896a2` or a descendant
|
||||
containing its terminal `remote_background` interaction support.
|
||||
The reader makes the only permission decision. Required speech access and
|
||||
optional keyboard, clipboard and Braille are offered within installation grants;
|
||||
all start unchecked. Optional permissions absent from installation are omitted.
|
||||
Only a nonempty local approval produces the SDK event for the exact requesting
|
||||
session. Remote compares that event with the continuation's metadata. It then
|
||||
opens the lease and joins immediately, avoiding the previous 30-second expiry
|
||||
during credential entry or certificate review. Approval still expires, is
|
||||
single-use, and is revoked on lock/handoff, disable or process loss.
|
||||
|
||||
## Ownership and behavior
|
||||
Progress forms poll once per second. Inspection completion replaces the progress
|
||||
form with certificate review; verified preflight advances to reader consent.
|
||||
After a successful join, polling returns the verified background lease to the
|
||||
reader, which releases form capture without renewing consent. No Refresh or
|
||||
Return to desktop action is needed. Failed attempts close their lease. There is
|
||||
no automatic retry or unattended connection.
|
||||
|
||||
`remote/cmd/remote` calls `remote.Serve` with owned SDK streams and a private
|
||||
settings directory. Its default is `$XDG_CONFIG_HOME/cthulhu-remote`, or
|
||||
`~/.config/cthulhu-remote` when unset. `--data-dir` selects an absolute directory;
|
||||
parents must already exist. Existing storage restrictions apply, including
|
||||
rejection of symlinked ancestors and unsafe permissions. Startup loads only
|
||||
ordinary relay/role/pin settings, with no networking or saved-key read.
|
||||
Reopening Remote shows status, Close and Disconnect. Close or Escape retains a
|
||||
live lease; Disconnect or the dedicated disconnect command ends it. The keyboard
|
||||
starts local. Cthulhu+Alt+Tab enters remote control; the same chord or F11 returns
|
||||
through the reader's capture owner. Other Remote shortcuts return capture first
|
||||
and run on a second press. Remapped commands retain the reader's routing rules.
|
||||
|
||||
The `remote` command uses **Cthulhu+Ctrl+Shift+R** in both layouts. It opens
|
||||
relay host, port and controller/controlled role selection, initially on Cancel.
|
||||
Save relay and role writes only ordinary settings and never connects. Changing
|
||||
the endpoint drops the previous endpoint's pin. Review access returns a typed
|
||||
`Interaction.remote` request to the host, not a lease or permission decision.
|
||||
Cthulhu+Alt+M toggles incoming remote speech. Muting invalidates queued speech
|
||||
and sends cancellation through the original remote lease's ordered operation
|
||||
owner, leaving local speech cancellation independent. Unmute admits new speech
|
||||
without replaying old queued utterances. Clipboard and Braille remain separate.
|
||||
|
||||
The host keeps its existing interaction slot and resolves the exact requesting
|
||||
process session. Install grants limit the requested role/grants. The reader's
|
||||
own local-only form starts on Cancel with every grant unchecked. The command
|
||||
requests `remote-present` for controller or `output-observe` for controlled,
|
||||
plus the keyboard, clipboard and Braille services explicitly selected for that
|
||||
connection. Install grants and the separate reader approval constrain each
|
||||
service. A shortcut, child request or fabricated command
|
||||
argument cannot approve access.
|
||||
## Verification
|
||||
|
||||
On explicit nonempty approval the reader issues `remote.action` through the SDK
|
||||
event stream and gives the continuation a matching `Submission.remote`. The
|
||||
command waits for that exact SDK event before claiming the connection workflow.
|
||||
Cancel, denial, policy loss and missing events cannot advance to credentials.
|
||||
The pending action expires after 30 seconds; long certificate/key reviews can
|
||||
outlast it. In that case Connect fails and a fresh local access review is needed.
|
||||
Run `make check GOPROXY=off` and the Remote race suite. The matching reader's
|
||||
actual-host tests run both roles through private TLS relays, synthetic local
|
||||
approval, ordinary speech observation, isolated incoming synthesis, automatic
|
||||
desktop return, status reopening, disconnect and lifecycle cancellation. Unit
|
||||
checks cover forged approval, optional grants, masked keys, endpoint trust,
|
||||
preflight with no application bytes, and mute ordering without replay.
|
||||
|
||||
Every Remote form uses the reader's sensitive XI2 input capture, including relay
|
||||
selection, secret editing, trust, saved keys and status. The coordinator owns
|
||||
the only SDK event consumer and heartbeats the lease before/during networking.
|
||||
All networking remains on its workers. The command never reconnects automatically.
|
||||
For live acceptance, use disposable Xorg desktops and a private relay with the
|
||||
matching reader and its helpers. Do not replace an active reader to run private
|
||||
tests. On both roles, check Tab/Shift+Tab and Cancel with empty fields, masked key
|
||||
speech/Braille, saved-key loading, trusted/untrusted/changed certificates, and
|
||||
cancel/lock/handoff during both inspection and connection. Connect must show
|
||||
permissions once, return to the desktop automatically, and leave the keyboard
|
||||
local. Close/Escape in status must retain the connection; Disconnect must end it.
|
||||
|
||||
When an interaction ends normally, core revokes only its original approved epoch,
|
||||
including unused actions. Explicit Return to desktop instead returns a terminal
|
||||
`remote_background` result carrying the opened lease/epoch. Core verifies its
|
||||
live ownership before releasing the interaction without child cancellation.
|
||||
Heartbeats continue independently; this action neither renews consent nor starts
|
||||
another connection. Reopening status requires no second consent. Before lease
|
||||
open, Return to desktop asks the user to refresh status or disconnect.
|
||||
Stale cleanup cannot revoke replacement consent. On cancellation
|
||||
or an unfinished exit, a bounded cleanup invocation also retires child setup.
|
||||
This is needed before `remote.open`, when no lease-revocation event exists.
|
||||
Lock/handoff invalidates the interaction's original policy context; returning
|
||||
does not revive it. Process EOF joins workflow/inspection/relay/event workers
|
||||
before closing storage. Repeated shortcuts cannot replace a live workflow.
|
||||
Allow keyboard access and check Alt+Tab, F11, held modifiers, repeated keys,
|
||||
Num Lock and supported layouts, including disconnect/lock/handoff while a key
|
||||
is held. Check that unsupported keys do not leave modifiers held. Verify local
|
||||
speech remains audible during remote mute/cancel; unmute must not replay speech.
|
||||
Test repeated letters, language and character-mode changes, ordinary focus,
|
||||
current-line/review/Where Am I and Say All. Password/private-source text must stay
|
||||
local. Test explicit clipboard send/accept and physical Braille pan/routing.
|
||||
Recheck ordinary reader forms, learn mode, remapped shortcuts, Hello World,
|
||||
Wormhole and Battery Status because polling shares their interaction host.
|
||||
|
||||
## Explicit saved trust
|
||||
|
||||
Certificate review additionally offers **Trust and remember this certificate
|
||||
for this relay host and port**. It consumes that review once, saves the exact
|
||||
observed digest using the existing private atomic store, and returns to explicit
|
||||
Connect. Copy fingerprint and Trust once retain their previous meanings.
|
||||
The credentials form can forget the current endpoint's pin and return to normal
|
||||
CA/hostname validation. These actions neither open a lease nor join the relay.
|
||||
Write errors are reported; a sync failure after rename can leave stored trust
|
||||
changed, so a failed save is not described as a rollback.
|
||||
|
||||
## Private verification
|
||||
|
||||
From the Tentacles checkout:
|
||||
|
||||
```sh
|
||||
make check GOPROXY=off
|
||||
GOCACHE=/tmp/cthulhu-cache GOPROXY=off go test -race ./remote/... -count=1 -timeout=90s
|
||||
go build -race -o /tmp/cthulhu-remote-next ./remote/cmd/remote
|
||||
```
|
||||
|
||||
From the reader checkout, using that separately built executable:
|
||||
|
||||
```sh
|
||||
GOCACHE=/tmp/cthulhu-go-cache GOPROXY=off CTHULHU_REMOTE_BINARY=/tmp/cthulhu-remote-next go test -race ./internal/app -run '^TestRemoteConnectionCommand' -count=1 -timeout=90s -v
|
||||
```
|
||||
|
||||
`make check` builds the source command, checks its initial interaction through
|
||||
the command host, and runs these real-process application integration cases.
|
||||
They cover both roles, unchecked core consent, denial/empty approval, fresh
|
||||
setup after lock/handoff cancellation, key-free inspection, explicit Trust once,
|
||||
fresh TLS join, explicit desktop return, repeated status reopening and background
|
||||
disconnect/lock/handoff/disable. A stalled-inspection case verifies cancellation
|
||||
before a lease exists. Unit/race tests additionally cover invalid requests,
|
||||
fabricated approval without an SDK event, endpoint trust isolation, explicit
|
||||
Remember/Forget pin, failed writes and stale/removed pins. Native form-model
|
||||
coverage verifies empty relay entries do not block Cancel. The complete Remote
|
||||
race suite, existing host/both-SDK conformance race suites, focused application
|
||||
race tests, vet, reader build and `make check` passed. The desktop-return change
|
||||
also passed ten repetitions of the source-command connection race cases and
|
||||
focused shared interaction/consent/observation checks. Earlier command increments
|
||||
passed the private Xorg remote-input and internal-form harnesses, retaining injected-approval
|
||||
rejection, secret/ordinary forms, learn mode and XTerm handoff behavior.
|
||||
Those native harnesses were not rerun for desktop return; physical capture
|
||||
release remains unverified.
|
||||
Fixtures use private loopback relays and synthetic local
|
||||
form submissions; they do not exercise physical keyboard input.
|
||||
|
||||
## Physical keyboard acceptance, still pending
|
||||
|
||||
Use a disposable Xorg desktop with the newly built matching reader and command.
|
||||
Do not attach synthetic input to the active reader. A development launch list
|
||||
may contain the following, with absolute paths substituted:
|
||||
|
||||
```json
|
||||
[
|
||||
{
|
||||
"ID": "remote",
|
||||
"Program": ["/absolute/cthulhu-tentacles/remote/bin/remote", "--data-dir", "/absolute/private-parent/remote-state"],
|
||||
"Presentation": true,
|
||||
"Interaction": true,
|
||||
"SessionEvents": true,
|
||||
"RemoteGrants": ["output-observe", "remote-present"]
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
Pass that file with `--tentacles /absolute/launch.json` and a disposable
|
||||
`--config` when starting the matching reader in that test session. Building
|
||||
Remote alone does not update the reader's consent-interaction support.
|
||||
|
||||
For each live test, first configure the disposable development session above.
|
||||
Quit its current Cthulhu with Cthulhu+Q. Press Ctrl+Escape, then press Shift+G to
|
||||
rebuild and launch through `~/devel/cthulhu-go.sh`; these are separate key presses.
|
||||
Use the matching development launch list when starting the reader in that test
|
||||
session. The standard launcher alone does not register Remote. Keep the active
|
||||
reader and personal configuration untouched while preparing the test session.
|
||||
|
||||
1. Use physical keys to open Remote, Tab/Shift+Tab through every control, select
|
||||
each role and cancel. Review access must focus Cancel, with no prechecked
|
||||
permissions. Approval with nothing checked must not reach credentials.
|
||||
2. Approve the requested grant and verify masked typing/editing, denied copy/cut,
|
||||
explicit paste and empty fields after cancelling/reopening. Confirm audible
|
||||
output and physical Braille do not reveal the key.
|
||||
3. Use a private relay. Inspect its certificate, verify/copy its fingerprint,
|
||||
test Cancel, Trust once, explicit Remember/Forget pin, and Remember/Forget key.
|
||||
Confirm none connects until Connect is chosen. Restart the test process and
|
||||
check stored trust without automatic connection or automatic key loading.
|
||||
4. Cancel while inspection or TLS join stalls; lock/unlock and trigger XTerm
|
||||
handoff during consent, inspection and an established relay connection.
|
||||
Confirm cancellation, no resume, no stale approval and a fresh usable command.
|
||||
5. After connecting, choose Return to desktop and keep this connection. Confirm
|
||||
the form disappears, ordinary typing reaches the local application, and
|
||||
application focus/reading and local Braille resume. Wait at least four seconds,
|
||||
then press Cthulhu+Ctrl+Shift+R: status must reopen without a new consent/key
|
||||
prompt. Disconnect must close the relay. Repeat Return to desktop followed by
|
||||
lock/unlock or XTerm handoff; the old connection must end and never resume.
|
||||
With a matching development reader using software speech, send harmless
|
||||
ordinary text, repeated-character spelling, a supported alternate language,
|
||||
significant whitespace and Say All from the peer. Confirm the intended speech
|
||||
is audible after desktop return, with no duplicate local export. While Remote
|
||||
is speaking, trigger local reading/key echo and status; local output must take
|
||||
priority and interrupted remote text must not resume. Peer cancel/pause must
|
||||
leave local announcements audible. Repeat disconnect, lock and handoff during
|
||||
active speech: old speech must stop, with no replay after reconnection.
|
||||
Record exact heard text/order and cancellation behavior; relay status alone
|
||||
does not establish speech acceptance.
|
||||
6. For current-line export, use two matching development peers on a private relay.
|
||||
On the controlled computer approve output observation and choose Return to
|
||||
desktop; the controller must also return to desktop to receive speech.
|
||||
Using the controlled computer's physical keyboard, open a harmless browser
|
||||
document containing a line such as "A book" and enter browse mode. After focus
|
||||
speech settles, press Cthulhu+Shift+Up Arrow once. Both computers should speak
|
||||
the current line. Repeat the chord twice quickly (within 500 milliseconds
|
||||
between presses) for spelling, then three times quickly for phonetic spelling.
|
||||
Record the final spelling/phonetic result, including both repeated "o"
|
||||
characters, and any interruption or duplicate output. The application focus,
|
||||
native/virtual caret and local Braille should stay at their previous position;
|
||||
ordinary arrow navigation and typing should retain their usual behavior.
|
||||
Repeat after disconnect: local reporting should remain available and the peer
|
||||
should receive nothing. Reconnect explicitly, focus an ordinary GTK entry or
|
||||
text editor outside browse mode, put its caret in the middle of "A book", and
|
||||
repeat the single/double/triple chord: both computers should speak the same
|
||||
whole line, spelling and phonetics, with both "o" characters retained.
|
||||
Confirm focus, caret, ordinary typing and local Braille stay unchanged.
|
||||
Password sources or private/unknown/incomplete ancestry must produce no new
|
||||
exported current-line utterance; an ordinary report whose ancestry cannot be
|
||||
captured should still be readable locally. Ordinary focus/typing events are
|
||||
separate output paths. Repeat disconnect, lock/unlock and XTerm handoff;
|
||||
old reports must not replay and a new connection requires explicit consent.
|
||||
Record exact local/peer speech, focused control,
|
||||
caret/Braille position and keys that behaved differently from these results.
|
||||
7. For object/flat-review export, keep the same two development peers connected
|
||||
and returned to desktop. On the controlled computer, open a harmless document
|
||||
or dialog with several ordinary labels. With the desktop layout and Num Lock
|
||||
off, use keypad 7/8/9 for previous/current/next line, 4/5/6 for
|
||||
previous/current/next word, and 1/2/3 for previous/current/next character.
|
||||
Both computers should speak the same ordinary report,
|
||||
including role announcements for object review. Repeat keypad 5 twice quickly
|
||||
for word spelling and three times for phonetics; repeated letters must remain.
|
||||
Use Cthulhu+Ctrl+Right/Left for sibling object review and
|
||||
Cthulhu+Ctrl+Down/Up for child/parent review. Application focus, native caret,
|
||||
normal typing and existing Braille behavior should stay unchanged by these
|
||||
speech export changes. Boundary/error announcements stay local. A password
|
||||
source or ancestor must produce no exported review report; if a flat line
|
||||
joins ordinary and private sources, the whole report stays local. Disconnect
|
||||
and repeat ordinary review: local speech must remain and the peer must receive
|
||||
nothing. Record exact local/peer text and order, focused control, caret/Braille
|
||||
position and any key whose behavior differs.
|
||||
8. For document Where Am I export, keep both peers connected and returned to
|
||||
desktop. On the controlled computer, navigate to a harmless browser document
|
||||
position using a browse navigation command or document caret movement. With
|
||||
the desktop layout and Num Lock off, press keypad Enter. Both computers should
|
||||
speak the same location and role, preserving pronunciation and speech order.
|
||||
Application focus, caret and local Braille should stay in place. Repeat after
|
||||
disconnect: local speech should remain and the peer should receive nothing.
|
||||
Reconnect explicitly and repeat on a password source or a source with private
|
||||
ancestry: no Where Am I report should reach the peer. Missing-location messages stay local.
|
||||
A same-object native update or a document reset clears sharing classification;
|
||||
navigate again before testing another ordinary export. Record exact local/peer
|
||||
speech, focus, caret/Braille position and keys differing from these expectations.
|
||||
9. For native Where Am I, keep both peers connected and returned to desktop.
|
||||
Focus a harmless entry or button in a native GTK application. After focus
|
||||
speech settles, press keypad Enter with Num Lock off. Both computers should
|
||||
speak the same item and role, preserving pronunciation and chunk order. Focus,
|
||||
caret, Braille and ordinary keyboard input should stay in place. Repeat after
|
||||
disconnect: local speech should remain and the peer must receive nothing.
|
||||
Reconnect explicitly and repeat on a password source or a source with private
|
||||
ancestry: no report should reach the peer. If native text changed since the
|
||||
cached focus report, local Where Am I stays available but export is withheld
|
||||
until fresh and cached reports match. Change focus or lock/handoff during a
|
||||
slow capture: its pending report must not speak afterward. Record exact local
|
||||
and peer speech, focused control, caret/Braille position and unexpected keys.
|
||||
10. For context announcements, connect two matching development peers to a
|
||||
private relay and return both to desktop. On the controlled computer, use
|
||||
browse mode in a harmless document containing a named list or table, with
|
||||
the corresponding navigation and Say All context settings enabled. Navigate
|
||||
into and out of the container: both peers should speak the same entry label
|
||||
and "Leaving ..." label before the ordinary content, once per transition.
|
||||
Repeat with Say All and current-line spelling; labels should follow their
|
||||
existing settings and should not repeat for each spelled letter. Named
|
||||
articles retain their entry-only behavior. Focus, caret movement, ordinary
|
||||
application keys and local Braille should retain their existing behavior.
|
||||
Disconnect while inside the container, reconnect explicitly, and move outside
|
||||
before reading inside it again. The local exit label should still be spoken,
|
||||
but the new peer must receive only the new ordinary content, without adopting
|
||||
the old cached label. Repeat with a container first read while disconnected.
|
||||
Password/private/unknown ancestry must export neither an entry label nor a
|
||||
later cached exit label; local reading should remain available. Stop speech,
|
||||
lock/handoff and disconnect during Say All: old context must not replay after
|
||||
reconnection. Record exact local/peer label and content order, focused control,
|
||||
caret/Braille position and keys that differ from these expectations.
|
||||
11. Recheck ordinary entries/menus, secret forms, learn mode, remapped shortcuts,
|
||||
application key delivery and Hello World/Wormhole/Battery Status. These share
|
||||
the changed host interaction path. Review the diff before any submission.
|
||||
|
||||
Physical-source acceptance, audible speech/masking, real-server priority, physical
|
||||
Braille, remaining desktop services,
|
||||
actual NVDA/Orca interoperability and packaging remain separate open gates.
|
||||
|
||||
## Controlled keyboard live checks, pending
|
||||
|
||||
Install the reader with `cthulhu-input-helper` beside it. On the controlled
|
||||
computer choose **Allow a helper to access this computer**, check the keyboard
|
||||
option and pick a key profile, then approve keyboard control in the reader's
|
||||
dialog using the physical keyboard. From the controller, type into a harmless
|
||||
text editor, use Shift+Tab, arrows and Control shortcuts, and confirm each key
|
||||
arrives once. Hold Shift or Control on the controller and disconnect, lock the
|
||||
controlled desktop, and trigger XTerm handoff; afterwards confirm no modifier
|
||||
is stuck (for example with `xinput query-state` or by typing). Repeat without
|
||||
the keyboard option and confirm keys are ignored.
|
||||
|
||||
## Controller keyboard live checks, pending
|
||||
|
||||
On the controller choose **Control another computer** with keyboard control
|
||||
checked and approve it in the reader dialog. Once the peer joins, press
|
||||
Cthulhu+Ctrl+Shift+F: the reader should announce that the keyboard controls the
|
||||
remote computer. Type into a remote text editor, use Shift+Tab, Insert/Caps
|
||||
Lock reader commands and arrows, and confirm nothing reaches the local
|
||||
application. Press F11 and confirm the keyboard returns with an announcement;
|
||||
repeat with Cthulhu+Ctrl+Shift+R. Hold Shift on the controller, press F11, and
|
||||
confirm Shift is not stuck on either computer. Lock the controller and trigger
|
||||
XTerm handoff during remote focus; both must return the keyboard. On Windows
|
||||
peers, check whether a withdrawn Alt prefix opens a menu bar.
|
||||
|
||||
## Clipboard live checks, pending
|
||||
|
||||
Connect with clipboard transfer checked on both computers. Copy harmless text
|
||||
on one and press Cthulhu+Ctrl+Shift+C; on the other press Cthulhu+Ctrl+Shift+V
|
||||
and paste into an editor. Confirm the clipboard did not change before the
|
||||
receive command, that a second receive reports nothing waiting, that copied
|
||||
files are refused, and that without the checkbox nothing transfers.
|
||||
|
||||
## Braille live checks, pending
|
||||
|
||||
With Braille checked on both computers and a display on the controller, open a
|
||||
text document on the controlled computer. The controller's display should show
|
||||
it at its own width. Pan both ways past the page edges, route to a word and
|
||||
confirm the controlled caret moves. Test contracted and computer Braille,
|
||||
non-Latin text and a controlled computer with no display attached. Open a
|
||||
reader dialog and a flashed message on the controlled computer and confirm
|
||||
neither appears remotely. Disconnect and confirm the controller's local Braille
|
||||
returns. Unplug and replug the display during a session.
|
||||
Record reader/peer revisions and actual keys, heard output and Braille results.
|
||||
Private tests do not establish physical input, audible speech, physical Braille,
|
||||
ARM64 execution or real NVDA/Orca interoperability. Human review and testing are
|
||||
required before treating this experimental release as accepted.
|
||||
+18
-102
@@ -1,106 +1,22 @@
|
||||
# Remote connection workflow
|
||||
# Remote connection UI
|
||||
|
||||
The connection library combines certificate review, saved-key actions and
|
||||
the coordinator in one workflow. The subsequent [source command](command.md)
|
||||
now wires endpoint/role selection and reader-owned consent into it; physical
|
||||
input acceptance is pending. No manifest or desktop service exists. The original
|
||||
library increment's maintained Tentacles `master` matched `origin/master` at
|
||||
`63e84e9` after fetch on 2026-11-03; existing uncommitted work was preserved.
|
||||
No reader files or installed programs changed.
|
||||
The current user workflow and validation steps are in [command.md](command.md).
|
||||
Mode, Host and masked Key share one connection form. More options holds
|
||||
certificate, saved-key and keyboard-map controls. Services are selected only in
|
||||
the reader-owned local approval form, constrained by installation grants.
|
||||
|
||||
## Workflow ownership
|
||||
The connection workflow owns pre-approval credentials and asynchronous verified
|
||||
TLS preflight/explicit certificate inspection. These workers use the interaction
|
||||
lifetime; lock/handoff and cleanup cancel them without needing a lease. They
|
||||
send no application bytes. Inspection never approves trust or connects.
|
||||
|
||||
`new_connection_workflow` accepts an already-selected, validated endpoint, an
|
||||
optional open settings store and an action received by the coordinator from the
|
||||
public SDK. It claims that action for one workflow and copies the reader's
|
||||
role/grants and endpoint trust. Caller-modified role/grants are ignored. Opening
|
||||
the workflow neither reads a saved key nor opens a network connection.
|
||||
The registered `remote-poll` continuation returns only changed progress,
|
||||
completed forms or a reader consent request. After local approval, the
|
||||
coordinator consumes the actual SDK event and starts the connection immediately.
|
||||
A successful join produces the existing verified `remote_background` terminal
|
||||
result automatically. The host checks its ownership before releasing capture.
|
||||
|
||||
The source-command owner supplies endpoint/role selection. The reader owns
|
||||
local-only input capture and cancels the interaction on lock/handoff or retirement.
|
||||
The workflow does not manufacture consent from a command or `Submission`. Its
|
||||
`remote-connection` continuation is now registered by the source command.
|
||||
The owner must serialize the currently displayed form's submissions; this
|
||||
library supplies no proof that a submission came from that form or a local key.
|
||||
|
||||
Pending approval has a context that ends on replacement, matching revocation,
|
||||
consumption, disconnect or SDK loss. A replacement cancels setup and inspection.
|
||||
The reader remains authoritative for action expiry at `remote.open`; it also
|
||||
notifies the coordinator when an unopened action expires or is revoked. Merely
|
||||
keeping a form open does not extend approval. An expired action cannot connect.
|
||||
|
||||
The workflow's `done` barrier includes its inspection worker. Cancelling it
|
||||
initiates coordinator cleanup; wait separately on the coordinator's Disconnect
|
||||
barrier before disposing the SDK session/store. Cleanup is scoped to the original
|
||||
epoch: closing an old form cannot retire a newer approval or connection.
|
||||
|
||||
Status offers **Return to desktop and keep this connection**. After reader lease
|
||||
open it returns a terminal `remote_background` result with that lease/epoch;
|
||||
the reader verifies ownership and releases the interaction without cancellation.
|
||||
The workflow and heartbeat remain under their original lease/policy lifetime.
|
||||
The Remote shortcut reopens status/Disconnect. Before open succeeds this action
|
||||
keeps status open with a refresh/disconnect notice. Ordinary Escape, Cancel and
|
||||
Disconnect and close continue to end the workflow; this is an explicit exception
|
||||
for desktop return, not a change to generic form cancellation.
|
||||
|
||||
## Explicit actions
|
||||
|
||||
- **Connect relay** validates the entered key, or uses a key previously loaded
|
||||
by **Use saved key**, and starts the coordinator. Install grants and a form
|
||||
are insufficient: the reader must still accept `remote.open` before dialing.
|
||||
- **Use saved key** loads only the selected host/port's credential. It does not
|
||||
connect, copy it or prefill an entry. A typed key overrides it for that attempt.
|
||||
- **Remember or forget a key** opens the existing masked form. Completion or its
|
||||
Cancel button returns to Connect. A remembered key still requires explicit
|
||||
loading; Forget also discards the workflow's previously loaded key.
|
||||
- **Inspect relay certificate** discards a loaded key and runs the bounded
|
||||
key-free probe in a worker. **Refresh inspection status** presents its result.
|
||||
Inspection failure never changes trust or starts a connection.
|
||||
- **Copy fingerprint** requests exactly that clipboard write. **Trust once**
|
||||
returns to Connect with an endpoint-bound pin. It neither persists the pin nor
|
||||
connects. Connect performs fresh TLS authentication before sending the key.
|
||||
- **Disconnect** cancels the original attempt. Status distinguishes opening,
|
||||
connecting, waiting, peer membership, cleanup and failure. Every status states
|
||||
that speech is experimental and keyboard, clipboard and Braille services are unavailable. **Disconnect and close**, Escape/form
|
||||
cancellation or owner cancellation retires the workflow.
|
||||
- **Trust and remember this certificate** saves its exact pin for this host/port
|
||||
and returns to explicit Connect. **Forget this relay's pin** restores normal
|
||||
certificate/hostname validation. Neither connects automatically.
|
||||
|
||||
Entries are always empty and masked. Responses and status omit channel keys and
|
||||
server/RPC error text. Loaded keys are released on Connect, inspection, saved-key
|
||||
actions and teardown; transient pins are released on Connect/teardown. This is
|
||||
reference cleanup, not guaranteed secure memory erasure. Unknown action names
|
||||
and duplicate Connect submissions cannot start another attempt. Completed
|
||||
nested workflows return to Connect rather than repeating a storage action.
|
||||
|
||||
## Verification and readiness
|
||||
|
||||
From the Tentacles repository, with private loopback sockets permitted:
|
||||
|
||||
```sh
|
||||
GOCACHE=/tmp/cthulhu-cache GOPROXY=off go test -race ./remote/src -run '^TestConnectionWorkflow' -count=1 -timeout=60s
|
||||
GOCACHE=/tmp/cthulhu-cache GOPROXY=off go test -race ./remote/src -count=1 -timeout=60s
|
||||
make check GOPROXY=off
|
||||
```
|
||||
|
||||
The workflow tests cover both roles, explicit saved-key use, secret-free replies,
|
||||
endpoint/permission failures, one-use approval, nested Remember/Forget, key-free
|
||||
inspection, Copy/Trust once, fresh pinned TLS, cancellation during stalled TLS,
|
||||
replacement/SDK EOF and old status controls against a newer connection. A
|
||||
separate executable speaks the real Go SDK over OS pipes to a synthetic host;
|
||||
it exercises the form continuations, saved-key storage, certificate review and
|
||||
relay join/close together. The fixtures grant synthetic approval and submit
|
||||
synthetic values. They do not prove local input origin or accessible form
|
||||
navigation. The focused race tests passed ten repetitions after correcting an
|
||||
inspection/cleanup race; the complete race suite and `make check` also passed.
|
||||
|
||||
Source registration, core consent, endpoint/role selection, persistent-pin
|
||||
management and lock/handoff cleanup now have private integration coverage.
|
||||
Physical-source input remains unverified. Test the actual forms with
|
||||
Tab/Shift+Tab, list navigation, masked editing,
|
||||
Copy, Cancel and failed storage, including cancellation during inspection/join.
|
||||
Recheck ordinary Tentacle forms, CA and pin connections, certificate rotation,
|
||||
Hello World, Wormhole and Battery Status. Remaining reader desktop services, audible speech and real NVDA/Orca
|
||||
interoperability, audible speech, physical keyboard/Braille and packaging remain
|
||||
separate gates. Passing these private checks does not make Remote installable.
|
||||
Status reopening retains the existing session. Close/Escape retains its live
|
||||
lease, while Disconnect retires that epoch. No form may reconnect or affect a
|
||||
replacement epoch. Mute cancels only incoming remote speech and drops old queued
|
||||
speech across both mute and unmute; keyboard, clipboard and Braille stay separate.
|
||||
+161
-88
@@ -7,7 +7,9 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"io"
|
||||
"net"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
@@ -44,12 +46,7 @@ type connectionCommand struct {
|
||||
coordinator *coordinator
|
||||
store *settingsStore
|
||||
selected settings
|
||||
awaiting bool
|
||||
workflow *connectionWorkflow
|
||||
keyboard bool // Session-only; never persisted.
|
||||
keyProfile string // "portable" or "us"; session-only.
|
||||
clipboard bool // Session-only; never persisted.
|
||||
braille bool // Session-only; never persisted.
|
||||
}
|
||||
|
||||
func (command *connectionCommand) commands() []sdk.Command {
|
||||
@@ -57,11 +54,15 @@ func (command *connectionCommand) commands() []sdk.Command {
|
||||
id, title string
|
||||
handler sdk.Handler
|
||||
}{
|
||||
{"remote", "Remote relay connection (experimental speech and keyboard)", command.open},
|
||||
{"remote", "Remote connection", command.open},
|
||||
{"remote-select", "Choose Remote relay and role", command.select_relay},
|
||||
{"remote-approved", "Continue after reader-owned Remote approval", command.approved},
|
||||
{"remote-connection", "Remote connection controls", command.submit},
|
||||
{"remote-focus", "Send this keyboard to the remote computer (F11 returns)", command.remote_focus},
|
||||
{"remote-poll", "Remote connection progress", command.poll},
|
||||
{"remote-disconnect", "Disconnect Remote", command.disconnect_command},
|
||||
{"remote-status", "Remote connection status", command.status_command},
|
||||
{"remote-mute", "Mute or unmute Remote speech", command.mute_command},
|
||||
{"remote-focus", "Switch between local and remote keyboard control", command.remote_focus},
|
||||
{"remote-send-clipboard", "Send clipboard text to the other Remote computer", command.send_clipboard_command},
|
||||
{"remote-clipboard-item", "Send the clipboard text chosen for Remote", command.send_clipboard_item},
|
||||
{"remote-receive-clipboard", "Copy clipboard text received over Remote", command.receive_clipboard_command},
|
||||
@@ -76,9 +77,18 @@ func (command *connectionCommand) commands() []sdk.Command {
|
||||
value.Bindings = []sdk.Binding{{Layout: "desktop", Scope: "global", Key: "Cthulhu+Ctrl+Shift+C"}, {Layout: "laptop", Scope: "global", Key: "Cthulhu+Ctrl+Shift+C"}}
|
||||
case "remote-receive-clipboard":
|
||||
value.Bindings = []sdk.Binding{{Layout: "desktop", Scope: "global", Key: "Cthulhu+Ctrl+Shift+V"}, {Layout: "laptop", Scope: "global", Key: "Cthulhu+Ctrl+Shift+V"}}
|
||||
case "remote-disconnect":
|
||||
value.Interaction = false
|
||||
value.Bindings = []sdk.Binding{{Layout: "desktop", Scope: "global", Key: "Cthulhu+Alt+Page_Down"}, {Layout: "laptop", Scope: "global", Key: "Cthulhu+Alt+Page_Down"}}
|
||||
case "remote-status":
|
||||
value.Interaction = false
|
||||
value.Bindings = []sdk.Binding{{Layout: "desktop", Scope: "global", Key: "Cthulhu+Ctrl+Shift+Page_Up"}, {Layout: "laptop", Scope: "global", Key: "Cthulhu+Ctrl+Shift+Page_Up"}}
|
||||
case "remote-mute":
|
||||
value.Interaction = false
|
||||
value.Bindings = []sdk.Binding{{Layout: "desktop", Scope: "global", Key: "Cthulhu+Alt+M"}, {Layout: "laptop", Scope: "global", Key: "Cthulhu+Alt+M"}}
|
||||
case "remote-focus":
|
||||
value.Interaction = false
|
||||
value.Bindings = []sdk.Binding{{Layout: "desktop", Scope: "global", Key: "Cthulhu+Ctrl+Shift+F"}, {Layout: "laptop", Scope: "global", Key: "Cthulhu+Ctrl+Shift+F"}}
|
||||
value.Bindings = []sdk.Binding{{Layout: "desktop", Scope: "global", Key: "Cthulhu+Alt+Tab"}, {Layout: "laptop", Scope: "global", Key: "Cthulhu+Alt+Tab"}}
|
||||
}
|
||||
commands = append(commands, value)
|
||||
}
|
||||
@@ -86,25 +96,21 @@ func (command *connectionCommand) commands() []sdk.Command {
|
||||
}
|
||||
|
||||
func (command *connectionCommand) selection_form(notice string) sdk.Interaction {
|
||||
roles := []sdk.ListItem{{ID: "controller", Label: "Control another computer"}, {ID: "controlled", Label: "Allow a helper to access this computer"}}
|
||||
roles := []sdk.ListItem{{ID: "controller", Label: "Control another computer"}, {ID: "controlled", Label: "Allow this computer to be controlled"}}
|
||||
if command.selected.Role == "controlled" {
|
||||
roles[0], roles[1] = roles[1], roles[0]
|
||||
}
|
||||
profiles := []sdk.ListItem{{ID: "portable", Label: "Letters, digits and navigation only"}, {ID: "us", Label: "Also US layout punctuation"}}
|
||||
if command.keyProfile == "us" {
|
||||
profiles[0], profiles[1] = profiles[1], profiles[0]
|
||||
host := command.selected.Host
|
||||
if host != "" && command.selected.Port != 6837 {
|
||||
host = net.JoinHostPort(host, strconv.Itoa(command.selected.Port))
|
||||
}
|
||||
result := sdk.Interaction{Form: &sdk.Form{Title: "Remote relay and role. Experimental speech, keyboard, clipboard and Braille; live verification is pending.", Elements: []sdk.Element{
|
||||
result := sdk.Interaction{Form: &sdk.Form{Title: "Remote", Elements: []sdk.Element{
|
||||
{ID: "cancel", Label: "Cancel", Kind: sdk.Button},
|
||||
{ID: "host", Label: "Relay host", Kind: sdk.Entry, Text: command.selected.Host, MaxLength: 253},
|
||||
{ID: "port", Label: "Relay port", Kind: sdk.Entry, Text: strconv.Itoa(command.selected.Port), MaxLength: 5},
|
||||
{ID: "role", Label: "Connection role", Kind: sdk.List, Items: roles},
|
||||
{ID: "keyboard", Label: "Include keyboard control for this session: controlling sends this keyboard when remote focus is on; allowing access lets the helper type here", Kind: sdk.CheckBox, Checked: command.keyboard},
|
||||
{ID: "key-profile", Label: "Keys that may be sent", Kind: sdk.List, Items: profiles},
|
||||
{ID: "clipboard", Label: "Allow explicit clipboard text transfer in both directions for this session", Kind: sdk.CheckBox, Checked: command.clipboard},
|
||||
{ID: "braille", Label: "Include Braille for this session: controlling shows the other computer's Braille on this display; allowing access sends this computer's Braille", Kind: sdk.CheckBox, Checked: command.braille},
|
||||
{ID: "review-access", Label: "Review access for this session", Kind: sdk.Button},
|
||||
{ID: "save-settings", Label: "Save relay and role without connecting", Kind: sdk.Button},
|
||||
{ID: "role", Label: "Mode", Kind: sdk.List, Items: roles},
|
||||
{ID: "host", Label: "Host", Kind: sdk.Entry, Text: host, MaxLength: 300},
|
||||
{ID: "channel-key", Label: "Key", Kind: sdk.Entry, Secret: true, MaxLength: 512},
|
||||
{ID: "connect", Label: "Connect", Kind: sdk.Button},
|
||||
{ID: "options", Label: "More options", Kind: sdk.Button},
|
||||
}}, Next: "remote-select"}
|
||||
if notice != "" {
|
||||
result.Presentation = security_message(notice).Presentation
|
||||
@@ -112,6 +118,28 @@ func (command *connectionCommand) selection_form(notice string) sdk.Interaction
|
||||
return result
|
||||
}
|
||||
|
||||
func parse_relay_address(value string) (string, int, error) {
|
||||
value = strings.TrimSpace(value)
|
||||
host, port := value, 6837
|
||||
if strings.HasPrefix(value, "[") || strings.Count(value, ":") == 1 {
|
||||
var portText string
|
||||
var err error
|
||||
host, portText, err = net.SplitHostPort(value)
|
||||
if err != nil {
|
||||
return "", 0, errSettings
|
||||
}
|
||||
port, err = strconv.Atoi(portText)
|
||||
if err != nil {
|
||||
return "", 0, errSettings
|
||||
}
|
||||
}
|
||||
selected := settings{Version: 1, Host: host, Port: port, Role: "controller"}
|
||||
if _, err := selected.endpoint(); err != nil {
|
||||
return "", 0, err
|
||||
}
|
||||
return host, port, nil
|
||||
}
|
||||
|
||||
func (command *connectionCommand) open(ctx context.Context, _ json.RawMessage) (any, error) {
|
||||
command.mu.Lock()
|
||||
defer command.mu.Unlock()
|
||||
@@ -119,6 +147,14 @@ func (command *connectionCommand) open(ctx context.Context, _ json.RawMessage) (
|
||||
return nil, ctx.Err()
|
||||
}
|
||||
if command.workflow != nil {
|
||||
status := command.coordinator.snapshot()
|
||||
command.workflow.mu.Lock()
|
||||
ended := command.workflow.mode == "status" && (status.state == "closed" || status.state == "failed")
|
||||
command.workflow.mu.Unlock()
|
||||
if ended {
|
||||
command.workflow.close()
|
||||
<-command.workflow.done
|
||||
}
|
||||
select {
|
||||
case <-command.workflow.done:
|
||||
command.workflow = nil
|
||||
@@ -126,9 +162,6 @@ func (command *connectionCommand) open(ctx context.Context, _ json.RawMessage) (
|
||||
return command.workflow.form(), nil
|
||||
}
|
||||
}
|
||||
if command.awaiting {
|
||||
return security_message("A Remote access review is already pending."), nil
|
||||
}
|
||||
if err := command.refresh_pin(&command.selected); err != nil {
|
||||
return security_message("Saved relay trust could not be read."), nil
|
||||
}
|
||||
@@ -159,54 +192,37 @@ func (command *connectionCommand) select_relay(ctx context.Context, raw json.Raw
|
||||
if ctx.Err() != nil || value.Cancelled || value.Activated == "cancel" {
|
||||
return security_message("Remote setup cancelled."), nil
|
||||
}
|
||||
if command.awaiting || command.workflow != nil {
|
||||
return security_message("A Remote connection workflow is already open."), nil
|
||||
if command.workflow != nil {
|
||||
return security_message("Remote setup is already open."), nil
|
||||
}
|
||||
if value.Activated != "review-access" && value.Activated != "save-settings" {
|
||||
if value.Activated != "connect" && value.Activated != "options" {
|
||||
return command.selection_form(""), nil
|
||||
}
|
||||
port, err := strconv.Atoi(value.Values["port"].Text)
|
||||
selected := settings{Version: 1, Host: value.Values["host"].Text, Port: port, Role: value.Values["role"].Selected}
|
||||
if _, validationErr := selected.endpoint(); err != nil || validationErr != nil {
|
||||
return command.selection_form("Enter a valid relay host, port and connection role."), nil
|
||||
host, port, err := parse_relay_address(value.Values["host"].Text)
|
||||
selected := settings{Version: 1, Host: host, Port: port, Role: value.Values["role"].Selected}
|
||||
target, validationErr := selected.endpoint()
|
||||
if err != nil || validationErr != nil {
|
||||
return command.selection_form("Enter a valid host and mode. Add :port for a nonstandard port."), nil
|
||||
}
|
||||
if err := command.refresh_pin(&selected); err != nil {
|
||||
return command.selection_form("Saved relay trust could not be read."), nil
|
||||
}
|
||||
command.selected = selected
|
||||
command.keyboard = value.Values["keyboard"].Checked
|
||||
command.clipboard = value.Values["clipboard"].Checked
|
||||
command.braille = value.Values["braille"].Checked
|
||||
command.keyProfile = "portable"
|
||||
if value.Values["key-profile"].Selected == "us" {
|
||||
command.keyProfile = "us"
|
||||
target, _ = selected.endpoint()
|
||||
if err := command.store.save(selected); err != nil {
|
||||
return command.selection_form("Relay settings could not be saved."), nil
|
||||
}
|
||||
if value.Activated == "save-settings" {
|
||||
if err := command.store.save(selected); err != nil {
|
||||
return command.selection_form("Relay settings could not be saved."), nil
|
||||
}
|
||||
return command.selection_form("Relay and role saved. No connection was started."), nil
|
||||
workflow, err := new_setup_workflow(command.coordinator, target, command.store, selected.Role)
|
||||
if err != nil {
|
||||
return security_message("Remote setup is unavailable."), nil
|
||||
}
|
||||
grants := []string{"remote-present"}
|
||||
keyboardGrant := "keyboard-capture"
|
||||
if selected.Role == "controlled" {
|
||||
grants, keyboardGrant = []string{"output-observe"}, "keyboard-inject"
|
||||
command.workflow = workflow
|
||||
workflow.key = value.Values["channel-key"].Text
|
||||
workflow.profile = "portable"
|
||||
if value.Activated == "connect" {
|
||||
return workflow.submit(ctx, sdk.Submission{Activated: "connect"})
|
||||
}
|
||||
command.coordinator.set_keyboard("")
|
||||
if command.keyboard {
|
||||
// The reader's consent dialog discloses keyboard control separately;
|
||||
// the profile limits which keys can be converted in either direction.
|
||||
grants = append(grants, keyboardGrant)
|
||||
command.coordinator.set_keyboard(command.keyProfile)
|
||||
}
|
||||
if command.clipboard {
|
||||
grants = append(grants, "clipboard-exchange")
|
||||
}
|
||||
if command.braille {
|
||||
grants = append(grants, "braille-stream")
|
||||
}
|
||||
command.awaiting = true
|
||||
return sdk.Interaction{Remote: &sdk.RemoteRequest{Role: selected.Role, Grants: grants}, Next: "remote-approved"}, nil
|
||||
return workflow.form(), nil
|
||||
}
|
||||
|
||||
func (command *connectionCommand) approved(ctx context.Context, raw json.RawMessage) (any, error) {
|
||||
@@ -216,46 +232,56 @@ func (command *connectionCommand) approved(ctx context.Context, raw json.RawMess
|
||||
if json.Unmarshal(raw, &value) != nil {
|
||||
return nil, sdk.ErrProtocol
|
||||
}
|
||||
if !command.awaiting || command.workflow != nil {
|
||||
return security_message("Start a fresh Remote access review."), nil
|
||||
w := command.workflow
|
||||
if w == nil {
|
||||
return security_message("Start a fresh Remote connection."), nil
|
||||
}
|
||||
command.awaiting = false
|
||||
if value.Cancelled || value.Remote == nil || ctx.Err() != nil {
|
||||
w.mu.Lock()
|
||||
defer w.mu.Unlock()
|
||||
if value.Cancelled || value.Remote == nil || ctx.Err() != nil || w.mode != "approval" || w.ctx.Err() != nil {
|
||||
w.finish_locked()
|
||||
return security_message("Remote access was not approved."), nil
|
||||
}
|
||||
// The event consumer and command handlers run independently. Wait briefly
|
||||
// for this exact SDK-delivered action; a command argument alone cannot mint
|
||||
// approval. Role/grants from the event remain authoritative in the coordinator.
|
||||
waitCtx, cancel := context.WithTimeout(ctx, time.Second)
|
||||
defer cancel()
|
||||
for {
|
||||
select {
|
||||
case action, open := <-command.coordinator.actions:
|
||||
if !open {
|
||||
w.finish_locked()
|
||||
return security_message("Reader approval is unavailable."), nil
|
||||
}
|
||||
if action.Action != value.Remote.Action || action.Epoch != value.Remote.Epoch {
|
||||
continue
|
||||
}
|
||||
if action.Role != command.selected.Role {
|
||||
return security_message("Remote role changed. Start a fresh access review."), nil
|
||||
if action.Role != w.role {
|
||||
w.finish_locked()
|
||||
return security_message("Remote mode changed. Start again."), nil
|
||||
}
|
||||
target, err := command.selected.endpoint()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
w.action = action
|
||||
command.coordinator.set_keyboard(w.profile)
|
||||
if err := command.coordinator.connect(action, w.target, w.key); err != nil {
|
||||
w.finish_locked()
|
||||
return security_message("The connection could not start. Start again."), nil
|
||||
}
|
||||
workflow, err := new_connection_workflow(command.coordinator.ctx, command.coordinator, action, target, command.store)
|
||||
if err != nil {
|
||||
return security_message("Remote approval ended. Start a fresh access review."), nil
|
||||
}
|
||||
command.workflow = workflow
|
||||
return workflow.form(), nil
|
||||
w.key, w.mode, w.autoBackground = "", "status", true
|
||||
return w.form_locked(), nil
|
||||
case <-waitCtx.Done():
|
||||
return security_message("Remote approval ended. Start a fresh access review."), nil
|
||||
w.finish_locked()
|
||||
return security_message("Reader approval expired. Start again."), nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (command *connectionCommand) poll(ctx context.Context, _ json.RawMessage) (any, error) {
|
||||
command.mu.Lock()
|
||||
defer command.mu.Unlock()
|
||||
if command.workflow == nil {
|
||||
return security_message("Remote setup ended."), nil
|
||||
}
|
||||
return command.workflow.poll(ctx), nil
|
||||
}
|
||||
|
||||
func (command *connectionCommand) submit(ctx context.Context, raw json.RawMessage) (any, error) {
|
||||
command.mu.Lock()
|
||||
defer command.mu.Unlock()
|
||||
@@ -282,16 +308,63 @@ func (command *connectionCommand) close() {
|
||||
<-command.coordinator.done
|
||||
}
|
||||
|
||||
// remote_focus asks the reader to send this keyboard to the remote computer.
|
||||
// It only enters remote focus: F11 or any Remote shortcut returns it, handled
|
||||
// by the reader without this process.
|
||||
// The reader owns capture and the emergency return path.
|
||||
func (command *connectionCommand) remote_focus(ctx context.Context, _ json.RawMessage) (any, error) {
|
||||
if ctx.Err() != nil {
|
||||
return nil, ctx.Err()
|
||||
}
|
||||
if err := command.coordinator.request_focus(true); err != nil {
|
||||
text := "Remote keyboard control needs a connected controller session with keyboard control approved."
|
||||
return sdk.Presentation{Speech: text, Braille: text}, nil
|
||||
remote := command.coordinator.snapshot().focus != "remote"
|
||||
if err := command.coordinator.request_focus(remote); err != nil {
|
||||
return sdk.Presentation{Speech: "Keyboard control needs a connected session with keyboard access allowed."}, nil
|
||||
}
|
||||
return sdk.Presentation{Speech: "Requesting remote keyboard focus.", Braille: "Requesting remote keyboard focus."}, nil
|
||||
text := "Switching keyboard control to this computer."
|
||||
if remote {
|
||||
text = "Switching keyboard control to the other computer. F11 returns here."
|
||||
}
|
||||
return sdk.Presentation{Speech: text, Braille: text}, nil
|
||||
}
|
||||
|
||||
func (command *connectionCommand) disconnect_command(ctx context.Context, _ json.RawMessage) (any, error) {
|
||||
if ctx.Err() != nil {
|
||||
return nil, ctx.Err()
|
||||
}
|
||||
command.mu.Lock()
|
||||
if command.workflow != nil {
|
||||
command.workflow.close()
|
||||
}
|
||||
command.mu.Unlock()
|
||||
command.coordinator.disconnect()
|
||||
return sdk.Presentation{Speech: "Remote disconnected.", Braille: "Remote disconnected."}, nil
|
||||
}
|
||||
|
||||
func (command *connectionCommand) status_command(ctx context.Context, _ json.RawMessage) (any, error) {
|
||||
if ctx.Err() != nil {
|
||||
return nil, ctx.Err()
|
||||
}
|
||||
status := command.coordinator.snapshot()
|
||||
text := connection_status_text(status)
|
||||
if status.focus == "remote" {
|
||||
text += " Keyboard controls the other computer."
|
||||
} else {
|
||||
text += " Keyboard controls this computer."
|
||||
}
|
||||
if status.muted {
|
||||
text += " Remote speech muted."
|
||||
}
|
||||
return sdk.Presentation{Speech: text, Braille: text}, nil
|
||||
}
|
||||
|
||||
func (command *connectionCommand) mute_command(ctx context.Context, _ json.RawMessage) (any, error) {
|
||||
if ctx.Err() != nil {
|
||||
return nil, ctx.Err()
|
||||
}
|
||||
muted, err := command.coordinator.toggle_mute()
|
||||
text := "Remote speech needs a connected controller session."
|
||||
if err == nil {
|
||||
text = "Remote speech unmuted."
|
||||
if muted {
|
||||
text = "Remote speech muted."
|
||||
}
|
||||
}
|
||||
return sdk.Presentation{Speech: text, Braille: text}, nil
|
||||
}
|
||||
+77
-41
@@ -15,43 +15,46 @@ import (
|
||||
sdk "git.stormux.org/storm/cthulhu/sdk/go/tentacle"
|
||||
)
|
||||
|
||||
func TestRemoteCommandSelectsEndpointWithoutAccessOrNetworking(t *testing.T) {
|
||||
func TestRemoteCommandCollectsCredentialsBeforeApproval(t *testing.T) {
|
||||
c, client := fixtureCoordinator(t, nil)
|
||||
store, _, saved := settingsFixture(t)
|
||||
command := &connectionCommand{coordinator: c, store: store, selected: saved}
|
||||
for _, entry := range command.commands() {
|
||||
if (entry.ID == "remote-select" || entry.ID == "remote-approved" || entry.ID == "remote-connection" || entry.ID == "remote-clipboard-item") && len(entry.Bindings) != 0 {
|
||||
t.Fatal("continuation has a shortcut")
|
||||
form := command.selection_form("")
|
||||
if len(form.Form.Elements) != 6 {
|
||||
t.Fatal("connection form has extra controls")
|
||||
}
|
||||
for _, element := range form.Form.Elements {
|
||||
if element.ID == "channel-key" && (!element.Secret || element.Text != "") {
|
||||
t.Fatal("key is unmasked or prefilled")
|
||||
}
|
||||
if element.Kind == sdk.CheckBox {
|
||||
t.Fatal("permissions duplicated in connection form")
|
||||
}
|
||||
}
|
||||
for _, role := range []string{"controller", "controlled"} {
|
||||
raw, _ := json.Marshal(sdk.Submission{Activated: "review-access", Values: map[string]sdk.Value{
|
||||
"host": {Text: "relay.invalid"}, "port": {Text: "6837"}, "role": {Selected: role},
|
||||
}})
|
||||
value, err := command.select_relay(t.Context(), raw)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
result := value.(sdk.Interaction)
|
||||
grant := "remote-present"
|
||||
if role == "controlled" {
|
||||
grant = "output-observe"
|
||||
}
|
||||
if result.Remote == nil || result.Remote.Role != role || len(result.Remote.Grants) != 1 || result.Remote.Grants[0] != grant {
|
||||
t.Fatal("selection did not request core approval for its role")
|
||||
}
|
||||
// A fabricated command argument cannot replace an SDK action event.
|
||||
limited, cancel := context.WithTimeout(t.Context(), 20*time.Millisecond)
|
||||
fake, _ := json.Marshal(sdk.Submission{Remote: &sdk.SessionEvent{Kind: "remote.action", Epoch: 1, Action: strings.Repeat("a", 32)}})
|
||||
value, err = command.approved(limited, fake)
|
||||
cancel()
|
||||
if err != nil || !value.(sdk.Interaction).Done || command.workflow != nil {
|
||||
t.Fatal("fabricated approval opened connection controls")
|
||||
}
|
||||
raw, _ := json.Marshal(sdk.Submission{Activated: "options", Values: map[string]sdk.Value{"host": {Text: "relay.invalid:7000"}, "role": {Selected: "controller"}}})
|
||||
result, err := command.select_relay(t.Context(), raw)
|
||||
if err != nil || result.(sdk.Interaction).Form == nil || command.workflow == nil {
|
||||
t.Fatal("options did not open", err)
|
||||
}
|
||||
if command.selected.Host != "relay.invalid" || command.selected.Port != 7000 {
|
||||
t.Fatal("address did not parse")
|
||||
}
|
||||
w := command.workflow
|
||||
w.mu.Lock()
|
||||
w.mode = "approval"
|
||||
w.key = "sample-key"
|
||||
w.mu.Unlock()
|
||||
limited, cancel := context.WithTimeout(t.Context(), 20*time.Millisecond)
|
||||
defer cancel()
|
||||
fake, _ := json.Marshal(sdk.Submission{Remote: &sdk.SessionEvent{Kind: "remote.action", Epoch: 1, Action: strings.Repeat("a", 32)}})
|
||||
result, err = command.approved(limited, fake)
|
||||
if err != nil || !result.(sdk.Interaction).Done {
|
||||
t.Fatal("fabricated approval accepted", err)
|
||||
}
|
||||
awaitDone(t, w.done)
|
||||
select {
|
||||
case call := <-client.calls:
|
||||
t.Fatal("selection or forged approval opened a lease", call.method)
|
||||
t.Fatal("setup made a reader call", call.method)
|
||||
default:
|
||||
}
|
||||
}
|
||||
@@ -60,26 +63,24 @@ func TestRemoteCommandRejectsInvalidSelectionAndDropsEndpointPin(t *testing.T) {
|
||||
c, _ := fixtureCoordinator(t, nil)
|
||||
store, _, saved := settingsFixture(t)
|
||||
command := &connectionCommand{coordinator: c, store: store, selected: saved}
|
||||
for _, host := range []string{"bad\nrelay", "bad\x00relay", ""} {
|
||||
raw, _ := json.Marshal(sdk.Submission{Activated: "review-access", Values: map[string]sdk.Value{
|
||||
"host": {Text: host}, "port": {Text: "6837"}, "role": {Selected: "controller"},
|
||||
}})
|
||||
for _, host := range []string{"bad\nrelay", "bad\x00relay", "", "relay:0", "relay:abc"} {
|
||||
raw, _ := json.Marshal(sdk.Submission{Activated: "options", Values: map[string]sdk.Value{"host": {Text: host}, "role": {Selected: "controller"}}})
|
||||
value, err := command.select_relay(t.Context(), raw)
|
||||
if err != nil || value.(sdk.Interaction).Remote != nil || command.awaiting {
|
||||
t.Fatal("invalid endpoint reached approval")
|
||||
if err != nil || value.(sdk.Interaction).Remote != nil || command.workflow != nil {
|
||||
t.Fatal("invalid endpoint accepted")
|
||||
}
|
||||
}
|
||||
raw, _ := json.Marshal(sdk.Submission{Activated: "save-settings", Values: map[string]sdk.Value{
|
||||
"host": {Text: "other.invalid"}, "port": {Text: "6838"}, "role": {Selected: "controlled"},
|
||||
}})
|
||||
raw, _ := json.Marshal(sdk.Submission{Activated: "options", Values: map[string]sdk.Value{"host": {Text: "other.invalid:6838"}, "role": {Selected: "controlled"}}})
|
||||
value, err := command.select_relay(t.Context(), raw)
|
||||
if err != nil || value.(sdk.Interaction).Remote != nil {
|
||||
t.Fatal("saving settings requested access")
|
||||
t.Fatal("options requested approval")
|
||||
}
|
||||
loaded, found, err := store.load()
|
||||
if err != nil || !found || loaded.Host != "other.invalid" || loaded.Pin != nil || loaded.Role != "controlled" {
|
||||
t.Fatal("endpoint change retained old trust or did not save settings")
|
||||
t.Fatal("endpoint change retained trust")
|
||||
}
|
||||
command.workflow.close()
|
||||
awaitDone(t, command.workflow.done)
|
||||
}
|
||||
|
||||
func TestRemoteCommandRefreshesRemovedPinsAndFailsClosedOnStorageError(t *testing.T) {
|
||||
@@ -126,7 +127,7 @@ func TestConnectionWorkflowRememberPinAndForgetAreExplicit(t *testing.T) {
|
||||
store.close()
|
||||
}
|
||||
result := workflowSubmit(t, w, "remember-pin", "")
|
||||
if result.Form == nil || result.Form.Title != "Connect Remote relay" {
|
||||
if result.Form == nil || result.Form.Title != "Remote options" {
|
||||
t.Fatal("Remember did not return to explicit Connect")
|
||||
}
|
||||
if failWrite {
|
||||
@@ -156,3 +157,38 @@ func TestConnectionWorkflowRememberPinAndForgetAreExplicit(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestRemoteSetupChecksTrustBeforeRequestingApproval(t *testing.T) {
|
||||
c, client := fixtureCoordinator(t, nil)
|
||||
cert, roots := testCertificate(t, true)
|
||||
inspected := make(chan struct{})
|
||||
target := testRelay(t, cert, func(connection net.Conn) {
|
||||
data, _ := io.ReadAll(connection)
|
||||
if len(data) != 0 {
|
||||
t.Error("preflight disclosed application data")
|
||||
}
|
||||
close(inspected)
|
||||
})
|
||||
target.roots = roots
|
||||
w, err := new_setup_workflow(c, target, nil, "controller")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Cleanup(func() { w.close(); awaitDone(t, w.done) })
|
||||
result, err := w.submit(t.Context(), sdk.Submission{Activated: "connect", Values: map[string]sdk.Value{"channel-key": {Text: "sample-key"}}})
|
||||
if err != nil || result.Poll != "remote-poll" || result.Remote != nil {
|
||||
t.Fatal("setup skipped certificate progress")
|
||||
}
|
||||
awaitDone(t, w.probeDone)
|
||||
awaitDone(t, inspected)
|
||||
result = w.poll(t.Context())
|
||||
if result.Remote == nil || result.Remote.Role != "controller" || len(result.Remote.OptionalGrants) != 3 || result.Next != "remote-approved" {
|
||||
t.Fatal("verified setup did not request optional local access")
|
||||
}
|
||||
assertSecretAbsent(t, result, "sample-key")
|
||||
select {
|
||||
case call := <-client.calls:
|
||||
t.Fatal("preflight opened reader access", call.method)
|
||||
default:
|
||||
}
|
||||
}
|
||||
@@ -270,7 +270,7 @@ func testConnectionWorkflowPublicSDKProcess(t *testing.T, role string) {
|
||||
assertSecretAbsent(t, result, "synthetic-fixture")
|
||||
return result
|
||||
}
|
||||
if result := invoke("remote-test-open", "", ""); result.Form == nil || result.Form.Title != "Connect Remote relay" {
|
||||
if result := invoke("remote-test-open", "", ""); result.Form == nil || result.Form.Title != "Remote options" {
|
||||
t.Fatal("SDK did not open connection controls")
|
||||
}
|
||||
invoke("remote-connection", "saved-key-actions", "")
|
||||
|
||||
+188
-53
@@ -4,12 +4,15 @@ package remote
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"net"
|
||||
"slices"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
sdk "git.stormux.org/storm/cthulhu/sdk/go/tentacle"
|
||||
)
|
||||
@@ -20,21 +23,26 @@ import (
|
||||
// Ordinary form cancellation ends the workflow. An explicit desktop return
|
||||
// retains it under the reader lease, which lock/handoff or process loss revokes.
|
||||
type connectionWorkflow struct {
|
||||
mu sync.Mutex
|
||||
ctx context.Context
|
||||
cancel context.CancelFunc
|
||||
done chan struct{}
|
||||
setupCtx context.Context
|
||||
owner *coordinator
|
||||
action sdk.SessionEvent
|
||||
target endpoint
|
||||
store *settingsStore
|
||||
mode string // credentials, inspecting, certificate, saved-key, status, finished
|
||||
notice string
|
||||
key string // Explicitly loaded only; never placed back into a form.
|
||||
review *certificateReview
|
||||
keys *keyActions
|
||||
probeDone chan struct{}
|
||||
mu sync.Mutex
|
||||
ctx context.Context
|
||||
cancel context.CancelFunc
|
||||
done chan struct{}
|
||||
setupCtx context.Context
|
||||
owner *coordinator
|
||||
action sdk.SessionEvent
|
||||
target endpoint
|
||||
store *settingsStore
|
||||
mode string // credentials, inspecting, certificate, saved-key, status, finished
|
||||
notice string
|
||||
key string // Explicitly loaded only; never placed back into a form.
|
||||
review *certificateReview
|
||||
keys *keyActions
|
||||
probeDone chan struct{}
|
||||
role string
|
||||
profile string
|
||||
needsApproval bool
|
||||
autoBackground bool
|
||||
lastStatus string
|
||||
}
|
||||
|
||||
func new_connection_workflow(ctx context.Context, owner *coordinator, action sdk.SessionEvent, target endpoint, store *settingsStore) (*connectionWorkflow, error) {
|
||||
@@ -57,7 +65,7 @@ func new_connection_workflow(ctx context.Context, owner *coordinator, action sdk
|
||||
}
|
||||
lifetime, cancel := context.WithCancel(owner.ctx)
|
||||
w := &connectionWorkflow{ctx: lifetime, cancel: cancel, done: make(chan struct{}), setupCtx: setupCtx,
|
||||
owner: owner, action: approval, target: target, store: store, mode: "credentials"}
|
||||
owner: owner, action: approval, target: target, store: store, mode: "credentials", role: approval.Role}
|
||||
stopParent := context.AfterFunc(ctx, cancel)
|
||||
go func() {
|
||||
defer close(w.done)
|
||||
@@ -105,7 +113,7 @@ func (w *connectionWorkflow) form_locked() sdk.Interaction {
|
||||
address := net.JoinHostPort(w.target.host, strconv.Itoa(w.target.port))
|
||||
details := sdk.Element{ID: "details", Label: "Connection details", Kind: sdk.List, Items: []sdk.ListItem{
|
||||
{ID: "endpoint", Label: "Relay: " + address},
|
||||
{ID: "role", Label: "Approved role: " + w.action.Role},
|
||||
{ID: "role", Label: "Mode: " + w.role},
|
||||
{ID: "privacy", Label: "The relay can read the channel key and session contents. A channel key does not verify the other person's identity."},
|
||||
{ID: "scope", Label: session_scope_text(w.action)},
|
||||
}}
|
||||
@@ -117,27 +125,30 @@ func (w *connectionWorkflow) form_locked() sdk.Interaction {
|
||||
}
|
||||
details.Items = append(details.Items, sdk.ListItem{ID: "trust", Label: trust})
|
||||
if w.key != "" {
|
||||
details.Items = append(details.Items, sdk.ListItem{ID: "loaded-key", Label: "A saved key was explicitly loaded. Leave Channel key empty to use it, or enter a replacement for this attempt."})
|
||||
details.Items = append(details.Items, sdk.ListItem{ID: "loaded-key", Label: "A key is ready for this attempt. Leave Key empty to use it, or enter a replacement."})
|
||||
}
|
||||
elements := []sdk.Element{details,
|
||||
{ID: "channel-key", Label: "Channel key", Kind: sdk.Entry, Secret: true, MaxLength: 512},
|
||||
{ID: "connect", Label: "Connect relay", Kind: sdk.Button},
|
||||
{ID: "channel-key", Label: "Key", Kind: sdk.Entry, Secret: true, MaxLength: 512},
|
||||
{ID: "connect", Label: "Connect", Kind: sdk.Button},
|
||||
{ID: "inspect-certificate", Label: "Inspect relay certificate", Kind: sdk.Button},
|
||||
}
|
||||
if w.store != nil {
|
||||
elements = append(elements,
|
||||
sdk.Element{ID: "load-key", Label: "Use saved key", Kind: sdk.Button},
|
||||
sdk.Element{ID: "saved-key-actions", Label: "Remember or forget a key", Kind: sdk.Button})
|
||||
sdk.Element{ID: "saved-key-actions", Label: "Saved key settings", Kind: sdk.Button})
|
||||
if w.target.pin != nil {
|
||||
elements = append(elements, sdk.Element{ID: "forget-pin", Label: "Forget this relay's pin and use normal certificate validation", Kind: sdk.Button})
|
||||
}
|
||||
}
|
||||
elements = append(elements, sdk.Element{ID: "cancel", Label: "Cancel", Kind: sdk.Button})
|
||||
result.Form = &sdk.Form{Title: "Connect Remote relay", Elements: elements}
|
||||
case "inspecting":
|
||||
profiles := []sdk.ListItem{{ID: "portable", Label: "Letters, numbers and navigation"}, {ID: "us", Label: "Include US punctuation"}}
|
||||
if w.profile == "us" {
|
||||
profiles[0], profiles[1] = profiles[1], profiles[0]
|
||||
}
|
||||
elements = append(elements, sdk.Element{ID: "key-profile", Label: "Keyboard mapping", Kind: sdk.List, Items: profiles}, sdk.Element{ID: "cancel", Label: "Cancel", Kind: sdk.Button})
|
||||
result.Form = &sdk.Form{Title: "Remote options", Elements: elements}
|
||||
case "inspecting", "checking":
|
||||
details.Items = append(details.Items, sdk.ListItem{ID: "inspection", Label: "Inspecting the certificate without sending a channel key. No connection will start automatically."})
|
||||
result.Form = &sdk.Form{Title: "Inspecting Remote certificate", Elements: []sdk.Element{details,
|
||||
{ID: "refresh", Label: "Refresh inspection status", Kind: sdk.Button},
|
||||
result.Form = &sdk.Form{Title: "Checking Remote certificate", Elements: []sdk.Element{details,
|
||||
{ID: "cancel", Label: "Cancel", Kind: sdk.Button},
|
||||
}}
|
||||
case "certificate":
|
||||
@@ -165,18 +176,22 @@ func (w *connectionWorkflow) form_locked() sdk.Interaction {
|
||||
}
|
||||
}
|
||||
details.Items = append(details.Items, sdk.ListItem{ID: "status", Label: text})
|
||||
result.Form = &sdk.Form{Title: "Remote relay status", Elements: []sdk.Element{details,
|
||||
{ID: "desktop", Label: "Return to desktop and keep this connection", Kind: sdk.Button},
|
||||
{ID: "refresh", Label: "Refresh connection status", Kind: sdk.Button},
|
||||
result.Form = &sdk.Form{Title: "Remote status", Elements: []sdk.Element{details,
|
||||
{ID: "desktop", Label: "Close", Kind: sdk.Button},
|
||||
{ID: "disconnect", Label: "Disconnect", Kind: sdk.Button},
|
||||
{ID: "cancel", Label: "Disconnect and close", Kind: sdk.Button},
|
||||
}}
|
||||
if w.autoBackground {
|
||||
result.Form = &sdk.Form{Title: "Connecting Remote", Elements: []sdk.Element{{ID: "disconnect", Label: "Cancel", Kind: sdk.Button}}}
|
||||
}
|
||||
default:
|
||||
return security_message("Remote connection workflow closed.")
|
||||
}
|
||||
// Nested forms always return through this instance's owner, never through
|
||||
// the standalone handlers or a newly selected endpoint.
|
||||
result.Next = "remote-connection"
|
||||
if w.mode == "inspecting" || w.mode == "checking" || w.mode == "status" && w.autoBackground {
|
||||
result.Poll = "remote-poll"
|
||||
}
|
||||
if w.notice != "" {
|
||||
result.Presentation = security_message(w.notice).Presentation
|
||||
}
|
||||
@@ -185,26 +200,23 @@ func (w *connectionWorkflow) form_locked() sdk.Interaction {
|
||||
|
||||
// session_scope_text names what this approved session can actually do.
|
||||
func session_scope_text(action sdk.SessionEvent) string {
|
||||
text := "Experimental speech"
|
||||
if slices.Contains(action.Grants, "keyboard-capture") {
|
||||
text += " and keyboard control of the remote computer"
|
||||
} else if slices.Contains(action.Grants, "keyboard-inject") {
|
||||
text += " and keyboard control of this computer by the helper"
|
||||
var access []string
|
||||
if slices.Contains(action.Grants, "output-observe") || slices.Contains(action.Grants, "remote-present") {
|
||||
access = append(access, "Speech")
|
||||
}
|
||||
if slices.Contains(action.Grants, "keyboard-capture") || slices.Contains(action.Grants, "keyboard-inject") {
|
||||
access = append(access, "keyboard")
|
||||
}
|
||||
if slices.Contains(action.Grants, "clipboard-exchange") {
|
||||
text += ", explicit clipboard text transfer"
|
||||
access = append(access, "clipboard")
|
||||
}
|
||||
if slices.Contains(action.Grants, "braille-stream") {
|
||||
text += ", Braille display output and routing"
|
||||
access = append(access, "Braille")
|
||||
}
|
||||
text += "; live verification is pending."
|
||||
if !slices.Contains(action.Grants, "clipboard-exchange") {
|
||||
text += " Clipboard transfer was not approved."
|
||||
if len(access) == 0 {
|
||||
return "Choose access in the reader approval dialog before connecting."
|
||||
}
|
||||
if !slices.Contains(action.Grants, "braille-stream") {
|
||||
text += " Braille was not approved."
|
||||
}
|
||||
return text
|
||||
return "Allowed: " + strings.Join(access, ", ") + "."
|
||||
}
|
||||
|
||||
func connection_status_text(status connectionStatus) string {
|
||||
@@ -214,9 +226,9 @@ func connection_status_text(status connectionStatus) string {
|
||||
case "connecting":
|
||||
return "Connecting and authenticating the relay."
|
||||
case "waiting":
|
||||
return "Connected to the relay; waiting for one opposite-role peer."
|
||||
return "Connected; waiting for the other computer."
|
||||
case "ready":
|
||||
return "One opposite-role peer has joined."
|
||||
return "Connected to the other computer."
|
||||
case "stopping":
|
||||
return "Disconnecting and releasing the reader lease."
|
||||
case "failed":
|
||||
@@ -233,10 +245,10 @@ func connection_status_text(status connectionStatus) string {
|
||||
}
|
||||
}
|
||||
|
||||
// Inspection is explicit and runs outside the command deadline. Only Refresh
|
||||
// Inspection is explicit and runs outside the command deadline. Polling
|
||||
// presents its result; neither completion nor Trust once starts a connection.
|
||||
func (w *connectionWorkflow) inspect_locked() {
|
||||
w.key, w.notice, w.mode = "", "", "inspecting"
|
||||
w.notice, w.mode = "", "inspecting"
|
||||
done := make(chan struct{})
|
||||
w.probeDone = done
|
||||
probeCtx, cancel := context.WithCancel(w.setupCtx)
|
||||
@@ -253,7 +265,7 @@ func (w *connectionWorkflow) inspect_locked() {
|
||||
return
|
||||
}
|
||||
if err != nil {
|
||||
w.mode, w.notice = "credentials", "Certificate inspection failed. No trust was changed and no channel key was sent."
|
||||
w.mode, w.notice = "credentials", "Certificate inspection failed. No trust was changed and no key was sent."
|
||||
return
|
||||
}
|
||||
// The probe's short-lived context ends here. The review belongs to the
|
||||
@@ -271,6 +283,13 @@ func (w *connectionWorkflow) submit(ctx context.Context, value sdk.Submission) (
|
||||
return security_message("Remote connection approval ended. Start a fresh local connection action."), nil
|
||||
}
|
||||
if value.Cancelled {
|
||||
if w.mode == "status" && !w.autoBackground {
|
||||
if lease, ok := w.owner.background_lease(w.action.Epoch); ok {
|
||||
result := security_message("Remote controls closed.")
|
||||
result.RemoteBackground = &lease
|
||||
return result, nil
|
||||
}
|
||||
}
|
||||
w.finish_locked()
|
||||
return w.form_locked(), nil
|
||||
}
|
||||
@@ -283,6 +302,9 @@ func (w *connectionWorkflow) submit(ctx context.Context, value sdk.Submission) (
|
||||
case "credentials":
|
||||
switch value.Activated {
|
||||
case "connect":
|
||||
if selected := value.Values["key-profile"].Selected; selected == "portable" || selected == "us" {
|
||||
w.profile = selected
|
||||
}
|
||||
key := value.Values["channel-key"].Text
|
||||
if key == "" {
|
||||
key = w.key
|
||||
@@ -291,6 +313,11 @@ func (w *connectionWorkflow) submit(ctx context.Context, value sdk.Submission) (
|
||||
w.notice = "Enter a valid channel key or explicitly load a saved key."
|
||||
break
|
||||
}
|
||||
if w.needsApproval {
|
||||
w.key = key
|
||||
w.check_locked()
|
||||
return w.form_locked(), nil
|
||||
}
|
||||
err := w.owner.connect(w.action, w.target, key)
|
||||
w.key = ""
|
||||
w.target.pin = nil
|
||||
@@ -313,6 +340,9 @@ func (w *connectionWorkflow) submit(ctx context.Context, value sdk.Submission) (
|
||||
w.key, w.notice = key, "Saved key loaded for this relay. Choose Connect relay to use it."
|
||||
}
|
||||
case "inspect-certificate":
|
||||
if key := value.Values["channel-key"].Text; validChannelKey(key) {
|
||||
w.key = key
|
||||
}
|
||||
w.inspect_locked()
|
||||
case "saved-key-actions":
|
||||
w.key = ""
|
||||
@@ -353,7 +383,7 @@ func (w *connectionWorkflow) submit(ctx context.Context, value sdk.Submission) (
|
||||
if err != nil {
|
||||
w.notice = "Certificate review ended without approval."
|
||||
} else if approved.host != "" && remember {
|
||||
selected := settings{Version: 1, Role: w.action.Role, Host: approved.host, Port: approved.port,
|
||||
selected := settings{Version: 1, Role: w.role, Host: approved.host, Port: approved.port,
|
||||
Pin: &savedPin{Host: approved.host, Port: approved.port, SHA256: hex.EncodeToString(approved.pin.sha256[:])}}
|
||||
if w.store.save(selected) != nil {
|
||||
w.notice = "The certificate pin save failed. Stored trust may have changed; review it before another connection."
|
||||
@@ -386,15 +416,120 @@ func (w *connectionWorkflow) submit(ctx context.Context, value sdk.Submission) (
|
||||
case "status":
|
||||
if value.Activated == "desktop" {
|
||||
if lease, ok := w.owner.background_lease(w.action.Epoch); ok {
|
||||
result := security_message("Remote connection controls closed. Press Cthulhu+Control+Shift+R to review status or disconnect. Speech support is experimental.")
|
||||
result := security_message("Remote controls closed. Cthulhu+Ctrl+Shift+R opens status.")
|
||||
result.RemoteBackground = &lease
|
||||
return result, nil
|
||||
}
|
||||
w.notice = "No live reader lease is available. Refresh connection status or disconnect."
|
||||
w.notice = "No live reader lease is available. Disconnect and start again."
|
||||
}
|
||||
if value.Activated == "disconnect" {
|
||||
w.owner.disconnect_epoch(w.action.Epoch)
|
||||
w.finish_locked()
|
||||
return security_message("Remote disconnected."), nil
|
||||
}
|
||||
}
|
||||
return w.form_locked(), nil
|
||||
}
|
||||
|
||||
// Setup belongs to the command's local interaction until it receives approval.
|
||||
// No short-lived reader action is issued during key entry or certificate review.
|
||||
func new_setup_workflow(owner *coordinator, target endpoint, store *settingsStore, role string) (*connectionWorkflow, error) {
|
||||
if _, err := target.tlsConfig(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if owner.ctx.Err() != nil {
|
||||
return nil, errLease
|
||||
}
|
||||
lifetime, cancel := context.WithCancel(owner.ctx)
|
||||
w := &connectionWorkflow{ctx: lifetime, cancel: cancel, done: make(chan struct{}), setupCtx: lifetime, owner: owner, target: target, store: store, role: role, mode: "credentials", needsApproval: true}
|
||||
go func() {
|
||||
defer close(w.done)
|
||||
<-lifetime.Done()
|
||||
w.mu.Lock()
|
||||
w.finish_locked()
|
||||
probeDone := w.probeDone
|
||||
w.mu.Unlock()
|
||||
if probeDone != nil {
|
||||
<-probeDone
|
||||
}
|
||||
}()
|
||||
return w, nil
|
||||
}
|
||||
|
||||
// A normal verified TLS handshake sends no application bytes. Failed trust
|
||||
// returns to explicit inspection; it never enables an insecure fallback.
|
||||
func (w *connectionWorkflow) check_locked() {
|
||||
w.mode, w.notice = "checking", "Checking relay certificate."
|
||||
done := make(chan struct{})
|
||||
w.probeDone = done
|
||||
target := w.target
|
||||
go func() {
|
||||
defer close(done)
|
||||
ctx, cancel := context.WithTimeout(w.ctx, dialTimeout)
|
||||
defer cancel()
|
||||
config, err := target.tlsConfig()
|
||||
if err == nil {
|
||||
dialer := tls.Dialer{NetDialer: &net.Dialer{Timeout: dialTimeout}, Config: config}
|
||||
connection, dialErr := dialer.DialContext(ctx, "tcp", net.JoinHostPort(target.host, strconv.Itoa(target.port)))
|
||||
err = dialErr
|
||||
if connection != nil {
|
||||
connection.SetDeadline(time.Now().Add(time.Second))
|
||||
connection.Close()
|
||||
}
|
||||
}
|
||||
w.mu.Lock()
|
||||
defer w.mu.Unlock()
|
||||
if w.mode != "checking" || w.ctx.Err() != nil {
|
||||
return
|
||||
}
|
||||
if err != nil {
|
||||
w.mode, w.notice = "credentials", "Could not verify the relay. No key was sent. Check the address or inspect its certificate."
|
||||
} else {
|
||||
w.mode, w.notice = "approval", ""
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
func (w *connectionWorkflow) poll(ctx context.Context) sdk.Interaction {
|
||||
w.mu.Lock()
|
||||
defer w.mu.Unlock()
|
||||
if ctx.Err() != nil || w.ctx.Err() != nil {
|
||||
w.finish_locked()
|
||||
return security_message("Remote setup ended.")
|
||||
}
|
||||
switch w.mode {
|
||||
case "checking", "inspecting":
|
||||
return sdk.Interaction{}
|
||||
case "approval":
|
||||
grant, keyboard := "remote-present", "keyboard-capture"
|
||||
if w.role == "controlled" {
|
||||
grant, keyboard = "output-observe", "keyboard-inject"
|
||||
}
|
||||
return sdk.Interaction{Remote: &sdk.RemoteRequest{Role: w.role, Grants: []string{grant}, OptionalGrants: []string{keyboard, "clipboard-exchange", "braille-stream"}}, Next: "remote-approved"}
|
||||
case "status":
|
||||
status := w.owner.snapshot()
|
||||
if w.autoBackground && status.epoch == w.action.Epoch && (status.state == "waiting" || status.state == "ready") {
|
||||
if lease, ok := w.owner.background_lease(w.action.Epoch); ok {
|
||||
w.autoBackground = false
|
||||
text := connection_status_text(status)
|
||||
if slices.Contains(w.action.Grants, "keyboard-capture") {
|
||||
text += " Keyboard remains local. Cthulhu+Alt+Tab switches control."
|
||||
}
|
||||
result := security_message(text)
|
||||
result.RemoteBackground = &lease
|
||||
return result
|
||||
}
|
||||
}
|
||||
if status.state == "failed" || status.state == "closed" {
|
||||
w.finish_locked()
|
||||
return security_message(connection_status_text(status))
|
||||
}
|
||||
text := connection_status_text(status)
|
||||
if text != w.lastStatus {
|
||||
w.lastStatus = text
|
||||
return sdk.Interaction{Presentation: sdk.Presentation{Speech: text, Braille: text}}
|
||||
}
|
||||
return sdk.Interaction{}
|
||||
default:
|
||||
return w.form_locked()
|
||||
}
|
||||
}
|
||||
@@ -72,7 +72,7 @@ func TestConnectionWorkflowBindsReaderActionAndFreezesTrust(t *testing.T) {
|
||||
}
|
||||
result := w.form()
|
||||
encoded, _ := json.Marshal(result)
|
||||
if result.Form == nil || result.Next != "remote-connection" || !strings.Contains(string(encoded), "was not approved") {
|
||||
if result.Form == nil || result.Next != "remote-connection" || !strings.Contains(string(encoded), "Allowed: Speech") {
|
||||
t.Fatal("missing form, continuation or service limitation")
|
||||
}
|
||||
workflowSubmit(t, w, "connect", strings.Repeat("猫", 200))
|
||||
@@ -155,7 +155,7 @@ func TestConnectionWorkflowConnectUsesLoadedKeyWithoutEcho(t *testing.T) {
|
||||
awaitStatus(t, c, func(s connectionStatus) bool { return s.state == "waiting" })
|
||||
result = workflowSubmit(t, w, "refresh", "")
|
||||
encoded, _ := json.Marshal(result)
|
||||
if !strings.Contains(string(encoded), "waiting for one opposite-role peer") || !strings.Contains(string(encoded), "Braille was not approved") || !strings.Contains(string(encoded), "Clipboard transfer was not approved") || strings.Contains(string(encoded), "keyboard control") {
|
||||
if !strings.Contains(string(encoded), "waiting for the other computer") || strings.Contains(string(encoded), "Allowed: Speech, keyboard") {
|
||||
t.Fatal("status advertised desktop control or omitted waiting state")
|
||||
}
|
||||
if w.key != "" {
|
||||
@@ -219,7 +219,7 @@ func TestConnectionWorkflowBackgroundRequiresOpenedLease(t *testing.T) {
|
||||
nextCall(t, f, "remote.heartbeat")
|
||||
command := &connectionCommand{coordinator: c, workflow: w}
|
||||
reopened, err := command.open(t.Context(), nil)
|
||||
if err != nil || reopened.(sdk.Interaction).Form.Title != "Remote relay status" {
|
||||
if err != nil || reopened.(sdk.Interaction).Form.Title != "Remote status" {
|
||||
t.Fatal("shortcut did not reopen connection status", err)
|
||||
}
|
||||
f.events <- sdk.SessionEvent{Kind: "remote.revoked", Lease: result.RemoteBackground.Lease, Epoch: 1}
|
||||
|
||||
@@ -28,6 +28,7 @@ type connectionStatus struct {
|
||||
epoch uint64
|
||||
peer int
|
||||
ignored uint64
|
||||
muted bool
|
||||
focus string // Controller keyboard: "", "local" or "remote", as reported by core.
|
||||
err error // Local constant errors only; never RPC/server diagnostic text.
|
||||
}
|
||||
|
||||
+84
-17
@@ -17,28 +17,32 @@ const maxSpeechItems = 64
|
||||
const maxKeyItems = 256
|
||||
|
||||
type speechItem struct {
|
||||
speech sdk.RemoteSpeech
|
||||
bytes int
|
||||
batch bool
|
||||
first bool
|
||||
final bool
|
||||
generation uint64
|
||||
speech sdk.RemoteSpeech
|
||||
bytes int
|
||||
batch bool
|
||||
first bool
|
||||
final bool
|
||||
}
|
||||
|
||||
// One stream belongs to one attempt and lease. The coordinator mutex owns
|
||||
// admission/accounting, including in-flight work. Only speech_operations owns
|
||||
// sequence; teardown reads it after that worker finishes.
|
||||
type speechStream struct {
|
||||
lease sdk.RemoteLease
|
||||
role string
|
||||
grants []string
|
||||
incoming chan speechItem
|
||||
outgoing chan []byte
|
||||
items int
|
||||
bytes int
|
||||
sequence uint64
|
||||
keys chan sdk.RemoteKey // Controlled keyboard-inject only.
|
||||
keyItems int // Queued plus in-flight; coordinator.mu.
|
||||
mapping *keyboardMap // Immutable; nil without a keyboard grant.
|
||||
lease sdk.RemoteLease
|
||||
role string
|
||||
grants []string
|
||||
incoming chan speechItem
|
||||
outgoing chan []byte
|
||||
items int
|
||||
bytes int
|
||||
sequence uint64
|
||||
muted bool
|
||||
speechGeneration uint64
|
||||
muteCancel chan struct{}
|
||||
keys chan sdk.RemoteKey // Controlled keyboard-inject only.
|
||||
keyItems int // Queued plus in-flight; coordinator.mu.
|
||||
mapping *keyboardMap // Immutable; nil without a keyboard grant.
|
||||
// Controller keyboard-capture only.
|
||||
captured chan sdk.RemoteCapturedKey
|
||||
capturedItems int // Queued plus in-flight; coordinator.mu.
|
||||
@@ -57,7 +61,7 @@ type speechStream struct {
|
||||
|
||||
func newSpeechStream(lease sdk.RemoteLease, approval sdk.SessionEvent) *speechStream {
|
||||
return &speechStream{lease: lease, role: approval.Role, grants: slices.Clone(approval.Grants),
|
||||
incoming: make(chan speechItem, maxSpeechItems), outgoing: make(chan []byte, maxSpeechItems),
|
||||
muteCancel: make(chan struct{}, 1), incoming: make(chan speechItem, maxSpeechItems), outgoing: make(chan []byte, maxSpeechItems),
|
||||
keys: make(chan sdk.RemoteKey, maxKeyItems), captured: make(chan sdk.RemoteCapturedKey, maxCapturedKeys),
|
||||
focusRequests: make(chan bool, 4), brailleOps: make(chan sdk.RemoteBraille, maxBrailleOps),
|
||||
readerCellsSignal: make(chan struct{}, 1), displaySignal: make(chan struct{}, 1)}
|
||||
@@ -151,6 +155,12 @@ func (c *coordinator) receive_speech(a *connectionAttempt, stream *speechStream,
|
||||
if !c.speech_ready_locked(a, stream) {
|
||||
return true, errLease
|
||||
}
|
||||
if stream.muted {
|
||||
return true, nil
|
||||
}
|
||||
for index := range items {
|
||||
items[index].generation = stream.speechGeneration
|
||||
}
|
||||
if stream.items+len(items) > maxSpeechItems || stream.bytes+bytes > maxQueuedBytes {
|
||||
return true, errLimit
|
||||
}
|
||||
@@ -226,7 +236,25 @@ func (c *coordinator) speech_operations_ticks(a *connectionAttempt, stream *spee
|
||||
}
|
||||
return err == nil
|
||||
}
|
||||
cancelMuted := func() bool {
|
||||
stream.sequence++
|
||||
request := sdk.RemotePresentation{RemoteOperation: sdk.RemoteOperation{Lease: stream.lease.Lease, Epoch: a.epoch, Sequence: stream.sequence}, Speech: sdk.RemoteSpeech{Kind: "cancel"}}
|
||||
if c.call("remote.present", request, nil) != nil {
|
||||
c.mu.Lock()
|
||||
c.stop_locked(errLease)
|
||||
c.mu.Unlock()
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
for {
|
||||
select {
|
||||
case <-stream.muteCancel:
|
||||
if !cancelMuted() {
|
||||
return
|
||||
}
|
||||
default:
|
||||
}
|
||||
// Every effect shares the heartbeat deadline, including Braille and
|
||||
// focus requests. A continuously ready queue must not starve it.
|
||||
select {
|
||||
@@ -243,6 +271,10 @@ func (c *coordinator) speech_operations_ticks(a *connectionAttempt, stream *spee
|
||||
if !heartbeat() {
|
||||
return
|
||||
}
|
||||
case <-stream.muteCancel:
|
||||
if !cancelMuted() {
|
||||
return
|
||||
}
|
||||
case value := <-stream.brailleOps:
|
||||
if !c.braille_call(a, stream, value) {
|
||||
return
|
||||
@@ -274,9 +306,22 @@ func (c *coordinator) speech_operations_ticks(a *connectionAttempt, stream *spee
|
||||
return
|
||||
}
|
||||
case item := <-stream.incoming:
|
||||
select {
|
||||
case <-stream.muteCancel:
|
||||
if !cancelMuted() {
|
||||
c.speech_release(stream, item.bytes)
|
||||
return
|
||||
}
|
||||
default:
|
||||
}
|
||||
c.mu.Lock()
|
||||
discard := stream.muted || item.generation != stream.speechGeneration
|
||||
ready := c.speech_ready_locked(a, stream)
|
||||
c.mu.Unlock()
|
||||
if discard {
|
||||
c.speech_release(stream, item.bytes)
|
||||
continue
|
||||
}
|
||||
if !ready {
|
||||
c.speech_release(stream, item.bytes)
|
||||
return
|
||||
@@ -384,3 +429,25 @@ func (c *coordinator) speech_output(a *connectionAttempt, stream *speechStream,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Mute invalidates queued speech and serializes cancellation through the same
|
||||
// remote lease owner. It never invokes the reader's general speech cancellation.
|
||||
func (c *coordinator) toggle_mute() (bool, error) {
|
||||
c.mu.Lock()
|
||||
defer c.mu.Unlock()
|
||||
a := c.active
|
||||
if a == nil || a.speech == nil || a.speech.role != "controller" || !slices.Contains(a.speech.grants, "remote-present") || !c.speech_ready_locked(a, a.speech) {
|
||||
return false, errLease
|
||||
}
|
||||
stream := a.speech
|
||||
stream.muted = !stream.muted
|
||||
stream.speechGeneration++
|
||||
c.status.muted = stream.muted
|
||||
if stream.muted {
|
||||
select {
|
||||
case stream.muteCancel <- struct{}{}:
|
||||
default:
|
||||
}
|
||||
}
|
||||
return stream.muted, nil
|
||||
}
|
||||
@@ -354,3 +354,41 @@ func TestSpeechStreamAdmissionBoundsAndGrants(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestRemoteMuteDiscardsOldSpeechAndCancelsOnlyItsLease(t *testing.T) {
|
||||
c, a, stream := inertSpeechStream(t, "controller", []string{"remote-present"})
|
||||
client := &fixtureClient{events: make(chan sdk.SessionEvent, 1), calls: make(chan readerCall, 16)}
|
||||
c.client = client
|
||||
message := message{kind: "speak", payload: speech{parts: []speechPart{{kind: "text", text: "old"}}}}
|
||||
if _, err := c.receive_speech(a, stream, message); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if muted, err := c.toggle_mute(); err != nil || !muted {
|
||||
t.Fatal("mute failed", err)
|
||||
}
|
||||
if _, err := c.receive_speech(a, stream, message); err != nil || len(stream.incoming) != 1 {
|
||||
t.Fatal("muted speech queued")
|
||||
}
|
||||
if muted, err := c.toggle_mute(); err != nil || muted {
|
||||
t.Fatal("unmute failed", err)
|
||||
}
|
||||
message.payload = speech{parts: []speechPart{{kind: "text", text: "new"}}}
|
||||
if _, err := c.receive_speech(a, stream, message); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
done := make(chan struct{})
|
||||
go func() { defer close(done); c.speech_operations_ticks(a, stream, make(chan time.Time)) }()
|
||||
cancel := nextCall(t, client, "remote.present").params.(sdk.RemotePresentation)
|
||||
if cancel.Speech.Kind != "cancel" || cancel.Lease != stream.lease.Lease || cancel.Epoch != 1 {
|
||||
t.Fatal("mute used general or wrong-session cancellation")
|
||||
}
|
||||
spoken := nextCall(t, client, "remote.present").params.(sdk.RemotePresentation)
|
||||
if len(spoken.Speech.Parts) != 1 || spoken.Speech.Parts[0].Text != "new" || spoken.Sequence <= cancel.Sequence {
|
||||
t.Fatal("old speech replayed or cancel reordered", spoken)
|
||||
}
|
||||
a.cancel()
|
||||
awaitDone(t, done)
|
||||
if stream.items != 0 || stream.bytes != 0 {
|
||||
t.Fatal("muted queue accounting leaked")
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@ format-version = 1
|
||||
id = "remote"
|
||||
name = "Remote"
|
||||
description = "Control another computer or let a helper access this one over an NVDA Remote compatible relay: speech, keyboard, clipboard text and Braille, each approved per session."
|
||||
version = "0.1.0"
|
||||
version = "0.1.1"
|
||||
authors = ["Storm Dragon"]
|
||||
license = "GPL-3.0-or-later"
|
||||
source = "https://git.stormux.org/storm/cthulhu-tentacles"
|
||||
@@ -18,6 +18,6 @@ major = 1
|
||||
minor = 1
|
||||
|
||||
[requirements]
|
||||
reader = "Cthulhu with Tentacle protocol 1.1 and Remote session services, including cthulhu-input-helper for keyboard control and cthulhu-braille for Braille"
|
||||
reader = "Cthulhu testing with optional Remote grants and polling form transitions, including cthulhu-input-helper for keyboard control and cthulhu-braille for Braille"
|
||||
runtime = "Xorg for keyboard capture and injection; an independently hosted NVDA Remote protocol 2 relay"
|
||||
build = "Go 1.24 or newer and the adjacent cthulhu source checkout"
|
||||
Reference in new issue
Block a user