mirror of
https://github.com/owntone/owntone-server.git
synced 2025-01-14 00:05:03 -05:00
[config] Make user_agent configurable + don't use ffmpeg default (ref issue #562)
This commit is contained in:
parent
970769cab6
commit
ab1ded35e4
@ -65,6 +65,7 @@ static cfg_opt_t sec_general[] =
|
||||
CFG_STR("db_pragma_journal_mode", NULL, CFGF_NONE),
|
||||
CFG_INT("db_pragma_synchronous", -1, CFGF_NONE),
|
||||
CFG_STR("allow_origin", "*", CFGF_NONE),
|
||||
CFG_STR("user_agent", PACKAGE_NAME "/" PACKAGE_VERSION, CFGF_NONE),
|
||||
CFG_END()
|
||||
};
|
||||
|
||||
|
11
src/http.c
11
src/http.c
@ -44,6 +44,7 @@
|
||||
#include "httpd.h"
|
||||
#include "logger.h"
|
||||
#include "misc.h"
|
||||
#include "conffile.h"
|
||||
|
||||
/* Formats we can read so far */
|
||||
#define PLAYLIST_UNK 0
|
||||
@ -190,6 +191,7 @@ http_client_request_impl(struct http_client_ctx *ctx)
|
||||
struct evbuffer *output_buffer;
|
||||
struct onekeyval *okv;
|
||||
enum evhttp_cmd_type method;
|
||||
const char *user_agent;
|
||||
char host[512];
|
||||
char host_port[1024];
|
||||
char path[2048];
|
||||
@ -258,7 +260,10 @@ http_client_request_impl(struct http_client_ctx *ctx)
|
||||
|
||||
headers = evhttp_request_get_output_headers(req);
|
||||
evhttp_add_header(headers, "Host", host_port);
|
||||
evhttp_add_header(headers, "User-Agent", "forked-daapd/" VERSION);
|
||||
|
||||
user_agent = cfg_getstr(cfg_getsec(cfg, "general"), "user_agent");
|
||||
evhttp_add_header(headers, "User-Agent", user_agent);
|
||||
|
||||
evhttp_add_header(headers, "Icy-MetaData", "1");
|
||||
|
||||
if (ctx->output_headers)
|
||||
@ -334,6 +339,7 @@ https_client_request_impl(struct http_client_ctx *ctx)
|
||||
CURLcode res;
|
||||
struct curl_slist *headers;
|
||||
struct onekeyval *okv;
|
||||
const char *user_agent;
|
||||
char header[1024];
|
||||
|
||||
curl = curl_easy_init();
|
||||
@ -343,8 +349,9 @@ https_client_request_impl(struct http_client_ctx *ctx)
|
||||
return -1;
|
||||
}
|
||||
|
||||
user_agent = cfg_getstr(cfg_getsec(cfg, "general"), "user_agent");
|
||||
curl_easy_setopt(curl, CURLOPT_USERAGENT, user_agent);
|
||||
curl_easy_setopt(curl, CURLOPT_URL, ctx->url);
|
||||
curl_easy_setopt(curl, CURLOPT_USERAGENT, "forked-daapd/" VERSION);
|
||||
|
||||
if (ctx->output_headers)
|
||||
{
|
||||
|
@ -1166,6 +1166,7 @@ raop_add_headers(struct raop_session *rs, struct evrtsp_request *req, enum evrts
|
||||
char buf[64];
|
||||
const char *method;
|
||||
const char *url;
|
||||
const char *user_agent;
|
||||
int ret;
|
||||
|
||||
method = evrtsp_method(req_method);
|
||||
@ -1177,7 +1178,8 @@ raop_add_headers(struct raop_session *rs, struct evrtsp_request *req, enum evrts
|
||||
|
||||
rs->cseq++;
|
||||
|
||||
evrtsp_add_header(req->output_headers, "User-Agent", "forked-daapd/" VERSION);
|
||||
user_agent = cfg_getstr(cfg_getsec(cfg, "general"), "user_agent");
|
||||
evrtsp_add_header(req->output_headers, "User-Agent", user_agent);
|
||||
|
||||
/* Add Authorization header */
|
||||
url = (req_method == EVRTSP_REQ_OPTIONS) ? "*" : rs->session_url;
|
||||
|
@ -733,6 +733,7 @@ open_input(struct decode_ctx *ctx, const char *path, struct evbuffer *evbuf)
|
||||
AVCodecContext *dec_ctx;
|
||||
AVInputFormat *ifmt;
|
||||
unsigned int stream_index;
|
||||
const char *user_agent;
|
||||
int ret;
|
||||
|
||||
CHECK_NULL(L_XCODE, ctx->ifmt_ctx = avformat_alloc_context());
|
||||
@ -744,6 +745,9 @@ open_input(struct decode_ctx *ctx, const char *path, struct evbuffer *evbuf)
|
||||
ctx->ifmt_ctx->probesize = 64000;
|
||||
# endif
|
||||
av_dict_set(&options, "icy", "1", 0);
|
||||
|
||||
user_agent = cfg_getstr(cfg_getsec(cfg, "general"), "user_agent");
|
||||
av_dict_set(&options, "user_agent", user_agent, 0);
|
||||
}
|
||||
|
||||
// TODO Newest versions of ffmpeg have timeout and reconnect options we should use
|
||||
|
Loading…
Reference in New Issue
Block a user