Exemplo n.º 1
0
        private async Task <IpData?> LoadReverseDns(IPAddress ip, CancellationToken cancellationToken)
        {
            try
            {
                var response = await _dns.QueryReverseAsync(ip, cancellationToken);

                var ptr = response.Answers.PtrRecords().FirstOrDefault();
                return(ptr == null
                                        ? null
                                        : new IpData
                {
                    HostName = ptr.PtrDomainName.ToString().TrimEnd('.')
                });
            }
            catch (Exception ex)
            {
                _logger.LogDebug(ex, $"Could not load reverse DNS data for {ip}: {ex.Message}");
                return(null);
            }
        }