diff options
author | David Thompson <dthompson2@worcester.edu> | 2016-03-25 16:24:51 -0400 |
---|---|---|
committer | David Thompson <dthompson2@worcester.edu> | 2016-03-25 16:24:51 -0400 |
commit | c4d4f854074dc2a021606119e797d68d8aa01168 (patch) | |
tree | 916400be9765f43968853bb6d2a53b36f8779bab /web | |
parent | 581482b4631cfa49d439b6574faf075daa7ebf7b (diff) |
client: Mask sent frames.
* web/socket/client.scm (generate-masking-key): New procedure.
(websocket-send): Mask the frame to be sent.
Diffstat (limited to 'web')
-rw-r--r-- | web/socket/client.scm | 8 |
1 files 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) |