Add an option under advanced->misc to specify a proxy for retreiving pfsense package info or downloading packages.

This commit is contained in:
Ermal 2011-04-18 18:25:25 +00:00
parent e8503ff4b6
commit 42c0700392
2 changed files with 85 additions and 3 deletions

View File

@ -703,7 +703,20 @@ function call_pfsense_method($method, $params, $timeout = 0) {
$xmlrpc_base_url = isset($config['system']['altpkgrepo']['enable']) ? $config['system']['altpkgrepo']['xmlrpcbaseurl'] : $g['xmlrpcbaseurl'];
$xmlrpc_path = $g['xmlrpcpath'];
$msg = new XML_RPC_Message($method, array(XML_RPC_Encode($params)));
$cli = new XML_RPC_Client($xmlrpc_path, $xmlrpc_base_url);
$port = 0;
$proxyurl = "";
$proxyport = 0;
$proxyuser = "";
$proxypass = "";
if (!empty($config['system']['httpproxy']))
$proxyurl = $config['system']['httpproxy'];
if (!empty($config['system']['httpproxyport']) && is_numeric($config['system']['httpproxyport']))
$proxyport = $config['system']['httpproxyport'];
if (!empty($config['system']['httpproxyuser']))
$proxyuser = $config['system']['httpproxyuser'];
if (!empty($config['system']['httpproxypass']))
$proxypass = $config['system']['httpproxypass'];
$cli = new XML_RPC_Client($xmlrpc_path, $xmlrpc_base_url, $port, $proxyurl, $proxyport, $proxyuser, $proxypass);
// If the ALT PKG Repo has a username/password set, use it.
if($config['system']['altpkgrepo']['username'] &&
$config['system']['altpkgrepo']['password']) {
@ -1430,7 +1443,7 @@ function get_freebsd_version() {
}
function download_file_with_progress_bar($url_file, $destination_file, $readbody = 'read_body', $connect_timeout=60, $timeout=0) {
global $ch, $fout, $file_size, $downloaded;
global $ch, $fout, $file_size, $downloaded, $config;
$file_size = 1;
$downloaded = 1;
/* open destination file */
@ -1452,6 +1465,16 @@ function download_file_with_progress_bar($url_file, $destination_file, $readbody
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $connect_timeout);
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
if (!empty($config['system']['proxyurl'])) {
curl_setopt($ch, CURLOPT_PROXY, $config['system']['proxyurl']);
if (!empty($config['system']['proxyport']))
curl_setopt($ch, CURLOPT_PROXYPORT, $config['system']['proxyport']);
if (!empty($config['system']['proxyuser']) && !empty($config['system']['proxypass'])) {
@curl_setopt($ch, CURLOPT_PROXYAUTH, CURLAUTH_ANY | CURLAUTH_ANYSAFE);
curl_setopt($ch, CURLOPT_PROXYUSERPASS, "{$config['system']['proxyuser']}:{$config['system']['proxypass']}");
}
}
@curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if($fout)
@ -2158,4 +2181,4 @@ function filter_rules_compare($a, $b) {
return compare_interface_friendly_names($a['interface'], $b['interface']);
}
?>
?>

View File

@ -50,6 +50,10 @@ require_once("shaper.inc");
require_once("ipsec.inc");
require_once("vpn.inc");
$pconfig['proxyurl'] = $config['system']['proxyurl'];
$pconfig['proxyport'] = $config['system']['proxyport'];
$pconfig['proxyuser'] = $config['system']['proxyuser'];
$pconfig['proxypass'] = $config['system']['proxypass'];
$pconfig['harddiskstandby'] = $config['system']['harddiskstandby'];
$pconfig['lb_use_sticky'] = isset($config['system']['lb_use_sticky']);
$pconfig['preferoldsa_enable'] = isset($config['ipsec']['preferoldsa']);
@ -77,6 +81,26 @@ if ($_POST) {
} else
unset($config['system']['harddiskstandby']);
if($_POST['proxyurl'] <> "")
$config['system']['proxyurl'] = $_POST['proxyurl'];
else
unset($config['system']['proxyurl']);
if($_POST['proxyport'] <> "")
$config['system']['proxyport'] = $_POST['proxyport'];
else
unset($config['system']['proxyport']);
if($_POST['proxyuser'] <> "")
$config['system']['proxyuser'] = $_POST['proxyuser'];
else
unset($config['system']['proxyuser']);
if($_POST['proxypass'] <> "")
$config['system']['proxypass'] = $_POST['proxypass'];
else
unset($config['system']['proxypass']);
if($_POST['lb_use_sticky'] == "yes")
$config['system']['lb_use_sticky'] = true;
else
@ -194,6 +218,41 @@ function maxmss_checked(obj) {
</span>
<br/>
<table width="100%" border="0" cellpadding="6" cellspacing="0">
<tr>
<td colspan="2" valign="top" class="listtopic"><?=gettext("Proxy support"); ?></td>
</tr>
<tr>
<td width="22%" valign="top" class="vncell"><?=gettext("Proxy URL"); ?></td>
<td width="78%" class="vtable">
<input name="proxyurl" id="proxyurl" value="<?php if ($pconfig['proxyurl'] <> "") echo $pconfig['proxyurl']; ?>" class="formfld unknown">
<br />
<?=gettext("Proxy url for allowing {$g['product']} to use this proxy to connect outside."); ?>
</td>
</tr>
<tr>
<td width="22%" valign="top" class="vncell"><?=gettext("Proxy Port"); ?></td>
<td width="78%" class="vtable">
<input name="proxyport" id="proxyport" value="<?php if ($pconfig['proxyport'] <> "") echo $pconfig['proxyport']; ?>" class="formfld unknown">
<br />
<?=gettext("Proxy url for allowing {$g['product']} to use this proxy port to connect outside. Default is 8080 for http protocol or ssl for 443."); ?>
</td>
</tr>
<tr>
<td width="22%" valign="top" class="vncell"><?=gettext("Proxy Username"); ?></td>
<td width="78%" class="vtable">
<input name="proxyuser" id="proxyuser" value="<?php if ($pconfig['proxyuser'] <> "") echo $pconfig['proxyuser']; ?>" class="formfld unknown">
<br />
<?=gettext("Proxy username for allowing {$g['product']} to use this proxy to connect outside"); ?>
</td>
</tr>
<tr>
<td width="22%" valign="top" class="vncell"><?=gettext("Proxy URL"); ?></td>
<td width="78%" class="vtable">
<input type="password" name="proxypass" id="proxypass" value="<?php if ($pconfig['proxypass'] <> "") echo $pconfig['proxypass']; ?>" class="formfld unknown">
<br />
<?=gettext("Proxy password for allowing {$g['product']} to use this proxy to connect outside"); ?>
</td>
</tr>
<tr>
<td colspan="2" valign="top" class="listtopic"><?=gettext("Load Balancing"); ?></td>
</tr>