Made check on peers more strict, made the script abandon checking when a peers entry is malformed

This commit is contained in:
pezcurrel 2022-12-26 15:27:14 +01:00
parent d301d25fcc
commit 44b6456695

View file

@ -283,7 +283,8 @@ function crawl($list,$id) {
if (!is_array($peers)) {
lecho(2,'loading «'.$inst.s peers, got not good JSON.'.N);
} else {
lecho(1,'successfully loaded «'.$inst.s peers :-)'.N);
$cp=count($peers);
lecho(1,'successfully loaded «'.$inst.s peers ('.$cp.') :-)'.N);
$responded=1;
if (!in_array($inst,$insts)) {
lecho(1,'instance «'.$inst.'» responded :-)'.N);
@ -296,12 +297,15 @@ function crawl($list,$id) {
$newc++;
}
}
$cp=count($peers);
$cp--;
$pi=0;
foreach ($peers as $peer) {
$pi++;
if (!is_string($peer)) {
lecho(2,'$peers, entity '.$pi.'/'.$cp.' is not a string.'.N);
foreach ($peers as $key=>$peer) {
if ($key!=$pi) {
lecho(2,'«'.$inst.s peers: entity '.$pi.'/'.$cp.'s key is not sequential; not checking further.'.N);
break;
} elseif (!is_string($peer)) {
lecho(2,'«'.$inst.s peers: entity '.$pi.'/'.$cp.' is not a string; not checking further.'.N);
break;
} else {
if (!in_array($peer,$ainsts)) {
$ainsts[]=$peer;
@ -321,6 +325,7 @@ function crawl($list,$id) {
$nlist[]=$peer;
}
}
$pi++;
}
}
}