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

Function websocket_to_lightningd

connectd/websocketd.c:290–313  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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