MCPcopy Create free account
hub / github.com/ElementsProject/lightning / websocket_to_lightningd

Function websocket_to_lightningd

connectd/websocketd.c:294–317  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

292}
293
294static void websocket_to_lightningd(int wsfd, int lightningfd)
295{
296 size_t len;
297 u8 inmask[4];
298 bool is_binframe;
299
300 len = read_payload_header(wsfd, inmask, &is_binframe);
301 while (len > 0) {
302 u8 buf[65536];
303 int rlen = len;
304
305 if (rlen > sizeof(buf))
306 rlen = sizeof(buf);
307
308 rlen = read(wsfd, buf, rlen);
309 if (rlen <= 0)
310 exit(0);
311 apply_mask(buf, rlen, inmask);
312 len -= rlen;
313 /* We ignore non binary frames (FIXME: Send error!) */
314 if (is_binframe && !write_all(lightningfd, buf, rlen))
315 exit(0);
316 }
317}
318
319/* stdin goes to the client, stdout goes to lightningd */
320int main(int argc, char *argv[])

Callers 1

mainFunction · 0.85

Calls 3

read_payload_headerFunction · 0.85
apply_maskFunction · 0.85
write_allFunction · 0.50

Tested by

no test coverage detected