diff --git a/ykval-sync.php b/ykval-sync.php index 51a7da0..a9f7d32 100644 --- a/ykval-sync.php +++ b/ykval-sync.php @@ -43,9 +43,18 @@ $myLog->addField('ip', $ipaddr); if (empty($_SERVER['QUERY_STRING'])) { sendResp(S_MISSING_PARAMETER, $myLog); } - $myLog->log(LOG_INFO, 'Request: ' . $_SERVER['QUERY_STRING']); + +// verify request sent by whitelisted address +$myLog->log(LOG_DEBUG, 'Received request from ' . $ipaddr); +if (in_array($ipaddr, $allowed, TRUE) === FALSE) { + $myLog->log(LOG_NOTICE, 'Operation not allowed from IP ' . $ipaddr); + $myLog->log(LOG_DEBUG, 'Remote IP ' . $ipaddr . ' not listed in allowed sync pool : ' . implode(', ', $allowed)); + sendResp(S_OPERATION_NOT_ALLOWED, $myLog); +} + + $sync = new SyncLib('ykval-sync:synclib'); $sync->addField('ip', $ipaddr); @@ -53,17 +62,6 @@ if (! $sync->isConnected()) { sendResp(S_BACKEND_ERROR, $myLog); } -# -# Verify that request comes from valid server -# -$myLog->log(LOG_DEBUG, 'Received request from ' . $ipaddr); - -if (in_array($ipaddr, $allowed, TRUE) === FALSE) { - $myLog->log(LOG_NOTICE, 'Operation not allowed from IP ' . $ipaddr); - $myLog->log(LOG_DEBUG, 'Remote IP ' . $ipaddr . ' not listed in allowed sync pool : ' . implode(', ', $allowed)); - sendResp(S_OPERATION_NOT_ALLOWED, $myLog); -} - # # Define requirements on protocol #