1
0
mirror of https://github.com/Yubico/yubikey-val.git synced 2025-03-04 03:29:18 +01:00

Cosmetic changes.

This commit is contained in:
Jean Paul Galea 2015-07-17 23:59:26 +02:00
parent 23474aec31
commit 39ce50b772

View File

@ -333,17 +333,23 @@ class SyncLib
public function reSync($older_than=60, $timeout)
{
$this->log(LOG_DEBUG, 'starting resync');
/* Loop over all unique servers in queue */
$queued_limit = time()-$older_than;
$server_res = $this->db->customQuery("select distinct server from queue WHERE queued < " . $queued_limit . " or queued is null");
while ($my_server=$this->db->fetchArray($server_res)) {
while ($my_server=$this->db->fetchArray($server_res))
{
$this->log(LOG_DEBUG, "Processing queue for server " . $my_server['server']);
$res = $this->db->customQuery("select * from queue WHERE (queued < " . $queued_limit . " or queued is null) and server='" . $my_server['server'] . "'");
$ch = curl_init();
while ($entry=$this->db->fetchArray($res)) {
while ($entry=$this->db->fetchArray($res))
{
$this->log(LOG_INFO, "server=" . $entry['server'] . ", server_nonce=" . $entry['server_nonce'] . ", info=" . $entry['info']);
$url = $entry['server'] .
"?otp=" . $entry['otp'] .
"&modified=" . $entry['modified'] .
@ -355,7 +361,8 @@ class SyncLib
$response = curl_exec($ch);
if ($response==False) {
if ($response == False)
{
$this->log(LOG_NOTICE, 'Timeout. Stopping queue resync for server ' . $entry['server']);
break;
}
@ -372,6 +379,7 @@ class SyncLib
/* This is the counter values we had in our database *before* processing the current OTP. */
$validationParams = $this->localParamsFromInfoString($entry['info']);
/* This is the data from the current OTP. */
$otpParams = $this->otpParamsFromInfoString($entry['info']);
@ -383,31 +391,39 @@ class SyncLib
/* Check for warnings */
if ($this->countersHigherThan($validationParams, $resParams)) {
if ($this->countersHigherThan($validationParams, $resParams))
{
$this->log(LOG_NOTICE, "Remote server out of sync compared to counters at validation request time. ");
}
if ($this->countersHigherThan($resParams, $validationParams)) {
if ($this->countersEqual($resParams, $otpParams)) {
if ($this->countersHigherThan($resParams, $validationParams))
{
if ($this->countersEqual($resParams, $otpParams))
{
$this->log(LOG_INFO, "Remote server had received the current counter values already. ");
} else {
}
else
{
$this->log(LOG_NOTICE, "Local server out of sync compared to counters at validation request time. ");
}
}
if ($this->countersHigherThan($localParams, $resParams)) {
if ($this->countersHigherThan($localParams, $resParams))
{
$this->log(LOG_WARNING, "Remote server out of sync compared to current local counters. ");
}
if ($this->countersHigherThan($resParams, $localParams)) {
if ($this->countersHigherThan($resParams, $localParams))
{
$this->log(LOG_WARNING, "Local server out of sync compared to current local counters. Local server updated. ");
}
if ($this->countersHigherThan($resParams, $otpParams)) {
if ($this->countersHigherThan($resParams, $otpParams))
{
$this->log(LOG_ERR, "Remote server has higher counters than OTP. This response would have marked the OTP as invalid. ");
}
elseif ($this->countersEqual($resParams, $otpParams)
&& $resParams['nonce']!=$otpParams['nonce']) {
elseif ($this->countersEqual($resParams, $otpParams) && $resParams['nonce']!=$otpParams['nonce'])
{
$this->log(LOG_ERR, "Remote server has equal counters as OTP and nonce differs. This response would have marked the OTP as invalid.");
}