diff --git a/utils/wsproxy.c b/utils/wsproxy.c index 2035dc57..2802f91c 100644 --- a/utils/wsproxy.c +++ b/utils/wsproxy.c @@ -169,6 +169,11 @@ void do_proxy(ws_ctx_t *ws_ctx, int target) { if (bytes <= 0) { fprintf(stderr, "client closed connection\n"); break; + } else if ((bytes == 2) && + (tbuf_tmp[0] == '\xff') && + (tbuf_tmp[1] == '\x00')) { + fprintf(stderr, "client sent orderly close frame"); + break; } if (recordfd) { write(recordfd, "'", 1); diff --git a/utils/wsproxy.py b/utils/wsproxy.py index 389e175e..1abdce9f 100755 --- a/utils/wsproxy.py +++ b/utils/wsproxy.py @@ -80,7 +80,9 @@ def do_proxy(client, target): buf = client.recv(buffer_size) 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: traffic(str(buf.count('\xff'))) traffic("}")