mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-21 18:37:31 +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;
|
||||
}
|
||||
|
||||
if ($queries['event'] == 'started') {
|
||||
if ($queries['event'] == 'started' || !$peer->exists) {
|
||||
$peer->started = $nowStr;
|
||||
$peer->uploadoffset = $queries['uploaded'];
|
||||
$peer->downloadoffset = $queries['downloaded'];
|
||||
|
||||
@@ -458,14 +458,8 @@ function getSchemeAndHttpHost()
|
||||
}
|
||||
$isHttps = isHttps();
|
||||
$protocol = $isHttps ? 'https' : 'http';
|
||||
if (RUNNING_IN_OCTANE) {
|
||||
$host = request()->server('HTTP_HOST', '');
|
||||
} else {
|
||||
$host = $_SERVER['HTTP_HOST'] ?? '';
|
||||
}
|
||||
$result = "$protocol://" . $host;
|
||||
return $result;
|
||||
|
||||
$host = nexus()->getRequestHost();
|
||||
return "$protocol://" . $host;
|
||||
}
|
||||
|
||||
function getBaseUrl()
|
||||
@@ -634,8 +628,12 @@ function get_tracker_schema_and_host($combine = false): array|string
|
||||
global $https_announce_urls, $announce_urls;
|
||||
$httpsAnnounceUrls = array_filter($https_announce_urls);
|
||||
$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)) {
|
||||
$log .= ", c_secure_tracker_ssl = base64('yeah'): " . base64("yeah") . ", or not empty https_announce_urls";
|
||||
if (
|
||||
(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;
|
||||
} else {
|
||||
$tracker_ssl = false;
|
||||
|
||||
+7
-1
@@ -107,9 +107,15 @@ final class Nexus
|
||||
return $schema;
|
||||
}
|
||||
|
||||
public function getRequestHost(): string
|
||||
{
|
||||
$host = $this->retrieveFromServer(['HTTP_HOST', 'host', ], true);
|
||||
return (string)$host;
|
||||
}
|
||||
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user