diff options
author | jim-p <jimp@pfsense.org> | 2011-02-13 11:14:26 -0500 |
---|---|---|
committer | jim-p <jimp@pfsense.org> | 2011-02-13 11:14:26 -0500 |
commit | d164643a3560174bf1caabef4649b5b2a382b8ff (patch) | |
tree | fa249a162684a799c94654a23433cb61c1a9b5aa | |
parent | b43b7613919b6e3c7ab0059704177993fde59894 (diff) | |
download | pfsense-d164643a3560174bf1caabef4649b5b2a382b8ff.zip pfsense-d164643a3560174bf1caabef4649b5b2a382b8ff.tar.gz |
Make update check a little more robust. Timeout after a few seconds, and if we get a non-200 http code, ignore the response.
-rw-r--r-- | etc/inc/pfsense-utils.inc | 6 | ||||
-rwxr-xr-x | usr/local/www/system_firmware_check.php | 5 | ||||
-rw-r--r-- | usr/local/www/widgets/widgets/system_information.widget.php | 4 |
3 files changed, 7 insertions, 8 deletions
diff --git a/etc/inc/pfsense-utils.inc b/etc/inc/pfsense-utils.inc index 0cdaa85..699e603 100644 --- a/etc/inc/pfsense-utils.inc +++ b/etc/inc/pfsense-utils.inc @@ -1429,7 +1429,7 @@ function get_freebsd_version() { return $version[0]; } -function download_file_with_progress_bar($url_file, $destination_file, $readbody = 'read_body') { +function download_file_with_progress_bar($url_file, $destination_file, $readbody = 'read_body', $connect_timeout=60, $timeout=0) { global $ch, $fout, $file_size, $downloaded; $file_size = 1; $downloaded = 1; @@ -1449,8 +1449,8 @@ function download_file_with_progress_bar($url_file, $destination_file, $readbody curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_WRITEFUNCTION, $readbody); curl_setopt($ch, CURLOPT_NOPROGRESS, '1'); - curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, '60'); - curl_setopt($ch, CURLOPT_TIMEOUT, 0); + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $connect_timeout); + curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); curl_exec($ch); $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); diff --git a/usr/local/www/system_firmware_check.php b/usr/local/www/system_firmware_check.php index d981a29..e4ab116 100755 --- a/usr/local/www/system_firmware_check.php +++ b/usr/local/www/system_firmware_check.php @@ -131,9 +131,8 @@ if ($g['platform'] == "nanobsd") { $nanosize .= strtolower(trim(file_get_contents("/etc/nanosize.txt"))); } -@unlink("/tmp/{$g['product_name']}_version"); -download_file_with_progress_bar("{$updater_url}/version{$nanosize}", "/tmp/{$g['product_name']}_version"); -$remote_version = trim(@file_get_contents("/tmp/{$g['product_name']}_version")); +if(download_file_with_progress_bar("{$updater_url}/version{$nanosize}", "/tmp/{$g['product_name']}_version", 5, 5)) + $remote_version = trim(@file_get_contents("/tmp/{$g['product_name']}_version")); $static_text .= gettext("done") . "\\n"; if (!$remote_version) { $static_text .= gettext("Unable to check for updates.") . "\\n"; diff --git a/usr/local/www/widgets/widgets/system_information.widget.php b/usr/local/www/widgets/widgets/system_information.widget.php index 90dcb36..c5f63ce 100644 --- a/usr/local/www/widgets/widgets/system_information.widget.php +++ b/usr/local/www/widgets/widgets/system_information.widget.php @@ -49,9 +49,9 @@ if($_REQUEST['getupdatestatus']) { } @unlink("/tmp/{$g['product_name']}_version"); - download_file_with_progress_bar("{$updater_url}/version{$nanosize}", "/tmp/{$g['product_name']}_version"); + if (download_file_with_progress_bar("{$updater_url}/version{$nanosize}", "/tmp/{$g['product_name']}_version", 5, 5)) + $remote_version = trim(@file_get_contents("/tmp/{$g['product_name']}_version")); - $remote_version = trim(@file_get_contents("/tmp/{$g['product_name']}_version")); if(empty($remote_version)) echo "<br /><br />Unable to check for updates."; else { |