mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-10 03:50:38 +03:00
Revert "New server config array "webfinger_domains"."
This reverts commit f2e0b77478
.
This commit is contained in:
parent
92b3b71532
commit
1a94d7c05b
2
snac.h
2
snac.h
@ -203,7 +203,7 @@ void httpd(void);
|
|||||||
|
|
||||||
int webfinger_request_signed(snac *snac, const char *qs, char **actor, char **user);
|
int webfinger_request_signed(snac *snac, const char *qs, char **actor, char **user);
|
||||||
int webfinger_request(const char *qs, char **actor, char **user);
|
int webfinger_request(const char *qs, char **actor, char **user);
|
||||||
int webfinger_get_handler(const xs_dict *req, const char *q_path,
|
int webfinger_get_handler(xs_dict *req, char *q_path,
|
||||||
char **body, int *b_size, char **ctype);
|
char **body, int *b_size, char **ctype);
|
||||||
|
|
||||||
const char *default_avatar_base64(void);
|
const char *default_avatar_base64(void);
|
||||||
|
31
webfinger.c
31
webfinger.c
@ -106,8 +106,8 @@ int webfinger_request(const char *qs, char **actor, char **user)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int webfinger_get_handler(const xs_dict *req, const char *q_path,
|
int webfinger_get_handler(d_char *req, char *q_path,
|
||||||
char **body, int *b_size, char **ctype)
|
char **body, int *b_size, char **ctype)
|
||||||
/* serves webfinger queries */
|
/* serves webfinger queries */
|
||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
@ -117,8 +117,8 @@ int webfinger_get_handler(const xs_dict *req, const char *q_path,
|
|||||||
if (strcmp(q_path, "/.well-known/webfinger") != 0)
|
if (strcmp(q_path, "/.well-known/webfinger") != 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
const xs_dict *q_vars = xs_dict_get(req, "q_vars");
|
char *q_vars = xs_dict_get(req, "q_vars");
|
||||||
const char *resource = xs_dict_get(q_vars, "resource");
|
char *resource = xs_dict_get(q_vars, "resource");
|
||||||
|
|
||||||
if (resource == NULL)
|
if (resource == NULL)
|
||||||
return 400;
|
return 400;
|
||||||
@ -129,8 +129,7 @@ int webfinger_get_handler(const xs_dict *req, const char *q_path,
|
|||||||
if (xs_startswith(resource, "https:/" "/")) {
|
if (xs_startswith(resource, "https:/" "/")) {
|
||||||
/* actor search: find a user with this actor */
|
/* actor search: find a user with this actor */
|
||||||
xs *list = user_list();
|
xs *list = user_list();
|
||||||
xs_list *p;
|
char *p, *uid;
|
||||||
char *uid;
|
|
||||||
|
|
||||||
p = list;
|
p = list;
|
||||||
while (xs_list_iter(&p, &uid)) {
|
while (xs_list_iter(&p, &uid)) {
|
||||||
@ -157,22 +156,11 @@ int webfinger_get_handler(const xs_dict *req, const char *q_path,
|
|||||||
l = xs_split_n(an, "@", 1);
|
l = xs_split_n(an, "@", 1);
|
||||||
|
|
||||||
if (xs_list_len(l) == 2) {
|
if (xs_list_len(l) == 2) {
|
||||||
const char *uid = xs_list_get(l, 0);
|
char *uid = xs_list_get(l, 0);
|
||||||
const char *host = xs_list_get(l, 1);
|
char *host = xs_list_get(l, 1);
|
||||||
|
|
||||||
if (strcmp(host, xs_dict_get(srv_config, "host")) == 0)
|
if (strcmp(host, xs_dict_get(srv_config, "host")) == 0)
|
||||||
found = user_open(&snac, uid);
|
found = user_open(&snac, uid);
|
||||||
|
|
||||||
if (!found) {
|
|
||||||
/* get the list of possible domain aliases */
|
|
||||||
xs_list *domains = xs_dict_get(srv_config, "webfinger_domains");
|
|
||||||
char *v;
|
|
||||||
|
|
||||||
while (!found && xs_list_iter(&domains, &v)) {
|
|
||||||
if (strcmp(host, v) == 0)
|
|
||||||
found = user_open(&snac, uid);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -182,6 +170,7 @@ int webfinger_get_handler(const xs_dict *req, const char *q_path,
|
|||||||
xs *aaj = xs_dict_new();
|
xs *aaj = xs_dict_new();
|
||||||
xs *links = xs_list_new();
|
xs *links = xs_list_new();
|
||||||
xs *obj = xs_dict_new();
|
xs *obj = xs_dict_new();
|
||||||
|
d_char *j;
|
||||||
|
|
||||||
acct = xs_fmt("acct:%s@%s",
|
acct = xs_fmt("acct:%s@%s",
|
||||||
xs_dict_get(snac.config, "uid"), xs_dict_get(srv_config, "host"));
|
xs_dict_get(snac.config, "uid"), xs_dict_get(srv_config, "host"));
|
||||||
@ -195,10 +184,12 @@ int webfinger_get_handler(const xs_dict *req, const char *q_path,
|
|||||||
obj = xs_dict_append(obj, "subject", acct);
|
obj = xs_dict_append(obj, "subject", acct);
|
||||||
obj = xs_dict_append(obj, "links", links);
|
obj = xs_dict_append(obj, "links", links);
|
||||||
|
|
||||||
|
j = xs_json_dumps_pp(obj, 4);
|
||||||
|
|
||||||
user_free(&snac);
|
user_free(&snac);
|
||||||
|
|
||||||
status = 200;
|
status = 200;
|
||||||
*body = xs_json_dumps_pp(obj, 4);
|
*body = j;
|
||||||
*ctype = "application/json";
|
*ctype = "application/json";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user