com web/master: the header check in host_has_error won' t work for the spoofed headers so we should c heck the response body that it matches the expe
cted format of mirror-info: scripts/mirror-test
| From: | Ferenc Kovacs | Date: | Fri, 01 Feb 2013 12:06:32 +0000 |
| Subject: | com web/master: the header check in host_has_error won' t work for the spoofed headers so we should c heck the response body that it matches the expe cted format of mirror-info: scripts/mirror-test |
||
| Groups: | php.webmaster | ||
| Request: | Send a blank email to php-webmaster+get-15416@lists.php.net to get a copy of this message | ||
Commit: 513be2a6d828e696c80271a52c58e2748ffed211
Author: Ferenc Kovacs <tyra3l@gmail.com> Fri, 1 Feb 2013 13:06:32 +0100
Parents: 8a6bfe8456f73c8dc1801356c3adeeadada917c2
Branches: master
Link: http://git.php.net/?p=web/master.git;a=commitdiff;h=513be2a6d828e696c80271a52c58e2748ffed211
Log:
the header check in host_has_error won't work for the spoofed headers so we should check the
response body that it matches the expected format of mirror-info
Changed paths:
M scripts/mirror-test
Diff:
diff --git a/scripts/mirror-test b/scripts/mirror-test
index 4fc5a51..074c668 100755
--- a/scripts/mirror-test
+++ b/scripts/mirror-test
@@ -165,17 +165,31 @@ foreach ($hosts as $index => $host) {
// if the mirror is used for the load balancing check that it can serve the mirror-info for
cc.php.net also
$lb_data = $lb_problem = '';
- if ($host['load_balanced'] && host_has_error($host['hostname'],
$filename, $lb_data, $lb_problem, $host['load_balanced'].'.php.net')) {
- // remove from rotation
- $query = "UPDATE mirrors SET load_balanced = '' WHERE hostname =
'" . $host['hostname'] . "'";
- $result = mysql_query($query) or die("unable to update the database: $query: " .
mysql_error());
- // send an email to systems, when we are stable enough, we should change this to php-mirrors@
- mail(
- "systems@php.net",
- "Round robin for {$host['hostname']} is deactivated",
- "The following error occured when testing {$host['hostname']} for
serving traffic for {$host['load_balanced']}.php.net: \n{$lb_problem}",
- "From: php-mirrors@lists.php.net"
- );
+ if ($host['load_balanced']) {
+ $lb_error = host_has_error($host['hostname'], $filename, $lb_data, $lb_problem,
$host['load_balanced'].'.php.net');
+ if (!$lb_error) {
+ // Explode information row by delimiter
+ $lb_info = explode("|", trim($lb_data));
+
+ // Invalid data received, skip mirror site
+ if (count($lb_info) < 8) {
+ $lb_error = TRUE;
+ $lb_problem = "Invalid data received from {$filename}.";
+ }
+ }
+
+ if ($lb_error) {
+ $lb_problem = "The following error occured when testing
{$host['hostname']} for serving traffic for
{$host['load_balanced']}.php.net:\n".$lb_problem;
+ $query = "UPDATE mirrors SET load_balanced = '' WHERE hostname =
'" . $host['hostname'] . "'";
+ $result = mysql_query($query) or die("unable to update the database: $query:
" . mysql_error());
+ // send an email to systems, when we are stable enough, we should change this to
php-mirrors@
+ mail(
+ "systems@php.net",
+ "Round robin for {$host['hostname']} is deactivated",
+ $lb_problem,
+ "From: php-mirrors@lists.php.net"
+ );
+ }
}
// Explode information row by delimiter