Always close WS, handle close message

This commit is contained in:
wingdeans 2023-11-27 13:36:04 -05:00 committed by Derek Meer
parent 5a61a59704
commit 91fdc9a476

View file

@ -5256,6 +5256,9 @@ static int LuaReadWS(lua_State *L) {
luaL_error(L, "Could not read WS data"); luaL_error(L, "Could not read WS data");
} }
if ((wshdr[0] & 0xF) == 0x8)
luaL_error(L, "WS connection closed");
for (i = 0, amt = amtread; i < got; ++i, ++amt) inbuf.p[amt] ^= mask[i & 0x3]; for (i = 0, amt = amtread; i < got; ++i, ++amt) inbuf.p[amt] ^= mask[i & 0x3];
lua_pushlstring(L, inbuf.p + amtread, got); lua_pushlstring(L, inbuf.p + amtread, got);
@ -6624,14 +6627,12 @@ static bool StreamWS(char *p) {
if (Send(iov, 4) == -1) break; if (Send(iov, 4) == -1) break;
} }
if (rc != -1) { wshdr[0] = 0x8 | (1 << 7);
wshdr[0] = 0x8;
wshdr[1] = 0; wshdr[1] = 0;
iov[0].iov_len = 2; iov[0].iov_len = 2;
Send(iov, 1); Send(iov, 1);
} else {
connectionclose = true; connectionclose = true;
}
return true; return true;
} }