Skip to content

Commit 3b69b81

Browse files
janbarasekdg
authored andcommitted
InfoPanel: Add information about localhost IP.
1 parent b174cc8 commit 3b69b81

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/Tracy/Bar/panels/info.panel.phtml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ $countClasses = function (array $list): int {
2525
}));
2626
};
2727

28+
$ipFormatter = static function (?string $ip): ?string {
29+
if ($ip === '127.0.0.1' || $ip === '::1') {
30+
$ip .= ' (localhost)';
31+
}
32+
return $ip;
33+
};
34+
2835
$opcache = function_exists('opcache_get_status') ? @opcache_get_status() : null; // @ can be restricted
2936
$cachedFiles = isset($opcache['scripts']) ? array_intersect(array_keys($opcache['scripts']), get_included_files()) : [];
3037

@@ -36,8 +43,8 @@ $info = [
3643
'OPcache' => $opcache ? round(count($cachedFiles) * 100 / count(get_included_files())) . '% cached' : null,
3744
'Classes + interfaces + traits' => $countClasses(get_declared_classes()) . ' + '
3845
. $countClasses(get_declared_interfaces()) . ' + ' . $countClasses(get_declared_traits()),
39-
'Your IP' => $_SERVER['REMOTE_ADDR'] ?? null,
40-
'Server IP' => $_SERVER['SERVER_ADDR'] ?? null,
46+
'Your IP' => $ipFormatter($_SERVER['REMOTE_ADDR'] ?? null),
47+
'Server IP' => $ipFormatter($_SERVER['SERVER_ADDR'] ?? null),
4148
'HTTP method / response code' => isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] . ' / ' . http_response_code() : null,
4249
'PHP' => PHP_VERSION,
4350
'Xdebug' => extension_loaded('xdebug') ? phpversion('xdebug') : null,

0 commit comments

Comments
 (0)