tracker support ipv6

This commit is contained in:
xiaomlove
2021-05-01 02:02:01 +08:00
parent cc9344aeb6
commit a46256e019
5 changed files with 48 additions and 25 deletions
+1 -1
View File
@@ -67,7 +67,7 @@ class Install
public function getLogFile() public function getLogFile()
{ {
return sprintf('%s/nexus_install_%s.log', sys_get_temp_dir(), date('Ymd')); return sprintf('%s/nexus-install-%s.log', sys_get_temp_dir(), date('YmdHis'));
} }
public function getInsallDirectory() public function getInsallDirectory()
+1 -1
View File
@@ -12,7 +12,7 @@ class Update extends Install
public function getLogFile() public function getLogFile()
{ {
return sprintf('%s/nexus_update_%s.log', sys_get_temp_dir(), date('Ymd')); return sprintf('%s/nexus-update-%s.log', sys_get_temp_dir(), date('YmdHis'));
} }
public function getUpdateDirectory() public function getUpdateDirectory()
+1 -1
View File
@@ -355,7 +355,7 @@
array ( array (
'mainversion' => 'NexusPHP', 'mainversion' => 'NexusPHP',
'subversion' => 'v1.6.0-beta5', 'subversion' => 'v1.6.0-beta5',
'releasedate' => '2021-04-30', 'releasedate' => '2021-05-01',
'website' => '<a href="https://nexusphp.org" target="_blank">https://nexusphp.org</a>', 'website' => '<a href="https://nexusphp.org" target="_blank">https://nexusphp.org</a>',
), ),
); );
+9 -2
View File
@@ -25,7 +25,8 @@ if ($currentStep == 1) {
} }
if ($currentStep == 2) { if ($currentStep == 2) {
$envExampleFile = "$rootpath.env.example"; $envExampleFile = $rootpath . ".env.example";
$dbstructureFile = $rootpath . "_db/dbstructure_v1.6.sql";
$envExampleData = readEnvFile($envExampleFile); $envExampleData = readEnvFile($envExampleFile);
$envFormControls = $update->listEnvFormControls(); $envFormControls = $update->listEnvFormControls();
$newData = array_column($envFormControls, 'value', 'name'); $newData = array_column($envFormControls, 'value', 'name');
@@ -41,11 +42,17 @@ if ($currentStep == 2) {
} }
$tableRows = [ $tableRows = [
[ [
'label' => '.env.example', 'label' => basename($envExampleFile),
'required' => 'exists && readable', 'required' => 'exists && readable',
'current' => $envExampleFile, 'current' => $envExampleFile,
'result' => $update->yesOrNo(file_exists($envExampleFile) && is_readable($envExampleFile)), 'result' => $update->yesOrNo(file_exists($envExampleFile) && is_readable($envExampleFile)),
], ],
[
'label' => basename($dbstructureFile),
'required' => 'exists && readable',
'current' => $dbstructureFile,
'result' => $update->yesOrNo(file_exists($dbstructureFile) && is_readable($dbstructureFile)),
],
]; ];
$fails = array_filter($tableRows, function ($value) {return $value['result'] == 'NO';}); $fails = array_filter($tableRows, function ($value) {return $value['result'] == 'NO';});
$pass = empty($fails); $pass = empty($fails);
+35 -19
View File
@@ -114,6 +114,7 @@ $real_annnounce_interval = $annintertwo;
$resp = "d" . benc_str("interval") . "i" . $real_annnounce_interval . "e" . benc_str("min interval") . "i" . $announce_wait . "e". benc_str("complete") . "i" . $torrent["seeders"] . "e" . benc_str("incomplete") . "i" . $torrent["leechers"] . "e" . benc_str("peers"); $resp = "d" . benc_str("interval") . "i" . $real_annnounce_interval . "e" . benc_str("min interval") . "i" . $announce_wait . "e". benc_str("complete") . "i" . $torrent["seeders"] . "e" . benc_str("incomplete") . "i" . $torrent["leechers"] . "e" . benc_str("peers");
$peer_list = ""; $peer_list = "";
$peer6_list = "";
unset($self); unset($self);
// bencoding the peers info get for this announce // bencoding the peers info get for this announce
while ($row = mysql_fetch_assoc($res)) while ($row = mysql_fetch_assoc($res))
@@ -126,27 +127,38 @@ while ($row = mysql_fetch_assoc($res))
$self = $row; $self = $row;
continue; continue;
} }
if ($compact == 1){ if ($compact == 1){
$longip = ip2long($row['ip']); $longip = ip2long($row['ip']);
if ($longip) //Ignore ipv6 address if ($longip) //Ignore ipv6 address
$peer_list .= pack("Nn", sprintf("%d",$longip), $row['port']); $peer_list .= pack("Nn", sprintf("%d",$longip), $row['port']);
} else
elseif ($no_peer_id == 1) {
$peer_list .= "d" . $ipv6_packed = inet_pton($row['ip']);
benc_str("ip") . benc_str($row["ip"]) . if ($ipv6_packed)
benc_str("port") . "i" . $row["port"] . "e" . $peer6_list .= $ipv6_packed . pack("n", $row['port']);
"e"; }
else }
$peer_list .= "d" . elseif ($no_peer_id == 1)
benc_str("ip") . benc_str($row["ip"]) . $peer_list .= "d" .
benc_str("peer id") . benc_str($row["peer_id"]) . benc_str("ip") . benc_str($row["ip"]) .
benc_str("port") . "i" . $row["port"] . "e" . benc_str("port") . "i" . $row["port"] . "e" .
"e"; "e";
else
$peer_list .= "d" .
benc_str("ip") . benc_str($row["ip"]) .
benc_str("peer id") . benc_str($row["peer_id"]) .
benc_str("port") . "i" . $row["port"] . "e" .
"e";
} }
if ($compact == 1) if ($compact == 1)
$resp .= benc_str($peer_list); $resp .= benc_str($peer_list);
else else
$resp .= "l".$peer_list."e"; $resp .= "l".$peer_list."e";
if ($compact == 1 && strlen($peer6_list) > 0)
{
$resp .= benc_str("peers6").benc_str($peer6_list);
}
$resp .= "e"; $resp .= "e";
$selfwhere = "torrent = $torrentid AND " . hash_where("peer_id", $peer_id); $selfwhere = "torrent = $torrentid AND " . hash_where("peer_id", $peer_id);
@@ -381,7 +393,11 @@ elseif(isset($self))
} }
else else
{ {
$sockres = @pfsockopen($ip, $port, $errno, $errstr, 5); if (strlen($ip) > 15) {
$sockres = @pfsockopen("tcp://[".$ip."]",$port,$errno,$errstr,5);
} else {
$sockres = @pfsockopen($ip, $port, $errno, $errstr, 5);
}
if (!$sockres) if (!$sockres)
{ {
$connectable = "no"; $connectable = "no";