From c4d4f854074dc2a021606119e797d68d8aa01168 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Fri, 25 Mar 2016 16:24:51 -0400 Subject: client: Mask sent frames. * web/socket/client.scm (generate-masking-key): New procedure. (websocket-send): Mask the frame to be sent. --- web/socket/client.scm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/web/socket/client.scm b/web/socket/client.scm index 8bd0c3d..7c176b4 100644 --- a/web/socket/client.scm +++ b/web/socket/client.scm @@ -188,12 +188,16 @@ resource described by URI-OR-STRING." (close-port (websocket-entropy-port ws)) (set-websocket-state! ws 'closed))) +(define (generate-masking-key ws) + "Create a new masking key using the entropy source of WS." + ;; Masking keys are 32 bits long. + (get-bytevector-n (websocket-entropy-port ws) 4)) + (define (websocket-send ws data) "Send DATA, a string or bytevector, to the server that WS is connected to." - ;; TODO: Generate maskng key. ;; TODO: Send frames over some threshold in fragments. - (write-frame (make-text-frame data) + (write-frame (make-text-frame data (generate-masking-key ws)) (websocket-socket ws))) (define (websocket-receive ws) -- cgit v1.2.3