Introduce write-message!/flush
This commit is contained in:
parent
17a537b5a2
commit
a7e26dcccd
|
@ -153,7 +153,7 @@
|
|||
#f)))
|
||||
(if handler
|
||||
(handler packet message conn)
|
||||
(begin (write-message! (ssh-msg-unimplemented seq) conn)
|
||||
(begin (write-message!/flush (ssh-msg-unimplemented seq) conn)
|
||||
conn)))))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
@ -267,11 +267,10 @@
|
|||
(define h-signature (host-key-signature host-key-private
|
||||
host-key-alg
|
||||
exchange-hash))
|
||||
(write-message! (ssh-msg-kexdh-reply host-key-bytes
|
||||
public-key-as-integer
|
||||
h-signature)
|
||||
conn)
|
||||
(flush-outbound-messages! conn)
|
||||
(write-message!/flush (ssh-msg-kexdh-reply host-key-bytes
|
||||
public-key-as-integer
|
||||
h-signature)
|
||||
conn)
|
||||
(finish shared-secret exchange-hash hash-alg conn))))
|
||||
(else (disconnect-with-error SSH_DISCONNECT_KEY_EXCHANGE_FAILED
|
||||
"Bad key-exchange algorithm ~v" kex-alg))))
|
||||
|
@ -288,8 +287,7 @@
|
|||
dh:oakley-group-2)) ;; yes, SSH's group1 == Oakley/RFC2409 group 2
|
||||
(define-values (private-key public-key) (generate-key group))
|
||||
(define public-key-as-integer (bit-string->integer public-key #t #f))
|
||||
(write-message! (ssh-msg-kexdh-init public-key-as-integer) conn)
|
||||
(flush-outbound-messages! conn)
|
||||
(write-message!/flush (ssh-msg-kexdh-init public-key-as-integer) conn)
|
||||
(oneshot-handler conn
|
||||
SSH_MSG_KEXDH_REPLY
|
||||
(lambda (packet message conn)
|
||||
|
@ -329,8 +327,7 @@
|
|||
(define encoded-remote-algs packet)
|
||||
|
||||
(when (rekey-wait? rekey)
|
||||
(write-message! local-algs conn)
|
||||
(flush-outbound-messages! conn))
|
||||
(write-message!/flush local-algs conn))
|
||||
|
||||
(define is-server? (connection-is-server? conn))
|
||||
(define c (if is-server? remote-algs local-algs))
|
||||
|
@ -414,8 +411,7 @@
|
|||
;; First, send our SSH_MSG_NEWKEYS,
|
||||
;; incrementing the various counters, and then
|
||||
;; apply the new algorithms.
|
||||
(write-message! (ssh-msg-newkeys) conn)
|
||||
(flush-outbound-messages! conn)
|
||||
(write-message!/flush (ssh-msg-newkeys) conn)
|
||||
(send (connection-io-room-handle conn) say
|
||||
(new-keys (connection-is-server? conn)
|
||||
derive-key
|
||||
|
@ -452,13 +448,16 @@
|
|||
(define (flush-outbound-messages! conn)
|
||||
(send (connection-io-room-handle conn) say 'flush))
|
||||
|
||||
(define (write-message!/flush message conn)
|
||||
(write-message! message conn)
|
||||
(flush-outbound-messages! conn))
|
||||
|
||||
(define (maybe-send-disconnect-message! e conn)
|
||||
(when (not (exn:fail:contract:protocol-originated-at-peer? e))
|
||||
(write-message! (ssh-msg-disconnect (exn:fail:contract:protocol-reason-code e)
|
||||
(string->bytes/utf-8 (exn-message e))
|
||||
#"")
|
||||
conn)
|
||||
(flush-outbound-messages! conn)))
|
||||
(write-message!/flush (ssh-msg-disconnect (exn:fail:contract:protocol-reason-code e)
|
||||
(string->bytes/utf-8 (exn-message e))
|
||||
#"")
|
||||
conn)))
|
||||
|
||||
(define (bump-total amount conn)
|
||||
(struct-copy connection conn [total-transferred (+ (connection-total-transferred conn) amount)]))
|
||||
|
@ -472,8 +471,7 @@
|
|||
(define rekey (connection-rekey-state conn))
|
||||
(if (time-to-rekey? rekey conn)
|
||||
(let ((algs ((local-algorithm-list))))
|
||||
(write-message! algs conn)
|
||||
(flush-outbound-messages! conn)
|
||||
(write-message!/flush algs conn)
|
||||
(loop (struct-copy connection conn [rekey-state (rekey-local algs)])))
|
||||
(sync (if (rekey-wait? rekey)
|
||||
(handle-evt (alarm-evt (* (rekey-wait-deadline rekey) 1000))
|
||||
|
|
Loading…
Reference in New Issue