mirror of
https://github.com/Yubico/yubikey-val.git
synced 2025-03-04 12:29:19 +01:00
Cosmetic changes.
- adhere with some form of convetion for comments. - use single quotes where possible.
This commit is contained in:
parent
13530c532f
commit
ef6adeb826
@ -437,31 +437,30 @@ class SyncLib
|
|||||||
|
|
||||||
public function sync($ans_req, $timeout=1)
|
public function sync($ans_req, $timeout=1)
|
||||||
{
|
{
|
||||||
/*
|
// construct URLs
|
||||||
Construct URLs
|
|
||||||
*/
|
|
||||||
$urls = array();
|
$urls = array();
|
||||||
$res=$this->db->findByMultiple('queue', array("modified"=>$this->otpParams['modified'], "server_nonce"=>$this->server_nonce));
|
$res = $this->db->findByMultiple('queue', array(
|
||||||
foreach($res as $row) {
|
'modified' => $this->otpParams['modified'],
|
||||||
|
'server_nonce' => $this->server_nonce
|
||||||
|
));
|
||||||
|
foreach ($res as $row)
|
||||||
|
{
|
||||||
$urls[] = $row['server'] .
|
$urls[] = $row['server'] .
|
||||||
"?otp=" . $row['otp'] .
|
"?otp=" . $row['otp'] .
|
||||||
"&modified=" . $row['modified'] .
|
"&modified=" . $row['modified'] .
|
||||||
"&" . $this->otpPartFromInfoString($row['info']);
|
"&" . $this->otpPartFromInfoString($row['info']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// send out requests
|
||||||
Send out requests
|
|
||||||
*/
|
|
||||||
$ans_arr = retrieveURLasync('YK-VAL sync', $urls, $this->myLog, $ans_req, $match='status=OK', $returl=True, $timeout, $this->curlopts);
|
$ans_arr = retrieveURLasync('YK-VAL sync', $urls, $this->myLog, $ans_req, $match='status=OK', $returl=True, $timeout, $this->curlopts);
|
||||||
|
|
||||||
if ($ans_arr === FALSE) {
|
if ($ans_arr === FALSE)
|
||||||
|
{
|
||||||
$this->log(LOG_WARNING, 'No responses from validation server pool');
|
$this->log(LOG_WARNING, 'No responses from validation server pool');
|
||||||
$ans_arr = array();
|
$ans_arr = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// parse responses
|
||||||
Parse responses
|
|
||||||
*/
|
|
||||||
$localParams = $this->localParams;
|
$localParams = $this->localParams;
|
||||||
|
|
||||||
$this->answers = count($ans_arr);
|
$this->answers = count($ans_arr);
|
||||||
@ -469,41 +468,42 @@ class SyncLib
|
|||||||
|
|
||||||
foreach ($ans_arr as $answer)
|
foreach ($ans_arr as $answer)
|
||||||
{
|
{
|
||||||
/* Parse out parameters from each response */
|
// parse out parameters from each response
|
||||||
$resParams=$this->parseParamsFromMultiLineString($answer);
|
$resParams=$this->parseParamsFromMultiLineString($answer);
|
||||||
$this->log(LOG_DEBUG, "local db contains ", $localParams);
|
$this->log(LOG_DEBUG, 'local db contains ', $localParams);
|
||||||
$this->log(LOG_DEBUG, "response contains ", $resParams);
|
$this->log(LOG_DEBUG, 'response contains ', $resParams);
|
||||||
$this->log(LOG_DEBUG, "OTP contains " , $this->otpParams);
|
$this->log(LOG_DEBUG, 'OTP contains ', $this->otpParams);
|
||||||
|
|
||||||
/* Update internal DB (conditional) */
|
// update internal DB (conditional)
|
||||||
$this->updateDbCounters($resParams);
|
$this->updateDbCounters($resParams);
|
||||||
|
|
||||||
/* Check for warnings
|
/**
|
||||||
|
* Check for warnings
|
||||||
See https://developers.yubico.com/yubikey-val/doc/ServerReplicationProtocol.html
|
*
|
||||||
|
* See https://developers.yubico.com/yubikey-val/doc/ServerReplicationProtocol.html
|
||||||
NOTE: We use localParams for validationParams comparison since they are actually the
|
*
|
||||||
same in this situation and we have them at hand.
|
* NOTE: We use localParams for validationParams comparison since they are actually the
|
||||||
|
* same in this situation and we have them at hand.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ($this->countersHigherThan($localParams, $resParams))
|
if ($this->countersHigherThan($localParams, $resParams))
|
||||||
{
|
{
|
||||||
$this->log(LOG_NOTICE, "Remote server out of sync");
|
$this->log(LOG_NOTICE, 'Remote server out of sync');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->countersHigherThan($resParams, $localParams))
|
if ($this->countersHigherThan($resParams, $localParams))
|
||||||
{
|
{
|
||||||
$this->log(LOG_NOTICE, "Local server out of sync");
|
$this->log(LOG_NOTICE, 'Local server out of sync');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->countersEqual($resParams, $localParams) && $resParams['nonce'] != $localParams['nonce'])
|
if ($this->countersEqual($resParams, $localParams) && $resParams['nonce'] != $localParams['nonce'])
|
||||||
{
|
{
|
||||||
$this->log(LOG_NOTICE, "Servers out of sync. Nonce differs. ");
|
$this->log(LOG_NOTICE, 'Servers out of sync. Nonce differs. ');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->countersEqual($resParams, $localParams) && $resParams['modified'] != $localParams['modified'])
|
if ($this->countersEqual($resParams, $localParams) && $resParams['modified'] != $localParams['modified'])
|
||||||
{
|
{
|
||||||
$this->log(LOG_NOTICE, "Servers out of sync. Modified differs. ");
|
$this->log(LOG_NOTICE, 'Servers out of sync. Modified differs. ');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->countersHigherThan($resParams, $this->otpParams))
|
if ($this->countersHigherThan($resParams, $this->otpParams))
|
||||||
@ -516,28 +516,30 @@ class SyncLib
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* The answer is ok since a REPLAY was not indicated */
|
// the answer is ok since a REPLAY was not indicated
|
||||||
$this->valid_answers++;
|
$this->valid_answers++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Delete entry from table */
|
// delete entry from table
|
||||||
$this->deleteQueueEntry($answer);
|
$this->deleteQueueEntry($answer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
NULL queued_time for remaining entries in queue, to allow
|
* NULL queued_time for remaining entries in queue, to allow
|
||||||
daemon to take care of them as soon as possible. */
|
* daemon to take care of them as soon as possible.
|
||||||
|
*/
|
||||||
$this->db->updateBy('queue', 'server_nonce', $this->server_nonce, array('queued'=>NULL));
|
$this->db->updateBy('queue', 'server_nonce', $this->server_nonce, array('queued'=>NULL));
|
||||||
|
|
||||||
/* Return true if valid answers equals required answers.
|
/**
|
||||||
Since we only obtain the required amount of answers from
|
* Return true if valid answers equals required answers.
|
||||||
retrieveAsync this indicates that all answers were actually valid.
|
* Since we only obtain the required amount of answers from
|
||||||
Otherwise, return false. */
|
* retrieveAsync this indicates that all answers were actually valid.
|
||||||
|
* Otherwise, return false.
|
||||||
|
*/
|
||||||
if ($this->valid_answers == $ans_req)
|
if ($this->valid_answers == $ans_req)
|
||||||
return True;
|
return true;
|
||||||
|
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getNumberOfValidAnswers()
|
public function getNumberOfValidAnswers()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user