[Asterisk-code-review] res_http_media_cache: Allow to specify the proxy (asterisk[20])

Holger Hans Peter Freyther asteriskteam at digium.com
Fri Dec 9 01:07:37 CST 2022


Holger Hans Peter Freyther has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/19659 )


Change subject: res_http_media_cache: Allow to specify the proxy
......................................................................

res_http_media_cache: Allow to specify the proxy

https://curl.se/libcurl/c/CURLOPT_PROXY.html

ASTERISK-30340

Change-Id: Ife7399f5da9b76937294800f52875125b77e1710
---
M res/res_http_media_cache.c
1 file changed, 25 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/59/19659/1

diff --git a/res/res_http_media_cache.c b/res/res_http_media_cache.c
index bef3750..7528aac 100644
--- a/res/res_http_media_cache.c
+++ b/res/res_http_media_cache.c
@@ -49,6 +49,9 @@
 				<configOption name="maxrdirects">
 					<synopsis>The maximum number of redirects to follow. See https://curl.se/libcurl/c/CURLOPT_MAXREDIRS.html for details</synopsis>
 				</configOption>
+				<configOption name="proxy">
+					<synopsis>The proxy to use for requests. See  https://curl.se/libcurl/c/CURLOPT_PROXY.html for details.</synopsis>
+				</configOption>
 			</configObject>
 		</configFile>
 	</configInfo>
@@ -71,6 +74,7 @@
 static char *cache_curl_useragent = NULL;
 static int cache_followlocation = 1;
 static int cache_maxredirs = 8;
+static char *cache_curl_proxy = NULL;
 
 
 
@@ -362,6 +366,7 @@
 	curl_easy_setopt(curl, CURLOPT_MAXREDIRS, cache_maxredirs);
 	curl_easy_setopt(curl, CURLOPT_URL, ast_sorcery_object_get_id(cb_data->bucket_file));
 	curl_easy_setopt(curl, CURLOPT_HEADERDATA, cb_data);
+	curl_easy_setopt(curl, CURLOPT_PROXY, cache_curl_proxy);
 
 	return curl;
 }
@@ -600,6 +605,13 @@
 					cache_followlocation = ast_true(var->value);
 				} else if (strcasecmp(var->name, "maxredirects") == 0) {
 					cache_maxredirs = strtoul(var->value, NULL, 0);
+				} else if (strcasecmp(var->name, "proxy") == 0) {
+					ast_free(cache_curl_proxy);
+					if (strlen(var->value) > 0) {
+						cache_curl_proxy = ast_strdup(var->value);
+					} else {
+						cache_curl_proxy = NULL;
+					}
 				} else {
 					ast_log(LOG_ERROR, "Unrecognized variable '%s' in category '%s'\n", var->name, cat);
 					ast_config_destroy(cfg);

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/19659
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 20
Gerrit-Change-Id: Ife7399f5da9b76937294800f52875125b77e1710
Gerrit-Change-Number: 19659
Gerrit-PatchSet: 1
Gerrit-Owner: Holger Hans Peter Freyther <automatic at freyther.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20221209/24065838/attachment-0001.html>


More information about the asterisk-code-review mailing list