diff options
Diffstat (limited to 'data.c')
| -rw-r--r-- | data.c | 17 |
1 files changed, 4 insertions, 13 deletions
| @@ -165,21 +165,12 @@ int srv_open(const char *basedir, int auto_upgrade) | |||
| 165 | write_default_css(); | 165 | write_default_css(); |
| 166 | } | 166 | } |
| 167 | 167 | ||
| 168 | /* if proxy_media is set but there is no token seed, create one */ | 168 | /* create the proxy token seed */ |
| 169 | if (xs_is_true(xs_dict_get(srv_config, "proxy_media")) && | 169 | { |
| 170 | xs_is_null(xs_dict_get(srv_config, "proxy_token_seed"))) { | ||
| 171 | char rnd[16]; | 170 | char rnd[16]; |
| 172 | xs_rnd_buf(rnd, sizeof(rnd)); | 171 | xs_rnd_buf(rnd, sizeof(rnd)); |
| 173 | xs *pts = xs_hex_enc(rnd, sizeof(rnd)); | ||
| 174 | |||
| 175 | xs_dict_set(srv_config, "proxy_token_seed", pts); | ||
| 176 | 172 | ||
| 177 | if ((f = fopen(cfg_file, "w")) != NULL) { | 173 | srv_proxy_token_seed = xs_hex_enc(rnd, sizeof(rnd)); |
| 178 | xs_json_dump(srv_config, 4, f); | ||
| 179 | fclose(f); | ||
| 180 | |||
| 181 | srv_log(xs_fmt("Created proxy_token_seed")); | ||
| 182 | } | ||
| 183 | } | 174 | } |
| 184 | 175 | ||
| 185 | return ret; | 176 | return ret; |
| @@ -3679,7 +3670,7 @@ xs_str *make_url(const char *href, const char *proxy, int by_token) | |||
| 3679 | xs *p = NULL; | 3670 | xs *p = NULL; |
| 3680 | 3671 | ||
| 3681 | if (by_token) { | 3672 | if (by_token) { |
| 3682 | xs *tks = xs_fmt("%s:%s", xs_dict_get(srv_config, "proxy_token_seed"), proxy); | 3673 | xs *tks = xs_fmt("%s:%s", srv_proxy_token_seed, proxy); |
| 3683 | xs *tk = xs_md5_hex(tks, strlen(tks)); | 3674 | xs *tk = xs_md5_hex(tks, strlen(tks)); |
| 3684 | 3675 | ||
| 3685 | p = xs_fmt("%s/y/%s/", proxy, tk); | 3676 | p = xs_fmt("%s/y/%s/", proxy, tk); |