Index: apimod.scm ================================================================== --- apimod.scm +++ apimod.scm @@ -411,11 +411,11 @@ (cmd (if (string? cmd-in)(string->symbol cmd-in) cmd-in)) (params (string->sexpr (alist-ref 'params indat))) (key (alist-ref 'key indat)) ;; TODO - add this back ) (debug:print 0 *default-log-port* "cmd:" cmd " with params " params "key " key) - (if (equal? key "nokey") ;; *server-id*) ;; TODO - get real key involved + (if (equal? key *server-id*) ;; TODO - get real key involved (begin (set! *api-process-request-count* (+ *api-process-request-count* 1)) (let* ((res (api:execute-requests dbstruct cmd params))) (debug:print 0 *default-log-port* "res:" res) #;(if (not success) Index: rmtmod.scm ================================================================== --- rmtmod.scm +++ rmtmod.scm @@ -149,15 +149,24 @@ (fullname #f) (hostport #f) (ipaddr #f) (port #f) (srvpkt #f) + (srvkey #f) (lastmsg 0) (expires 0) (inport #f) (outport #f)) +(define *srvpktspec* + `((server (host . h) + (port . p) + (servkey . k) + (pid . i) + (ipaddr . a) + (dbpath . d)))) + ;;====================================================================== ;; S U P P O R T F U N C T I O N S ;;====================================================================== ;; replaces *runremote* @@ -210,10 +219,11 @@ ))) (if the-srv ;; yes, we have a server, now try connecting to it (let* ((srv-addr (server-address the-srv)) (ipaddr (alist-ref 'ipaddr the-srv)) (port (alist-ref 'port the-srv)) + (srv-key (alist-ref 'srvkey the-srv)) (fullpath (db:dbname->path apath dbname)) (srvready (server-ready? ipaddr port fullpath))) (if srvready (begin (hash-table-set! (rmt:remote-conns remote) @@ -224,10 +234,11 @@ fullname: fullpath hostport: srv-addr ipaddr: ipaddr port: port srvpkt: the-srv + srvkey: srv-key lastmsg: (current-seconds) expires: (+ (current-seconds) 60) ;; this needs to be gathered during the ping )) #t) (start-main-srv))) @@ -274,11 +285,11 @@ (rmt:send-receive-real conns apath dbname cmd params))) (define (rmt:send-receive-setup conn) (if (not (rmt:conn-inport conn)) (let-values (((i o) (tcp-connect (rmt:conn-ipaddr conn) - (rmt:conn-port conn)))) + (rmt:conn-port conn)))) (rmt:conn-inport-set! conn i) (rmt:conn-outport-set! conn o)))) ;; db is at apath/.db/dbname, rid is an intermediary solution and will be removed ;; sometime in the future @@ -287,11 +298,11 @@ (let* ((conn (rmt:get-conn remote apath dbname))) (assert conn "FATAL: rmt:send-receive-real called without the needed channels opened") (rmt:send-receive-setup conn) (let* ((key #f) (payload (sexpr->string `((cmd . ,cmd) - (key . ,key) + (key . ,(rmt:conn-srvpkt conn)) (params . ,params)))) (res (begin (write payload (rmt:conn-outport conn)) (with-input-from-port (rmt:conn-inport conn) @@ -1761,18 +1772,10 @@ (res (db:get-iam-server-lock dbh dbfile))) (sqlite3:finalize! dbh) res)) -(define *srvpktspec* - `((server (host . h) - (port . p) - (servkey . k) - (pid . i) - (ipaddr . a) - (dbpath . d)))) - (define (register-server pkts-dir pkt-spec host port servkey ipaddr dbpath) (let* ((pkt-dat `((host . ,host) (port . ,port) (servkey . ,servkey) (pid . ,(current-process-id))