And it works! Encrypted, p2p deliverable content federated :)

parent 311db57b
......@@ -32,6 +32,13 @@
(ok (xexp->html-bytes sxml)
#:content-type #"text/html"))
(define (not-found)
(response 404 #"Not Found"
(current-seconds) #"text/plain"
'()
(lambda (out-port)
(display #"404 Not Found X_X" out-port))))
(define (json->string json)
(call-with-output-string
(lambda (p)
......@@ -80,6 +87,7 @@
[("inbox") #:method "post" post-inbox]
[("outbox") #:method "get" get-outbox]
[("post-note") #:method "post" post-note]
[("read-only-cas") read-only-cas]
[("enc" (string-arg)) serve-encrypted-object]))
(define (golem-absolute-url handler)
......@@ -200,6 +208,15 @@
(a (@ (href ,(golem-url actor-profile)))
"go home") "!"))))))
(define (read-only-cas req)
(match (assoc 'xt (url-query (request-uri req)))
[#f (not-found)]
[(cons 'xt uri-to-get)
(match (send (magenc-store) get (string->url uri-to-get))
[#f (not-found)]
[(? bytes? out-bytes)
(ok out-bytes)])]))
(define (serve-encrypted-object req enc-hash-str)
'TODO)
......@@ -311,8 +328,7 @@
(define object
(store-get-json (string->url (hash-ref activity 'object))
(hungry-store)))
(db-append! 'inbox activity-url)
(displayln "YEAH!")))
(db-append! 'inbox activity-url)))
(void))
......@@ -347,24 +363,61 @@
;;; =====================
(define (main #:users-name users-name_
#:magenc-store magenc-store_
#:magenc-store [magenc-store_
(new memory-store%)]
#:port [port 8000]
#:host [host "localhost"]
#:base-url [base-url_ (url "http" #f
host port
#f '() '() #f)])
#f '() '() #f)]
#:other-stores [other-stores_ '()])
(parameterize ([users-name users-name_]
[db (make-hasheq)]
[magenc-store magenc-store_]
[base-url base-url_])
[base-url base-url_]
[other-stores other-stores_])
(serve/servlet golem-dispatch
#:servlet-regexp #rx""
#:launch-browser? #f
#:listen-ip host
#:port port
#:extra-files-paths
(list (build-path cwd "static"))))
(void))
(module+ main
(install-default-factories!)
(main #:users-name "Alice"
#:magenc-store (new memory-store%)))
(define other-stores
(make-parameter '()))
(define port
(make-parameter 8000))
(define host
(make-parameter "localhost"))
(command-line
#:program "golem"
#:once-each
[("-o" "--other-stores")
other-stores-option
("Space-separated set of other store URIs to check for content")
(other-stores
(map (lambda (str-uri)
(new web-store%
[server-url (string->url str-uri)]))
(string-split other-stores-option)))]
[("--port")
port-option
("Port to serve on")
(port (string->number port-option))]
[("--host")
host-option
("Hostname to serve on")
(host host-option)]
#:args (users-name)
(main #:users-name users-name
#:host (host)
#:port (port)
#:other-stores (other-stores))))
(module+ try-it-out
(install-default-factories!)
(main #:users-name "Alice"))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment