summaryrefslogtreecommitdiff
path: root/web
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2016-03-25 16:24:51 -0400
committerDavid Thompson <dthompson2@worcester.edu>2016-03-25 16:24:51 -0400
commitc4d4f854074dc2a021606119e797d68d8aa01168 (patch)
tree916400be9765f43968853bb6d2a53b36f8779bab /web
parent581482b4631cfa49d439b6574faf075daa7ebf7b (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.scm8
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)