© 2026 Hedgehog Software, LLC
await Dns.GetHostEntryAsync(ipAddress);
private async Task<List<DeviceInfo>> GetDevices(XDocument xDocument) { List<DeviceInfo> deviceList = new List<DeviceInfo>(); var itemElements = xDocument.Descendants("item"); foreach (var itemElement in itemElements) { string? deviceName = itemElement.Element("device")?.Value; string? host = itemElement.Element("host")?.Value; string? objId = itemElement.Element("objid")?.Value; if (IPAddress.TryParse(host, out IPAddress? ipAddress) && ipAddress.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork) { try { var hostEntry = await Dns.GetHostEntryAsync(ipAddress); host = hostEntry.HostName; } catch { _logger.LogError($"There is an error occured while resolving {ipAddress}: {host}"); } } // remove all possible domains from FQDNs to get hostnames even if they include dots if (_optionsAccessor.PossibleOccuringDomains is not null && !string.IsNullOrEmpty(host)) { deviceName = host; _optionsAccessor.PossibleOccuringDomains.ForEach(item => { deviceName = deviceName.Replace(item, string.Empty); }); } deviceList.Add(new DeviceInfo { HostName = deviceName, FQDN = host, ObjID = objId }); } return deviceList; }