mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-11-09 23:24:07 -08:00
Use Settings.get
This commit is contained in:
parent
a3b1612938
commit
2389b604fe
|
@ -8,7 +8,7 @@ const { log } = require("../src/util");
|
||||||
const Database = require("./database");
|
const Database = require("./database");
|
||||||
const util = require("util");
|
const util = require("util");
|
||||||
const { CacheableDnsHttpAgent } = require("./cacheable-dns-http-agent");
|
const { CacheableDnsHttpAgent } = require("./cacheable-dns-http-agent");
|
||||||
const { setting } = require("./util-server");
|
const { Settings } = require("./settings");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* `module.exports` (alias: `server`) should be inside this class, in order to avoid circular dependency issue.
|
* `module.exports` (alias: `server`) should be inside this class, in order to avoid circular dependency issue.
|
||||||
|
@ -133,7 +133,7 @@ class UptimeKumaServer {
|
||||||
async getClientIP(socket) {
|
async getClientIP(socket) {
|
||||||
const clientIP = socket.client.conn.remoteAddress.replace(/^.*:/, "");
|
const clientIP = socket.client.conn.remoteAddress.replace(/^.*:/, "");
|
||||||
|
|
||||||
if (await setting("trustProxy")) {
|
if (await Settings.get("trustProxy")) {
|
||||||
return socket.client.conn.request.headers["x-forwarded-for"]
|
return socket.client.conn.request.headers["x-forwarded-for"]
|
||||||
|| socket.client.conn.request.headers["x-real-ip"]
|
|| socket.client.conn.request.headers["x-real-ip"]
|
||||||
|| clientIP;
|
|| clientIP;
|
||||||
|
|
|
@ -289,6 +289,7 @@ exports.postgresQuery = function (connectionString, query) {
|
||||||
* Retrieve value of setting based on key
|
* Retrieve value of setting based on key
|
||||||
* @param {string} key Key of setting to retrieve
|
* @param {string} key Key of setting to retrieve
|
||||||
* @returns {Promise<any>} Value
|
* @returns {Promise<any>} Value
|
||||||
|
* @deprecated Use await Settings.get(key)
|
||||||
*/
|
*/
|
||||||
exports.setting = async function (key) {
|
exports.setting = async function (key) {
|
||||||
return await Settings.get(key);
|
return await Settings.get(key);
|
||||||
|
|
Loading…
Reference in a new issue