mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-15 01:55:03 +00:00
New function webfinger_request_fake().
This commit is contained in:
parent
97cc35f577
commit
ee63e2a78c
3 changed files with 30 additions and 9 deletions
3
main.c
3
main.c
|
@ -47,8 +47,9 @@ int usage(void)
|
||||||
printf("unlimit {basedir} {uid} {actor} Unlimits an actor\n");
|
printf("unlimit {basedir} {uid} {actor} Unlimits an actor\n");
|
||||||
printf("verify_links {basedir} {uid} Verifies a user's links (in the metadata)\n");
|
printf("verify_links {basedir} {uid} Verifies a user's links (in the metadata)\n");
|
||||||
printf("search {basedir} {uid} {regex} Searches posts by content\n");
|
printf("search {basedir} {uid} {regex} Searches posts by content\n");
|
||||||
printf("aka {basedir} {uid} {actor} Sets actor (@user@host or url) as an a.k.a.\n");
|
printf("aka {basedir} {uid} {actor} Sets actor (@user@host or url) as the a.k.a.\n");
|
||||||
printf("export_csv {basedir} {uid} Exports data as CSV files into current directory\n");
|
printf("export_csv {basedir} {uid} Exports data as CSV files into current directory\n");
|
||||||
|
printf("migrate {basedir} {uid} Migrates the account to the one set as the a.k.a.\n");
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
9
snac.h
9
snac.h
|
@ -284,10 +284,11 @@ int check_signature(const xs_dict *req, xs_str **err);
|
||||||
srv_state *srv_state_op(xs_str **fname, int op);
|
srv_state *srv_state_op(xs_str **fname, int op);
|
||||||
void httpd(void);
|
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, xs_str **actor, xs_str **user);
|
||||||
int webfinger_request(const char *qs, char **actor, char **user);
|
int webfinger_request(const char *qs, xs_str **actor, xs_str **user);
|
||||||
int webfinger_get_handler(xs_dict *req, char *q_path,
|
int webfinger_request_fake(const char *qs, xs_str **actor, xs_str **user);
|
||||||
char **body, int *b_size, char **ctype);
|
int webfinger_get_handler(xs_dict *req, const char *q_path,
|
||||||
|
xs_val **body, int *b_size, char **ctype);
|
||||||
|
|
||||||
const char *default_avatar_base64(void);
|
const char *default_avatar_base64(void);
|
||||||
|
|
||||||
|
|
27
webfinger.c
27
webfinger.c
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
#include "snac.h"
|
#include "snac.h"
|
||||||
|
|
||||||
int webfinger_request_signed(snac *snac, const char *qs, char **actor, char **user)
|
int webfinger_request_signed(snac *snac, const char *qs, xs_str **actor, xs_str **user)
|
||||||
/* queries the webfinger for qs and fills the required fields */
|
/* queries the webfinger for qs and fills the required fields */
|
||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
|
@ -117,15 +117,34 @@ int webfinger_request_signed(snac *snac, const char *qs, char **actor, char **us
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int webfinger_request(const char *qs, char **actor, char **user)
|
int webfinger_request(const char *qs, xs_str **actor, xs_str **user)
|
||||||
/* queries the webfinger for qs and fills the required fields */
|
/* queries the webfinger for qs and fills the required fields */
|
||||||
{
|
{
|
||||||
return webfinger_request_signed(NULL, qs, actor, user);
|
return webfinger_request_signed(NULL, qs, actor, user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int webfinger_get_handler(xs_dict *req, char *q_path,
|
int webfinger_request_fake(const char *qs, xs_str **actor, xs_str **user)
|
||||||
char **body, int *b_size, char **ctype)
|
/* queries the webfinger and, if it fails, a user is faked if possible */
|
||||||
|
{
|
||||||
|
int status;
|
||||||
|
|
||||||
|
if (!valid_status(status = webfinger_request(qs, actor, user))) {
|
||||||
|
if (xs_startswith(qs, "https:/") || xs_startswith(qs, "http:/")) {
|
||||||
|
xs *l = xs_split(qs, "/");
|
||||||
|
|
||||||
|
/* i'll end up in hell for this */
|
||||||
|
*user = xs_fmt("%s@%s", xs_list_get(l, 2), xs_list_get(l, -1));
|
||||||
|
status = HTTP_STATUS_RESET_CONTENT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int webfinger_get_handler(xs_dict *req, const char *q_path,
|
||||||
|
xs_val **body, int *b_size, char **ctype)
|
||||||
/* serves webfinger queries */
|
/* serves webfinger queries */
|
||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
|
|
Loading…
Reference in a new issue