aboutsummaryrefslogtreecommitdiffstats
path: root/config/autoconfigbackup/autoconfigbackup.inc
diff options
context:
space:
mode:
authorRenato Botelho <garga@FreeBSD.org>2014-08-26 18:54:53 -0300
committerRenato Botelho <garga@FreeBSD.org>2014-08-26 18:54:53 -0300
commit613eba4dd146bcc0890b42e185bb2fda46dcef26 (patch)
treedd31129efb38b35d0419e423d96cda3da32934b6 /config/autoconfigbackup/autoconfigbackup.inc
parent4d68442d89b78154f5f9cb46271e7e5527685a2c (diff)
parent2fb2c17eef49225706b2fb1d4bd522dea58ce982 (diff)
downloadpfsense-packages-613eba4dd146bcc0890b42e185bb2fda46dcef26.tar.gz
pfsense-packages-613eba4dd146bcc0890b42e185bb2fda46dcef26.tar.bz2
pfsense-packages-613eba4dd146bcc0890b42e185bb2fda46dcef26.zip
Merge pull request #681 from msilvoso/master
Diffstat (limited to 'config/autoconfigbackup/autoconfigbackup.inc')
-rw-r--r--config/autoconfigbackup/autoconfigbackup.inc24
1 files changed, 22 insertions, 2 deletions
diff --git a/config/autoconfigbackup/autoconfigbackup.inc b/config/autoconfigbackup/autoconfigbackup.inc
index b49b81fd..2c9d18f9 100644
--- a/config/autoconfigbackup/autoconfigbackup.inc
+++ b/config/autoconfigbackup/autoconfigbackup.inc
@@ -68,6 +68,21 @@ function custom_php_validation_command($post, &$input_errors) {
unset($_POST['testconnection']);
}
+function configure_proxy() {
+ global $config;
+ $ret = array();
+ if (!empty($config['system']['proxyurl'])) {
+ $ret[CURLOPT_PROXY] = $config['system']['proxyurl'];
+ if (!empty($config['system']['proxyport']))
+ $ret[CURLOPT_PROXYPORT] = $config['system']['proxyport'];
+ if (!empty($config['system']['proxyuser']) && !empty($config['system']['proxypass'])) {
+ $ret[CURLOPT_PROXYAUTH] = CURLAUTH_ANY | CURLAUTH_ANYSAFE;
+ $ret[CURLOPT_PROXYUSERPWD] = "{$config['system']['proxyuser']}:{$config['system']['proxypass']}";
+ }
+ }
+ return $ret;
+}
+
function test_connection($post) {
global $savemsg, $config, $g;
@@ -102,6 +117,9 @@ function test_connection($post) {
curl_setopt($curl_session, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl_session, CURLOPT_CONNECTTIMEOUT, 55);
curl_setopt($curl_session, CURLOPT_TIMEOUT, 30);
+ curl_setopt($curl_session, CURLOPT_USERAGENT, $g['product_name'] . '/' . rtrim(file_get_contents("/etc/version")));
+ // Proxy
+ curl_setopt_array($curl_session, configure_proxy());
curl_setopt($curl_session, CURLOPT_POSTFIELDS, "action=showbackups&hostname={$hostname}");
$data = curl_exec($curl_session);
@@ -209,7 +227,10 @@ function upload_config($reasonm = "") {
curl_setopt($curl_session, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl_session, CURLOPT_CONNECTTIMEOUT, 55);
curl_setopt($curl_session, CURLOPT_TIMEOUT, 30);
-
+ curl_setopt($curl_session, CURLOPT_USERAGENT, $g['product_name'] . '/' . rtrim(file_get_contents("/etc/version")));
+ // Proxy
+ curl_setopt_array($curl_session, configure_proxy());
+
$data = curl_exec($curl_session);
if (curl_errno($curl_session)) {
$fd = fopen("/tmp/backupdebug.txt", "w");
@@ -248,4 +269,3 @@ function upload_config($reasonm = "") {
}
}
-?>