<p>Holger Hans Peter Freyther has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/19713">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_http_media_cache: Introduce options and customize<br><br>Make the existing CURL parameters configurable and allow<br>to specify the usable protocols, proxy and DNS timeout.<br><br>ASTERISK-30340<br><br>Change-Id: I3f8efbdf50f233df26197aa2836f5a206baa33ce<br>---<br>A doc/CHANGES-staging/res_http_media_cache.txt<br>M res/res_http_media_cache.c<br>2 files changed, 247 insertions(+), 4 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/13/19713/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/doc/CHANGES-staging/res_http_media_cache.txt b/doc/CHANGES-staging/res_http_media_cache.txt</span><br><span>new file mode 100644</span><br><span>index 0000000..8549817</span><br><span>--- /dev/null</span><br><span>+++ b/doc/CHANGES-staging/res_http_media_cache.txt</span><br><span>@@ -0,0 +1,5 @@</span><br><span style="color: hsl(120, 100%, 40%);">+Subject: res_http_media_cache</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+The res_http_media_cache module now attempts to load</span><br><span style="color: hsl(120, 100%, 40%);">+configuration from the res_http_media_cache.conf file.</span><br><span style="color: hsl(120, 100%, 40%);">+This can be used to control various CURL options.</span><br><span>diff --git a/res/res_http_media_cache.c b/res/res_http_media_cache.c</span><br><span>index cd5fe42..244596b 100644</span><br><span>--- a/res/res_http_media_cache.c</span><br><span>+++ b/res/res_http_media_cache.c</span><br><span>@@ -31,6 +31,41 @@</span><br><span> <support_level>core</support_level></span><br><span> ***/</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+/*** DOCUMENTATION</span><br><span style="color: hsl(120, 100%, 40%);">+ <configInfo name="res_http_media_cache" language="en_US"></span><br><span style="color: hsl(120, 100%, 40%);">+ <synopsis>HTTP media cache</synopsis></span><br><span style="color: hsl(120, 100%, 40%);">+ <configFile name="http_media_cache.conf"></span><br><span style="color: hsl(120, 100%, 40%);">+ <configObject name="general"></span><br><span style="color: hsl(120, 100%, 40%);">+ <synopsis>General configuration</synopsis></span><br><span style="color: hsl(120, 100%, 40%);">+ <configOption name="timeout_secs" default="180"></span><br><span style="color: hsl(120, 100%, 40%);">+ <synopsis>The maximum time the transfer is allowed to complete in seconds. See https://curl.se/libcurl/c/CURLOPT_TIMEOUT.html for details.</synopsis></span><br><span style="color: hsl(120, 100%, 40%);">+ </configOption></span><br><span style="color: hsl(120, 100%, 40%);">+ <configOption name="useragent"></span><br><span style="color: hsl(120, 100%, 40%);">+ <synopsis>The HTTP User-Agent to use for requests. See https://curl.se/libcurl/c/CURLOPT_USERAGENT.html for details.</synopsis></span><br><span style="color: hsl(120, 100%, 40%);">+ </configOption></span><br><span style="color: hsl(120, 100%, 40%);">+ <configOption name="followlocation" default="1"></span><br><span style="color: hsl(120, 100%, 40%);">+ <synopsis>Follow HTTP 3xx redirects on requests. See https://curl.se/libcurl/c/CURLOPT_FOLLOWLOCATION.html for details.</synopsis></span><br><span style="color: hsl(120, 100%, 40%);">+ </configOption></span><br><span style="color: hsl(120, 100%, 40%);">+ <configOption name="maxredirects" default="8"></span><br><span style="color: hsl(120, 100%, 40%);">+ <synopsis>The maximum number of redirects to follow. See https://curl.se/libcurl/c/CURLOPT_MAXREDIRS.html for details</synopsis></span><br><span style="color: hsl(120, 100%, 40%);">+ </configOption></span><br><span style="color: hsl(120, 100%, 40%);">+ <configOption name="proxy"></span><br><span style="color: hsl(120, 100%, 40%);">+ <synopsis>The proxy to use for requests. See https://curl.se/libcurl/c/CURLOPT_PROXY.html for details.</synopsis></span><br><span style="color: hsl(120, 100%, 40%);">+ </configOption></span><br><span style="color: hsl(120, 100%, 40%);">+ <configOption name="protocols"></span><br><span style="color: hsl(120, 100%, 40%);">+ <synopsis>The comma separated list of allowed protocols for the request. Available with curl 7.85.0 or later. See https://curl.se/libcurl/c/CURLOPT_PROTOCOLS.html for details.</synopsis></span><br><span style="color: hsl(120, 100%, 40%);">+ </configOption></span><br><span style="color: hsl(120, 100%, 40%);">+ <configOption name="redir_protocols"></span><br><span style="color: hsl(120, 100%, 40%);">+ <synopsis>The comma separated list of allowed protocols for redirects. Available with curl 7.85.0 or later. See https://curl.se/libcurl/c/CURLOPT_REDIR_PROTOCOLS_STR.html for details.</synopsis></span><br><span style="color: hsl(120, 100%, 40%);">+ </configOption></span><br><span style="color: hsl(120, 100%, 40%);">+ <configOption name="dns_cache_timeout_secs" default="60"></span><br><span style="color: hsl(120, 100%, 40%);">+ <synopsis>The life-time for DNS cache entries. See https://curl.se/libcurl/c/CURLOPT_DNS_CACHE_TIMEOUT.html for details.</synopsis></span><br><span style="color: hsl(120, 100%, 40%);">+ </configOption></span><br><span style="color: hsl(120, 100%, 40%);">+ </configObject></span><br><span style="color: hsl(120, 100%, 40%);">+ </configFile></span><br><span style="color: hsl(120, 100%, 40%);">+ </configInfo></span><br><span style="color: hsl(120, 100%, 40%);">+***/</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> #include "asterisk.h"</span><br><span> </span><br><span> #include <curl/curl.h></span><br><span>@@ -44,6 +79,96 @@</span><br><span> </span><br><span> #define MAX_HEADER_LENGTH 1023</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+#ifdef CURL_AT_LEAST_VERSION</span><br><span style="color: hsl(120, 100%, 40%);">+#if CURL_AT_LEAST_VERSION(7, 85, 0)</span><br><span style="color: hsl(120, 100%, 40%);">+#define AST_CURL_HAS_PROTOCOLS_STR 1</span><br><span style="color: hsl(120, 100%, 40%);">+#endif</span><br><span style="color: hsl(120, 100%, 40%);">+#endif</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/*! \brief General configuration options for http media cache. */</span><br><span style="color: hsl(120, 100%, 40%);">+struct conf_general_options {</span><br><span style="color: hsl(120, 100%, 40%);">+ /*! \brief Request timeout to use */</span><br><span style="color: hsl(120, 100%, 40%);">+ int curl_timeout;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ /*! \brief Follow 3xx redirects automatically. */</span><br><span style="color: hsl(120, 100%, 40%);">+ int curl_followlocation;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ /*! \brief Number of redirects to follow for one request. */</span><br><span style="color: hsl(120, 100%, 40%);">+ int curl_maxredirs;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ /*! \brief Life-time of CURL DNS cache entries. */</span><br><span style="color: hsl(120, 100%, 40%);">+ int curl_dns_cache_timeout;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ AST_DECLARE_STRING_FIELDS(</span><br><span style="color: hsl(120, 100%, 40%);">+ AST_STRING_FIELD(curl_useragent); /*! \brief User-agent to use for requests. */</span><br><span style="color: hsl(120, 100%, 40%);">+ AST_STRING_FIELD(curl_proxy); /*! \brief Proxy to use for requests. None by default. */</span><br><span style="color: hsl(120, 100%, 40%);">+ AST_STRING_FIELD(curl_protocols); /*! \brief Allowed protocols to use for requests. All by default. */</span><br><span style="color: hsl(120, 100%, 40%);">+ AST_STRING_FIELD(curl_redir_protocols); /*! \brief Allowed protocols to use on redirect. All by default. */</span><br><span style="color: hsl(120, 100%, 40%);">+ );</span><br><span style="color: hsl(120, 100%, 40%);">+};</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/*! \brief All configuration options for http media cache. */</span><br><span style="color: hsl(120, 100%, 40%);">+struct conf {</span><br><span style="color: hsl(120, 100%, 40%);">+ /*! The general section configuration options. */</span><br><span style="color: hsl(120, 100%, 40%);">+ struct conf_general_options *general;</span><br><span style="color: hsl(120, 100%, 40%);">+};</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/*! \brief Locking container for safe configuration access. */</span><br><span style="color: hsl(120, 100%, 40%);">+static AO2_GLOBAL_OBJ_STATIC(confs);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/*! \brief Mapping of the http media cache conf struct's general to the general context in the config file. */</span><br><span style="color: hsl(120, 100%, 40%);">+static struct aco_type general_option = {</span><br><span style="color: hsl(120, 100%, 40%);">+ .type = ACO_GLOBAL,</span><br><span style="color: hsl(120, 100%, 40%);">+ .name = "general",</span><br><span style="color: hsl(120, 100%, 40%);">+ .item_offset = offsetof(struct conf, general),</span><br><span style="color: hsl(120, 100%, 40%);">+ .category = "general",</span><br><span style="color: hsl(120, 100%, 40%);">+ .category_match = ACO_WHITELIST_EXACT,</span><br><span style="color: hsl(120, 100%, 40%);">+};</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+static struct aco_type *general_options[] = ACO_TYPES(&general_option);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/*! \brief Disposes of the http media cache conf object */</span><br><span style="color: hsl(120, 100%, 40%);">+static void conf_destructor(void *obj)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ struct conf *cfg = obj;</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_string_field_free_memory(cfg->general);</span><br><span style="color: hsl(120, 100%, 40%);">+ ao2_cleanup(cfg->general);</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/*! \brief Creates the http media cache conf object. */</span><br><span style="color: hsl(120, 100%, 40%);">+static void *conf_alloc(void)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ struct conf *cfg;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!(cfg = ao2_alloc(sizeof(*cfg), conf_destructor))) {</span><br><span style="color: hsl(120, 100%, 40%);">+ return NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!(cfg->general = ao2_alloc(sizeof(*cfg->general), NULL))) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ao2_ref(cfg, -1);</span><br><span style="color: hsl(120, 100%, 40%);">+ return NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ if (ast_string_field_init(cfg->general, 256)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ao2_ref(cfg, -1);</span><br><span style="color: hsl(120, 100%, 40%);">+ return NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ return cfg;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/*! \brief The conf file that's processed for the module. */</span><br><span style="color: hsl(120, 100%, 40%);">+static struct aco_file conf_file = {</span><br><span style="color: hsl(120, 100%, 40%);">+ /*! The config file name. */</span><br><span style="color: hsl(120, 100%, 40%);">+ .filename = "res_http_media_cache.conf",</span><br><span style="color: hsl(120, 100%, 40%);">+ /*! The mapping object types to be processed. */</span><br><span style="color: hsl(120, 100%, 40%);">+ .types = ACO_TYPES(&general_option),</span><br><span style="color: hsl(120, 100%, 40%);">+};</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+CONFIG_INFO_STANDARD(cfg_info, confs, conf_alloc,</span><br><span style="color: hsl(120, 100%, 40%);">+ .files = ACO_FILES(&conf_file));</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> /*! \brief Data passed to cURL callbacks */</span><br><span> struct curl_bucket_file_data {</span><br><span> /*! The \c ast_bucket_file object that caused the operation */</span><br><span>@@ -317,6 +442,8 @@</span><br><span> */</span><br><span> static CURL *get_curl_instance(struct curl_bucket_file_data *cb_data)</span><br><span> {</span><br><span style="color: hsl(120, 100%, 40%);">+ RAII_VAR(struct conf *, cfg, ao2_global_obj_ref(confs), ao2_cleanup);</span><br><span style="color: hsl(120, 100%, 40%);">+ CURLcode rc;</span><br><span> CURL *curl;</span><br><span> </span><br><span> curl = curl_easy_init();</span><br><span>@@ -325,14 +452,47 @@</span><br><span> }</span><br><span> </span><br><span> curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);</span><br><span style="color: hsl(0, 100%, 40%);">- curl_easy_setopt(curl, CURLOPT_TIMEOUT, 180);</span><br><span> curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, curl_header_callback);</span><br><span style="color: hsl(0, 100%, 40%);">- curl_easy_setopt(curl, CURLOPT_USERAGENT, AST_CURL_USER_AGENT);</span><br><span style="color: hsl(0, 100%, 40%);">- curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1);</span><br><span style="color: hsl(0, 100%, 40%);">- curl_easy_setopt(curl, CURLOPT_MAXREDIRS, 8);</span><br><span> curl_easy_setopt(curl, CURLOPT_URL, ast_sorcery_object_get_id(cb_data->bucket_file));</span><br><span> curl_easy_setopt(curl, CURLOPT_HEADERDATA, cb_data);</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ curl_easy_setopt(curl, CURLOPT_TIMEOUT, cfg->general->curl_timeout);</span><br><span style="color: hsl(120, 100%, 40%);">+ curl_easy_setopt(curl, CURLOPT_USERAGENT, cfg->general->curl_useragent);</span><br><span style="color: hsl(120, 100%, 40%);">+ curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, !!cfg->general->curl_followlocation);</span><br><span style="color: hsl(120, 100%, 40%);">+ curl_easy_setopt(curl, CURLOPT_MAXREDIRS, cfg->general->curl_maxredirs);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!ast_strlen_zero(cfg->general->curl_proxy)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ curl_easy_setopt(curl, CURLOPT_PROXY, cfg->general->curl_proxy);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!ast_strlen_zero(cfg->general->curl_protocols)) {</span><br><span style="color: hsl(120, 100%, 40%);">+#ifdef AST_CURL_HAS_PROTOCOLS_STR</span><br><span style="color: hsl(120, 100%, 40%);">+ CURLcode rc = curl_easy_setopt(curl, CURLOPT_PROTOCOLS_STR, cfg->general->curl_protocols);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (rc != CURLE_OK) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_log(AST_LOG_ERROR, "Setting protocols to '%s' failed: %d\n", cfg->general->curl_protocols, rc);</span><br><span style="color: hsl(120, 100%, 40%);">+ curl_easy_cleanup(curl);</span><br><span style="color: hsl(120, 100%, 40%);">+ return NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+#endif</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!ast_strlen_zero(cfg->general->curl_redir_protocols)) {</span><br><span style="color: hsl(120, 100%, 40%);">+#ifdef AST_CURL_HAS_PROTOCOLS_STR</span><br><span style="color: hsl(120, 100%, 40%);">+ CURLcode rc = curl_easy_setopt(curl, CURLOPT_REDIR_PROTOCOLS_STR, cfg->general->curl_redir_protocols);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (rc != CURLE_OK) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_log(AST_LOG_ERROR, "Setting redir_protocols to '%s' failed: %d\n", cfg->general->curl_redir_protocols, rc);</span><br><span style="color: hsl(120, 100%, 40%);">+ curl_easy_cleanup(curl);</span><br><span style="color: hsl(120, 100%, 40%);">+ return NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+#endif</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ rc = curl_easy_setopt(curl, CURLOPT_DNS_CACHE_TIMEOUT, cfg->general->curl_dns_cache_timeout);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (rc != CURLE_OK) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_log(AST_LOG_ERROR, "Setting dns_cache_timeout to '%d' failed: %d\n", cfg->general->curl_dns_cache_timeout, rc);</span><br><span style="color: hsl(120, 100%, 40%);">+ curl_easy_cleanup(curl);</span><br><span style="color: hsl(120, 100%, 40%);">+ return NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> return curl;</span><br><span> }</span><br><span> </span><br><span>@@ -534,11 +694,75 @@</span><br><span> </span><br><span> static int unload_module(void)</span><br><span> {</span><br><span style="color: hsl(120, 100%, 40%);">+ aco_info_destroy(&cfg_info);</span><br><span style="color: hsl(120, 100%, 40%);">+ ao2_global_obj_release(confs);</span><br><span> return 0;</span><br><span> }</span><br><span> </span><br><span> static int load_module(void)</span><br><span> {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (aco_info_init(&cfg_info)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ aco_info_destroy(&cfg_info);</span><br><span style="color: hsl(120, 100%, 40%);">+ return AST_MODULE_LOAD_DECLINE;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ aco_option_register(&cfg_info, "timeout_secs", ACO_EXACT, general_options,</span><br><span style="color: hsl(120, 100%, 40%);">+ "180", OPT_INT_T, 0,</span><br><span style="color: hsl(120, 100%, 40%);">+ FLDSET(struct conf_general_options, curl_timeout));</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ aco_option_register(&cfg_info, "useragent", ACO_EXACT, general_options,</span><br><span style="color: hsl(120, 100%, 40%);">+ AST_CURL_USER_AGENT, OPT_STRINGFIELD_T, 0,</span><br><span style="color: hsl(120, 100%, 40%);">+ STRFLDSET(struct conf_general_options, curl_useragent));</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ aco_option_register(&cfg_info, "followlocation", ACO_EXACT, general_options,</span><br><span style="color: hsl(120, 100%, 40%);">+ "yes", OPT_BOOL_T, 1,</span><br><span style="color: hsl(120, 100%, 40%);">+ FLDSET(struct conf_general_options, curl_followlocation));</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ aco_option_register(&cfg_info, "maxredirects", ACO_EXACT, general_options,</span><br><span style="color: hsl(120, 100%, 40%);">+ "8", OPT_INT_T, 0,</span><br><span style="color: hsl(120, 100%, 40%);">+ FLDSET(struct conf_general_options, curl_maxredirs));</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ aco_option_register(&cfg_info, "proxy", ACO_EXACT, general_options,</span><br><span style="color: hsl(120, 100%, 40%);">+ NULL, OPT_STRINGFIELD_T, 1,</span><br><span style="color: hsl(120, 100%, 40%);">+ STRFLDSET(struct conf_general_options, curl_proxy));</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ aco_option_register(&cfg_info, "dns_cache_timeout_secs", ACO_EXACT, general_options,</span><br><span style="color: hsl(120, 100%, 40%);">+ "60", OPT_INT_T, 0,</span><br><span style="color: hsl(120, 100%, 40%);">+ FLDSET(struct conf_general_options, curl_dns_cache_timeout));</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#ifdef AST_CURL_HAS_PROTOCOLS_STR</span><br><span style="color: hsl(120, 100%, 40%);">+ aco_option_register(&cfg_info, "protocols", ACO_EXACT, general_options,</span><br><span style="color: hsl(120, 100%, 40%);">+ NULL, OPT_STRINGFIELD_T, 1,</span><br><span style="color: hsl(120, 100%, 40%);">+ STRFLDSET(struct conf_general_options, curl_protocols));</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ aco_option_register(&cfg_info, "redir_protocols", ACO_EXACT, general_options,</span><br><span style="color: hsl(120, 100%, 40%);">+ NULL, OPT_STRINGFIELD_T, 1,</span><br><span style="color: hsl(120, 100%, 40%);">+ STRFLDSET(struct conf_general_options, curl_redir_protocols));</span><br><span style="color: hsl(120, 100%, 40%);">+#endif</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ if (aco_process_config(&cfg_info, 0) == ACO_PROCESS_ERROR) {</span><br><span style="color: hsl(120, 100%, 40%);">+ struct conf *cfg;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_log(LOG_NOTICE, "Could not load res_http_media_cache config; using defaults\n");</span><br><span style="color: hsl(120, 100%, 40%);">+ cfg = conf_alloc();</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!cfg) {</span><br><span style="color: hsl(120, 100%, 40%);">+ aco_info_destroy(&cfg_info);</span><br><span style="color: hsl(120, 100%, 40%);">+ return AST_MODULE_LOAD_DECLINE;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ if (aco_set_defaults(&general_option, "general", cfg->general)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_log(LOG_ERROR, "Failed to initialize res_http_media_cache defaults.\n");</span><br><span style="color: hsl(120, 100%, 40%);">+ ao2_ref(cfg, -1);</span><br><span style="color: hsl(120, 100%, 40%);">+ aco_info_destroy(&cfg_info);</span><br><span style="color: hsl(120, 100%, 40%);">+ return AST_MODULE_LOAD_DECLINE;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ ao2_global_obj_replace_unref(confs, cfg);</span><br><span style="color: hsl(120, 100%, 40%);">+ ao2_ref(cfg, -1);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> if (ast_bucket_scheme_register("http", &http_bucket_wizard, &http_bucket_file_wizard,</span><br><span> NULL, NULL)) {</span><br><span> ast_log(LOG_ERROR, "Failed to register Bucket HTTP wizard scheme implementation\n");</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/19713">change 19713</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/c/asterisk/+/19713"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 20 </div>
<div style="display:none"> Gerrit-Change-Id: I3f8efbdf50f233df26197aa2836f5a206baa33ce </div>
<div style="display:none"> Gerrit-Change-Number: 19713 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Holger Hans Peter Freyther <automatic@freyther.de> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>