diff options
Diffstat (limited to 'packages/meshbay-cli/src/meshbay_cli/client/transfers.py')
| -rw-r--r-- | packages/meshbay-cli/src/meshbay_cli/client/transfers.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/packages/meshbay-cli/src/meshbay_cli/client/transfers.py b/packages/meshbay-cli/src/meshbay_cli/client/transfers.py index 3f23c85..2cbf4cd 100644 --- a/packages/meshbay-cli/src/meshbay_cli/client/transfers.py +++ b/packages/meshbay-cli/src/meshbay_cli/client/transfers.py @@ -268,6 +268,20 @@ async def _fetch_chunks(session: GroupSession, lease: Lease, file_id: str, file_ return written +async def read_chunk(session: GroupSession, entry: dict, i: int) -> bytes: + """ + Chunk `i` of a file, decrypted, asked for without a lease: what the + application's players do, and what the node bounds (a dozen files at once + per connection). A refusal raises `NodeRefusal`; a connection that failed, + another `CliError`. + """ + msg = await session.ch.request( + {"type": "file_req", "v": MNP_VERSION, "file_id": entry["id"], "chunk_index": i}, + "file_chunk", timeout=CHUNK_TIMEOUT) + return decrypt_chunk_aes(chunk_key_aes(session.gek, bytes.fromhex(entry["id"]), i), + msg["nonce"], msg["ct"]) + + def mark_of_the_web(path: Path) -> None: """ZoneId 3, as a browser marks a download, so SmartScreen and Protected View apply when it is opened. FAT and exFAT have no alternate streams: nothing to do.""" |