From 7312f4ce51100d4ed98988cb3af0ab06e4fba53c Mon Sep 17 00:00:00 2001 From: iwojim0 Date: Sat, 9 Mar 2024 14:37:54 +0000 Subject: [PATCH] Ability to federate with hidden networks #93 (update for v2.49) --- activitypub.c | 4 ++-- data.c | 5 +++-- html.c | 2 +- http.c | 3 ++- mastoapi.c | 2 +- webfinger.c | 9 +++++---- 6 files changed, 14 insertions(+), 11 deletions(-) diff --git a/activitypub.c b/activitypub.c index 1976012..73fbbc6 100644 --- a/activitypub.c +++ b/activitypub.c @@ -1228,7 +1228,7 @@ xs_dict *msg_actor(snac *snac) xs *k2 = encode_html(k); xs *v2 = NULL; - if (xs_startswith(v, "https:")) { + if (xs_startswith(v, "http")) { xs *t = encode_html(v); v2 = xs_fmt("%s", t, t); } @@ -1320,7 +1320,7 @@ xs_dict *msg_follow(snac *snac, const char *q) xs *url_or_uid = xs_strip_i(xs_str_new(q)); - if (xs_startswith(url_or_uid, "https:/")) + if (xs_startswith(url_or_uid, "http")) actor = xs_dup(url_or_uid); else if (!valid_status(webfinger_request(url_or_uid, &actor, NULL)) || actor == NULL) { diff --git a/data.c b/data.c index 4d9824a..f4cd6d6 100644 --- a/data.c +++ b/data.c @@ -67,7 +67,7 @@ int srv_open(char *basedir, int auto_upgrade) if (host == NULL || prefix == NULL) error = xs_str_new("ERROR: cannot get server data"); else { - srv_baseurl = xs_fmt("https://%s%s", host, prefix); + srv_baseurl = xs_fmt("http://%s%s", host, prefix); dbglevel = (int) xs_number_get(dbglvl); @@ -1944,7 +1944,8 @@ xs_list *inbox_list(void) xs_str *_instance_block_fn(const char *instance) { - xs *s1 = xs_replace(instance, "https:/" "/", ""); + xs *s = xs_replace(instance, "http:/" "/", ""); + xs *s1 = xs_replace(s, "https:/" "/", ""); xs *l = xs_split(s1, "/"); char *p = xs_list_get(l, 0); xs *md5 = xs_md5_hex(p, strlen(p)); diff --git a/html.c b/html.c index 59fd6c9..46ef735 100644 --- a/html.c +++ b/html.c @@ -783,7 +783,7 @@ static xs_html *html_user_body(snac *user, int read_only) while (xs_dict_next(metadata, &k, &v, &c)) { xs_html *value; - if (xs_startswith(v, "https:/" "/")) { + if (xs_startswith(v, "http")) { /* is this link validated? */ xs *verified_link = NULL; xs_number *val_time = xs_dict_get(val_links, v); diff --git a/http.c b/http.c index 1b3d590..f7ff9ba 100644 --- a/http.c +++ b/http.c @@ -32,7 +32,8 @@ xs_dict *http_signed_request_raw(const char *keyid, const char *seckey, date = xs_str_utctime(0, "%a, %d %b %Y %H:%M:%S GMT"); { - xs *s = xs_replace_n(url, "https:/" "/", "", 1); + xs *s1 = xs_replace_n(url, "http:/" "/", "", 1); + xs *s = xs_replace_n(s1, "https:/" "/", "", 1); l1 = xs_split_n(s, "/", 1); } diff --git a/mastoapi.c b/mastoapi.c index 416f96c..d702c47 100644 --- a/mastoapi.c +++ b/mastoapi.c @@ -156,7 +156,7 @@ const char *login_page = "" "\n" "

%s OAuth identify

\n" "
%s
\n" -"
\n" +"\n" "

Login:

\n" "

Password:

\n" "\n" diff --git a/webfinger.c b/webfinger.c index a883d7f..331191b 100644 --- a/webfinger.c +++ b/webfinger.c @@ -19,9 +19,10 @@ int webfinger_request_signed(snac *snac, const char *qs, char **actor, char **us xs_str *host = NULL; xs *resource = NULL; - if (xs_startswith(qs, "https:/" "/")) { + if (xs_startswith(qs, "http")) { /* actor query: pick the host */ - xs *s = xs_replace_n(qs, "https:/" "/", "", 1); + xs *s1 = xs_replace_n(qs, "http:/" "/", "", 1); + xs *s = xs_replace_n(s1, "https:/" "/", "", 1); l = xs_split_n(s, "/", 1); @@ -69,7 +70,7 @@ int webfinger_request_signed(snac *snac, const char *qs, char **actor, char **us &payload, &p_size, &ctype); } else { - xs *url = xs_fmt("https:/" "/%s/.well-known/webfinger?resource=%s", host, resource); + xs *url = xs_fmt("http:/" "/%s/.well-known/webfinger?resource=%s", host, resource); if (snac == NULL) xs_http_request("GET", url, headers, NULL, 0, &status, &payload, &p_size, 0); @@ -139,7 +140,7 @@ int webfinger_get_handler(xs_dict *req, char *q_path, snac snac; int found = 0; - if (xs_startswith(resource, "https:/" "/")) { + if (xs_startswith(resource, "https")) { /* actor search: find a user with this actor */ xs *l = xs_split(resource, "/"); char *uid = xs_list_get(l, -1);