[db] show original client IP in postgres status

This commit is contained in:
Shish 2024-02-14 07:28:55 +00:00
parent ebeb3b6c60
commit 937cef38db

View file

@ -82,11 +82,8 @@ class PostgreSQL extends DBEngine
public function init(PDO $db): void public function init(PDO $db): void
{ {
if (array_key_exists('REMOTE_ADDR', $_SERVER)) { $addr = array_key_exists('REMOTE_ADDR', $_SERVER) ? get_real_ip() : 'local';
$db->exec("SET application_name TO 'shimmie [{$_SERVER['REMOTE_ADDR']}]';"); $db->exec("SET application_name TO 'shimmie [$addr]';");
} else {
$db->exec("SET application_name TO 'shimmie [local]';");
}
if (defined("DATABASE_TIMEOUT")) { if (defined("DATABASE_TIMEOUT")) {
$this->set_timeout($db, DATABASE_TIMEOUT); $this->set_timeout($db, DATABASE_TIMEOUT);
} }