MCPcopy Create free account
hub / github.com/tailscale/tailcat / sendStream

Function sendStream

web/app.js:264–281  ·  view source on GitHub ↗
(addr, size, readChunk, progressEl)

Source from the content-addressed store, hash-verified

262// --- Send side ---
263
264async function sendStream(addr, size, readChunk, progressEl) {
265 const conn = await tailcatDial({ addr, derpMapURL, verbose });
266 let off = 0;
267 while (off < size) {
268 const chunk = await readChunk(off, Math.min(CHUNK, size - off));
269 await conn.write(chunk);
270 off += chunk.length;
271 progressEl.textContent = `${off} / ${size} bytes`;
272 }
273 await conn.closeWrite();
274 // Wait for the receiver's close: like the CLI, the peer's EOF is
275 // the confirmation that everything we sent was delivered.
276 while ((await conn.read()) !== null) {}
277 conn.close();
278 window.tcTest.sentBytes = off;
279 window.tcTest.sendDone = true;
280 progressEl.textContent = `sent ${off} bytes`;
281}
282
283$("send-btn").onclick = async () => {
284 const addr = $("send-addr").value.trim();

Callers 1

app.jsFile · 0.85

Calls 1

tailcatDialFunction · 0.85

Tested by

no test coverage detected