| 288 | } |
| 289 | |
| 290 | static 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 */ |
| 316 | int main(int argc, char *argv[]) |
no test coverage detected