From c1f81a3439f2d3a6ac65ffc880fcc1da1b9fe5e6 Mon Sep 17 00:00:00 2001 From: Andrey Savihin Date: Wed, 23 Aug 2023 14:11:34 +0300 Subject: [PATCH] ASC.ApiSystem: SettingsController: fixed CheckDomain method --- common/services/ASC.ApiSystem/Classes/CommonMethods.cs | 7 +++++++ .../ASC.ApiSystem/Controllers/SettingsController.cs | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/common/services/ASC.ApiSystem/Classes/CommonMethods.cs b/common/services/ASC.ApiSystem/Classes/CommonMethods.cs index 95e3a70fc0..0809732b5f 100644 --- a/common/services/ASC.ApiSystem/Classes/CommonMethods.cs +++ b/common/services/ASC.ApiSystem/Classes/CommonMethods.cs @@ -252,6 +252,13 @@ public class CommonMethods //return null; } + public async Task> GetHostIpsAsync() + { + var hostName = Dns.GetHostName(); + var hostEntry = await Dns.GetHostEntryAsync(hostName); + return hostEntry.AddressList.Select(ip => ip.ToString()); + } + public bool ValidateRecaptcha(string response, RecaptchaType recaptchaType, string ip) { try diff --git a/common/services/ASC.ApiSystem/Controllers/SettingsController.cs b/common/services/ASC.ApiSystem/Controllers/SettingsController.cs index e8f4d97d48..62c749a286 100644 --- a/common/services/ASC.ApiSystem/Controllers/SettingsController.cs +++ b/common/services/ASC.ApiSystem/Controllers/SettingsController.cs @@ -140,13 +140,13 @@ public class SettingsController : ControllerBase }); } - var clientIP = CommonMethods.GetClientIp(); + var currentHostIps = await CommonMethods.GetHostIpsAsync(); var hostIps = await Dns.GetHostAddressesAsync(model.HostName); return Ok(new { - value = Array.IndexOf(hostIps, clientIP) > -1 + value = currentHostIps.Any(ip => Array.IndexOf(hostIps, ip) > -1) }); }