mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-22 13:25:04 +00:00
make_url() now accepts generating proxied urls by token.
This commit is contained in:
parent
af92863ebb
commit
bbe061ca19
1 changed files with 11 additions and 1 deletions
12
data.c
12
data.c
|
@ -3676,7 +3676,17 @@ xs_str *make_url(const char *href, const char *proxy, int by_token)
|
||||||
xs_str *url = NULL;
|
xs_str *url = NULL;
|
||||||
|
|
||||||
if (proxy && !xs_startswith(href, srv_baseurl)) {
|
if (proxy && !xs_startswith(href, srv_baseurl)) {
|
||||||
xs *p = xs_str_cat(xs_dup(proxy), "/x/");
|
xs *p = NULL;
|
||||||
|
|
||||||
|
if (by_token) {
|
||||||
|
xs *tks = xs_fmt("%s:%s", xs_dict_get(srv_config, "proxy_token_seed"), proxy);
|
||||||
|
xs *tk = xs_md5_hex(tks, strlen(tks));
|
||||||
|
|
||||||
|
p = xs_fmt("y/%s/", tk);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
p = xs_str_cat(xs_dup(proxy), "/x/");
|
||||||
|
|
||||||
url = xs_replace(href, "https:/" "/", p);
|
url = xs_replace(href, "https:/" "/", p);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue