/LogProxy.Lib/DnsCacheReader.cs
C# | 21 lines | 20 code | 1 blank | 0 comment | 0 complexity | cd4614ef11c0105d59bc24ea66619a6d MD5 | raw file
Possible License(s): Apache-2.0
- using System.Collections.Generic;
- using System.Linq;
- using System.Net;
- using System.Xml.Linq;
- using System.Xml.XPath;
- namespace LogProxy.Lib
- {
- public static class DnsCacheReader
- {
- public static void ReadDnsCache(string filename, IDictionary<string, IPAddress> cache)
- {
- var doc = XDocument.Load(filename);
- foreach (var entry in doc.XPathSelectElements("/cache/entry")
- .ToDictionary(e => (string)e.Attribute("host"), e => IPAddress.Parse((string)e.Attribute("ip"))))
- {
- cache.Add(entry.Key.ToUpperInvariant(), entry.Value);
- }
- }
- }
- }