summaryrefslogtreecommitdiffstats
path: root/etc
diff options
context:
space:
mode:
authorErmal <eri@pfsense.org>2014-02-24 14:57:04 +0000
committerErmal <eri@pfsense.org>2014-02-24 14:58:35 +0000
commit2c02c4d09aac8186e739cc9fe08afcaba91dc237 (patch)
treeb40acc888a28445883a4840108a35352548cc812 /etc
parent846bedf994079102c29cd140b41b2d1deb466a13 (diff)
downloadpfsense-2c02c4d09aac8186e739cc9fe08afcaba91dc237.zip
pfsense-2c02c4d09aac8186e739cc9fe08afcaba91dc237.tar.gz
Properly detect when there are issues with communicating with syncip and to use the local DB for this. Otherwise detect if the remote says the voucher is not valid say its not valid.
Diffstat (limited to 'etc')
-rw-r--r--etc/inc/voucher.inc15
1 files changed, 10 insertions, 5 deletions
diff --git a/etc/inc/voucher.inc b/etc/inc/voucher.inc
index 4b8398c..695857d 100644
--- a/etc/inc/voucher.inc
+++ b/etc/inc/voucher.inc
@@ -188,24 +188,26 @@ EOF;
$error = "A communications error occurred while attempting CaptivePortalVoucherSync XMLRPC sync with {$url}:{$port} (pfsense.exec_php).";
log_error($error);
file_notice("CaptivePortalVoucherSync", $error, "Communications error occurred", "");
- return 0; // $timeleft
+ return null; // $timeleft
} elseif($resp->faultCode()) {
$error = "An error code was received while attempting CaptivePortalVoucherSync XMLRPC sync with {$url}:{$port} - Code " . $resp->faultCode() . ": " . $resp->faultString();
log_error($error);
file_notice("CaptivePortalVoucherSync", $error, "Error code received", "");
- return 0; // $timeleft
+ return null; // $timeleft
} else {
log_error("CaptivePortalVoucherSync XMLRPC reload data success with {$url}:{$port} (pfsense.exec_php).");
}
$toreturn = XML_RPC_Decode($resp->value());
if (!is_array($config['voucher']))
$config['voucher'] = array();
+
if (is_array($toreturn['voucher']) && (count($toreturn['voucher']['roll']) <> count($config['voucher'][$cpzone]['roll']))) {
$config['voucher'][$cpzone]['roll'] = $toreturn['voucher']['roll'];
write_config("Captive Portal Voucher database synchronized with {$url}");
voucher_configure_zone(true);
unset($toreturn['voucher']);
- }
+ } else if (!isset($toreturn['timeleft']))
+ return null;
return $toreturn['timeleft'];
}
@@ -437,9 +439,12 @@ function voucher_auth($voucher_received, $test = 0) {
}
// If we did a XMLRPC sync earlier check the timeleft
- if (!empty($config['voucher'][$cpzone]['vouchersyncdbip']))
- if($remote_time_used < $total_minutes)
+ if (!empty($config['voucher'][$cpzone]['vouchersyncdbip'])) {
+ if (!is_null($remote_time_used))
+ $total_minutes = $remote_time_used;
+ else if ($remote_time_used < $total_minutes)
$total_minutes -= $remote_time_used;
+ }
// All given vouchers were valid and this isn't simply a test.
// Write back the used DB's
OpenPOWER on IntegriCloud