From 68d44dd9b37fa6743d9aa9cf6bce069248ca3499 Mon Sep 17 00:00:00 2001 From: Louis Lam Date: Mon, 18 Oct 2021 17:11:41 +0800 Subject: [PATCH] [steam] do not request if there is no steam api key --- server/model/monitor.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/server/model/monitor.js b/server/model/monitor.js index 6d699258..fb736291 100644 --- a/server/model/monitor.js +++ b/server/model/monitor.js @@ -274,8 +274,13 @@ class Monitor extends BeanModel { } else if (this.type === "steam") { const steamApiUrl = "https://api.steampowered.com/IGameServersService/GetServerList/v1/"; + const steamAPIKey = await setting("steamAPIKey"); const filter = `addr\\${this.hostname}:${this.port}`; + if (!steamAPIKey) { + throw new Error("Steam API Key not found"); + } + let res = await axios.get(steamApiUrl, { timeout: this.interval * 1000 * 0.8, headers: { @@ -292,7 +297,7 @@ class Monitor extends BeanModel { }, params: { filter: filter, - key: await setting("steamAPIKey"), + key: steamAPIKey, } }); @@ -303,7 +308,6 @@ class Monitor extends BeanModel { try { bean.ping = await ping(this.hostname); } catch (_) { } - } else { throw new Error("Server not found on Steam"); }