Remove use of :PROTOCOL & :ADDRESS in *CONFIG*
Now, the protocol is inferred through the :HOST, and :ADDRESS is, well, :HOST.
This commit is contained in:
parent
dbb23ad8b8
commit
2182eb4ebe
|
@ -26,11 +26,12 @@
|
||||||
(defvar *store* (make-hash-table :test #'equal)
|
(defvar *store* (make-hash-table :test #'equal)
|
||||||
"Our “object-store” — stores all ActivityPub objects, mapped by their IRI @ID.")
|
"Our “object-store” — stores all ActivityPub objects, mapped by their IRI @ID.")
|
||||||
|
|
||||||
(defvar *config* '(:address "localhost" :protocol "http" :port 8080 :fetch fetch))
|
(defvar *config*
|
||||||
|
'(:host "http://localhost:8080" :address "127.0.0.1" :port 8080 :fetch fetch))
|
||||||
|
|
||||||
(defvar *user-id-format* "~A://~A/users/~A"
|
(defvar *user-id-format* "~A/users/~A"
|
||||||
"The format we use for user’s @IDs/URIs.
|
"The format we use for user’s @IDs/URIs.
|
||||||
The first parameter is the protocol, the second the host, and the third the username.
|
The first parameter is the protocol+host, and the second is the username.
|
||||||
For example: “https://localhost:8080/users/lena”.")
|
For example: “https://localhost:8080/users/lena”.")
|
||||||
|
|
||||||
|
|
||||||
|
@ -91,15 +92,16 @@ That is, an “acct:username@host.tld” URI."
|
||||||
(destructuring-bind (user host)
|
(destructuring-bind (user host)
|
||||||
(str:split "@" sans-preceding-@)
|
(str:split "@" sans-preceding-@)
|
||||||
(format nil *user-id-format*
|
(format nil *user-id-format*
|
||||||
(host-scheme host) host user))))
|
(host-w-scheme host) user))))
|
||||||
|
|
||||||
(defun host-scheme (hostname)
|
(defun host-w-scheme (hostname)
|
||||||
"Helper-function for ACCT-URI->ID. Returns the expected protocol of a hostname.
|
"Helper-function for ACCT-URI->ID. From a hostname, returns “scheme://hostname”.
|
||||||
If it’s our configured :ADDRESS (in *CONFIG*), then return *CONFIG*’s :PROTOCOL.
|
If it matches our configured :HOST (in *CONFIG*), simply returns :HOST’s value.
|
||||||
Otherwise, assume “https”."
|
Otherwise, assume “https”."
|
||||||
(if (equal (getf *config* :address) hostname)
|
(let ((our-host (getf *config* :host)))
|
||||||
(getf *config* :protocol)
|
(if (equal (quri:uri-host (quri:uri our-host)) hostname)
|
||||||
"https"))
|
our-host
|
||||||
|
(format nil "https://~A" hostname))))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -136,9 +138,7 @@ Otherwise, assume “https”."
|
||||||
The ID and ENDPOINTS are derived using the parameter USERNAME and the global *USER-ID-FORMAT*."
|
The ID and ENDPOINTS are derived using the parameter USERNAME and the global *USER-ID-FORMAT*."
|
||||||
(let ((obj (make-instance 'user))
|
(let ((obj (make-instance 'user))
|
||||||
(uri (format nil *user-id-format*
|
(uri (format nil *user-id-format*
|
||||||
(getf *config* :protocol)
|
(getf *config* :host) username)))
|
||||||
(getf *config* :address)
|
|
||||||
username)))
|
|
||||||
(flet ((sub-uri (path)
|
(flet ((sub-uri (path)
|
||||||
(format nil "~A/~A" uri path)))
|
(format nil "~A/~A" uri path)))
|
||||||
(setf (as:name obj) username)
|
(setf (as:name obj) username)
|
||||||
|
|
|
@ -29,12 +29,12 @@
|
||||||
|
|
||||||
;;; Globals
|
;;; Globals
|
||||||
;;; ————————————————————————————————————————
|
;;; ————————————————————————————————————————
|
||||||
(defvar *config* '(:address "localhost" :port 8080 :protocol "https")
|
(defvar *config* '(:host "http://localhost:8080" :address "127.0.0.1" :port 8080)
|
||||||
"Configuration for the server, a property-list.
|
"Configuration for the server, a property-list.
|
||||||
There are three optional properties:
|
There are three optional properties:
|
||||||
• :PROTOCOL, either “https” or “http” (the latter for testing, only!).
|
• :HOST, the public-facing URI of the server.
|
||||||
• :ADDRESS, the server’s domain-name/address.
|
• :ADDRESS, the address the server is exposed on.
|
||||||
• :PORT, the server’s port.
|
• :PORT, the port the server is exposed on.
|
||||||
|
|
||||||
There is one required property:
|
There is one required property:
|
||||||
• :FETCH, a function used as a callback by activity-servist.
|
• :FETCH, a function used as a callback by activity-servist.
|
||||||
|
@ -77,16 +77,12 @@ Returns the ActivityPub object associated with the given URI."
|
||||||
(,(str:concat "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
|
(,(str:concat "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
|
||||||
<XRD xmlns=\"http://docs.oasis-open.org/ns/xri/xrd-1.0\">
|
<XRD xmlns=\"http://docs.oasis-open.org/ns/xri/xrd-1.0\">
|
||||||
<link rel=\"lrdd\" type=\"application/xrd+xml\" template=\""
|
<link rel=\"lrdd\" type=\"application/xrd+xml\" template=\""
|
||||||
(getf *config* :protocol)
|
(getf *config* :host)
|
||||||
"://"
|
|
||||||
(getf *config* :address)
|
|
||||||
"/.well-known/webfinger?resource={uri}\"/>
|
"/.well-known/webfinger?resource={uri}\"/>
|
||||||
</XRD>
|
</XRD>
|
||||||
"))))
|
"))))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
;;; Webfinger response
|
;;; Webfinger response
|
||||||
;;; ————————————————————————————————————————
|
;;; ————————————————————————————————————————
|
||||||
|
|
Ŝarĝante…
Reference in New Issue