Commit 801482be authored by Joel Martin's avatar Joel Martin

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)
parent 208c832b
...@@ -169,6 +169,11 @@ void do_proxy(ws_ctx_t *ws_ctx, int target) { ...@@ -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): ...@@ -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("}")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment