WebSockets orderly/clean close frame.
- When a packet with only '\xff\x00' is received, this means the client is doing an orderly shutdown. (WebSockets spec version 76)
This commit is contained in:
parent
208c832b28
commit
801482be6a
|
@ -169,6 +169,11 @@ void do_proxy(ws_ctx_t *ws_ctx, int target) {
|
||||||
if (bytes <= 0) {
|
if (bytes <= 0) {
|
||||||
fprintf(stderr, "client closed connection\n");
|
fprintf(stderr, "client closed connection\n");
|
||||||
break;
|
break;
|
||||||
|
} else if ((bytes == 2) &&
|
||||||
|
(tbuf_tmp[0] == '\xff') &&
|
||||||
|
(tbuf_tmp[1] == '\x00')) {
|
||||||
|
fprintf(stderr, "client sent orderly close frame");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (recordfd) {
|
if (recordfd) {
|
||||||
write(recordfd, "'", 1);
|
write(recordfd, "'", 1);
|
||||||
|
|
|
@ -80,7 +80,9 @@ def do_proxy(client, target):
|
||||||
buf = client.recv(buffer_size)
|
buf = client.recv(buffer_size)
|
||||||
if len(buf) == 0: raise Exception("Client closed")
|
if len(buf) == 0: raise Exception("Client closed")
|
||||||
|
|
||||||
if buf[-1] == '\xff':
|
if buf == '\xff\x00':
|
||||||
|
raise Exception("Client sent orderly close frame")
|
||||||
|
elif buf[-1] == '\xff':
|
||||||
if buf.count('\xff') > 1:
|
if buf.count('\xff') > 1:
|
||||||
traffic(str(buf.count('\xff')))
|
traffic(str(buf.count('\xff')))
|
||||||
traffic("}")
|
traffic("}")
|
||||||
|
|
Loading…
Reference in New Issue