diff options
Diffstat (limited to 'packages/anastasis-webui/watch')
-rwxr-xr-x | packages/anastasis-webui/watch/reply.sh | 17 | ||||
-rwxr-xr-x | packages/anastasis-webui/watch/send_reload.sh | 7 | ||||
-rwxr-xr-x | packages/anastasis-webui/watch/serve.sh | 4 | ||||
-rw-r--r-- | packages/anastasis-webui/watch/web_socket_client.request | 6 | ||||
-rw-r--r-- | packages/anastasis-webui/watch/web_socket_server.reply | 5 |
5 files changed, 39 insertions, 0 deletions
diff --git a/packages/anastasis-webui/watch/reply.sh b/packages/anastasis-webui/watch/reply.sh new file mode 100755 index 000000000..1b42aa4e3 --- /dev/null +++ b/packages/anastasis-webui/watch/reply.sh @@ -0,0 +1,17 @@ +#!/bin/bash +SERVER_KEY=258EAFA5-E914-47DA-95CA-C5AB0DC85B11 + +while read line; do + LINE=$(echo $line | tr -d '\r') + case $LINE in + Sec-WebSocket-Key:*) + CLIENT_KEY="${LINE:19}" + export WS_ACCEPT=$( echo -n $CLIENT_KEY$SERVER_KEY | sha1sum | xxd -r -p | base64 ) + ;; + "") break ;; + esac +done + +cat watch/web_socket_server.reply | sed 's/$'"/`echo \\\r`/" | envsubst '$WS_ACCEPT' + +socat UNIX-RECV:./send_signal STDOUT diff --git a/packages/anastasis-webui/watch/send_reload.sh b/packages/anastasis-webui/watch/send_reload.sh new file mode 100755 index 000000000..87eef7d54 --- /dev/null +++ b/packages/anastasis-webui/watch/send_reload.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +COMMAND='{"type":"RELOAD"}' +LEN=$(printf '%x\n' ${#COMMAND}) +OPCODE=81 +cat <(echo -n $OPCODE$LEN | xxd -r -p) <(echo -n $COMMAND) | socat - UNIX-SEND:./send_signal + diff --git a/packages/anastasis-webui/watch/serve.sh b/packages/anastasis-webui/watch/serve.sh new file mode 100755 index 000000000..cf2737416 --- /dev/null +++ b/packages/anastasis-webui/watch/serve.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +socat TCP-LISTEN:8003,fork EXEC:"./watch/reply.sh" + diff --git a/packages/anastasis-webui/watch/web_socket_client.request b/packages/anastasis-webui/watch/web_socket_client.request new file mode 100644 index 000000000..e7077b0cb --- /dev/null +++ b/packages/anastasis-webui/watch/web_socket_client.request @@ -0,0 +1,6 @@ +GET /socket HTTP/1.1 +Connection: Upgrade +Upgrade: websocket +Sec-WebSocket-Version: 13 +Sec-WebSocket-Key: aaaaaaaaaaaaaaaaaaaaaa== + diff --git a/packages/anastasis-webui/watch/web_socket_server.reply b/packages/anastasis-webui/watch/web_socket_server.reply new file mode 100644 index 000000000..b4e0db001 --- /dev/null +++ b/packages/anastasis-webui/watch/web_socket_server.reply @@ -0,0 +1,5 @@ +HTTP/1.1 101 Switching Protocols +Upgrade: websocket +Connection: Upgrade +Sec-WebSocket-Accept: $WS_ACCEPT + |