repeer fix

This commit is contained in:
Arionum
2018-01-09 08:53:32 +02:00
parent 068d8798c8
commit 7800e5965f
2 changed files with 9 additions and 3 deletions

View File

@@ -43,8 +43,14 @@ if($q=="peer"){
$res=$db->single("SELECT COUNT(1) FROM peers WHERE hostname=:hostname AND ip=:ip",array(":hostname"=>$hostname,":ip"=>$ip));
if($res==1) api_echo("peer-ok-already");
if($res==1){
if($data['repeer']==1){
$res=peer_post($hostname."/peer.php?q=peer",array("hostname"=>$_config['hostname']));
if($res!==false) api_echo("re-peer-ok");
else api_err("re-peer failed - $result");
}
api_echo("peer-ok-already");
}
$res=$db->single("SELECT COUNT(1) FROM peers WHERE blacklisted<UNIX_TIMESTAMP() AND ping >UNIX_TIMESTAMP()-86400 AND reserve=0");
$reserve=1;
if($res<$_config['max_peers']) $reserve=0;

View File

@@ -143,7 +143,7 @@ if($total_peers==0){
$peer = filter_var($peer, FILTER_SANITIZE_URL);
if (!filter_var($peer, FILTER_VALIDATE_URL)) continue;
$res=peer_post($peer."/peer.php?q=peer",array("hostname"=>$_config['hostname']));
$res=peer_post($peer."/peer.php?q=peer",array("hostname"=>$_config['hostname'], "repeer"=>1));
if($res!==false) {$i++; echo "Peering OK - $peer\n"; }
else echo "Peering FAIL - $peer\n";
if($i>$_config['max_peers']) break;