diff options
| author | Christophe Besson <cbesson@gmail.com> | 2026-10-15 10:17:29 +0200 |
|---|---|---|
| committer | Christophe Besson <cbesson@gmail.com> | 2026-10-15 10:17:29 +0200 |
| commit | a0be6bfcac07a256949082e935e1be06753ab872 (patch) | |
| tree | c6f531254e0abf8303080ba6287cf1fc405a72c1 /packages/meshbay-cli/tests/fake_node.py | |
| parent | 2f90f4b60cd50f7e9649daaf8e76a120e608cff6 (diff) | |
| download | meshbay-a0be6bfcac07a256949082e935e1be06753ab872.tar.gz | |
feat(cli): stream — a film or a song played in a media player
`meshbay-cli stream PATH` serves one video or sound file over HTTP on
127.0.0.1 for VLC, mpv or any player that reads HTTP; `--player PROGRAM`
starts the player, and closing it stops the stream, as Ctrl+C does.
The file goes as the node stores it: no remux, no transcode, no stream
slot on the node. Byte ranges are answered from leaseless file_req chunks
decrypted in memory, eight ahead and the last 24 kept. Loopback only, a
random token in the address, a foreign Host refused (DNS rebinding), an
audio or video type with nosniff. The connection is pinged and reopened
when it dies; a refusal by the node stops the stream (exit 5).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'packages/meshbay-cli/tests/fake_node.py')
| -rw-r--r-- | packages/meshbay-cli/tests/fake_node.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/packages/meshbay-cli/tests/fake_node.py b/packages/meshbay-cli/tests/fake_node.py index b4e64ff..f9c552c 100644 --- a/packages/meshbay-cli/tests/fake_node.py +++ b/packages/meshbay-cli/tests/fake_node.py @@ -57,6 +57,7 @@ class FakeNode: self.fail_chunk: tuple[str, int] | None = None # (file_id, index) → refused self.refuse_upload_code = "" self.chunk_requests = 0 + self.leaseless_reads: list[tuple[str, int]] = [] self.chunk_delay = 0.0 # This machine's key here, the account's other devices, and the requests # waiting for an approval — each `{pk_ed25519, pk_x25519, code_hash}`. @@ -215,7 +216,11 @@ class FakeChannel: def _file_req(self, msg): n = self.node n.chunk_requests += 1 - if n.leases.get(msg.get("tr")) != "granted": + if "tr" not in msg: + # A read without a lease, as a player's: the node admits a dozen + # files at once per connection. + n.leaseless_reads.append((msg["file_id"], msg["chunk_index"])) + elif n.leases.get(msg.get("tr")) != "granted": return {"type": "error", "detail": "no lease", "code": "lease_not_granted"} if n.fail_chunk == (msg["file_id"], msg["chunk_index"]): return {"type": "error", "detail": "The drive stopped answering"} |