diff options
| author | 2024-04-18 15:12:47 +0000 | |
|---|---|---|
| committer | 2024-04-18 15:12:47 +0000 | |
| commit | 100c9cf569ef4497160ac60a55f5b94b9cb524bc (patch) | |
| tree | 30791ca1d83e2b94787e42432898ac7b2c7f7943 | |
| parent | Improved non-public reply check. (diff) | |
| parent | Ability to federate with hidden networks #93 (update for v2.49) (diff) | |
| download | snac2-100c9cf569ef4497160ac60a55f5b94b9cb524bc.tar.gz snac2-100c9cf569ef4497160ac60a55f5b94b9cb524bc.tar.xz snac2-100c9cf569ef4497160ac60a55f5b94b9cb524bc.zip | |
Merge pull request 'Ability to federate with hidden networks #93 (update for v2.49)' (#149) from iwojima/snac2:master into master
Reviewed-on: https://codeberg.org/grunfink/snac2/pulls/149
| -rw-r--r-- | activitypub.c | 4 | ||||
| -rw-r--r-- | data.c | 5 | ||||
| -rw-r--r-- | html.c | 2 | ||||
| -rw-r--r-- | http.c | 3 | ||||
| -rw-r--r-- | mastoapi.c | 2 | ||||
| -rw-r--r-- | webfinger.c | 9 |
6 files changed, 14 insertions, 11 deletions
diff --git a/activitypub.c b/activitypub.c index 526302a..53f102e 100644 --- a/activitypub.c +++ b/activitypub.c | |||
| @@ -1277,7 +1277,7 @@ xs_dict *msg_actor(snac *snac) | |||
| 1277 | xs *k2 = encode_html(k); | 1277 | xs *k2 = encode_html(k); |
| 1278 | xs *v2 = NULL; | 1278 | xs *v2 = NULL; |
| 1279 | 1279 | ||
| 1280 | if (xs_startswith(v, "https:")) { | 1280 | if (xs_startswith(v, "http")) { |
| 1281 | xs *t = encode_html(v); | 1281 | xs *t = encode_html(v); |
| 1282 | v2 = xs_fmt("<a href=\"%s\" rel=\"me\">%s</a>", t, t); | 1282 | v2 = xs_fmt("<a href=\"%s\" rel=\"me\">%s</a>", t, t); |
| 1283 | } | 1283 | } |
| @@ -1369,7 +1369,7 @@ xs_dict *msg_follow(snac *snac, const char *q) | |||
| 1369 | 1369 | ||
| 1370 | xs *url_or_uid = xs_strip_i(xs_str_new(q)); | 1370 | xs *url_or_uid = xs_strip_i(xs_str_new(q)); |
| 1371 | 1371 | ||
| 1372 | if (xs_startswith(url_or_uid, "https:/")) | 1372 | if (xs_startswith(url_or_uid, "http")) |
| 1373 | actor = xs_dup(url_or_uid); | 1373 | actor = xs_dup(url_or_uid); |
| 1374 | else | 1374 | else |
| 1375 | if (!valid_status(webfinger_request(url_or_uid, &actor, NULL)) || actor == NULL) { | 1375 | if (!valid_status(webfinger_request(url_or_uid, &actor, NULL)) || actor == NULL) { |
| @@ -68,7 +68,7 @@ int srv_open(char *basedir, int auto_upgrade) | |||
| 68 | if (host == NULL || prefix == NULL) | 68 | if (host == NULL || prefix == NULL) |
| 69 | error = xs_str_new("ERROR: cannot get server data"); | 69 | error = xs_str_new("ERROR: cannot get server data"); |
| 70 | else { | 70 | else { |
| 71 | srv_baseurl = xs_fmt("https://%s%s", host, prefix); | 71 | srv_baseurl = xs_fmt("http://%s%s", host, prefix); |
| 72 | 72 | ||
| 73 | dbglevel = (int) xs_number_get(dbglvl); | 73 | dbglevel = (int) xs_number_get(dbglvl); |
| 74 | 74 | ||
| @@ -1990,7 +1990,8 @@ xs_list *inbox_list(void) | |||
| 1990 | 1990 | ||
| 1991 | xs_str *_instance_block_fn(const char *instance) | 1991 | xs_str *_instance_block_fn(const char *instance) |
| 1992 | { | 1992 | { |
| 1993 | xs *s1 = xs_replace(instance, "https:/" "/", ""); | 1993 | xs *s = xs_replace(instance, "http:/" "/", ""); |
| 1994 | xs *s1 = xs_replace(s, "https:/" "/", ""); | ||
| 1994 | xs *l = xs_split(s1, "/"); | 1995 | xs *l = xs_split(s1, "/"); |
| 1995 | char *p = xs_list_get(l, 0); | 1996 | char *p = xs_list_get(l, 0); |
| 1996 | xs *md5 = xs_md5_hex(p, strlen(p)); | 1997 | xs *md5 = xs_md5_hex(p, strlen(p)); |
| @@ -813,7 +813,7 @@ static xs_html *html_user_body(snac *user, int read_only) | |||
| 813 | while (xs_dict_next(metadata, &k, &v, &c)) { | 813 | while (xs_dict_next(metadata, &k, &v, &c)) { |
| 814 | xs_html *value; | 814 | xs_html *value; |
| 815 | 815 | ||
| 816 | if (xs_startswith(v, "https:/" "/")) { | 816 | if (xs_startswith(v, "http")) { |
| 817 | /* is this link validated? */ | 817 | /* is this link validated? */ |
| 818 | xs *verified_link = NULL; | 818 | xs *verified_link = NULL; |
| 819 | xs_number *val_time = xs_dict_get(val_links, v); | 819 | xs_number *val_time = xs_dict_get(val_links, v); |
| @@ -32,7 +32,8 @@ xs_dict *http_signed_request_raw(const char *keyid, const char *seckey, | |||
| 32 | date = xs_str_utctime(0, "%a, %d %b %Y %H:%M:%S GMT"); | 32 | date = xs_str_utctime(0, "%a, %d %b %Y %H:%M:%S GMT"); |
| 33 | 33 | ||
| 34 | { | 34 | { |
| 35 | xs *s = xs_replace_n(url, "https:/" "/", "", 1); | 35 | xs *s1 = xs_replace_n(url, "http:/" "/", "", 1); |
| 36 | xs *s = xs_replace_n(s1, "https:/" "/", "", 1); | ||
| 36 | l1 = xs_split_n(s, "/", 1); | 37 | l1 = xs_split_n(s, "/", 1); |
| 37 | } | 38 | } |
| 38 | 39 | ||
| @@ -156,7 +156,7 @@ const char *login_page = "" | |||
| 156 | "</head>\n" | 156 | "</head>\n" |
| 157 | "<body><h1>%s OAuth identify</h1>\n" | 157 | "<body><h1>%s OAuth identify</h1>\n" |
| 158 | "<div style=\"background-color: red; color: white\">%s</div>\n" | 158 | "<div style=\"background-color: red; color: white\">%s</div>\n" |
| 159 | "<form method=\"post\" action=\"https:/" "/%s/%s\">\n" | 159 | "<form method=\"post\" action=\"http:/" "/%s/%s\">\n" |
| 160 | "<p>Login: <input type=\"text\" name=\"login\"></p>\n" | 160 | "<p>Login: <input type=\"text\" name=\"login\"></p>\n" |
| 161 | "<p>Password: <input type=\"password\" name=\"passwd\"></p>\n" | 161 | "<p>Password: <input type=\"password\" name=\"passwd\"></p>\n" |
| 162 | "<input type=\"hidden\" name=\"redir\" value=\"%s\">\n" | 162 | "<input type=\"hidden\" name=\"redir\" value=\"%s\">\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 | |||
| 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, "https:/" "/")) { | 22 | if (xs_startswith(qs, "http")) { |
| 23 | /* actor query: pick the host */ | 23 | /* actor query: pick the host */ |
| 24 | xs *s = xs_replace_n(qs, "https:/" "/", "", 1); | 24 | xs *s1 = xs_replace_n(qs, "http:/" "/", "", 1); |
| 25 | xs *s = xs_replace_n(s1, "https:/" "/", "", 1); | ||
| 25 | 26 | ||
| 26 | l = xs_split_n(s, "/", 1); | 27 | l = xs_split_n(s, "/", 1); |
| 27 | 28 | ||
| @@ -69,7 +70,7 @@ int webfinger_request_signed(snac *snac, const char *qs, char **actor, char **us | |||
| 69 | &payload, &p_size, &ctype); | 70 | &payload, &p_size, &ctype); |
| 70 | } | 71 | } |
| 71 | else { | 72 | else { |
| 72 | xs *url = xs_fmt("https:/" "/%s/.well-known/webfinger?resource=%s", host, resource); | 73 | xs *url = xs_fmt("http:/" "/%s/.well-known/webfinger?resource=%s", host, resource); |
| 73 | 74 | ||
| 74 | if (snac == NULL) | 75 | if (snac == NULL) |
| 75 | xs_http_request("GET", url, headers, NULL, 0, &status, &payload, &p_size, 0); | 76 | 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, | |||
| 139 | snac snac; | 140 | snac snac; |
| 140 | int found = 0; | 141 | int found = 0; |
| 141 | 142 | ||
| 142 | if (xs_startswith(resource, "https:/" "/")) { | 143 | if (xs_startswith(resource, "https")) { |
| 143 | /* actor search: find a user with this actor */ | 144 | /* actor search: find a user with this actor */ |
| 144 | xs *l = xs_split(resource, "/"); | 145 | xs *l = xs_split(resource, "/"); |
| 145 | char *uid = xs_list_get(l, -1); | 146 | char *uid = xs_list_get(l, -1); |