From a4b3dbc3648e631e323f441e14b824a9b7e327c5 Mon Sep 17 00:00:00 2001 From: Olov Danielson Date: Mon, 7 Dec 2009 15:31:33 +0000 Subject: [PATCH] Moved config to ykval-config --- ykval-config.php | 4 ++++ ykval-db.sql | 2 +- ykval-queuedaemon.php | 8 ++++---- ykval-synclib.php | 9 +++++---- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/ykval-config.php b/ykval-config.php index 5983f72..8de886f 100644 --- a/ykval-config.php +++ b/ykval-config.php @@ -8,6 +8,10 @@ $baseParams['__YKVAL_DB_USER__'] = 'ykval_verifier'; $baseParams['__YKVAL_DB_PW__'] = 'lab'; # For the validation server sync $baseParams['__YKVAL_SYNC_POOL__'] = "http://api2.yubico.com/wsapi/sync;http://api3.yubico.com/wsapi/sync;http://api4.yubico.com/wsapi/sync"; +$baseParams['__YKVAL_SYNC_INTERVAL__'] = 60; +$baseParams['__YKVAL_SYNC_MAX_SIMUL__'] = 50; +$baseParams['__YKVAL_SYNC_TIMEOUT__'] = 30; +$baseParams['__YKVAL_SYNC_OLD_LIMIT_'] = 1; # For the get-api-key service. $baseParams['__YKGAK_DB_HOST__'] = $baseParams['__YKVAL_DB_HOST__']; diff --git a/ykval-db.sql b/ykval-db.sql index 064032d..61aa9f4 100644 --- a/ykval-db.sql +++ b/ykval-db.sql @@ -35,7 +35,7 @@ CREATE TABLE queue ( random_key INT, otp VARCHAR(100) NOT NULL, server VARCHAR(100) NOT NULL, - info VARCHAR(100) NOT NULL, + info VARCHAR(256) NOT NULL, PRIMARY KEY (id) ); diff --git a/ykval-queuedaemon.php b/ykval-queuedaemon.php index 27aa519..432727a 100644 --- a/ykval-queuedaemon.php +++ b/ykval-queuedaemon.php @@ -5,13 +5,13 @@ require_once 'ykval-config.php'; $sl = new SyncLib(); - +$resync = $baseParams['__YKVAL_SYNC_INTERVAL__']; # Loop forever and resync while (True) { - $sl->reSync(10); + $sl->reSync($baseParams['__YKVAL_SYNC_OLD_LIMIT__']); - sleep(60); - } + sleep($baseParams['__YKVAL_SYNC_INTERVAL__');) + } ?> \ No newline at end of file diff --git a/ykval-synclib.php b/ykval-synclib.php index 91b6980..0990c26 100644 --- a/ykval-synclib.php +++ b/ykval-synclib.php @@ -19,7 +19,8 @@ class SyncLib $baseParams['__YKVAL_DB_NAME__']); $this->db->connect(); $this->random_key=rand(0,1<<16); - $this->max_url_chunk=100; + $this->max_url_chunk=$baseParams['__YKVAL_SYNC_MAX_SIMUL__']; + $this->resync_timeout=$baseParams['__YKVAL_SYNC_TIMEOUT__']; } @@ -222,7 +223,7 @@ class SyncLib $url_chunks=array_chunk($urls, $this->max_url_chunk); foreach($url_chunks as $urls) { - $ans_arr=$this->retrieveURLasync($urls, count($urls)); + $ans_arr=$this->retrieveURLasync($urls, count($urls), $this->resync_timeout); if (!is_array($ans_arr)) { $this->log('notice', 'No responses from validation server pool'); @@ -402,7 +403,7 @@ class SyncLib URLs fail, data from some URL that did not match parameter $match (defaults to ^OK) is returned, or if all URLs failed, false. */ - function retrieveURLasync ($urls, $ans_req=1) { + function retrieveURLasync ($urls, $ans_req=1, $timeout=1.0) { $mh = curl_multi_init(); $ch = array(); @@ -458,7 +459,7 @@ class SyncLib unset ($ch[$info['handle']]); } - curl_multi_select ($mh); + curl_multi_select ($mh, $timeout); } } while($active);