diff --git a/main.cpp b/main.cpp index 4b09e05..de78461 100644 --- a/main.cpp +++ b/main.cpp @@ -46,8 +46,17 @@ struct per_session_data__echo { unsigned char buf[LWS_SEND_BUFFER_PRE_PADDING + MAX_ECHO_PAYLOAD + LWS_SEND_BUFFER_POST_PADDING]; unsigned int len; unsigned int index; + int counter; }; +void scramble(unsigned char* str, unsigned int len){ + unsigned int i = rand() % (len-1); + unsigned int j = i+1; + char t = str[i]; + str[i] = str[j]; + str[j] = t; +} + static int callback_echo(struct libwebsocket_context *context, struct libwebsocket *wsi, @@ -58,6 +67,8 @@ callback_echo(struct libwebsocket_context *context, switch (reason) { case LWS_CALLBACK_SERVER_WRITEABLE: + pss->counter++; + scramble(&pss->buf[LWS_SEND_BUFFER_PRE_PADDING], pss->len); n = libwebsocket_write(wsi, &pss->buf[LWS_SEND_BUFFER_PRE_PADDING], pss->len, LWS_WRITE_TEXT); if (n < 0) { lwsl_err("ERROR %d writing to socket, hanging up\n", n); @@ -101,8 +112,7 @@ static struct libwebsocket_protocols protocols[] = { } }; -void sighandler(int sig) -{ +void sighandler(int sig){ force_exit = 1; } diff --git a/run b/run index 3e5983b..de5b4a3 100755 --- a/run +++ b/run @@ -3,7 +3,7 @@ mkdir -p build cd build cmake .. -make -j8 +make -j8 || exit 1 cd .. ./build/server