|
|
|
|
@ -65,16 +65,12 @@
|
|
|
|
|
;; For the handoff stuff: |
|
|
|
|
;; https://dustycloud.org/tmp/captp-handoff-musings.org.txt |
|
|
|
|
;; https://dustycloud.org/misc/3vat-handoff-scaled.jpg |
|
|
|
|
(define captp-version "goblins-0.11") |
|
|
|
|
(define captp-version "goblins-0.12") |
|
|
|
|
|
|
|
|
|
(struct captp-session-severed ()) |
|
|
|
|
|
|
|
|
|
;;; Messages |
|
|
|
|
|
|
|
|
|
(define-recordable-struct op:bootstrap |
|
|
|
|
(answer-pos resolve-me-desc) |
|
|
|
|
marshall::op:bootstrap unmarshall::op:bootstrap) |
|
|
|
|
|
|
|
|
|
;; Queue a delivery of verb(args..) to recip, discarding the outcome. |
|
|
|
|
(define-recordable-struct op:deliver-only |
|
|
|
|
(;; Position in the table for the target |
|
|
|
|
@ -197,8 +193,7 @@
|
|
|
|
|
marshall::op:start-session unmarshall::op:start-session) |
|
|
|
|
|
|
|
|
|
(define marshallers |
|
|
|
|
(list marshall::op:bootstrap |
|
|
|
|
marshall::op:deliver-only |
|
|
|
|
(list marshall::op:deliver-only |
|
|
|
|
marshall::op:deliver |
|
|
|
|
marshall::op:abort |
|
|
|
|
marshall::op:listen |
|
|
|
|
@ -219,8 +214,7 @@
|
|
|
|
|
marshall::ocapn-bearer-union)) |
|
|
|
|
|
|
|
|
|
(define unmarshallers |
|
|
|
|
(list unmarshall::op:bootstrap |
|
|
|
|
unmarshall::op:deliver-only |
|
|
|
|
(list unmarshall::op:deliver-only |
|
|
|
|
unmarshall::op:deliver |
|
|
|
|
unmarshall::op:abort |
|
|
|
|
unmarshall::op:listen |
|
|
|
|
@ -248,8 +242,6 @@
|
|
|
|
|
#t] |
|
|
|
|
[_ #f])) |
|
|
|
|
|
|
|
|
|
;; TODO: |
|
|
|
|
|
|
|
|
|
(define (signed-handoff-receive? obj) |
|
|
|
|
(match obj |
|
|
|
|
[(desc:sig-envelope (desc:handoff-receive (? bytes? session) |
|
|
|
|
@ -342,7 +334,7 @@
|
|
|
|
|
[(get-remote-location) |
|
|
|
|
($ coordinator 'get-remote-location)] |
|
|
|
|
[(get-remote-bootstrap) |
|
|
|
|
remote-bootstrap-vow] |
|
|
|
|
remote-bootstrap-obj] |
|
|
|
|
[(get-session-name) |
|
|
|
|
($ coordinator 'get-session-name)] |
|
|
|
|
[(get-our-side-name) |
|
|
|
|
@ -714,18 +706,16 @@
|
|
|
|
|
[(keyword? arg) (values args (cons arg kw-args) kw-vals #t)] |
|
|
|
|
[else (values (cons arg args) kw-args kw-vals #f)]))) |
|
|
|
|
|
|
|
|
|
(define remote-bootstrap-obj |
|
|
|
|
(maybe-install-import! (desc:import-object 0))) |
|
|
|
|
(unless (eq? (maybe-install-export! bootstrap-obj) 0) |
|
|
|
|
(error 'invalid-bootstrap-export "Bootstrap object MUST be exported at position 0")) |
|
|
|
|
|
|
|
|
|
(define ((^captp-incoming-handler bcom) msg) |
|
|
|
|
(unless running? |
|
|
|
|
(error 'captp-breakage "Captp session is no longer running but got ~a" |
|
|
|
|
msg)) |
|
|
|
|
(match msg |
|
|
|
|
[(op:bootstrap (? integer? answer-pos) resolve-me-desc) |
|
|
|
|
(define-values (_answer-promise answer-resolver) |
|
|
|
|
(install-answer! answer-pos resolve-me-desc)) |
|
|
|
|
|
|
|
|
|
;; And since we're bootstrapping, we resolve it immediately |
|
|
|
|
($ answer-resolver 'fulfill bootstrap-obj) |
|
|
|
|
(void)] |
|
|
|
|
;; TODO: Handle case where the target doesn't exist? |
|
|
|
|
;; Or maybe just generally handle unmarshalling errors :P |
|
|
|
|
[(op:deliver-only to-desc args-marshalled) |
|
|
|
|
@ -877,25 +867,7 @@
|
|
|
|
|
(define internal-handler |
|
|
|
|
(spawn ^internal-handler)) |
|
|
|
|
|
|
|
|
|
;;; BEGIN REMOTE BOOTSTRAP OPERATION |
|
|
|
|
;;; ================================ |
|
|
|
|
(define this-question-finder |
|
|
|
|
(question-finder)) |
|
|
|
|
;; called for its effect of installing the question |
|
|
|
|
(question-finder->question-pos! this-question-finder) |
|
|
|
|
(define-values (remote-bootstrap-vow remote-bootstrap-resolver) |
|
|
|
|
(_spawn-promise-values #:question-finder |
|
|
|
|
this-question-finder |
|
|
|
|
#:captp-connector |
|
|
|
|
captp-connector)) |
|
|
|
|
(define bootstrap-msg |
|
|
|
|
(op:bootstrap (hash-ref questions this-question-finder) |
|
|
|
|
(outgoing-pre-marshall! remote-bootstrap-resolver))) |
|
|
|
|
(send-to-remote bootstrap-msg) |
|
|
|
|
;;; END REMOTE BOOTSTRAP OPERATION |
|
|
|
|
;;; ============================== |
|
|
|
|
|
|
|
|
|
(values captp-incoming-handler remote-bootstrap-vow)) |
|
|
|
|
(values captp-incoming-handler remote-bootstrap-obj)) |
|
|
|
|
|
|
|
|
|
;;; ================BEGIN CRYPTOGRAPHY ADMONISHMENT============== |
|
|
|
|
;;; *TODO TODO TODO:* This cryptography stuff doesn't belong here, |
|
|
|
|
@ -1390,7 +1362,7 @@
|
|
|
|
|
|
|
|
|
|
;; We don't actually have a bootstrap vow until setup completion, so |
|
|
|
|
;; we'll have to return a vow to a vow |
|
|
|
|
(define-values (meta-bootstrap-vow meta-bootstrap-resolver) |
|
|
|
|
(define-values (remote-bootstrap-vow remote-bootstrap-resolver) |
|
|
|
|
(spawn-promise-values)) |
|
|
|
|
|
|
|
|
|
;; Complete the initialization step against the remote node. |
|
|
|
|
@ -1468,13 +1440,13 @@
|
|
|
|
|
(when can-continue? |
|
|
|
|
(let*-values ([(session-name) ($ coordinator 'get-session-name)] |
|
|
|
|
[(local-bootstrap-obj) (make-local-bootstrap-obj)] |
|
|
|
|
[(captp-incoming-handler remote-bootstrap-vow) |
|
|
|
|
[(captp-incoming-handler remote-bootstrap-obj) |
|
|
|
|
(setup-captp-conn send-to-remote coordinator |
|
|
|
|
local-bootstrap-obj |
|
|
|
|
intra-node-warden intra-node-incanter)]) |
|
|
|
|
;; Fulfill the meta-bootstrap-promise with the promise that |
|
|
|
|
;; setup-captp-conn gave us |
|
|
|
|
($ meta-bootstrap-resolver 'fulfill remote-bootstrap-vow) |
|
|
|
|
($ remote-bootstrap-resolver 'fulfill remote-bootstrap-obj) |
|
|
|
|
|
|
|
|
|
;; Set things up so that the incoming-forwarder now goes |
|
|
|
|
;; to the captp-incoming-handler |
|
|
|
|
@ -1487,15 +1459,17 @@
|
|
|
|
|
($ open-session-names->sessionmeta 'set |
|
|
|
|
session-name |
|
|
|
|
(sessionmeta remote-location |
|
|
|
|
local-bootstrap-obj remote-bootstrap-vow |
|
|
|
|
local-bootstrap-obj remote-bootstrap-obj |
|
|
|
|
coordinator session-name)))) |
|
|
|
|
(void)] |
|
|
|
|
[(op:abort _reason) |
|
|
|
|
(bcom (lambda _ (void)))] |
|
|
|
|
[(internal-shutdown type reason) |
|
|
|
|
;; We're shutting down before we've properly set the connection up, |
|
|
|
|
;; we're no longer needed :( |
|
|
|
|
(when (eq? type 'abort) |
|
|
|
|
(send-to-remote (op:abort reason))) |
|
|
|
|
(bcom (^setup-completer (lambda _ (void))))])) |
|
|
|
|
(bcom (lambda _ (void)))])) |
|
|
|
|
|
|
|
|
|
(define-values (incoming-forwarder incoming-swap) |
|
|
|
|
(swappable (spawn ^setup-completer))) |
|
|
|
|
@ -1556,8 +1530,8 @@
|
|
|
|
|
our-location |
|
|
|
|
our-location-sig)) |
|
|
|
|
|
|
|
|
|
;; Return the meta-bootstrap-vow, which will be completed as above |
|
|
|
|
meta-bootstrap-vow] |
|
|
|
|
;; Return the remote-bootstrap-vow, which will be completed as above |
|
|
|
|
remote-bootstrap-vow] |
|
|
|
|
|
|
|
|
|
[self-location? self-location?] |
|
|
|
|
;; ... is that it? |
|
|
|
|
|