summaryrefslogtreecommitdiff
path: root/webfinger.c
diff options
context:
space:
mode:
authorGravatar default2024-04-18 17:13:31 +0200
committerGravatar default2024-04-18 17:13:31 +0200
commit26840e0dc0e7322b2041c21b4e44ed9a34afff4b (patch)
tree096c8e9c65df453f5e45bfde8ca8662b9a82c899 /webfinger.c
parentMerge pull request 'Ability to federate with hidden networks #93 (update for ... (diff)
downloadpenes-snac2-26840e0dc0e7322b2041c21b4e44ed9a34afff4b.tar.gz
penes-snac2-26840e0dc0e7322b2041c21b4e44ed9a34afff4b.tar.xz
penes-snac2-26840e0dc0e7322b2041c21b4e44ed9a34afff4b.zip
Some tweaks to previous patch.
Diffstat (limited to '')
-rw-r--r--webfinger.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/webfinger.c b/webfinger.c
index 331191b..5b13d2f 100644
--- a/webfinger.c
+++ b/webfinger.c
@@ -19,7 +19,7 @@ int webfinger_request_signed(snac *snac, const char *qs, char **actor, char **us
19 xs_str *host = NULL; 19 xs_str *host = NULL;
20 xs *resource = NULL; 20 xs *resource = NULL;
21 21
22 if (xs_startswith(qs, "http")) { 22 if (xs_startswith(qs, "https:/") || xs_startswith(qs, "http:/")) {
23 /* actor query: pick the host */ 23 /* actor query: pick the host */
24 xs *s1 = xs_replace_n(qs, "http:/" "/", "", 1); 24 xs *s1 = xs_replace_n(qs, "http:/" "/", "", 1);
25 xs *s = xs_replace_n(s1, "https:/" "/", "", 1); 25 xs *s = xs_replace_n(s1, "https:/" "/", "", 1);
@@ -70,7 +70,9 @@ int webfinger_request_signed(snac *snac, const char *qs, char **actor, char **us
70 &payload, &p_size, &ctype); 70 &payload, &p_size, &ctype);
71 } 71 }
72 else { 72 else {
73 xs *url = xs_fmt("http:/" "/%s/.well-known/webfinger?resource=%s", host, resource); 73 const char *proto = xs_dict_get_def(srv_config, "protocol", "https");
74
75 xs *url = xs_fmt("%s:/" "/%s/.well-known/webfinger?resource=%s", proto, host, resource);
74 76
75 if (snac == NULL) 77 if (snac == NULL)
76 xs_http_request("GET", url, headers, NULL, 0, &status, &payload, &p_size, 0); 78 xs_http_request("GET", url, headers, NULL, 0, &status, &payload, &p_size, 0);
@@ -140,7 +142,7 @@ int webfinger_get_handler(xs_dict *req, char *q_path,
140 snac snac; 142 snac snac;
141 int found = 0; 143 int found = 0;
142 144
143 if (xs_startswith(resource, "https")) { 145 if (xs_startswith(resource, "https:/") || xs_startswith(resource, "http:/")) {
144 /* actor search: find a user with this actor */ 146 /* actor search: find a user with this actor */
145 xs *l = xs_split(resource, "/"); 147 xs *l = xs_split(resource, "/");
146 char *uid = xs_list_get(l, -1); 148 char *uid = xs_list_get(l, -1);