mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-24 03:57:22 +08:00
fix get host from octane
This commit is contained in:
@@ -722,7 +722,7 @@ class TrackerRepository extends BaseRepository
|
|||||||
$peer->prev_action = $peer->last_action;
|
$peer->prev_action = $peer->last_action;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($queries['event'] == 'started') {
|
if ($queries['event'] == 'started' || !$peer->exists) {
|
||||||
$peer->started = $nowStr;
|
$peer->started = $nowStr;
|
||||||
$peer->uploadoffset = $queries['uploaded'];
|
$peer->uploadoffset = $queries['uploaded'];
|
||||||
$peer->downloadoffset = $queries['downloaded'];
|
$peer->downloadoffset = $queries['downloaded'];
|
||||||
|
|||||||
@@ -458,14 +458,8 @@ function getSchemeAndHttpHost()
|
|||||||
}
|
}
|
||||||
$isHttps = isHttps();
|
$isHttps = isHttps();
|
||||||
$protocol = $isHttps ? 'https' : 'http';
|
$protocol = $isHttps ? 'https' : 'http';
|
||||||
if (RUNNING_IN_OCTANE) {
|
$host = nexus()->getRequestHost();
|
||||||
$host = request()->server('HTTP_HOST', '');
|
return "$protocol://" . $host;
|
||||||
} else {
|
|
||||||
$host = $_SERVER['HTTP_HOST'] ?? '';
|
|
||||||
}
|
|
||||||
$result = "$protocol://" . $host;
|
|
||||||
return $result;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getBaseUrl()
|
function getBaseUrl()
|
||||||
@@ -634,8 +628,12 @@ function get_tracker_schema_and_host($combine = false): array|string
|
|||||||
global $https_announce_urls, $announce_urls;
|
global $https_announce_urls, $announce_urls;
|
||||||
$httpsAnnounceUrls = array_filter($https_announce_urls);
|
$httpsAnnounceUrls = array_filter($https_announce_urls);
|
||||||
$log = "cookie: " . json_encode($_COOKIE) . ", https_announce_urls: " . json_encode($httpsAnnounceUrls);
|
$log = "cookie: " . json_encode($_COOKIE) . ", https_announce_urls: " . json_encode($httpsAnnounceUrls);
|
||||||
if ((isset($_COOKIE["c_secure_tracker_ssl"]) && $_COOKIE["c_secure_tracker_ssl"] == base64("yeah")) || !empty($httpsAnnounceUrls)) {
|
if (
|
||||||
$log .= ", c_secure_tracker_ssl = base64('yeah'): " . base64("yeah") . ", or not empty https_announce_urls";
|
(isset($_COOKIE["c_secure_tracker_ssl"]) && $_COOKIE["c_secure_tracker_ssl"] == base64("yeah"))
|
||||||
|
|| !empty($httpsAnnounceUrls)
|
||||||
|
|| isHttps()
|
||||||
|
) {
|
||||||
|
$log .= ", c_secure_tracker_ssl = base64('yeah'): " . base64("yeah") . ", or not empty https_announce_urls, or isHttps()";
|
||||||
$tracker_ssl = true;
|
$tracker_ssl = true;
|
||||||
} else {
|
} else {
|
||||||
$tracker_ssl = false;
|
$tracker_ssl = false;
|
||||||
|
|||||||
+7
-1
@@ -107,9 +107,15 @@ final class Nexus
|
|||||||
return $schema;
|
return $schema;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getRequestHost(): string
|
||||||
|
{
|
||||||
|
$host = $this->retrieveFromServer(['HTTP_HOST', 'host', ], true);
|
||||||
|
return (string)$host;
|
||||||
|
}
|
||||||
|
|
||||||
public function getRequestIp()
|
public function getRequestIp()
|
||||||
{
|
{
|
||||||
return $this->retrieveFromServer(['HTTP_CF_CONNECTING_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_REMOTE_ADDR', 'REMOTE_ADDR']);
|
return $this->retrieveFromServer(['HTTP_CF_CONNECTING_IP', 'HTTP_X_FORWARDED_FOR', 'x-forwarded-for', 'HTTP_REMOTE_ADDR', 'REMOTE_ADDR'], true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function retrieveFromServer(array $fields, bool $includeHeader = false)
|
private function retrieveFromServer(array $fields, bool $includeHeader = false)
|
||||||
|
|||||||
Reference in New Issue
Block a user