finish announce api

This commit is contained in:
xiaomlove
2022-03-18 15:44:04 +08:00
parent 6665c98169
commit ab1ed60f44
13 changed files with 151 additions and 125 deletions

View File

@@ -89,6 +89,7 @@ class Peer extends NexusModel
$tmp_ip = '['.$tmp_ip.']';
}
$cacheKey = 'peers:connectable:'.$tmp_ip.'-'.$this->port.'-'.$this->agent;
$log = "cacheKey: $cacheKey";
if (!Cache::has($cacheKey)) {
$con = @fsockopen($tmp_ip, $this->port, $error_code, $error_message, 1);
if (is_resource($con)) {
@@ -98,6 +99,10 @@ class Peer extends NexusModel
$this->connectable = self::CONNECTABLE_NO;
}
Cache::put($cacheKey, $this->connectable, 600);
$log .= ", do check, connectable: " . $this->connectable;
} else {
$log .= ", don't do check";
}
do_log($log);
}
}