1
0
mirror of https://github.com/Yubico/yubikey-val.git synced 2025-01-20 10:52:15 +01:00

Merge branch 'master' of github.com:Yubico/yubikey-val-server-php

This commit is contained in:
Klas Lindfors 2012-05-22 13:16:41 +02:00
commit 44ad4ff5e1
6 changed files with 38 additions and 15 deletions

View File

@ -141,6 +141,7 @@ class Db
*/ */
public function updateBy($table, $k, $v, $values) public function updateBy($table, $k, $v, $values)
{ {
$query = "";
foreach ($values as $key=>$value){ foreach ($values as $key=>$value){
if (!is_null($value)) $query .= ' ' . $key . "='" . $value . "',"; if (!is_null($value)) $query .= ' ' . $key . "='" . $value . "',";

6
ykval-munin-ksmlatency.php Normal file → Executable file
View File

@ -46,6 +46,12 @@ echo "multigraph yk_latency\n";
foreach ($ksms as $ksm) { foreach ($ksms as $ksm) {
$shortksm = url2shortname ($ksm); $shortksm = url2shortname ($ksm);
$time = `curl --silent --write-out '%{time_total}' --max-time 3 '$ksm' -o /dev/null`; $time = `curl --silent --write-out '%{time_total}' --max-time 3 '$ksm' -o /dev/null`;
if (preg_match("/^3\./", $time)) {
$time = "timeout";
}
if (preg_match("/^0\.000/", $time)) {
$time = "error";
}
echo "${shortksm}_avgwait.value $time\n"; echo "${shortksm}_avgwait.value $time\n";
} }

View File

@ -26,7 +26,9 @@ if ($argc==2 && strcmp($argv[1], "config") == 0) {
} }
$sync = new SyncLib('ykval-verify:synclib'); $sync = new SyncLib('ykval-verify:synclib');
if (isset($_SERVER['REMOTE_ADDR'])) {
$sync->addField('ip', $_SERVER['REMOTE_ADDR']); $sync->addField('ip', $_SERVER['REMOTE_ADDR']);
}
$len = $sync->getQueueLength (); $len = $sync->getQueueLength ();
echo "queuelength.value $len\n"; echo "queuelength.value $len\n";

View File

@ -52,10 +52,16 @@ echo "multigraph ykval_latency\n";
foreach ($urls as $url) { foreach ($urls as $url) {
$shortname = url2shortname ($url); $shortname = url2shortname ($url);
$cmd = "--user-agent ykval-munin-vallatency/1.0 --silent --write-out '%{time_total}' --max-time 3 '$url' -o /dev/null"; $cmd = "--user-agent ykval-munin-vallatency/1.0 --silent --write-out '%{time_total}' --max-time 3 '$url' -o /dev/null";
$ipv4time = `curl --ipv4 $cmd`; foreach (array('ipv4', 'ipv6') as $ipv) {
echo "ipv4${shortname}_avgwait.value $ipv4time\n"; $time = `curl --$ipv $cmd`;
$ipv6time = `curl --ipv6 $cmd`; if (preg_match("/^3\./", $time)) {
echo "ipv6${shortname}_avgwait.value $ipv6time\n"; $time = "timeout";
}
if (preg_match("/^0\.000/", $time)) {
$time = "error";
}
echo "$ipv${shortname}_avgwait.value $time\n";
}
} }
#%# family=auto #%# family=auto

View File

@ -538,7 +538,7 @@ class SyncLib
while ($info = curl_multi_info_read($mh)) { while ($info = curl_multi_info_read($mh)) {
debug ("YK-KSM multi", $info); debug ("YK-KSM multi", $info);
if ($info['result'] == CURL_OK) { if ($info['result'] == CURLE_OK) {
$str = curl_multi_getcontent($info['handle']); $str = curl_multi_getcontent($info['handle']);
if (preg_match("/status=OK/", $str)) { if (preg_match("/status=OK/", $str)) {
$error = curl_error ($info['handle']); $error = curl_error ($info['handle']);

View File

@ -75,10 +75,18 @@ if ($protocol_version>=2.0) {
*/ */
/* Change default protocol "strings" to numeric values */ /* Change default protocol "strings" to numeric values */
if (strcasecmp($sl, 'fast')==0) $sl=$baseParams['__YKVAL_SYNC_FAST_LEVEL__']; if (isset($sl) && strcasecmp($sl, 'fast')==0) {
if (strcasecmp($sl, 'secure')==0) $sl=$baseParams['__YKVAL_SYNC_SECURE_LEVEL__']; $sl=$baseParams['__YKVAL_SYNC_FAST_LEVEL__'];
if (!$sl) $sl=$baseParams['__YKVAL_SYNC_DEFAULT_LEVEL__']; }
if (!$timeout) $timeout=$baseParams['__YKVAL_SYNC_DEFAULT_TIMEOUT__']; if (isset($sl) && strcasecmp($sl, 'secure')==0) {
$sl=$baseParams['__YKVAL_SYNC_SECURE_LEVEL__'];
}
if (!isset($sl)) {
$sl=$baseParams['__YKVAL_SYNC_DEFAULT_LEVEL__'];
}
if (!isset($timeout)) {
$timeout=$baseParams['__YKVAL_SYNC_DEFAULT_TIMEOUT__'];
}
if ($otp == '') { if ($otp == '') {
$myLog->log(LOG_NOTICE, 'OTP is missing'); $myLog->log(LOG_NOTICE, 'OTP is missing');
@ -110,13 +118,13 @@ if ($timeout && preg_match("/^[0-9]+$/", $timeout)==0) {
exit; exit;
} }
if ($nonce && preg_match("/^[A-Za-z0-9]+$/", $nonce)==0) { if (isset($nonce) && preg_match("/^[A-Za-z0-9]+$/", $nonce)==0) {
$myLog->log(LOG_NOTICE, 'NONCE is provided but not correct'); $myLog->log(LOG_NOTICE, 'NONCE is provided but not correct');
sendResp(S_MISSING_PARAMETER); sendResp(S_MISSING_PARAMETER);
exit; exit;
} }
if ($nonce && (strlen($nonce) < 16 || strlen($nonce) > 40)) { if (isset($nonce) && (strlen($nonce) < 16 || strlen($nonce) > 40)) {
$myLog->log(LOG_NOTICE, 'Nonce too short or too long'); $myLog->log(LOG_NOTICE, 'Nonce too short or too long');
sendResp(S_MISSING_PARAMETER); sendResp(S_MISSING_PARAMETER);
exit; exit;