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()
{
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()
+2 -2
View File
@@ -12,7 +12,7 @@ class Update extends Install
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()
@@ -64,4 +64,4 @@ class Update extends Install
}
}
}
}
+1 -1
View File
@@ -355,7 +355,7 @@
array (
'mainversion' => 'NexusPHP',
'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>',
),
);
+9 -2
View File
@@ -25,7 +25,8 @@ if ($currentStep == 1) {
}
if ($currentStep == 2) {
$envExampleFile = "$rootpath.env.example";
$envExampleFile = $rootpath . ".env.example";
$dbstructureFile = $rootpath . "_db/dbstructure_v1.6.sql";
$envExampleData = readEnvFile($envExampleFile);
$envFormControls = $update->listEnvFormControls();
$newData = array_column($envFormControls, 'value', 'name');
@@ -41,11 +42,17 @@ if ($currentStep == 2) {
}
$tableRows = [
[
'label' => '.env.example',
'label' => basename($envExampleFile),
'required' => 'exists && readable',
'current' => $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';});
$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");
$peer_list = "";
$peer6_list = "";
unset($self);
// bencoding the peers info get for this announce
while ($row = mysql_fetch_assoc($res))
@@ -126,27 +127,38 @@ while ($row = mysql_fetch_assoc($res))
$self = $row;
continue;
}
if ($compact == 1){
$longip = ip2long($row['ip']);
if ($longip) //Ignore ipv6 address
$peer_list .= pack("Nn", sprintf("%d",$longip), $row['port']);
}
elseif ($no_peer_id == 1)
$peer_list .= "d" .
benc_str("ip") . benc_str($row["ip"]) .
benc_str("port") . "i" . $row["port"] . "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){
$longip = ip2long($row['ip']);
if ($longip) //Ignore ipv6 address
$peer_list .= pack("Nn", sprintf("%d",$longip), $row['port']);
else
{
$ipv6_packed = inet_pton($row['ip']);
if ($ipv6_packed)
$peer6_list .= $ipv6_packed . pack("n", $row['port']);
}
}
elseif ($no_peer_id == 1)
$peer_list .= "d" .
benc_str("ip") . benc_str($row["ip"]) .
benc_str("port") . "i" . $row["port"] . "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)
$resp .= benc_str($peer_list);
$resp .= benc_str($peer_list);
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";
$selfwhere = "torrent = $torrentid AND " . hash_where("peer_id", $peer_id);
@@ -381,7 +393,11 @@ elseif(isset($self))
}
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)
{
$connectable = "no";